Can get current Citizen
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package fr.dcproject.routes
|
package fr.dcproject.routes
|
||||||
|
|
||||||
|
import fr.dcproject.citizen
|
||||||
import fr.dcproject.entity.Citizen
|
import fr.dcproject.entity.Citizen
|
||||||
import fr.dcproject.security.voter.CitizenVoter.Action.VIEW
|
import fr.dcproject.security.voter.CitizenVoter.Action.VIEW
|
||||||
import fr.dcproject.security.voter.assertCan
|
import fr.dcproject.security.voter.assertCan
|
||||||
@@ -19,6 +20,7 @@ object CitizenPaths {
|
|||||||
val limit: Int = if (limit > 50) 50 else if (limit < 1) 1 else limit
|
val limit: Int = if (limit > 50) 50 else if (limit < 1) 1 else limit
|
||||||
}
|
}
|
||||||
@Location("/citizens/{citizen}") class CitizenRequest(val citizen: Citizen)
|
@Location("/citizens/{citizen}") class CitizenRequest(val citizen: Citizen)
|
||||||
|
@Location("/citizens/current") class CurrentCitizenRequest
|
||||||
@Location("/citizens/{citizen}/follows/articles") class CitizenFollowArticleRequest(val citizen: Citizen)
|
@Location("/citizens/{citizen}/follows/articles") class CitizenFollowArticleRequest(val citizen: Citizen)
|
||||||
@Location("/citizens/{citizen}/follows/constitutions") class CitizenFollowConstitutionRequest(val citizen: Citizen)
|
@Location("/citizens/{citizen}/follows/constitutions") class CitizenFollowConstitutionRequest(val citizen: Citizen)
|
||||||
}
|
}
|
||||||
@@ -36,4 +38,10 @@ fun Route.citizen(repo: CitizenRepository) {
|
|||||||
|
|
||||||
call.respond(it.citizen)
|
call.respond(it.citizen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get<CitizenPaths.CurrentCitizenRequest> {
|
||||||
|
assertCan(VIEW, citizen)
|
||||||
|
|
||||||
|
call.respond(citizen)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -38,6 +38,21 @@ paths:
|
|||||||
example:
|
example:
|
||||||
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag
|
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag
|
||||||
|
|
||||||
|
/citizens/current:
|
||||||
|
get:
|
||||||
|
security:
|
||||||
|
- JWTAuth: []
|
||||||
|
summary: Get Citizen
|
||||||
|
tags:
|
||||||
|
- citizen
|
||||||
|
operationId: getCurrentCitizen
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: The Citizen object
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/CitizenResponse'
|
||||||
/citizens/{citizen}:
|
/citizens/{citizen}:
|
||||||
get:
|
get:
|
||||||
security:
|
security:
|
||||||
|
|||||||
@@ -11,3 +11,10 @@ Feature: citizens routes
|
|||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
And the response should contain object:
|
And the response should contain object:
|
||||||
| id | 6434f4f9-f570-f22a-c134-8668350651ff |
|
| id | 6434f4f9-f570-f22a-c134-8668350651ff |
|
||||||
|
|
||||||
|
Scenario: Can get connected citizen
|
||||||
|
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||||
|
When I send a GET request to "/citizens/current"
|
||||||
|
Then the response status code should be 200
|
||||||
|
And the response should contain object:
|
||||||
|
| id | 64b7b379-2298-43ec-b428-ba134930cabd |
|
||||||
|
|||||||
Reference in New Issue
Block a user