Add household and membership domain with role-based APIs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Introduced `Household` and `HouseholdMember` entities, services, and repositories, enabling role-based access (`OWNER` and `MEMBER`). Added REST APIs for household creation, member management, and listing. Configured Flyway migrations, updated tests, and included IntelliJ HTTP client script for API testing. Updated `README.md` with feature details, usage instructions, and architecture overview.
This commit is contained in:
55
src/test/http/hemhub-api.http
Normal file
55
src/test/http/hemhub-api.http
Normal file
@ -0,0 +1,55 @@
|
||||
### 1. Get access token for user "maria"
|
||||
POST http://localhost:8081/realms/hemhub/protocol/openid-connect/token
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
client_id=hemhub-public&
|
||||
grant_type=password&
|
||||
username=maria&
|
||||
password=Passw0rd
|
||||
|
||||
> {%
|
||||
client.global.set("token", response.body.access_token);
|
||||
client.global.set("refresh_token", response.body.refresh_token);
|
||||
%}
|
||||
|
||||
### 2. Decode token (optional, debugging)
|
||||
GET https://jwt.io/?access_token={{token}}
|
||||
|
||||
### 3. Get current user info
|
||||
GET http://localhost:8080/me
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 4. Create a household
|
||||
POST http://localhost:8080/api/v1/households
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"name": "Familjen Andersson"
|
||||
}
|
||||
|
||||
> {% client.global.set("householdId", JSON.parse(response.body).id); %}
|
||||
|
||||
### 5. List my households
|
||||
GET http://localhost:8080/api/v1/households
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 6. List household members
|
||||
GET http://localhost:8080/api/v1/households/{{householdId}}/members
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 7. Add a member (requires OWNER role)
|
||||
POST http://localhost:8080/api/v1/households/{{householdId}}/members
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"userSub": "ulf-sub",
|
||||
"email": "ulf@example.com",
|
||||
"displayName": "Ulf",
|
||||
"role": "MEMBER"
|
||||
}
|
||||
|
||||
### 8. List members again (should now include Ulf)
|
||||
GET http://localhost:8080/api/v1/households/{{householdId}}/members
|
||||
Authorization: Bearer {{token}}
|
||||
Reference in New Issue
Block a user