46 Commits

Author SHA1 Message Date
Rob Winch
7bc98db23c Add WebTestClient test support
SecurityExchangeMutators

Fixes gh-4343
2017-05-19 15:09:23 -05:00
Vedran Pavic
85719fcd64 Use Base64 implementation provided by Java 8 2017-05-10 00:27:36 -05:00
Rob Winch
9c03571bbb Use message in all Assert
This ensures compatibility with Spring 5.

Fixes gh-4193
2017-01-30 19:58:24 -06:00
Rob Winch
050198e51b Fix csrf() when used then not used
Previously if csrf() was used and subsequently not used, the
TestCsrfTokenRepository was still used. This makes it difficult to test
the actual CsrfTokenRepository implementation.

Now the TestCsrfTokenRepository is only used if explicitly enabled.

Fixes gh-4016
2016-08-09 17:09:16 -04:00
Rob Winch
8ad91ef6a5 WithSecurityContextTestExecutionListener > SqlScriptsTestExecutionListener
WithSecurityContextTestExecutionListener should order after
SqlScriptsTestExecutionListener so sql can setup the current user's info
in the database.

Fixes gh-3962
2016-07-06 16:09:17 -05:00
Rob Winch
bbeb7f94d7 Fix checkstyle
Issue gh-3920
2016-06-20 19:36:51 -05:00
Micah Silverman
314828859e Added accept method call to buildRequest in SecurityMockMvcRequestBuilders with default of MediaType.APPLICATION_FORM_URLENCODED 2016-06-20 15:46:01 -05:00
Rob Winch
101190ad8b Format WithSecurityContextTestExecutionListener 2016-05-20 10:46:26 -05:00
Rob Winch
336de35874 Polish WithSecurityContextTestExecutionListener
Extract method for reuse

SecurityContext createSecurityContext(AnnotatedElement annotated,
    WithSecurityContext withSecurityContext,
    TestContext context)

Issue gh-3888
2016-05-20 10:46:26 -05:00
Eddú Meléndez
a53d022312 Support WithSecurityContextFactory on superclass
Fixes gh-3888
2016-05-20 10:46:14 -05:00
Rob Winch
7b61a44929 Fix test .standaloneSetup
Previously, Spring Security's test support did not work well with the
standalone setup. This was because the springSecurityFilterChain was not
found by the WebTestUtils.

This commit ensures that the springSecurityFilterChain is added as a
servlet attribute if it is explicitly defined. WebTestUtils can then
find the springSecurityFilterChain in the ServletContext.

Fixes gh-3881
2016-05-16 11:02:40 -04:00
Rob Winch
602bb457b8 Formatting
Issue gh-3881
2016-05-16 11:02:40 -04:00
Rob Winch
78bf6e2bd5 WithSecurityContextTestExecutionListener supports generic Annotation
Previously Spring Security's WithSecurityContextTestExecutionListener
allowed a WithSecurityContextFactory<Annotation> to be used. This
was broken in SEC-3074.

This commit ensures that WithSecurityContextFactory<Annotation> is
supported again.

Fixes gh-3837
2016-05-03 15:41:25 -04:00
Jens Goldhammer
ceef70946b Resolve springSecurityFilterChain to Filter
When enabling debug for spring security, the FilterChainProxy will be wrapped by the DebugFilter.
This DebugFilter will be registered as bean springSecurityFilterChain. The WebTestUtils will now search for the bean by name instead of FilterChainProxy class.
In this case we have to cast to a Java ServletFilter to support both filter...

Fixes gh-3836
2016-04-26 15:53:38 -04:00
Rob Winch
b2b53f7a81 Fix unauthenitcated() and AnonymousAuthenticationToken
Previously if unauthenticated() experienced an AnonymousAuthenticationToken
it would not match.

This commit ensures that if the user is anonymous (not just null)
unauthenticated() works.

Fixes gh-3409
2016-04-19 15:08:47 -05:00
Rob Winch
8a28a27225 Formatting Polish 2016-04-19 14:24:11 -05:00
Rob Winch
d3a9cc6eae Add CsrfTokenRepository (#3805)
* Create LazyCsrfTokenRepository

Fixes gh-3790

* Add CookieCsrfTokenRepository

Fixes gh-3009
2016-04-12 17:26:53 -04:00
Eddú Meléndez Gonzales
a5a5d9a1a9 Add support to subclass of GrantedAuthority in SecurityMockMvcResultMatchers withAuthorities (#3793)
SecurityMockMvcResultMatchers.withAuthorities(Collection<? extends GrantedAuthority>)

Fixes gh-3791
2016-04-08 08:55:53 -05:00
Rob Winch
8abb882927 Rename poorly named withUser variable
WithSecurityContextTestExecutionListener used the variable name withUser
in mulitple places when it should have been named withSecurityContext.

This commit renames the variables to withSecurityContext.

Fixes gh-3775
2016-04-01 10:27:14 -05:00
Rob Winch
f221920a19 Clean up code to conform to basic checkstyle
Issue gh-3746
2016-03-14 00:15:12 -05:00
Rob Winch
df5e3ba6ee Polish Imports 2016-03-09 16:24:50 -06:00
Rob Winch
835ac0a217 Add @WithUserDetails userDetailsServiceBeanName
Fixes gh-3346
2016-03-09 15:59:23 -06:00
Rob Winch
618b8a2d83 Fix WebTestUtils when no matching HttpSecurity found
Previously a NullPointerException would be thrown if no HttpSecurity
matched on the request passed in. This was because findFilters would
return null rather than an empty List.

This commit returns null if findFilters gets a null result.

Fixes gh-3343
2016-03-09 15:20:10 -06:00
Rob Winch
81e2778106 SEC-3097: Change CsrfRequestPostProcessor to use TestCsrfTokenRepository
This ensures that when using a wrapped HttpServletRequest (i.e. Spring
Session) that the CSRF token test support still works.
2015-09-02 00:21:40 -05:00
Rob Winch
35393098f8 SEC-3094: Add @WithAnonymousUser & anonymous() MockMvcRequestPostProcessor 2015-08-27 15:17:44 -05:00
Rob Winch
5f328b1178 SEC-2709: Fix WithSecurityContextTestExecutionListener Order 2015-08-20 10:41:09 -05:00
Rob Winch
327695ab0c SEC-3084: Doc SecurityContextRequestPostProcessorSupport & SecurityContextHolder 2015-08-20 09:30:24 -05:00
Rob Winch
567c51e109 SEC-3074: Add Test Meta Annotation Support 2015-08-19 16:05:54 -05:00
Thomas Darimont
ad1d858e2b SEC-3056 - Fix JavaDoc errors.
Fixed JavaDoc errors accross multiple modules in order to make javadoc happy with Java 8.
2015-08-03 08:02:24 -05:00
Rob Winch
2d448658cd SEC-3042: Add SecurityTestExecutionListeners 2015-07-16 13:51:37 -05:00
Rob Winch
4cafd575c0 SEC-3041: Fix WithSecurityContextTestExecutionListener w/ no ApplicationContext 2015-07-16 13:13:46 -05:00
Rob Winch
e4517016ca SEC-2984: Add @WithMockUser authorities property 2015-07-16 08:41:40 -05:00
Rob Winch
1bca645add SEC-2935: Multiple MockMvc invocations proper SecurityContext setup
Previously if a MockMvc instance was setup with a user and then again with
no user, then the original user would be setup.

This commit ensures that if a user is setup and then no user is setup no
user is used.
2015-04-22 16:12:18 -05:00
Rob Winch
ae6af5d73c SEC-2915: Updated Java Code Formatting 2015-03-25 13:09:18 -05:00
Rob Winch
5ba8f000a7 SEC-2714: Add AuthenticationPrincipal resolver for messaging support 2014-09-23 16:28:48 -05:00
Rob Winch
d316f661e8 SEC-2719: Fix order sensitive authenticated().withRoles(..) 2014-09-16 10:54:50 -05:00
Rob Winch
02c3565e22 Fix compiling in Eclipse 2014-09-16 10:18:46 -05:00
Rob Winch
533b71b9b8 SEC-2688: Remove ORDER constant 2014-08-15 21:14:12 -05:00
Rob Winch
3187ee8bf3 SEC-2700: Register WithSecurityContextTestExecutionListener by default 2014-08-15 16:41:33 -05:00
Rob Winch
b72c1ad314 SEC-2686: Create SecurityMockMvcConfigurer 2014-07-22 15:11:37 -05:00
Rob Winch
9654817fd8 SEC-2601: Add DigestRequestPostProcessor 2014-07-21 22:46:18 -05:00
Rob Winch
c8348d60e1 SEC-2602: Add test support for x509 certificate 2014-07-21 15:09:30 -05:00
Rob Winch
906a0cb0e2 SEC-2684: Correct spelling of WithSecurityContextTestExecutionListener 2014-07-18 13:53:41 -05:00
Rob Winch
7e3e821db1 SEC-2593: Support stateless mode in Spring Security Test 2014-06-13 15:22:06 -05:00
Rob Winch
dabe3a03e7 SEC-2586: Create DefaultSecurityTestExecutionListeners 2014-05-07 10:44:05 -05:00
Rob Winch
8baf82532c SEC-2015: Add spring-security-test 2014-04-22 16:47:48 -05:00