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,
@@ -21,80 +21,80 @@ import spock.lang.*
* https://github.com/kensiprell/geb-multibrowser
*/
abstract class MultiBrowserGebSpec extends Specification {
String gebConfEnv = null
String gebConfScript = null
String gebConfEnv = null
String gebConfScript = null
// Map of geb browsers which can be referenced by name in the spec
// THese currently share the same config. This is not a problem for
// my uses, but I can see potential for wanting to configure different
// browsers separately
@Shared _browsers = createBrowserMap()
def currentBrowser
// Map of geb browsers which can be referenced by name in the spec
// THese currently share the same config. This is not a problem for
// my uses, but I can see potential for wanting to configure different
// browsers separately
@Shared _browsers = createBrowserMap()
def currentBrowser
def createBrowserMap() {
[:].withDefault { new Browser(createConf()) }
}
def createBrowserMap() {
[:].withDefault { new Browser(createConf()) }
}
Configuration createConf() {
// Use the standard configured geb driver, but turn off cacheing so
// we can run multiple
def conf = new ConfigurationLoader(gebConfEnv).getConf(gebConfScript)
conf.cacheDriver = false
return conf
}
Configuration createConf() {
// Use the standard configured geb driver, but turn off cacheing so
// we can run multiple
def conf = new ConfigurationLoader(gebConfEnv).getConf(gebConfScript)
conf.cacheDriver = false
return conf
}
def withBrowserSession(browser, Closure c) {
currentBrowser = browser
def returnedValue = c.call()
currentBrowser = null
returnedValue
}
def withBrowserSession(browser, Closure c) {
currentBrowser = browser
def returnedValue = c.call()
currentBrowser = null
returnedValue
}
void resetBrowsers() {
_browsers.each { k, browser ->
if (browser.config?.autoClearCookies) {
browser.clearCookiesQuietly()
}
browser.quit()
}
_browsers = createBrowserMap()
}
void resetBrowsers() {
_browsers.each { k, browser ->
if (browser.config?.autoClearCookies) {
browser.clearCookiesQuietly()
}
browser.quit()
}
_browsers = createBrowserMap()
}
def propertyMissing(String name) {
if(currentBrowser) {
return currentBrowser."$name"
} else {
return _browsers[name]
}
}
def propertyMissing(String name) {
if(currentBrowser) {
return currentBrowser."$name"
} else {
return _browsers[name]
}
}
def methodMissing(String name, args) {
if(currentBrowser) {
return currentBrowser."$name"(*args)
} else {
def browser = _browsers[name]
if(args) {
return browser."${args[0]}"(*(args[1..-1]))
} else {
return browser
}
}
}
def methodMissing(String name, args) {
if(currentBrowser) {
return currentBrowser."$name"(*args)
} else {
def browser = _browsers[name]
if(args) {
return browser."${args[0]}"(*(args[1..-1]))
} else {
return browser
}
}
}
def propertyMissing(String name, value) {
if(!currentBrowser) throw new IllegalArgumentException("No context for setting property $name")
currentBrowser."$name" = value
}
def propertyMissing(String name, value) {
if(!currentBrowser) throw new IllegalArgumentException("No context for setting property $name")
currentBrowser."$name" = value
}
private isSpecStepwise() {
this.class.getAnnotation(Stepwise) != null
}
private isSpecStepwise() {
this.class.getAnnotation(Stepwise) != null
}
def cleanup() {
if (!isSpecStepwise()) resetBrowsers()
}
def cleanup() {
if (!isSpecStepwise()) resetBrowsers()
}
def cleanupSpec() {
if (isSpecStepwise()) resetBrowsers()
}
def cleanupSpec() {
if (isSpecStepwise()) resetBrowsers()
}
}

View File

@@ -40,7 +40,7 @@ task runGemFireServer(dependsOn: availablePort) << {
String classpath = sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
String[] commandLine = ['java', '-server', '-ea',
"-Dspring.session.data.gemfire.port=$port",
"-Dspring.session.data.gemfire.port=$port",
"-Dsample.httpsession.gemfire.log-level="
+ System.getProperty('sample.httpsession.gemfire.log-level', 'warning'),
'-classpath', classpath, 'sample.ServerConfig']

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,
@@ -68,7 +68,7 @@ public class ServerConfig {
@Bean
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache, // <4>
@Value("${spring.session.data.gemfire.port:"+SERVER_PORT+"}") int port) {
@Value("${spring.session.data.gemfire.port:"+SERVER_PORT+"}") int port) {
CacheServerFactoryBean cacheServerFactory = new CacheServerFactoryBean();

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 == ''
}
}