Commit Graph

80 Commits

Author SHA1 Message Date
Lars Grefer
c5b5cc507c Cleanup redundant type casts 2019-07-10 09:31:09 -05:00
sandmannn
23a7c3010c Added jwt injection for reactive test mocks
Added new implementation of jwt() method that
makes it possible to directly provide a previously
prepared JWT token to WebTestClient mutator.

Fixes: spring-projectsgh-6896
2019-06-15 10:01:57 -06:00
sandmannn
9323d8e821 Extended testing api for JWT
Added new implementation of jwt() method that
makes it possible to directly provide a previously
prepared JWT token to the MockMvc request builder.

Issue: spring-projectsgh-6896
2019-06-12 10:09:32 -06:00
Josh Cummings
d0f5b42884 Mock Jwt Test Support and Jwt.Builder Polish
Simplified the initial support to introduce fewer classes and only the
features described in the ticket.

Changed tests to align with existing patterns in the repository.

Added JavaDoc to remaining public methods introduced for this feature.

Issue: gh-6634
Issue: gh-6851
2019-05-22 14:23:02 -06:00
Jérôme Wacongne
e59d8a529b Mock Jwt Test Support and Jwt.Builder
Fixes: gh-6634
Fixes: gh-6851
2019-05-22 14:23:02 -06:00
Spring Operator
b93528138e URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* http://www.apache.org/licenses/LICENSE-2.0 with 2691 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
* http://www.apache.org/licenses/LICENSE-2.0.html with 2 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0.html ([https](https://www.apache.org/licenses/LICENSE-2.0.html) result 200).
2019-03-14 15:46:20 -05:00
Aanuoluwapo Otitoola
a28c677f88 ReactorContextTestExecutionListener should use named hooks
Fixes: gh-6075
2018-11-30 11:13:26 -06:00
Tadaya Tsuyukubo
12050404ad Populate test security context with authentication
Add setAuthentication method on TestSecurityContextHolder.
2018-10-03 14:24:45 -04:00
Vedran Pavic
cb0ba58b58 Fix WhitespaceAfterCheck Checkstyle check 2018-08-27 10:45:35 -05:00
mhyeon.lee
18db425861 Polish Javadoc to remove warning 2018-07-18 09:24:59 -06:00
Rob Winch
1137f3b46d Add cross references to ReactorContextTestExecutionListener
Fixes: gh-5418
2018-06-11 17:13:24 -05:00
Rob Winch
7a204a5f58 Fixes for SPR-16624
Fixes: gh-5164
2018-03-27 22:35:08 -05:00
Rob Winch
1851aaa66d Fix ReactorContextTestExecutionListener with custom SecurityContext
Fixes: gh-5137
2018-03-19 09:29:27 -05:00
Oleh Dokuka
76e36bd06e fix Mock Authentication resolution 2018-03-19 09:16:55 -05:00
Rob Winch
2228485a40 WithUserDetails supports ReactiveUserDetailsService
Fixes: gh-4888
2018-03-08 23:13:19 -06:00
Rob Winch
abae2f3e87 Allow WithSecurityContextTestExecutionListener to execute after @Before
Fixes: gh-2935
2018-03-08 14:13:07 -06:00
Rob Winch
e1a8d250de Add authenticated().withAuthentication(Consumer<Authentication>)
This allows arbitrary assertions of the authenticated user

Fixes: gh-4996
2018-02-02 16:56:45 -06:00
Johnny Lim
57353d18e5 Use diamond type 2017-12-21 15:09:00 -06:00
Johnny Lim
d900f2a623 Remove unused imports
This commit also adds UnusedImportsCheck Checkstyle module.
2017-11-14 14:41:08 -06:00
Johnny Lim
cdcf65de1e Polish
Fixes gh-4425
2017-10-29 23:43:13 -05:00
Rob Winch
8da2c7f657 Add WebFlux CSRF Protection
Fixes gh-4734
2017-10-28 22:59:24 -05:00
Rob Winch
c467dcdbe1 SecurityMockServerConfiguers fixes
Issue: gh-4719
2017-10-27 18:17:36 -05:00
Rob Winch
77aedcf502 SecurityMockServerConfigurers updates
Issue: gh-4719
2017-10-27 18:17:33 -05:00
Rob Winch
3bceadd369 Only populate a Context once
Fixes gh-4718
2017-10-27 17:35:54 -05:00
Rob Winch
be593b95a8 Prefer existing Context in ReactorContextTestExecutionListener
Issue gh-4718
2017-10-27 17:35:54 -05:00
Rob Winch
3abec60188 SecurityMockServerConfigurers checkstyle 2017-10-27 17:33:08 -05:00
Rob Winch
747473257f Use ReactorSecurityContextHolder
Issue gh-4713
2017-10-26 20:11:42 -05:00
Johnny Lim
25052214ae Polish 2017-10-16 18:33:27 -05:00
Rob Winch
1f4082e754 Fix copyright lines 2017-09-18 11:11:25 -05:00
Rob Winch
3ecf3ea034 Fix double * in Copyright headers 2017-09-18 10:47:26 -05:00
Rob Winch
7ae4506a88 Add ReactorContextTestExecutionListener
Fixes gh-4502
2017-08-17 16:42:01 -05:00
Rob Winch
544f39f826 Add Annotated Support for WebTestClient
Fixes gh-4457
2017-07-15 22:05:54 -05:00
Rob Winch
03f2d654ad Fix WebTestClient Support
Fixes gh-4419
2017-07-13 21:02:07 -05:00
Rob Winch
915de03f42 Polish ExchangeMutatorWebFilter Support
Issue gh-4343
2017-05-31 13:23:55 -05:00
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