generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c5c058
commit 5ff804b
Showing
3 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import uk.gov.justice.digital.hmpps.api.model.ManagedCases | |
import uk.gov.justice.digital.hmpps.api.model.Name | ||
import uk.gov.justice.digital.hmpps.api.model.UserDetail | ||
import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator | ||
import uk.gov.justice.digital.hmpps.data.generator.ProviderGenerator | ||
import uk.gov.justice.digital.hmpps.data.generator.UserGenerator | ||
import uk.gov.justice.digital.hmpps.security.withOAuth2Token | ||
import uk.gov.justice.digital.hmpps.service.CaseAccess | ||
|
@@ -188,6 +189,15 @@ class UserResourceTest { | |
).andExpect(status().isNotFound) | ||
} | ||
|
||
@Test | ||
fun `user details not found returns 404 from id`() { | ||
mockMvc.perform( | ||
MockMvcRequestBuilders.get("/users/829185656291/details") | ||
.withOAuth2Token(wireMockServer) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
).andExpect(status().isNotFound) | ||
} | ||
|
||
@Test | ||
fun `user details are correctly returned`() { | ||
val res = mockMvc.perform( | ||
|
@@ -199,4 +209,16 @@ class UserResourceTest { | |
val userDetail = objectMapper.readValue<UserDetail>(res) | ||
assertThat(userDetail, equalTo(UserDetail("john-smith", Name("John", "Smith"), "[email protected]"))) | ||
} | ||
|
||
@Test | ||
fun `user details are correctly returned from id`() { | ||
val res = mockMvc.perform( | ||
MockMvcRequestBuilders.get("/users/${ProviderGenerator.JOHN_SMITH_USER.id}/details") | ||
.withOAuth2Token(wireMockServer) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
).andReturn().response.contentAsString | ||
|
||
val userDetail = objectMapper.readValue<UserDetail>(res) | ||
assertThat(userDetail, equalTo(UserDetail("john-smith", Name("John", "Smith"), "[email protected]"))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters