Merge Remove Redudant Throws
Fixes gh-7301
This commit is contained in:
@@ -32,7 +32,7 @@ public class DataSourcePopulator implements InitializingBean {
|
||||
|
||||
JdbcTemplate template;
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(template, "dataSource required");
|
||||
|
||||
template.execute("CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(500) NOT NULL,ENABLED BOOLEAN NOT NULL);");
|
||||
|
||||
@@ -105,7 +105,7 @@ public class FilterChainProxyConfigTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pathWithNoMatchHasNoFilters() throws Exception {
|
||||
public void pathWithNoMatchHasNoFilters() {
|
||||
FilterChainProxy filterChainProxy = appCtx.getBean(
|
||||
"newFilterChainProxyNoDefaultPath", FilterChainProxy.class);
|
||||
assertThat(filterChainProxy.getFilters("/nomatch")).isNull();
|
||||
@@ -113,7 +113,7 @@ public class FilterChainProxyConfigTests {
|
||||
|
||||
// SEC-1235
|
||||
@Test
|
||||
public void mixingPatternsAndPlaceholdersDoesntCauseOrderingIssues() throws Exception {
|
||||
public void mixingPatternsAndPlaceholdersDoesntCauseOrderingIssues() {
|
||||
FilterChainProxy fcp = appCtx.getBean("sec1235FilterChainProxy",
|
||||
FilterChainProxy.class);
|
||||
|
||||
@@ -128,8 +128,7 @@ public class FilterChainProxyConfigTests {
|
||||
.getRequestMatcher()).getPattern();
|
||||
}
|
||||
|
||||
private void checkPathAndFilterOrder(FilterChainProxy filterChainProxy)
|
||||
throws Exception {
|
||||
private void checkPathAndFilterOrder(FilterChainProxy filterChainProxy) {
|
||||
List<Filter> filters = filterChainProxy.getFilters("/foo/blah;x=1");
|
||||
assertThat(filters).hasSize(1);
|
||||
assertThat(filters.get(0) instanceof SecurityContextHolderAwareRequestFilter).isTrue();
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SecurityNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pre32SchemaAreNotSupported() throws Exception {
|
||||
public void pre32SchemaAreNotSupported() {
|
||||
try {
|
||||
new InMemoryXmlApplicationContext(
|
||||
"<user-service id='us'>"
|
||||
|
||||
@@ -27,7 +27,7 @@ class ConcereteSecurityConfigurerAdapter extends
|
||||
private List<Object> list = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void configure(SecurityBuilder<Object> builder) throws Exception {
|
||||
public void configure(SecurityBuilder<Object> builder) {
|
||||
list = postProcess(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class NamespaceAuthenticationProviderTests {
|
||||
|
||||
@EnableWebSecurity
|
||||
static class AuthenticationProviderRefConfig extends WebSecurityConfigurerAdapter {
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
protected void configure(AuthenticationManagerBuilder auth) {
|
||||
auth
|
||||
.authenticationProvider(authenticationProvider());
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PasswordEncoderConfigurerTests {
|
||||
// @formatter:on
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -203,7 +203,7 @@ public class AuthenticationConfigurationTests {
|
||||
inits.add(getClass());
|
||||
}
|
||||
|
||||
public void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
public void configure(AuthenticationManagerBuilder auth) {
|
||||
configs.add(getClass());
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class AuthenticationConfigurationTests {
|
||||
|
||||
static class DefaultBootGlobalAuthenticationConfigurerAdapter extends DefaultOrderGlobalAuthenticationConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
public void configure(AuthenticationManagerBuilder auth) {
|
||||
if (auth.isConfigured()) {
|
||||
return;
|
||||
}
|
||||
@@ -477,7 +477,7 @@ public class AuthenticationConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enableGlobalMethodSecurityWhenPreAuthorizeThenNoException() throws Exception {
|
||||
public void enableGlobalMethodSecurityWhenPreAuthorizeThenNoException() {
|
||||
this.spring.register(UsesPreAuthorizeMethodSecurityConfig.class, AuthenticationManagerBeanConfig.class).autowire();
|
||||
|
||||
// no exception
|
||||
@@ -491,7 +491,7 @@ public class AuthenticationConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enableGlobalMethodSecurityWhenPreAuthorizeThenUsesMethodSecurityService() throws Exception {
|
||||
public void enableGlobalMethodSecurityWhenPreAuthorizeThenUsesMethodSecurityService() {
|
||||
this.spring.register(ServicesConfig.class, UsesPreAuthorizeMethodSecurityConfig.class, AuthenticationManagerBeanConfig.class).autowire();
|
||||
|
||||
// no exception
|
||||
|
||||
@@ -154,7 +154,7 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
|
||||
|
||||
@Test
|
||||
// SEC-2382
|
||||
public void autowireBeanFactoryWhenBeanNameAutoProxyCreatorThenWorks() throws Exception {
|
||||
public void autowireBeanFactoryWhenBeanNameAutoProxyCreatorThenWorks() {
|
||||
this.spring.testConfigLocations("AutowireBeanFactoryObjectPostProcessorTests-aopconfig.xml").autowire();
|
||||
|
||||
MyAdvisedBean bean = this.spring.getContext().getBean(MyAdvisedBean.class);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
// @formatter:off
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
protected void configure(AuthenticationManagerBuilder auth) {
|
||||
auth
|
||||
.authenticationProvider(authenticationProvider());
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiPermissionEvaluatorConfig() throws Exception {
|
||||
public void multiPermissionEvaluatorConfig() {
|
||||
this.spring.register(MultiPermissionEvaluatorConfig.class).autowire();
|
||||
|
||||
// no exception
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AbstractConfiguredSecurityBuilderTests {
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void getObjectWhenNotBuiltThenThrowIllegalStateException() throws Exception {
|
||||
public void getObjectWhenNotBuiltThenThrowIllegalStateException() {
|
||||
this.builder.getObject();
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class AbstractConfiguredSecurityBuilderTests {
|
||||
super(objectPostProcessor, allowConfigurersOfSameType);
|
||||
}
|
||||
|
||||
public Object performBuild() throws Exception {
|
||||
public Object performBuild() {
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class HttpSecurityHeadersTests {
|
||||
MockMvc mockMvc;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
mockMvc = MockMvcBuilders
|
||||
.webAppContextSetup(wac)
|
||||
.addFilters(springSecurityFilterChain)
|
||||
@@ -86,7 +86,7 @@ public class HttpSecurityHeadersTests {
|
||||
@EnableWebSecurity
|
||||
static class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ public class SampleWebSecurityConfigurerAdapterTests {
|
||||
public static class SampleWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
web
|
||||
.ignoring()
|
||||
.antMatchers("/resources/**");
|
||||
@@ -367,7 +367,7 @@ public class SampleWebSecurityConfigurerAdapterTests {
|
||||
@Configuration
|
||||
public static class FormLoginWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
web
|
||||
.ignoring()
|
||||
.antMatchers("/resources/**");
|
||||
|
||||
@@ -79,7 +79,7 @@ public class WebSecurityConfigurerAdapterPowermockTests {
|
||||
@EnableWebSecurity
|
||||
static class Config extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,12 +88,12 @@ public class WebSecurityConfigurerAdapterPowermockTests {
|
||||
boolean configure;
|
||||
|
||||
@Override
|
||||
public void init(HttpSecurity builder) throws Exception {
|
||||
public void init(HttpSecurity builder) {
|
||||
this.init = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity builder) throws Exception {
|
||||
public void configure(HttpSecurity builder) {
|
||||
this.configure = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenCustomContentNegotiationStrategyBeanThenOverridesDefault() throws Exception {
|
||||
public void loadConfigWhenCustomContentNegotiationStrategyBeanThenOverridesDefault() {
|
||||
OverrideContentNegotiationStrategySharedObjectConfig.CONTENT_NEGOTIATION_STRATEGY_BEAN = mock(ContentNegotiationStrategy.class);
|
||||
this.spring.register(OverrideContentNegotiationStrategySharedObjectConfig.class).autowire();
|
||||
|
||||
@@ -267,7 +267,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenDefaultContentNegotiationStrategyThenHeaderContentNegotiationStrategy() throws Exception {
|
||||
public void loadConfigWhenDefaultContentNegotiationStrategyThenHeaderContentNegotiationStrategy() {
|
||||
this.spring.register(ContentNegotiationStrategyDefaultSharedObjectConfig.class).autowire();
|
||||
|
||||
ContentNegotiationStrategyDefaultSharedObjectConfig securityConfig =
|
||||
@@ -289,7 +289,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenUserDetailsServiceHasCircularReferenceThenStillLoads() throws Exception {
|
||||
public void loadConfigWhenUserDetailsServiceHasCircularReferenceThenStillLoads() {
|
||||
this.spring.register(RequiresUserDetailsServiceConfig.class, UserDetailsServiceConfig.class).autowire();
|
||||
|
||||
MyFilter myFilter = this.spring.getContext().getBean(MyFilter.class);
|
||||
@@ -350,7 +350,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
|
||||
// SEC-2274: WebSecurityConfigurer adds ApplicationContext as a shared object
|
||||
@Test
|
||||
public void loadConfigWhenSharedObjectsCreatedThenApplicationContextAdded() throws Exception {
|
||||
public void loadConfigWhenSharedObjectsCreatedThenApplicationContextAdded() {
|
||||
this.spring.register(ApplicationContextSharedObjectConfig.class).autowire();
|
||||
|
||||
ApplicationContextSharedObjectConfig securityConfig =
|
||||
@@ -372,7 +372,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenCustomAuthenticationTrustResolverBeanThenOverridesDefault() throws Exception {
|
||||
public void loadConfigWhenCustomAuthenticationTrustResolverBeanThenOverridesDefault() {
|
||||
CustomTrustResolverConfig.AUTHENTICATION_TRUST_RESOLVER_BEAN = mock(AuthenticationTrustResolver.class);
|
||||
this.spring.register(CustomTrustResolverConfig.class).autowire();
|
||||
|
||||
@@ -402,7 +402,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareOrderWebSecurityConfigurerAdapterWhenLowestOrderToDefaultOrderThenGreaterThanZero() throws Exception {
|
||||
public void compareOrderWebSecurityConfigurerAdapterWhenLowestOrderToDefaultOrderThenGreaterThanZero() {
|
||||
AnnotationAwareOrderComparator comparator = new AnnotationAwareOrderComparator();
|
||||
assertThat(comparator.compare(
|
||||
new LowestPriorityWebSecurityConfig(),
|
||||
|
||||
@@ -56,7 +56,7 @@ public class HttpConfigurationTests {
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
public void configureWhenAddFilterUnregisteredThenThrowsBeanCreationException() throws Exception {
|
||||
public void configureWhenAddFilterUnregisteredThenThrowsBeanCreationException() {
|
||||
Throwable thrown = catchThrowable(() -> this.spring.register(UnregisteredFilterConfig.class).autowire() );
|
||||
assertThat(thrown).isInstanceOf(BeanCreationException.class);
|
||||
assertThat(thrown.getMessage()).contains("The Filter class " + UnregisteredFilter.class.getName() +
|
||||
@@ -67,7 +67,7 @@ public class HttpConfigurationTests {
|
||||
@EnableWebSecurity
|
||||
static class UnregisteredFilterConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
http
|
||||
.addFilter(new UnregisteredFilter());
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class HttpConfigurationTests {
|
||||
static class CasAuthenticationFilterConfig extends WebSecurityConfigurerAdapter {
|
||||
static CasAuthenticationFilter CAS_AUTHENTICATION_FILTER;
|
||||
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
http
|
||||
.addFilter(CAS_AUTHENTICATION_FILTER);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class NamespaceHttpTests {
|
||||
static AuthenticationManager AUTHENTICATION_MANAGER;
|
||||
|
||||
@Override
|
||||
protected AuthenticationManager authenticationManager() throws Exception {
|
||||
protected AuthenticationManager authenticationManager() {
|
||||
return AUTHENTICATION_MANAGER;
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ public class NamespaceHttpTests {
|
||||
@EnableWebSecurity
|
||||
static class JaasApiProvisionConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
http
|
||||
.addFilter(new JaasApiIntegrationFilter());
|
||||
}
|
||||
@@ -327,7 +327,7 @@ public class NamespaceHttpTests {
|
||||
}
|
||||
|
||||
@Test // http@request-matcher-ref ant
|
||||
public void configureWhenAntPatternMatchingThenAntPathRequestMatcherUsed() throws Exception {
|
||||
public void configureWhenAntPatternMatchingThenAntPathRequestMatcherUsed() {
|
||||
this.spring.register(RequestMatcherAntConfig.class).autowire();
|
||||
|
||||
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
|
||||
@@ -340,14 +340,14 @@ public class NamespaceHttpTests {
|
||||
@EnableWebSecurity
|
||||
static class RequestMatcherAntConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
http
|
||||
.antMatcher("/api/**");
|
||||
}
|
||||
}
|
||||
|
||||
@Test // http@request-matcher-ref regex
|
||||
public void configureWhenRegexPatternMatchingThenRegexRequestMatcherUsed() throws Exception {
|
||||
public void configureWhenRegexPatternMatchingThenRegexRequestMatcherUsed() {
|
||||
this.spring.register(RequestMatcherRegexConfig.class).autowire();
|
||||
|
||||
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
|
||||
@@ -360,14 +360,14 @@ public class NamespaceHttpTests {
|
||||
@EnableWebSecurity
|
||||
static class RequestMatcherRegexConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
http
|
||||
.regexMatcher("/regex/.*");
|
||||
}
|
||||
}
|
||||
|
||||
@Test // http@request-matcher-ref
|
||||
public void configureWhenRequestMatcherProvidedThenRequestMatcherUsed() throws Exception {
|
||||
public void configureWhenRequestMatcherProvidedThenRequestMatcherUsed() {
|
||||
this.spring.register(RequestMatcherRefConfig.class).autowire();
|
||||
|
||||
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
|
||||
@@ -380,7 +380,7 @@ public class NamespaceHttpTests {
|
||||
@EnableWebSecurity
|
||||
static class RequestMatcherRefConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
http
|
||||
.requestMatcher(new MyRequestMatcher());
|
||||
}
|
||||
@@ -393,7 +393,7 @@ public class NamespaceHttpTests {
|
||||
}
|
||||
|
||||
@Test // http@security=none
|
||||
public void configureWhenIgnoredAntPatternsThenAntPathRequestMatcherUsedWithNoFilters() throws Exception {
|
||||
public void configureWhenIgnoredAntPatternsThenAntPathRequestMatcherUsedWithNoFilters() {
|
||||
this.spring.register(SecurityNoneConfig.class).autowire();
|
||||
|
||||
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
|
||||
@@ -415,14 +415,14 @@ public class NamespaceHttpTests {
|
||||
static class SecurityNoneConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
web
|
||||
.ignoring()
|
||||
.antMatchers("/resources/**", "/public/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,7 +510,7 @@ public class NamespaceHttpTests {
|
||||
}
|
||||
|
||||
@Test // http@use-expressions=true
|
||||
public void configureWhenUseExpressionsEnabledThenExpressionBasedSecurityMetadataSource() throws Exception {
|
||||
public void configureWhenUseExpressionsEnabledThenExpressionBasedSecurityMetadataSource() {
|
||||
this.spring.register(UseExpressionsConfig.class).autowire();
|
||||
|
||||
UseExpressionsConfig config = this.spring.getContext().getBean(UseExpressionsConfig.class);
|
||||
@@ -545,7 +545,7 @@ public class NamespaceHttpTests {
|
||||
}
|
||||
|
||||
@Test // http@use-expressions=false
|
||||
public void configureWhenUseExpressionsDisabledThenDefaultSecurityMetadataSource() throws Exception {
|
||||
public void configureWhenUseExpressionsDisabledThenDefaultSecurityMetadataSource() {
|
||||
this.spring.register(DisableUseExpressionsConfig.class).autowire();
|
||||
|
||||
DisableUseExpressionsConfig config = this.spring.getContext().getBean(DisableUseExpressionsConfig.class);
|
||||
|
||||
@@ -104,7 +104,7 @@ public class WebSecurityTests {
|
||||
@EnableWebMvc
|
||||
static class MvcMatcherConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
// @formatter:off
|
||||
web
|
||||
.ignoring()
|
||||
@@ -180,7 +180,7 @@ public class WebSecurityTests {
|
||||
@EnableWebMvc
|
||||
static class MvcMatcherServletPathConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
// @formatter:off
|
||||
web
|
||||
.ignoring()
|
||||
|
||||
@@ -51,7 +51,7 @@ public class EnableWebSecurityTests {
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
public void configureWhenOverrideAuthenticationManagerBeanThenAuthenticationManagerBeanRegistered() throws Exception {
|
||||
public void configureWhenOverrideAuthenticationManagerBeanThenAuthenticationManagerBeanRegistered() {
|
||||
this.spring.register(SecurityConfig.class).autowire();
|
||||
|
||||
AuthenticationManager authenticationManager = this.spring.getContext().getBean(AuthenticationManager.class);
|
||||
@@ -85,7 +85,7 @@ public class EnableWebSecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenChildConfigExtendsSecurityConfigThenSecurityConfigInherited() throws Exception {
|
||||
public void loadConfigWhenChildConfigExtendsSecurityConfigThenSecurityConfigInherited() {
|
||||
this.spring.register(ChildSecurityConfig.class).autowire();
|
||||
this.spring.getContext().getBean("springSecurityFilterChain", DebugFilter.class);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class EnableWebSecurityTests {
|
||||
@EnableWebMvc
|
||||
static class AuthenticationPrincipalConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
|
||||
@RestController
|
||||
|
||||
@@ -133,7 +133,7 @@ public class OAuth2ClientConfigurationTests {
|
||||
static OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> ACCESS_TOKEN_RESPONSE_CLIENT;
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
|
||||
@RestController
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Sec2515Tests {
|
||||
|
||||
// SEC-2515
|
||||
@Test(expected = FatalBeanException.class)
|
||||
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanThenThrowFatalBeanException() throws Exception {
|
||||
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanThenThrowFatalBeanException() {
|
||||
this.spring.register(StackOverflowSecurityConfig.class).autowire();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Sec2515Tests {
|
||||
}
|
||||
|
||||
@Test(expected = FatalBeanException.class)
|
||||
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanCustomNameThenThrowFatalBeanException() throws Exception {
|
||||
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanCustomNameThenThrowFatalBeanException() {
|
||||
this.spring.register(CustomBeanNameStackOverflowSecurityConfig.class).autowire();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Sec2515Tests {
|
||||
|
||||
// SEC-2549
|
||||
@Test
|
||||
public void loadConfigWhenChildClassLoaderSetThenContextLoads() throws Exception {
|
||||
public void loadConfigWhenChildClassLoaderSetThenContextLoads() {
|
||||
CanLoadWithChildConfig.AUTHENTICATION_MANAGER = mock(AuthenticationManager.class);
|
||||
this.spring.register(CanLoadWithChildConfig.class);
|
||||
AnnotationConfigWebApplicationContext context = (AnnotationConfigWebApplicationContext) this.spring.getContext();
|
||||
@@ -92,7 +92,7 @@ public class Sec2515Tests {
|
||||
|
||||
// SEC-2515
|
||||
@Test
|
||||
public void loadConfigWhenAuthenticationManagerConfiguredAndRegisterBeanThenContextLoads() throws Exception {
|
||||
public void loadConfigWhenAuthenticationManagerConfiguredAndRegisterBeanThenContextLoads() {
|
||||
this.spring.register(SecurityConfig.class).autowire();
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class WebSecurityConfigurationTests {
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenWebSecurityConfigurersHaveOrderThenFilterChainsOrdered() throws Exception {
|
||||
public void loadConfigWhenWebSecurityConfigurersHaveOrderThenFilterChainsOrdered() {
|
||||
this.spring.register(SortedWebSecurityConfigurerAdaptersConfig.class).autowire();
|
||||
|
||||
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
|
||||
@@ -116,7 +116,7 @@ public class WebSecurityConfigurationTests {
|
||||
@Order(1)
|
||||
static class WebConfigurer1 extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
web
|
||||
.ignoring()
|
||||
.antMatchers("/ignore1", "/ignore2");
|
||||
@@ -168,7 +168,7 @@ public class WebSecurityConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenWebSecurityConfigurersHaveSameOrderThenThrowBeanCreationException() throws Exception {
|
||||
public void loadConfigWhenWebSecurityConfigurersHaveSameOrderThenThrowBeanCreationException() {
|
||||
Throwable thrown = catchThrowable(() -> this.spring.register(DuplicateOrderConfig.class).autowire());
|
||||
|
||||
assertThat(thrown).isInstanceOf(BeanCreationException.class)
|
||||
@@ -205,7 +205,7 @@ public class WebSecurityConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenWebInvocationPrivilegeEvaluatorSetThenIsRegistered() throws Exception {
|
||||
public void loadConfigWhenWebInvocationPrivilegeEvaluatorSetThenIsRegistered() {
|
||||
PrivilegeEvaluatorConfigurerAdapterConfig.PRIVILEGE_EVALUATOR = mock(WebInvocationPrivilegeEvaluator.class);
|
||||
|
||||
this.spring.register(PrivilegeEvaluatorConfigurerAdapterConfig.class).autowire();
|
||||
@@ -219,13 +219,13 @@ public class WebSecurityConfigurationTests {
|
||||
static WebInvocationPrivilegeEvaluator PRIVILEGE_EVALUATOR;
|
||||
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
web.privilegeEvaluator(PRIVILEGE_EVALUATOR);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenSecurityExpressionHandlerSetThenIsRegistered() throws Exception {
|
||||
public void loadConfigWhenSecurityExpressionHandlerSetThenIsRegistered() {
|
||||
WebSecurityExpressionHandlerConfig.EXPRESSION_HANDLER = mock(SecurityExpressionHandler.class);
|
||||
when(WebSecurityExpressionHandlerConfig.EXPRESSION_HANDLER.getExpressionParser()).thenReturn(mock(ExpressionParser.class));
|
||||
|
||||
@@ -240,7 +240,7 @@ public class WebSecurityConfigurationTests {
|
||||
static SecurityExpressionHandler EXPRESSION_HANDLER;
|
||||
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
web.expressionHandler(EXPRESSION_HANDLER);
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ public class WebSecurityConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenDefaultSecurityExpressionHandlerThenDefaultIsRegistered() throws Exception {
|
||||
public void loadConfigWhenDefaultSecurityExpressionHandlerThenDefaultIsRegistered() {
|
||||
this.spring.register(WebSecurityExpressionHandlerDefaultsConfig.class).autowire();
|
||||
|
||||
assertThat(this.spring.getContext().getBean(SecurityExpressionHandler.class))
|
||||
@@ -272,7 +272,7 @@ public class WebSecurityConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securityExpressionHandlerWhenPermissionEvaluatorBeanThenPermissionEvaluatorUsed() throws Exception {
|
||||
public void securityExpressionHandlerWhenPermissionEvaluatorBeanThenPermissionEvaluatorUsed() {
|
||||
this.spring.register(WebSecurityExpressionHandlerPermissionEvaluatorBeanConfig.class).autowire();
|
||||
TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "notused");
|
||||
FilterInvocation invocation = new FilterInvocation(new MockHttpServletRequest("GET", ""), new MockHttpServletResponse(), new MockFilterChain());
|
||||
@@ -308,7 +308,7 @@ public class WebSecurityConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadConfigWhenDefaultWebInvocationPrivilegeEvaluatorThenDefaultIsRegistered() throws Exception {
|
||||
public void loadConfigWhenDefaultWebInvocationPrivilegeEvaluatorThenDefaultIsRegistered() {
|
||||
this.spring.register(WebInvocationPrivilegeEvaluatorDefaultsConfig.class).autowire();
|
||||
|
||||
assertThat(this.spring.getContext().getBean(WebInvocationPrivilegeEvaluator.class))
|
||||
@@ -372,7 +372,7 @@ public class WebSecurityConfigurationTests {
|
||||
|
||||
// SEC-2461
|
||||
@Test
|
||||
public void loadConfigWhenMultipleWebSecurityConfigurationThenContextLoads() throws Exception {
|
||||
public void loadConfigWhenMultipleWebSecurityConfigurationThenContextLoads() {
|
||||
this.spring.register(ParentConfig.class).autowire();
|
||||
|
||||
this.child.register(ChildConfig.class);
|
||||
@@ -400,7 +400,7 @@ public class WebSecurityConfigurationTests {
|
||||
|
||||
// SEC-2773
|
||||
@Test
|
||||
public void getMethodDelegatingApplicationListenerWhenWebSecurityConfigurationThenIsStatic() throws Exception {
|
||||
public void getMethodDelegatingApplicationListenerWhenWebSecurityConfigurationThenIsStatic() {
|
||||
Method method = ClassUtils.getMethod(WebSecurityConfiguration.class, "delegatingApplicationListener", null);
|
||||
assertThat(Modifier.isStatic(method.getModifiers())).isTrue();
|
||||
}
|
||||
@@ -426,7 +426,7 @@ public class WebSecurityConfigurationTests {
|
||||
@Order(1)
|
||||
static class WebConfigurer1 extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
web
|
||||
.ignoring()
|
||||
.antMatchers("/ignore1", "/ignore2");
|
||||
|
||||
@@ -71,7 +71,7 @@ public class CsrfConfigurerNoWebMvcTests {
|
||||
static class EnableWebConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class CsrfConfigurerNoWebMvcTests {
|
||||
static class EnableWebMvcConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ public class CsrfConfigurerTests {
|
||||
static class CsrfAppliedDefaultConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ public class DefaultFiltersTests {
|
||||
@EnableWebSecurity
|
||||
static class FilterChainProxyBuilderIgnoringConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
// @formatter:off
|
||||
web
|
||||
.ignoring()
|
||||
|
||||
@@ -166,7 +166,7 @@ public class FormLoginConfigurerTests {
|
||||
@EnableWebSecurity
|
||||
static class FormLoginConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
// @formatter:off
|
||||
web
|
||||
.ignoring()
|
||||
|
||||
@@ -101,7 +101,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
super(true);
|
||||
}
|
||||
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
http
|
||||
// this works so long as the CustomFilter extends one of the standard filters
|
||||
// if not, use addFilterBefore or addFilterAfter
|
||||
@@ -123,7 +123,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
super(true);
|
||||
}
|
||||
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
http
|
||||
.addFilterAt(new OtherCustomFilter(), UsernamePasswordAuthenticationFilter.class);
|
||||
}
|
||||
@@ -141,8 +141,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
super(true);
|
||||
}
|
||||
|
||||
protected AuthenticationManager authenticationManager()
|
||||
throws Exception {
|
||||
protected AuthenticationManager authenticationManager() {
|
||||
return new CustomAuthenticationManager();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class NamespaceHttpFirewallTests {
|
||||
MockMvc mvc;
|
||||
|
||||
@Test
|
||||
public void requestWhenPathContainsDoubleDotsThenBehaviorMatchesNamespace() throws Exception {
|
||||
public void requestWhenPathContainsDoubleDotsThenBehaviorMatchesNamespace() {
|
||||
this.rule.register(HttpFirewallConfig.class).autowire();
|
||||
assertThatCode(() -> this.mvc.perform(get("/public/../private/")))
|
||||
.isInstanceOf(RequestRejectedException.class);
|
||||
@@ -69,7 +69,7 @@ public class NamespaceHttpFirewallTests {
|
||||
@EnableWebSecurity
|
||||
static class CustomHttpFirewallConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
web
|
||||
.httpFirewall(new CustomHttpFirewall());
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class NamespaceHttpFormLoginTests {
|
||||
static class FormLoginConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void configure(WebSecurity web) throws Exception {
|
||||
public void configure(WebSecurity web) {
|
||||
web
|
||||
.ignoring()
|
||||
.antMatchers("/resources/**");
|
||||
|
||||
@@ -81,7 +81,7 @@ public class NamespaceHttpLogoutTests {
|
||||
@EnableWebSecurity
|
||||
static class HttpLogoutConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class RememberMeConfigurerTests {
|
||||
MockMvc mvc;
|
||||
|
||||
@Test
|
||||
public void postWhenNoUserDetailsServiceThenException() throws Exception {
|
||||
public void postWhenNoUserDetailsServiceThenException() {
|
||||
this.spring.register(NullUserDetailsConfig.class).autowire();
|
||||
|
||||
assertThatThrownBy(() ->
|
||||
@@ -103,7 +103,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
protected void configure(AuthenticationManagerBuilder auth) {
|
||||
User user = (User) PasswordEncodedUser.user();
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new InMemoryUserDetailsManager(Collections.singletonList(user)));
|
||||
|
||||
@@ -233,7 +233,7 @@ public class ServletApiConfigurerTests {
|
||||
static AuthenticationTrustResolver TR = spy(AuthenticationTrustResolver.class);
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.setSharedObject(AuthenticationTrustResolver.class, TR);
|
||||
|
||||
@@ -476,7 +476,7 @@ public class SessionManagementConfigurerTests {
|
||||
static AuthenticationTrustResolver TR;
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(HttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.setSharedObject(AuthenticationTrustResolver.class, TR);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class SessionManagementConfigurerTransientAuthenticationTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
protected void configure(AuthenticationManagerBuilder auth) {
|
||||
auth
|
||||
.authenticationProvider(new TransientAuthenticationProvider());
|
||||
}
|
||||
|
||||
@@ -1171,7 +1171,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configureWhenOnlyIntrospectionUrlThenException() throws Exception {
|
||||
public void configureWhenOnlyIntrospectionUrlThenException() {
|
||||
assertThatCode(() -> this.spring.register(OpaqueTokenHalfConfiguredConfig.class).autowire())
|
||||
.isInstanceOf(BeanCreationException.class);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addsAuthenticationPrincipalResolver() throws InterruptedException {
|
||||
public void addsAuthenticationPrincipalResolver() {
|
||||
loadConfig(SockJsSecurityConfig.class);
|
||||
|
||||
MessageChannel messageChannel = clientInboundChannel();
|
||||
@@ -146,8 +146,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addsAuthenticationPrincipalResolverWhenNoAuthorization()
|
||||
throws InterruptedException {
|
||||
public void addsAuthenticationPrincipalResolverWhenNoAuthorization() {
|
||||
loadConfig(NoInboundSecurityConfig.class);
|
||||
|
||||
MessageChannel messageChannel = clientInboundChannel();
|
||||
@@ -159,7 +158,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addsCsrfProtectionWhenNoAuthorization() throws InterruptedException {
|
||||
public void addsCsrfProtectionWhenNoAuthorization() {
|
||||
loadConfig(NoInboundSecurityConfig.class);
|
||||
|
||||
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor
|
||||
@@ -177,7 +176,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void csrfProtectionForConnect() throws InterruptedException {
|
||||
public void csrfProtectionForConnect() {
|
||||
loadConfig(SockJsSecurityConfig.class);
|
||||
|
||||
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor
|
||||
@@ -195,7 +194,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void csrfProtectionDisabledForConnect() throws InterruptedException {
|
||||
public void csrfProtectionDisabledForConnect() {
|
||||
loadConfig(CsrfDisabledSockJsSecurityConfig.class);
|
||||
|
||||
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor
|
||||
@@ -265,8 +264,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void msmsRegistryCustomPatternMatcher()
|
||||
throws Exception {
|
||||
public void msmsRegistryCustomPatternMatcher() {
|
||||
loadConfig(MsmsRegistryCustomPatternMatcherConfig.class);
|
||||
|
||||
clientInboundChannel().send(message("/app/a.b"));
|
||||
@@ -317,8 +315,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideMsmsRegistryCustomPatternMatcher()
|
||||
throws Exception {
|
||||
public void overrideMsmsRegistryCustomPatternMatcher() {
|
||||
loadConfig(OverrideMsmsRegistryCustomPatternMatcherConfig.class);
|
||||
|
||||
clientInboundChannel().send(message("/app/a/b"));
|
||||
@@ -371,8 +368,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultPatternMatcher()
|
||||
throws Exception {
|
||||
public void defaultPatternMatcher() {
|
||||
loadConfig(DefaultPatternMatcherConfig.class);
|
||||
|
||||
clientInboundChannel().send(message("/app/a/b"));
|
||||
@@ -422,8 +418,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customExpression()
|
||||
throws Exception {
|
||||
public void customExpression() {
|
||||
loadConfig(CustomExpressionConfig.class);
|
||||
|
||||
clientInboundChannel().send(message("/denyRob"));
|
||||
@@ -612,8 +607,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
return parameter.getParameterType().isAssignableFrom(MyCustomArgument.class);
|
||||
}
|
||||
|
||||
public Object resolveArgument(MethodParameter parameter, Message<?> message)
|
||||
throws Exception {
|
||||
public Object resolveArgument(MethodParameter parameter, Message<?> message) {
|
||||
return new MyCustomArgument("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
// SEC-1225
|
||||
public void providersAreRegisteredAsTopLevelBeans() throws Exception {
|
||||
public void providersAreRegisteredAsTopLevelBeans() {
|
||||
ConfigurableApplicationContext context = this.spring.context(CONTEXT)
|
||||
.getContext();
|
||||
assertThat(context.getBeansOfType(AuthenticationProvider.class)).hasSize(1);
|
||||
@@ -78,7 +78,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void credentialsAreClearedByDefault() throws Exception {
|
||||
public void credentialsAreClearedByDefault() {
|
||||
ConfigurableApplicationContext appContext = this.spring.context(CONTEXT)
|
||||
.getContext();
|
||||
ProviderManager pm = (ProviderManager) appContext
|
||||
@@ -87,7 +87,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearCredentialsPropertyIsRespected() throws Exception {
|
||||
public void clearCredentialsPropertyIsRespected() {
|
||||
ConfigurableApplicationContext appContext = this.spring.context("<authentication-manager erase-credentials='false'/>")
|
||||
.getContext();
|
||||
ProviderManager pm = (ProviderManager) appContext
|
||||
|
||||
@@ -57,7 +57,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void externalUserServiceRefWorks() throws Exception {
|
||||
public void externalUserServiceRefWorks() {
|
||||
appContext = new InMemoryXmlApplicationContext(
|
||||
" <authentication-manager>"
|
||||
+ " <authentication-provider user-service-ref='myUserService' />"
|
||||
@@ -69,7 +69,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void providerWithBCryptPasswordEncoderWorks() throws Exception {
|
||||
public void providerWithBCryptPasswordEncoderWorks() {
|
||||
setContext(" <authentication-provider>"
|
||||
+ " <password-encoder hash='bcrypt'/>"
|
||||
+ " <user-service>"
|
||||
@@ -80,7 +80,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void providerWithMd5PasswordEncoderWorks() throws Exception {
|
||||
public void providerWithMd5PasswordEncoderWorks() {
|
||||
appContext = new InMemoryXmlApplicationContext(
|
||||
" <authentication-manager>"
|
||||
+ " <authentication-provider>"
|
||||
@@ -99,7 +99,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void providerWithShaPasswordEncoderWorks() throws Exception {
|
||||
public void providerWithShaPasswordEncoderWorks() {
|
||||
appContext = new InMemoryXmlApplicationContext(
|
||||
" <authentication-manager>"
|
||||
+ " <authentication-provider>"
|
||||
@@ -116,7 +116,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void passwordIsBase64EncodedWhenBase64IsEnabled() throws Exception {
|
||||
public void passwordIsBase64EncodedWhenBase64IsEnabled() {
|
||||
appContext = new InMemoryXmlApplicationContext(
|
||||
" <authentication-manager>"
|
||||
+ " <authentication-provider>"
|
||||
@@ -137,7 +137,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
|
||||
|
||||
// SEC-1466
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
public void exernalProviderDoesNotSupportChildElements() throws Exception {
|
||||
public void exernalProviderDoesNotSupportChildElements() {
|
||||
appContext = new InMemoryXmlApplicationContext(
|
||||
" <authentication-manager>"
|
||||
+ " <authentication-provider ref='aProvider'> "
|
||||
|
||||
@@ -61,7 +61,7 @@ public class JdbcUserServiceBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanNameIsCorrect() throws Exception {
|
||||
public void beanNameIsCorrect() {
|
||||
assertThat(JdbcUserDetailsManager.class.getName()).isEqualTo(
|
||||
new JdbcUserServiceBeanDefinitionParser()
|
||||
.getBeanClassName(mock(Element.class)));
|
||||
|
||||
@@ -42,14 +42,14 @@ public class UserDetailsResourceFactoryBeanTest {
|
||||
UserDetailsResourceFactoryBean factory = new UserDetailsResourceFactoryBean();
|
||||
|
||||
@Test
|
||||
public void setResourceLoaderWhenNullThenThrowsException() throws Exception {
|
||||
public void setResourceLoaderWhenNullThenThrowsException() {
|
||||
assertThatThrownBy(() -> factory.setResourceLoader(null) )
|
||||
.isInstanceOf(IllegalArgumentException.class)
|
||||
.hasStackTraceContaining("resourceLoader cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectWhenPropertiesResourceLocationNullThenThrowsIllegalStateException() throws Exception {
|
||||
public void getObjectWhenPropertiesResourceLocationNullThenThrowsIllegalStateException() {
|
||||
factory.setResourceLoader(resourceLoader);
|
||||
|
||||
assertThatThrownBy(() -> factory.getObject() )
|
||||
@@ -74,7 +74,7 @@ public class UserDetailsResourceFactoryBeanTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectWhenInvalidUserThenThrowsMeaningfulException() throws Exception {
|
||||
public void getObjectWhenInvalidUserThenThrowsMeaningfulException() {
|
||||
factory.setResource(new InMemoryResource("user=invalidFormatHere"));
|
||||
|
||||
assertThatThrownBy(() -> factory.getObject() )
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CsrfBeanDefinitionParserTests {
|
||||
"classpath:org/springframework/security/config/http/CsrfBeanDefinitionParserTests";
|
||||
|
||||
@Test
|
||||
public void registerDataValueProcessorOnlyIfNotRegistered() throws Exception {
|
||||
public void registerDataValueProcessorOnlyIfNotRegistered() {
|
||||
try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext()) {
|
||||
context.setAllowBeanDefinitionOverriding(false);
|
||||
context.setConfigLocation(this.xml("RegisterDataValueProcessorOnyIfNotRegistered"));
|
||||
|
||||
@@ -621,7 +621,7 @@ public class CsrfConfigTests {
|
||||
|
||||
static class CsrfCreatedResultMatcher implements ResultMatcher {
|
||||
@Override
|
||||
public void match(MvcResult result) throws Exception {
|
||||
public void match(MvcResult result) {
|
||||
MockHttpServletRequest request = result.getRequest();
|
||||
CsrfToken token = WebTestUtils.getCsrfTokenRepository(request).loadToken(request);
|
||||
assertThat(token).isNotNull();
|
||||
|
||||
@@ -61,7 +61,7 @@ public class DefaultFilterChainValidatorTests {
|
||||
private FilterSecurityInterceptor fsi;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
AnonymousAuthenticationFilter aaf = new AnonymousAuthenticationFilter("anonymous");
|
||||
fsi = new FilterSecurityInterceptor();
|
||||
fsi.setAccessDecisionManager(accessDecisionManager);
|
||||
|
||||
@@ -34,10 +34,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -227,7 +225,7 @@ public class FormLoginConfigTests {
|
||||
public void onAuthenticationFailure(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
AuthenticationException exception) throws IOException, ServletException {
|
||||
AuthenticationException exception) {
|
||||
|
||||
response.setStatus(HttpStatus.I_AM_A_TEAPOT.value());
|
||||
}
|
||||
@@ -236,7 +234,7 @@ public class FormLoginConfigTests {
|
||||
public void onAuthenticationSuccess(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
Authentication authentication) throws IOException, ServletException {
|
||||
Authentication authentication) {
|
||||
|
||||
response.setStatus(HttpStatus.I_AM_A_TEAPOT.value());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.security.auth.Subject;
|
||||
import javax.security.auth.callback.CallbackHandler;
|
||||
import javax.security.auth.login.LoginException;
|
||||
import javax.security.auth.spi.LoginModule;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.ServletException;
|
||||
@@ -858,22 +857,22 @@ public class MiscHttpConfigTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean login() throws LoginException {
|
||||
public boolean login() {
|
||||
return this.subject.getPrincipals().add(() -> "user");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean commit() throws LoginException {
|
||||
public boolean commit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean abort() throws LoginException {
|
||||
public boolean abort() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean logout() throws LoginException {
|
||||
public boolean logout() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +104,7 @@ public class OpenIDConfigTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configureWhenOpenIDAndFormLoginBothConfigureLoginPagesThenWiringException()
|
||||
throws Exception {
|
||||
public void configureWhenOpenIDAndFormLoginBothConfigureLoginPagesThenWiringException() {
|
||||
|
||||
assertThatCode(() -> this.spring.configLocations(this.xml("WithFormLoginAndOpenIDLoginPages")).autowire())
|
||||
.isInstanceOf(BeanDefinitionParsingException.class);
|
||||
|
||||
@@ -314,7 +314,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
||||
|
||||
// SEC-1392
|
||||
@Test
|
||||
public void customPermissionEvaluatorIsSupported() throws Exception {
|
||||
public void customPermissionEvaluatorIsSupported() {
|
||||
setContext("<global-method-security pre-post-annotations='enabled'>"
|
||||
+ " <expression-handler ref='expressionHandler'/>"
|
||||
+ "</global-method-security>"
|
||||
@@ -328,7 +328,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
||||
// SEC-1450
|
||||
@Test(expected = AuthenticationException.class)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void genericsAreMatchedByProtectPointcut() throws Exception {
|
||||
public void genericsAreMatchedByProtectPointcut() {
|
||||
setContext("<b:bean id='target' class='org.springframework.security.config.method.GlobalMethodSecurityBeanDefinitionParserTests$ConcreteFoo'/>"
|
||||
+ "<global-method-security>"
|
||||
+ " <protect-pointcut expression='execution(* org..*Foo.foo(..))' access='ROLE_USER'/>"
|
||||
@@ -340,7 +340,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
||||
// SEC-1448
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void genericsMethodArgumentNamesAreResolved() throws Exception {
|
||||
public void genericsMethodArgumentNamesAreResolved() {
|
||||
setContext("<b:bean id='target' class='" + ConcreteFoo.class.getName() + "'/>"
|
||||
+ "<global-method-security pre-post-annotations='enabled'/>"
|
||||
+ AUTH_PROVIDER_XML);
|
||||
@@ -368,7 +368,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void supportsExternalMetadataSource() throws Exception {
|
||||
public void supportsExternalMetadataSource() {
|
||||
setContext("<b:bean id='target' class='"
|
||||
+ ConcreteFoo.class.getName()
|
||||
+ "'/>"
|
||||
@@ -394,7 +394,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supportsCustomAuthenticationManager() throws Exception {
|
||||
public void supportsCustomAuthenticationManager() {
|
||||
setContext("<b:bean id='target' class='"
|
||||
+ ConcreteFoo.class.getName()
|
||||
+ "'/>"
|
||||
|
||||
@@ -103,7 +103,7 @@ public class InterceptMethodsBeanDefinitionDecoratorTests implements
|
||||
}
|
||||
|
||||
@Test(expected = AuthenticationException.class)
|
||||
public void transactionalMethodsShouldBeSecured() throws Exception {
|
||||
public void transactionalMethodsShouldBeSecured() {
|
||||
transactionalTarget.doSomething();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CommonOAuth2ProviderTests {
|
||||
private static final String DEFAULT_REDIRECT_URL = "{baseUrl}/{action}/oauth2/code/{registrationId}";
|
||||
|
||||
@Test
|
||||
public void getBuilderWhenGoogleShouldHaveGoogleSettings() throws Exception {
|
||||
public void getBuilderWhenGoogleShouldHaveGoogleSettings() {
|
||||
ClientRegistration registration = build(CommonOAuth2Provider.GOOGLE);
|
||||
ProviderDetails providerDetails = registration.getProviderDetails();
|
||||
assertThat(providerDetails.getAuthorizationUri())
|
||||
@@ -58,7 +58,7 @@ public class CommonOAuth2ProviderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBuilderWhenGitHubShouldHaveGitHubSettings() throws Exception {
|
||||
public void getBuilderWhenGitHubShouldHaveGitHubSettings() {
|
||||
ClientRegistration registration = build(CommonOAuth2Provider.GITHUB);
|
||||
ProviderDetails providerDetails = registration.getProviderDetails();
|
||||
assertThat(providerDetails.getAuthorizationUri())
|
||||
@@ -81,7 +81,7 @@ public class CommonOAuth2ProviderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBuilderWhenFacebookShouldHaveFacebookSettings() throws Exception {
|
||||
public void getBuilderWhenFacebookShouldHaveFacebookSettings() {
|
||||
ClientRegistration registration = build(CommonOAuth2Provider.FACEBOOK);
|
||||
ProviderDetails providerDetails = registration.getProviderDetails();
|
||||
assertThat(providerDetails.getAuthorizationUri())
|
||||
@@ -104,7 +104,7 @@ public class CommonOAuth2ProviderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBuilderWhenOktaShouldHaveOktaSettings() throws Exception {
|
||||
public void getBuilderWhenOktaShouldHaveOktaSettings() {
|
||||
ClientRegistration registration = builder(CommonOAuth2Provider.OKTA)
|
||||
.authorizationUri("https://example.com/auth")
|
||||
.tokenUri("https://example.com/token")
|
||||
|
||||
@@ -35,11 +35,9 @@ import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -62,7 +60,7 @@ public class SpringTestContext implements Closeable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void close() {
|
||||
try {
|
||||
this.context.close();
|
||||
} catch(Exception e) {}
|
||||
@@ -104,8 +102,7 @@ public class SpringTestContext implements Closeable {
|
||||
return addFilter(new OncePerRequestFilter() {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
HttpServletResponse response, FilterChain filterChain) {
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,8 +23,6 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.security.util.InMemoryResource;
|
||||
import org.springframework.web.context.support.AbstractRefreshableWebApplicationContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.springframework.security.config.util.InMemoryXmlApplicationContext.BEANS_CLOSE;
|
||||
import static org.springframework.security.config.util.InMemoryXmlApplicationContext.BEANS_OPENING;
|
||||
import static org.springframework.security.config.util.InMemoryXmlApplicationContext.SPRING_SECURITY_VERSION;
|
||||
@@ -52,7 +50,7 @@ public class InMemoryXmlWebApplicationContext extends AbstractRefreshableWebAppl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {
|
||||
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException {
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
|
||||
reader.loadBeanDefinitions(new Resource[] { inMemoryXml });
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class AuthorizeExchangeSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void antMatchersWhenPatternsInLambdaThenAnyMethod() throws Exception {
|
||||
public void antMatchersWhenPatternsInLambdaThenAnyMethod() {
|
||||
this.http
|
||||
.csrf(ServerHttpSecurity.CsrfSpec::disable)
|
||||
.authorizeExchange(exchanges ->
|
||||
@@ -151,7 +151,7 @@ public class AuthorizeExchangeSpecTests {
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void buildWhenMatcherDefinedWithNoAccessInLambdaThenThrowsException() throws Exception {
|
||||
public void buildWhenMatcherDefinedWithNoAccessInLambdaThenThrowsException() {
|
||||
this.http
|
||||
.authorizeExchange(exchanges ->
|
||||
exchanges
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CorsSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void corsWhenEnabledInLambdaThenAccessControlAllowOriginAndSecurityHeaders() throws Exception {
|
||||
public void corsWhenEnabledInLambdaThenAccessControlAllowOriginAndSecurityHeaders() {
|
||||
this.http.cors(cors -> cors.configurationSource(this.source));
|
||||
this.expectedHeaders.set("Access-Control-Allow-Origin", "*");
|
||||
this.expectedHeaders.set("X-Frame-Options", "DENY");
|
||||
|
||||
@@ -59,8 +59,7 @@ public class ExceptionHandlingSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAuthenticationEntryPointUsed()
|
||||
throws Exception {
|
||||
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAuthenticationEntryPointUsed() {
|
||||
SecurityWebFilterChain securityWebFilter = this.http
|
||||
.authorizeExchange(exchanges ->
|
||||
exchanges
|
||||
@@ -106,7 +105,7 @@ public class ExceptionHandlingSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestWhenCustomAuthenticationEntryPointInLambdaThenCustomAuthenticationEntryPointUsed() throws Exception {
|
||||
public void requestWhenCustomAuthenticationEntryPointInLambdaThenCustomAuthenticationEntryPointUsed() {
|
||||
SecurityWebFilterChain securityWebFilter = this.http
|
||||
.authorizeExchange(exchanges ->
|
||||
exchanges
|
||||
@@ -155,8 +154,7 @@ public class ExceptionHandlingSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAccessDeniedHandlerUsed()
|
||||
throws Exception {
|
||||
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAccessDeniedHandlerUsed() {
|
||||
SecurityWebFilterChain securityWebFilter = this.http
|
||||
.httpBasic(withDefaults())
|
||||
.authorizeExchange(exchanges ->
|
||||
@@ -204,8 +202,7 @@ public class ExceptionHandlingSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestWhenCustomAccessDeniedHandlerInLambdaThenCustomAccessDeniedHandlerUsed()
|
||||
throws Exception {
|
||||
public void requestWhenCustomAccessDeniedHandlerInLambdaThenCustomAccessDeniedHandlerUsed() {
|
||||
SecurityWebFilterChain securityWebFilter = this.http
|
||||
.httpBasic(withDefaults())
|
||||
.authorizeExchange(exchanges ->
|
||||
|
||||
@@ -105,7 +105,7 @@ public class FormLoginTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() throws Exception {
|
||||
public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() {
|
||||
SecurityWebFilterChain securityWebFilter = this.http
|
||||
.authorizeExchange(exchanges ->
|
||||
exchanges
|
||||
@@ -180,7 +180,7 @@ public class FormLoginTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formLoginWhenCustomLoginPageInLambdaThenUsed() throws Exception {
|
||||
public void formLoginWhenCustomLoginPageInLambdaThenUsed() {
|
||||
SecurityWebFilterChain securityWebFilter = this.http
|
||||
.authorizeExchange(exchanges ->
|
||||
exchanges
|
||||
|
||||
@@ -79,7 +79,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenDisableInLambdaThenNoSecurityHeaders() throws Exception {
|
||||
public void headersWhenDisableInLambdaThenNoSecurityHeaders() {
|
||||
new HashSet<>(this.expectedHeaders.keySet()).forEach(this::expectHeaderNamesNotPresent);
|
||||
|
||||
this.http.headers(headers -> headers.disable());
|
||||
@@ -103,7 +103,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenDefaultsInLambdaThenAllDefaultsWritten() throws Exception {
|
||||
public void headersWhenDefaultsInLambdaThenAllDefaultsWritten() {
|
||||
this.http.headers(withDefaults());
|
||||
|
||||
assertHeaders();
|
||||
@@ -119,7 +119,7 @@ public class HeaderSpecTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void headersWhenCacheDisableInLambdaThenCacheNotWritten() throws Exception {
|
||||
public void headersWhenCacheDisableInLambdaThenCacheNotWritten() {
|
||||
expectHeaderNamesNotPresent(HttpHeaders.CACHE_CONTROL, HttpHeaders.PRAGMA, HttpHeaders.EXPIRES);
|
||||
this.http
|
||||
.headers(headers ->
|
||||
@@ -138,7 +138,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenContentOptionsDisableInLambdaThenContentTypeOptionsNotWritten() throws Exception {
|
||||
public void headersWhenContentOptionsDisableInLambdaThenContentTypeOptionsNotWritten() {
|
||||
expectHeaderNamesNotPresent(ContentTypeOptionsServerHttpHeadersWriter.X_CONTENT_OPTIONS);
|
||||
this.http
|
||||
.headers(headers ->
|
||||
@@ -157,7 +157,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenHstsDisableInLambdaThenHstsNotWritten() throws Exception {
|
||||
public void headersWhenHstsDisableInLambdaThenHstsNotWritten() {
|
||||
expectHeaderNamesNotPresent(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY);
|
||||
this.http
|
||||
.headers(headers ->
|
||||
@@ -179,7 +179,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenHstsCustomInLambdaThenCustomHstsWritten() throws Exception {
|
||||
public void headersWhenHstsCustomInLambdaThenCustomHstsWritten() {
|
||||
this.expectedHeaders.remove(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY);
|
||||
this.expectedHeaders.add(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY, "max-age=60");
|
||||
this.http
|
||||
@@ -207,7 +207,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenHstsCustomWithPreloadInLambdaThenCustomHstsWritten() throws Exception {
|
||||
public void headersWhenHstsCustomWithPreloadInLambdaThenCustomHstsWritten() {
|
||||
this.expectedHeaders.remove(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY);
|
||||
this.expectedHeaders.add(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY, "max-age=60 ; includeSubDomains ; preload");
|
||||
this.http
|
||||
@@ -232,7 +232,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenFrameOptionsDisableInLambdaThenFrameOptionsNotWritten() throws Exception {
|
||||
public void headersWhenFrameOptionsDisableInLambdaThenFrameOptionsNotWritten() {
|
||||
expectHeaderNamesNotPresent(XFrameOptionsServerHttpHeadersWriter.X_FRAME_OPTIONS);
|
||||
this.http
|
||||
.headers(headers ->
|
||||
@@ -253,7 +253,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenFrameOptionsModeInLambdaThenFrameOptionsCustomMode() throws Exception {
|
||||
public void headersWhenFrameOptionsModeInLambdaThenFrameOptionsCustomMode() {
|
||||
this.expectedHeaders.set(XFrameOptionsServerHttpHeadersWriter.X_FRAME_OPTIONS, "SAMEORIGIN");
|
||||
this.http
|
||||
.headers(headers ->
|
||||
@@ -276,7 +276,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenXssProtectionDisableInLambdaThenXssProtectionNotWritten() throws Exception {
|
||||
public void headersWhenXssProtectionDisableInLambdaThenXssProtectionNotWritten() {
|
||||
expectHeaderNamesNotPresent("X-Xss-Protection");
|
||||
this.http
|
||||
.headers(headers ->
|
||||
@@ -309,7 +309,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenContentSecurityPolicyEnabledWithDefaultsInLambdaThenDefaultPolicyWritten() throws Exception {
|
||||
public void headersWhenContentSecurityPolicyEnabledWithDefaultsInLambdaThenDefaultPolicyWritten() {
|
||||
String expectedPolicyDirectives = "default-src 'self'";
|
||||
this.expectedHeaders.add(ContentSecurityPolicyServerHttpHeadersWriter.CONTENT_SECURITY_POLICY,
|
||||
expectedPolicyDirectives);
|
||||
@@ -323,7 +323,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenContentSecurityPolicyEnabledInLambdaThenContentSecurityPolicyWritten() throws Exception {
|
||||
public void headersWhenContentSecurityPolicyEnabledInLambdaThenContentSecurityPolicyWritten() {
|
||||
String policyDirectives = "default-src 'self' *.trusted.com";
|
||||
this.expectedHeaders.add(ContentSecurityPolicyServerHttpHeadersWriter.CONTENT_SECURITY_POLICY,
|
||||
policyDirectives);
|
||||
@@ -350,7 +350,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenReferrerPolicyEnabledInLambdaThenReferrerPolicyWritten() throws Exception {
|
||||
public void headersWhenReferrerPolicyEnabledInLambdaThenReferrerPolicyWritten() {
|
||||
this.expectedHeaders.add(ReferrerPolicyServerHttpHeadersWriter.REFERRER_POLICY,
|
||||
ReferrerPolicy.NO_REFERRER.getPolicy());
|
||||
this.http
|
||||
@@ -372,7 +372,7 @@ public class HeaderSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersWhenReferrerPolicyCustomEnabledInLambdaThenCustomReferrerPolicyWritten() throws Exception {
|
||||
public void headersWhenReferrerPolicyCustomEnabledInLambdaThenCustomReferrerPolicyWritten() {
|
||||
this.expectedHeaders.add(ReferrerPolicyServerHttpHeadersWriter.REFERRER_POLICY,
|
||||
ReferrerPolicy.NO_REFERRER_WHEN_DOWNGRADE.getPolicy());
|
||||
this.http
|
||||
|
||||
@@ -121,7 +121,7 @@ public class LogoutSpecTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() throws Exception {
|
||||
public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() {
|
||||
SecurityWebFilterChain securityWebFilter = this.http
|
||||
.authorizeExchange(authorizeExchange ->
|
||||
authorizeExchange
|
||||
|
||||
@@ -522,7 +522,7 @@ public class OAuth2LoginTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void logoutWhenUsingOidcLogoutHandlerThenRedirects() throws Exception {
|
||||
public void logoutWhenUsingOidcLogoutHandlerThenRedirects() {
|
||||
this.spring.register(OAuth2LoginConfigWithOidcLogoutSuccessHandler.class).autowire();
|
||||
|
||||
OAuth2AuthenticationToken token = new OAuth2AuthenticationToken(
|
||||
|
||||
@@ -683,7 +683,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class CustomAuthenticationManagerResolverConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange()
|
||||
|
||||
@@ -105,7 +105,7 @@ public class RequestCacheTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() throws Exception {
|
||||
public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() {
|
||||
SecurityWebFilterChain securityWebFilter = this.http
|
||||
.authorizeExchange(authorizeExchange ->
|
||||
authorizeExchange
|
||||
|
||||
@@ -264,7 +264,7 @@ public class ServerHttpSecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWhenAnonymousConfiguredThenAuthenticationIsAnonymous() throws Exception {
|
||||
public void getWhenAnonymousConfiguredThenAuthenticationIsAnonymous() {
|
||||
SecurityWebFilterChain securityFilterChain = this.http.anonymous(withDefaults()).build();
|
||||
WebTestClient client = WebTestClientBuilder.bindToControllerAndWebFilters(AnonymousAuthenticationWebFilterTests.HttpMeController.class,
|
||||
securityFilterChain).build();
|
||||
@@ -323,7 +323,7 @@ public class ServerHttpSecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestWhenBasicWithRealmNameInLambdaThenRealmNameUsed() throws Exception {
|
||||
public void requestWhenBasicWithRealmNameInLambdaThenRealmNameUsed() {
|
||||
this.http.securityContextRepository(new WebSessionServerSecurityContextRepository());
|
||||
HttpBasicServerAuthenticationEntryPoint authenticationEntryPoint = new HttpBasicServerAuthenticationEntryPoint();
|
||||
authenticationEntryPoint.setRealm("myrealm");
|
||||
@@ -367,7 +367,7 @@ public class ServerHttpSecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestWhenBasicWithAuthenticationManagerInLambdaThenAuthenticationManagerUsed() throws Exception {
|
||||
public void requestWhenBasicWithAuthenticationManagerInLambdaThenAuthenticationManagerUsed() {
|
||||
ReactiveAuthenticationManager customAuthenticationManager = mock(ReactiveAuthenticationManager.class);
|
||||
given(customAuthenticationManager.authenticate(any()))
|
||||
.willReturn(Mono.just(new TestingAuthenticationToken("rob", "rob", "ROLE_USER", "ROLE_ADMIN")));
|
||||
@@ -409,7 +409,7 @@ public class ServerHttpSecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void x509WhenCustomizedThenAddsX509Filter() throws Exception {
|
||||
public void x509WhenCustomizedThenAddsX509Filter() {
|
||||
X509PrincipalExtractor mockExtractor = mock(X509PrincipalExtractor.class);
|
||||
ReactiveAuthenticationManager mockAuthenticationManager = mock(ReactiveAuthenticationManager.class);
|
||||
|
||||
@@ -436,7 +436,7 @@ public class ServerHttpSecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void x509WhenDefaultsThenAddsX509Filter() throws Exception {
|
||||
public void x509WhenDefaultsThenAddsX509Filter() {
|
||||
this.http.x509(withDefaults());
|
||||
|
||||
SecurityWebFilterChain securityWebFilterChain = this.http.build();
|
||||
@@ -446,7 +446,7 @@ public class ServerHttpSecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postWhenCsrfDisabledThenPermitted() throws Exception {
|
||||
public void postWhenCsrfDisabledThenPermitted() {
|
||||
SecurityWebFilterChain securityFilterChain = this.http.csrf(csrf -> csrf.disable()).build();
|
||||
WebFilterChainProxy springSecurityFilterChain = new WebFilterChainProxy(securityFilterChain);
|
||||
WebTestClient client = WebTestClientBuilder.bindToWebFilters(springSecurityFilterChain).build();
|
||||
@@ -458,7 +458,7 @@ public class ServerHttpSecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postWhenCustomCsrfTokenRepositoryThenUsed() throws Exception {
|
||||
public void postWhenCustomCsrfTokenRepositoryThenUsed() {
|
||||
ServerCsrfTokenRepository customServerCsrfTokenRepository = mock(ServerCsrfTokenRepository.class);
|
||||
when(customServerCsrfTokenRepository.loadToken(any(ServerWebExchange.class))).thenReturn(Mono.empty());
|
||||
SecurityWebFilterChain securityFilterChain = this.http
|
||||
|
||||
@@ -299,7 +299,7 @@ public class WebSocketMessageBrokerConfigTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendWhenNoIdMessageThenAuthenticationPrincipalResolved() throws Exception {
|
||||
public void sendWhenNoIdMessageThenAuthenticationPrincipalResolved() {
|
||||
this.spring.configLocations(xml("SyncConfig")).autowire();
|
||||
|
||||
this.clientInboundChannel.send(message("/message"));
|
||||
@@ -484,7 +484,7 @@ public class WebSocketMessageBrokerConfigTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception {
|
||||
public Object resolveArgument(MethodParameter parameter, Message<?> message) {
|
||||
return new MessageArgument("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ final class MockWebResponseBuilder {
|
||||
return new WebResponse(webResponseData, this.webRequest, endTime - this.startTime);
|
||||
}
|
||||
|
||||
private WebResponseData webResponseData() throws IOException {
|
||||
private WebResponseData webResponseData() {
|
||||
List<NameValuePair> responseHeaders = responseHeaders();
|
||||
HttpStatus status = this.exchangeResult.getStatus();
|
||||
return new WebResponseData(this.exchangeResult.getResponseBodyContent(), status.value(), status.getReasonPhrase(), responseHeaders);
|
||||
|
||||
Reference in New Issue
Block a user