Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/update role #45

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OpenApiConfiguration(buildProperties: BuildProperties) {
.components(
Components().addSecuritySchemes(
"template-kotlin-ui-role",
SecurityScheme().addBearerJwtRequirement("ROLE_LEARNER_RECORDS_SEARCH__RW"),
SecurityScheme().addBearerJwtRequirement("ROLE_LEARNER_RECORDS_SEARCH__RO"),
),
)
.addSecurityItem(SecurityRequirement().addList("template-kotlin-ui-role", listOf("read")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import uk.gov.justice.digital.hmpps.learnerrecordsapi.openapi.FindByDemographicA
import uk.gov.justice.digital.hmpps.learnerrecordsapi.service.LRSService

@RestController
@PreAuthorize("hasRole('ROLE_LEARNER_RECORDS_SEARCH__RW')")
@PreAuthorize("hasRole('ROLE_LEARNER_RECORDS_SEARCH__RO')")
@RequestMapping(value = ["/learners"], produces = ["application/json"])
class LearnersResource(
private val lrsService: LRSService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import uk.gov.justice.digital.hmpps.learnerrecordsapi.openapi.FindByULNApi
import uk.gov.justice.digital.hmpps.learnerrecordsapi.service.PLRService

@RestController
@PreAuthorize("hasRole('ROLE_LEARNER_RECORDS_SEARCH__RW')")
@PreAuthorize("hasRole('ROLE_LEARNER_RECORDS_SEARCH__RO')")
@RequestMapping(value = ["/plr"], produces = ["application/json"])
class PLRResource(
private val plrService: PLRService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class HmppsBoldLrsExceptionHandlerTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/learners")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(findLearnerByDemographicsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down Expand Up @@ -74,7 +74,7 @@ class HmppsBoldLrsExceptionHandlerTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/learners")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(findLearnerByDemographicsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down Expand Up @@ -109,7 +109,7 @@ class HmppsBoldLrsExceptionHandlerTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/learners")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(findLearnerByDemographicsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down Expand Up @@ -144,7 +144,7 @@ class HmppsBoldLrsExceptionHandlerTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/learners")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(findLearnerByDemographicsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down Expand Up @@ -179,7 +179,7 @@ class HmppsBoldLrsExceptionHandlerTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/someotherEndpoint")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(findLearnerByDemographicsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down Expand Up @@ -217,7 +217,7 @@ class HmppsBoldLrsExceptionHandlerTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/learners")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.contentType(MediaType.APPLICATION_JSON)
.bodyValue(requestJsonWithoutGivenName)
.accept(MediaType.parseMediaType("application/json"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LearnersResourceIntTest : IntegrationTestBase() {
private fun actualResponse(request: FindLearnerByDemographicsRequest = findLearnerByDemographicsRequest, expectedStatus: Int = 200): String? {
val executedRequest = webTestClient.post()
.uri("/learners")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(request)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class OpenApiDocsTest : IntegrationTestBase() {
}

@ParameterizedTest
@CsvSource(value = ["template-kotlin-ui-role, ROLE_LEARNER_RECORDS_SEARCH__RW"])
@CsvSource(value = ["template-kotlin-ui-role, ROLE_LEARNER_RECORDS_SEARCH__RO"])
fun `the security scheme is setup for bearer tokens`(key: String, role: String) {
webTestClient.get()
.uri("/v3/api-docs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PLRResourceIntTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/plr")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(getLearningEventsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down Expand Up @@ -79,7 +79,7 @@ class PLRResourceIntTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/plr")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(getLearningEventsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down Expand Up @@ -130,7 +130,7 @@ class PLRResourceIntTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/plr")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(getLearningEventsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down Expand Up @@ -158,7 +158,7 @@ class PLRResourceIntTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/plr")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(getLearningEventsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down Expand Up @@ -186,7 +186,7 @@ class PLRResourceIntTest : IntegrationTestBase() {

val actualResponse = webTestClient.post()
.uri("/plr")
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RW")))
.headers(setAuthorisation(roles = listOf("ROLE_LEARNER_RECORDS_SEARCH__RO")))
.bodyValue(getLearningEventsRequest)
.accept(MediaType.parseMediaType("application/json"))
.exchange()
Expand Down
Loading