Spaces to Tabs

This commit is contained in:
Rob Winch
2016-02-22 22:12:47 -06:00
parent e338e70972
commit fad66c5cd2
7 changed files with 182 additions and 182 deletions

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -31,55 +31,55 @@ import javax.servlet.http.HttpServletResponse
@Stepwise
class RestTests extends Specification {
@Shared
RESTClient client = new RESTClient(System.properties.'geb.build.baseUrl')
@Shared
RESTClient client = new RESTClient(System.properties.'geb.build.baseUrl')
@Shared
String session
@Shared
String session
def 'Unauthenticated user sent to log in page'() {
when: 'unauthenticated user request protected page'
def resp = client.get path: '/', headers: ['Accept':'application/json']
then: 'sent to the log in page'
def e = thrown(HttpResponseException)
e.response.status == HttpServletResponse.SC_UNAUTHORIZED
}
def 'Unauthenticated user sent to log in page'() {
when: 'unauthenticated user request protected page'
def resp = client.get path: '/', headers: ['Accept':'application/json']
then: 'sent to the log in page'
def e = thrown(HttpResponseException)
e.response.status == HttpServletResponse.SC_UNAUTHORIZED
}
def 'Authenticate with Basic Works'() {
when: 'Authenticate with Basic'
def username, response
client.get(path: '/', headers: ['Authorization': 'Basic ' + 'user:password'.bytes.encodeBase64() ]) { resp, json ->
response = resp
username = json.username
session = resp.headers.'x-auth-token'
}
then: 'Access the User information and obtain session via x-auth-token header'
response.status == HttpServletResponse.SC_OK
username == 'user'
session
}
def 'Authenticate with Basic Works'() {
when: 'Authenticate with Basic'
def username, response
client.get(path: '/', headers: ['Authorization': 'Basic ' + 'user:password'.bytes.encodeBase64() ]) { resp, json ->
response = resp
username = json.username
session = resp.headers.'x-auth-token'
}
then: 'Access the User information and obtain session via x-auth-token header'
response.status == HttpServletResponse.SC_OK
username == 'user'
session
}
def 'Authenticate with x-auth-token works'() {
when: 'Authenticate with x-auth-token'
def username, response
client.get(path: '/', headers: ['x-auth-token': session ]) { resp, json ->
response = resp
username = json.username
}
then: 'Access the User information'
response.status == HttpServletResponse.SC_OK
username == 'user'
}
def 'Authenticate with x-auth-token works'() {
when: 'Authenticate with x-auth-token'
def username, response
client.get(path: '/', headers: ['x-auth-token': session ]) { resp, json ->
response = resp
username = json.username
}
then: 'Access the User information'
response.status == HttpServletResponse.SC_OK
username == 'user'
}
def 'Logout'() {
when: 'invalide session'
def response
client.get(path: '/logout', headers: ['x-auth-token': session ]) { resp, json ->
response = resp
session = resp.headers.'x-auth-token'
}
then: 'The session is deleted and an empty x-auth-token is returned'
response.status == HttpServletResponse.SC_NO_CONTENT
session == ''
}
def 'Logout'() {
when: 'invalide session'
def response
client.get(path: '/logout', headers: ['x-auth-token': session ]) { resp, json ->
response = resp
session = resp.headers.'x-auth-token'
}
then: 'The session is deleted and an empty x-auth-token is returned'
response.status == HttpServletResponse.SC_NO_CONTENT
session == ''
}
}