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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
6729f22
commit e589eb7
Showing
10 changed files
with
135 additions
and
6 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 |
---|---|---|
|
@@ -10,4 +10,16 @@ cn: peter-parker | |
sn: Parker | ||
givenname: Peter | ||
mail: [email protected] | ||
telephoneNumber: 07321165373 | ||
telephoneNumber: 07321165373 | ||
|
||
dn: cn=MAABT001,cn=peter-parker,ou=Users,dc=moj,dc=com | ||
objectclass: NDRoleAssociation | ||
objectclass: alias | ||
cn: MAABT001 | ||
aliasedObjectName: cn=MAABT001,cn=NDRoleAssociation,ou=Users,dc=moj,dc=com | ||
|
||
dn: cn=APBT001,cn=peter-parker,ou=Users,dc=moj,dc=com | ||
objectclass: NDRoleAssociation | ||
objectclass: alias | ||
cn: APBT001 | ||
aliasedObjectName: cn=APBT001,cn=NDRoleAssociation,ou=Users,dc=moj,dc=com |
37 changes: 37 additions & 0 deletions
37
...delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/UserRoleIntegrationTest.kt
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package uk.gov.justice.digital.hmpps | ||
|
||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.web.servlet.MockMvc | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers | ||
import uk.gov.justice.digital.hmpps.api.model.user.UserDetails | ||
import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.contentAsJson | ||
import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken | ||
|
||
@AutoConfigureMockMvc | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
class UserRoleIntegrationTest { | ||
@Autowired | ||
lateinit var mockMvc: MockMvc | ||
|
||
@Test | ||
fun `unauthorized status returned`() { | ||
mockMvc | ||
.perform(MockMvcRequestBuilders.get("/caseload/user/peter-parker")) | ||
.andExpect(MockMvcResultMatchers.status().isUnauthorized) | ||
} | ||
|
||
@Test | ||
fun `get roles for user`() { | ||
val response = mockMvc | ||
.perform(MockMvcRequestBuilders.get("/user/peter-parker").withToken()) | ||
.andExpect(MockMvcResultMatchers.status().isOk) | ||
.andReturn().response.contentAsJson<UserDetails>() | ||
|
||
assertEquals(listOf("APBT001", "MAABT001"), response.roles) | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
...ion-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/user/UserDetails.kt
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package uk.gov.justice.digital.hmpps.api.model.user | ||
|
||
data class UserDetails( | ||
val userId: Long, | ||
val username: String, | ||
val firstName: String, | ||
val surname: String, | ||
val email: String?, | ||
val enabled: Boolean, | ||
val roles: List<String> | ||
) |
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
32 changes: 31 additions & 1 deletion
32
...upervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/UserService.kt
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
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