Skip to content

Commit

Permalink
[SHIBUI-1062]
Browse files Browse the repository at this point in the history
Added test to check that we really can find users by role.
Updated dev config to once again include anonymousUser as an admin.
  • Loading branch information
Bill Smith committed Jan 23, 2019
1 parent 127a230 commit 7a1de10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class DevConfig {
roles.add(roleRepository.findByName('ROLE_USER').get())
it
}, new User().with {
username = 'admin2'
username = 'anonymousUser'
password = '{noop}anotheradmin'
firstName = 'Rand'
lastName = 'al\'Thor'
emailAddress = 'rand@institution.edu'
firstName = 'Anon'
lastName = 'Ymous'
emailAddress = 'anonymous@institution.edu'
roles.add(roleRepository.findByName('ROLE_ADMIN').get())
it
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ class UsersControllerIntegrationTests extends Specification {
result.body[0].role == 'ROLE_ADMIN'
}
def 'GET ALL users by role (when there are existing users)'() {
when:
def result = this.restTemplate.getForEntity(RESOURCE_URI + '/role/ROLE_ADMIN', Object)
then: 'Request completed with HTTP 200 and returned a list of users'
result.statusCodeValue == 200
((Object[]) result.body).size() == 2
result.body[0].role == 'ROLE_ADMIN'
result.body[1].role == 'ROLE_ADMIN'
}
def 'GET ONE existing user'() {
when: 'GET request is made for one existing user'
def result = this.restTemplate.getForEntity("$RESOURCE_URI/admin", Map)
Expand Down

0 comments on commit 7a1de10

Please sign in to comment.