Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Рустам, [06.03.17 17:06]
- class PersonServiceAuthenticationSpec extends RestIntegrationBase {
- String getBasePath() {"persons/"}
- @Shared
- def ROLE_TO_USER = [
- NO_ROLE: [name: null, password: null],
- USER: [name: 'user', password: 'password'],
- ADMIN: [name: 'admin', password: 'pwd']]
- @Unroll("calling #endpoint with user #user should return status #status")
- def "test authentication of #endpoint"() {
- given:
- RestTemplate restTemplate = new TestRestTemplate(user.name, user.password)
- RequestEntity request = RequestEntity.get(serviceURI(endpoint)).build()
- when:
- ResponseEntity response = restTemplate.exchange(request, Object)
- then:
- response.statusCode == status
- where:
- endpoint | user || status
- "" | ROLE_TO_USER.NO_ROLE || HttpStatus.UNAUTHORIZED
- "" | ROLE_TO_USER.USER || HttpStatus.OK
- "" | ROLE_TO_USER.ADMIN || HttpStatus.OK
- "search/byFirstName/John" | ROLE_TO_USER.NO_ROLE || HttpStatus.UNAUTHORIZED
- "search/byFirstName/John" | ROLE_TO_USER.USER || HttpStatus.OK
- "search/byFirstName/John" | ROLE_TO_USER.ADMIN || HttpStatus.OK }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement