Skip to content

Commit

Permalink
add /v1/persons/.*/sentences to private prison role and integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
emmalanigan committed Mar 11, 2025
1 parent b81b47a commit f477c34
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SentencesController(
throw EntityNotFoundException("Could not find person with id: $hmppsId")
}
if (response.hasError(UpstreamApiError.Type.BAD_REQUEST)) {
throw ValidationException("Invalid or missing HMPPS ID")
throw ValidationException("Invalid HMPPS ID: $hmppsId")
}

auditService.createEvent("GET_PERSON_SENTENCES", mapOf("hmppsId" to hmppsId))
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/globals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ globals:
- "/v1/persons/.*/alerts"
- "/v1/persons/.*/name"
- "/v1/persons/.*/cell-location"
- "/v1/persons/.*/sentences"
- "/v1/prison/prisoners"
- "/v1/prison/prisoners/[^/]*$"
- "/v1/prison/.*/prisoners/[^/]*/balances$"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ class SentencesIntegrationTest : IntegrationTestBase() {
.andExpect(content().json(getExpectedResponse("person-sentence")))
}

@Test
fun `sentences returns a 400 if the hmppsId is invalid`() {
callApi(invalidHmppsIdPath)
.andExpect(status().isBadRequest)
}

@Test
fun `sentences returns a 404 for if consumer has empty list of prisons on latest sentence key dates and adjustments `() {
callApiWithCN(path, noPrisonsCn)
.andExpect(status().isNotFound)
}

@Test
fun `sentences returns a 404 for prisoner in wrong prison on latest sentence key dates and adjustments`() {
callApiWithCN(path, limitedPrisonsCn)
.andExpect(status().isNotFound)
}

@Test
fun `returns latest sentence key dates and adjustments for a person`() {
callApi("$path/latest-key-dates-and-adjustments")
Expand All @@ -24,7 +42,7 @@ class SentencesIntegrationTest : IntegrationTestBase() {
}

@Test
fun `returns a 404 if the hmppsId is invalid`() {
fun `returns a 400 if the hmppsId is invalid`() {
callApi("$invalidHmppsIdPath/latest-key-dates-and-adjustments")
.andExpect(status().isBadRequest)
}
Expand Down

0 comments on commit f477c34

Please sign in to comment.