From 7a1de10eb858d041c18c2d94bf7dd4ad2a42b819 Mon Sep 17 00:00:00 2001 From: Bill Smith Date: Wed, 23 Jan 2019 12:07:08 -0700 Subject: [PATCH] [SHIBUI-1062] Added test to check that we really can find users by role. Updated dev config to once again include anonymousUser as an admin. --- .../admin/ui/configuration/DevConfig.groovy | 8 ++++---- .../controller/UsersControllerIntegrationTests.groovy | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/configuration/DevConfig.groovy b/backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/configuration/DevConfig.groovy index dcf255601..bcee9a94c 100644 --- a/backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/configuration/DevConfig.groovy +++ b/backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/configuration/DevConfig.groovy @@ -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 }] diff --git a/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersControllerIntegrationTests.groovy b/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersControllerIntegrationTests.groovy index 04aa033e9..e92e99193 100644 --- a/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersControllerIntegrationTests.groovy +++ b/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersControllerIntegrationTests.groovy @@ -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)