Skip to content

Commit

Permalink
Merge branch '2.2.x' into 2.3.x
Browse files Browse the repository at this point in the history
Closes gh-22175
  • Loading branch information
wilkinsona committed Jun 30, 2020
2 parents 4566ac5 + 500d2bd commit 0e1ded6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -73,7 +73,7 @@ private EnumSet<DispatcherType> getDispatcherTypes(SecurityProperties securityPr
}
return securityProperties.getFilter().getDispatcherTypes().stream()
.map((type) -> DispatcherType.valueOf(type.name()))
.collect(Collectors.collectingAndThen(Collectors.toSet(), EnumSet::copyOf));
.collect(Collectors.toCollection(() -> EnumSet.noneOf(DispatcherType.class)));
}

}
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,7 +53,7 @@ private EnumSet<DispatcherType> getDispatcherTypes(SessionProperties sessionProp
return null;
}
return servletProperties.getFilterDispatcherTypes().stream().map((type) -> DispatcherType.valueOf(type.name()))
.collect(Collectors.collectingAndThen(Collectors.toSet(), EnumSet::copyOf));
.collect(Collectors.toCollection(() -> EnumSet.noneOf(DispatcherType.class)));
}

}
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -164,6 +164,19 @@ void customFilterDispatcherTypes() {
});
}

@Test
void emptyFilterDispatcherTypesDoNotThrowException() {
this.contextRunner.withPropertyValues("spring.security.filter.dispatcher-types:")
.withConfiguration(AutoConfigurations.of(SecurityFilterAutoConfiguration.class)).run((context) -> {
DelegatingFilterProxyRegistrationBean bean = context.getBean("securityFilterChainRegistration",
DelegatingFilterProxyRegistrationBean.class);
@SuppressWarnings("unchecked")
EnumSet<DispatcherType> dispatcherTypes = (EnumSet<DispatcherType>) ReflectionTestUtils
.getField(bean, "dispatcherTypes");
assertThat(dispatcherTypes).isEmpty();
});
}

@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(City.class)
static class EntityConfiguration {
Expand Down
Expand Up @@ -143,6 +143,17 @@ void filterDispatcherTypesCanBeCustomized() {
});
}

@SuppressWarnings("unchecked")
@Test
void emptyFilterDispatcherTypesDoNotThrowException() {
this.contextRunner.withUserConfiguration(SessionRepositoryConfiguration.class)
.withPropertyValues("spring.session.servlet.filter-dispatcher-types=").run((context) -> {
FilterRegistrationBean<?> registration = context.getBean(FilterRegistrationBean.class);
Object dispatcherTypes = ReflectionTestUtils.getField(registration, "dispatcherTypes");
assertThat((EnumSet<DispatcherType>) dispatcherTypes).isEmpty();
});
}

@Test
void sessionCookieConfigurationIsAppliedToAutoConfiguredCookieSerializer() {
this.contextRunner.withUserConfiguration(SessionRepositoryConfiguration.class)
Expand Down

0 comments on commit 0e1ded6

Please sign in to comment.