Fix indentation of InterceptUrlConfigTests

This commit is contained in:
Rob Winch 2015-04-21 09:38:17 -05:00
parent b433cdda7e
commit 38e2e23b86

View File

@ -84,48 +84,48 @@ import org.springframework.security.authentication.AuthenticationManager
*/ */
class InterceptUrlConfigTests extends AbstractHttpConfigTests { class InterceptUrlConfigTests extends AbstractHttpConfigTests {
def "SEC-2256: intercept-url method is not given priority"() { def "SEC-2256: intercept-url method is not given priority"() {
when: when:
httpAutoConfig { httpAutoConfig {
'intercept-url'(pattern: '/anyurl', access: "ROLE_USER") 'intercept-url'(pattern: '/anyurl', access: "ROLE_USER")
'intercept-url'(pattern: '/anyurl', 'method':'GET',access: 'ROLE_ADMIN') 'intercept-url'(pattern: '/anyurl', 'method':'GET',access: 'ROLE_ADMIN')
} }
createAppContext() createAppContext()
def fids = getFilter(FilterSecurityInterceptor).securityMetadataSource def fids = getFilter(FilterSecurityInterceptor).securityMetadataSource
def attrs = fids.getAttributes(createFilterinvocation("/anyurl", "GET")) def attrs = fids.getAttributes(createFilterinvocation("/anyurl", "GET"))
def attrsPost = fids.getAttributes(createFilterinvocation("/anyurl", "POST")) def attrsPost = fids.getAttributes(createFilterinvocation("/anyurl", "POST"))
then: then:
attrs.size() == 1 attrs.size() == 1
attrs.contains(new SecurityConfig("ROLE_USER")) attrs.contains(new SecurityConfig("ROLE_USER"))
attrsPost.size() == 1 attrsPost.size() == 1
attrsPost.contains(new SecurityConfig("ROLE_USER")) attrsPost.contains(new SecurityConfig("ROLE_USER"))
} }
def "SEC-2355: intercept-url support patch"() { def "SEC-2355: intercept-url support patch"() {
setup: setup:
MockHttpServletRequest request = new MockHttpServletRequest(method:'GET') MockHttpServletRequest request = new MockHttpServletRequest(method:'GET')
MockHttpServletResponse response = new MockHttpServletResponse() MockHttpServletResponse response = new MockHttpServletResponse()
MockFilterChain chain = new MockFilterChain() MockFilterChain chain = new MockFilterChain()
xml.http('use-expressions':false) { xml.http('use-expressions':false) {
'http-basic'() 'http-basic'()
'intercept-url'(pattern: '/**', 'method':'PATCH',access: 'ROLE_ADMIN') 'intercept-url'(pattern: '/**', 'method':'PATCH',access: 'ROLE_ADMIN')
csrf(disabled:true) csrf(disabled:true)
} }
createAppContext() createAppContext()
when: 'Method other than PATCH is used' when: 'Method other than PATCH is used'
springSecurityFilterChain.doFilter(request,response,chain) springSecurityFilterChain.doFilter(request,response,chain)
then: 'The response is OK' then: 'The response is OK'
response.status == HttpServletResponse.SC_OK response.status == HttpServletResponse.SC_OK
when: 'Method of PATCH is used' when: 'Method of PATCH is used'
request = new MockHttpServletRequest(method:'PATCH') request = new MockHttpServletRequest(method:'PATCH')
response = new MockHttpServletResponse() response = new MockHttpServletResponse()
chain = new MockFilterChain() chain = new MockFilterChain()
springSecurityFilterChain.doFilter(request, response, chain) springSecurityFilterChain.doFilter(request, response, chain)
then: 'The response is unauthorized' then: 'The response is unauthorized'
response.status == HttpServletResponse.SC_UNAUTHORIZED response.status == HttpServletResponse.SC_UNAUTHORIZED
} }
def "intercept-url supports hasAnyRoles"() { def "intercept-url supports hasAnyRoles"() {
setup: setup: