Update spring-javaformat to 0.0.39
Closes gh-2528
This commit is contained in:
@@ -38,7 +38,7 @@ public interface FindByIndexNameSessionRepository<S extends Session> extends Ses
|
||||
* @since 1.1
|
||||
*/
|
||||
String PRINCIPAL_NAME_INDEX_NAME = FindByIndexNameSessionRepository.class.getName()
|
||||
.concat(".PRINCIPAL_NAME_INDEX_NAME");
|
||||
.concat(".PRINCIPAL_NAME_INDEX_NAME");
|
||||
|
||||
/**
|
||||
* Find a {@link Map} of the session id to the {@link Session} of all sessions that
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class MapSession implements Session, Serializable {
|
||||
* Default {@link #setMaxInactiveInterval(Duration)} (30 minutes).
|
||||
*/
|
||||
public static final Duration DEFAULT_MAX_INACTIVE_INTERVAL = Duration
|
||||
.ofSeconds(DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS);
|
||||
.ofSeconds(DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS);
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
@@ -33,16 +33,17 @@ class CommonSessionRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
Arrays.asList(TypeReference.of(String.class), TypeReference.of(ArrayList.class),
|
||||
TypeReference.of(TreeSet.class), TypeReference.of(Number.class), TypeReference.of(Long.class),
|
||||
TypeReference.of(Integer.class), TypeReference.of(StackTraceElement.class),
|
||||
TypeReference.of(Throwable.class), TypeReference.of(Exception.class),
|
||||
TypeReference.of(RuntimeException.class),
|
||||
TypeReference.of("java.util.Collections$UnmodifiableCollection"),
|
||||
TypeReference.of("java.util.Collections$UnmodifiableList"),
|
||||
TypeReference.of("java.util.Collections$EmptyList"),
|
||||
TypeReference.of("java.util.Collections$UnmodifiableRandomAccessList"),
|
||||
TypeReference.of("java.util.Collections$UnmodifiableSet")).forEach(hints.serialization()::registerType);
|
||||
Arrays
|
||||
.asList(TypeReference.of(String.class), TypeReference.of(ArrayList.class), TypeReference.of(TreeSet.class),
|
||||
TypeReference.of(Number.class), TypeReference.of(Long.class), TypeReference.of(Integer.class),
|
||||
TypeReference.of(StackTraceElement.class), TypeReference.of(Throwable.class),
|
||||
TypeReference.of(Exception.class), TypeReference.of(RuntimeException.class),
|
||||
TypeReference.of("java.util.Collections$UnmodifiableCollection"),
|
||||
TypeReference.of("java.util.Collections$UnmodifiableList"),
|
||||
TypeReference.of("java.util.Collections$EmptyList"),
|
||||
TypeReference.of("java.util.Collections$UnmodifiableRandomAccessList"),
|
||||
TypeReference.of("java.util.Collections$UnmodifiableSet"))
|
||||
.forEach(hints.serialization()::registerType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,34 +53,37 @@ class CommonSessionSecurityRuntimeHints implements RuntimeHintsRegistrar {
|
||||
TypeReference.of("org.springframework.security.authentication.CredentialsExpiredException"),
|
||||
TypeReference.of("org.springframework.security.authentication.InsufficientAuthenticationException"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.web.authentication.session.SessionAuthenticationException"),
|
||||
TypeReference.of(
|
||||
"org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationException"),
|
||||
.of("org.springframework.security.web.authentication.session.SessionAuthenticationException"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationException"),
|
||||
TypeReference.of("org.springframework.security.core.userdetails.User$AuthorityComparator"))
|
||||
.forEach((type) -> hints.serialization().registerType(type, (hint) -> hint.onReachableType(
|
||||
.forEach((type) -> hints.serialization()
|
||||
.registerType(type, (hint) -> hint.onReachableType(
|
||||
TypeReference.of("org.springframework.security.core.context.SecurityContextImpl"))));
|
||||
}
|
||||
|
||||
private void registerOAuth2ResourceServerHintsIfNeeded(RuntimeHints hints) {
|
||||
Arrays.asList(
|
||||
TypeReference.of("org.springframework.security.oauth2.server.resource.BearerTokenAuthenticationToken"),
|
||||
TypeReference.of(
|
||||
"org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken"),
|
||||
TypeReference.of("org.springframework.security.oauth2.core.OAuth2AuthenticationException"))
|
||||
.forEach((type) -> hints.serialization().registerType(type, (hint) -> hint.onReachableType(TypeReference
|
||||
.of("org.springframework.security.oauth2.server.resource.BearerTokenAuthenticationToken"))));
|
||||
.forEach((type) -> hints.serialization()
|
||||
.registerType(type, (hint) -> hint.onReachableType(TypeReference
|
||||
.of("org.springframework.security.oauth2.server.resource.BearerTokenAuthenticationToken"))));
|
||||
}
|
||||
|
||||
private void registerOAuth2ClientHintsIfNeeded(RuntimeHints hints) {
|
||||
Arrays.asList(
|
||||
TypeReference.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationToken"),
|
||||
TypeReference.of(
|
||||
"org.springframework.security.oauth2.client.authentication.OAuth2AuthorizationCodeAuthenticationToken"),
|
||||
.of("org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationToken"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthorizationCodeAuthenticationToken"),
|
||||
TypeReference.of("org.springframework.security.oauth2.core.OAuth2AuthenticationException"))
|
||||
.forEach((type) -> hints.serialization().registerType(type, (hint) -> hint.onReachableType(TypeReference
|
||||
.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken"))));
|
||||
.forEach((type) -> hints.serialization()
|
||||
.registerType(type, (hint) -> hint.onReachableType(TypeReference
|
||||
.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken"))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class WebSessionSecurityRuntimeHints implements RuntimeHintsRegistrar {
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
if (!ClassUtils.isPresent("org.springframework.web.server.WebSession", classLoader) || !ClassUtils
|
||||
.isPresent("org.springframework.security.web.server.csrf.DefaultCsrfToken", classLoader)) {
|
||||
.isPresent("org.springframework.security.web.server.csrf.DefaultCsrfToken", classLoader)) {
|
||||
return;
|
||||
}
|
||||
hints.serialization().registerType(DefaultCsrfToken.class);
|
||||
|
||||
@@ -42,11 +42,12 @@ class HttpSessionSecurityRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|| !ClassUtils.isPresent("org.springframework.security.web.csrf.DefaultCsrfToken", classLoader)) {
|
||||
return;
|
||||
}
|
||||
Arrays.asList(TypeReference.of(TreeMap.class), TypeReference.of(Locale.class),
|
||||
TypeReference.of(DefaultSavedRequest.class), TypeReference.of(DefaultCsrfToken.class),
|
||||
TypeReference.of(WebAuthenticationDetails.class), TypeReference.of(SavedCookie.class),
|
||||
TypeReference.of("java.lang.String$CaseInsensitiveComparator"))
|
||||
.forEach(hints.serialization()::registerType);
|
||||
Arrays
|
||||
.asList(TypeReference.of(TreeMap.class), TypeReference.of(Locale.class),
|
||||
TypeReference.of(DefaultSavedRequest.class), TypeReference.of(DefaultCsrfToken.class),
|
||||
TypeReference.of(WebAuthenticationDetails.class), TypeReference.of(SavedCookie.class),
|
||||
TypeReference.of("java.lang.String$CaseInsensitiveComparator"))
|
||||
.forEach(hints.serialization()::registerType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class SpringHttpSessionConfiguration implements InitializingBean, Applica
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (ClassUtils.isPresent("org.springframework.security.web.authentication.RememberMeServices", null)) {
|
||||
this.usesSpringSessionRememberMeServices = !ObjectUtils
|
||||
.isEmpty(applicationContext.getBeanNamesForType(SpringSessionRememberMeServices.class));
|
||||
.isEmpty(applicationContext.getBeanNamesForType(SpringSessionRememberMeServices.class));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ import org.springframework.session.web.http.CookieSerializer.CookieValue;
|
||||
public final class CookieHttpSessionIdResolver implements HttpSessionIdResolver {
|
||||
|
||||
private static final String WRITTEN_SESSION_ID_ATTR = CookieHttpSessionIdResolver.class.getName()
|
||||
.concat(".WRITTEN_SESSION_ID_ATTR");
|
||||
.concat(".WRITTEN_SESSION_ID_ATTR");
|
||||
|
||||
private CookieSerializer cookieSerializer = new DefaultCookieSerializer();
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class HttpSessionAdapter<S extends Session> implements HttpSession {
|
||||
if (oldValue instanceof HttpSessionBindingListener) {
|
||||
try {
|
||||
((HttpSessionBindingListener) oldValue)
|
||||
.valueUnbound(new HttpSessionBindingEvent(this, name, oldValue));
|
||||
.valueUnbound(new HttpSessionBindingEvent(this, name, oldValue));
|
||||
}
|
||||
catch (Throwable th) {
|
||||
logger.error("Error invoking session binding event listener", th);
|
||||
|
||||
@@ -92,7 +92,8 @@ public class SpringSessionWebSessionStore<S extends Session> implements WebSessi
|
||||
@Override
|
||||
public Mono<WebSession> retrieveSession(String sessionId) {
|
||||
return this.sessions.findById(sessionId)
|
||||
.doOnNext((session) -> session.setLastAccessedTime(this.clock.instant())).map(this::existingSession);
|
||||
.doOnNext((session) -> session.setLastAccessedTime(this.clock.instant()))
|
||||
.map(this::existingSession);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -233,8 +234,9 @@ public class SpringSessionWebSessionStore<S extends Session> implements WebSessi
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
return this.session.getAttributeNames().stream()
|
||||
.anyMatch((attrName) -> this.session.getAttribute(attrName) != null);
|
||||
return this.session.getAttributeNames()
|
||||
.stream()
|
||||
.anyMatch((attrName) -> this.session.getAttribute(attrName) != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,7 +67,7 @@ public final class WebSocketRegistryListener implements ApplicationListener<Appl
|
||||
else if (event instanceof SessionDisconnectEvent) {
|
||||
SessionDisconnectEvent e = (SessionDisconnectEvent) event;
|
||||
Map<String, Object> sessionAttributes = SimpMessageHeaderAccessor
|
||||
.getSessionAttributes(e.getMessage().getHeaders());
|
||||
.getSessionAttributes(e.getMessage().getHeaders());
|
||||
String httpSessionId = (sessionAttributes != null)
|
||||
? SessionRepositoryMessageInterceptor.getSessionId(sessionAttributes) : null;
|
||||
afterConnectionClosed(httpSessionId, e.getSessionId());
|
||||
|
||||
@@ -39,7 +39,7 @@ class MapSessionTests {
|
||||
@Test
|
||||
void constructorNullSession() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new MapSession((Session) null))
|
||||
.withMessage("session cannot be null");
|
||||
.withMessage("session cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,7 +70,7 @@ class MapSessionTests {
|
||||
@Test
|
||||
void getRequiredAttributeWhenNullThenException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.session.getRequiredAttribute("attrName"))
|
||||
.withMessage("Required attribute 'attrName' is missing.");
|
||||
.withMessage("Required attribute 'attrName' is missing.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -61,7 +61,7 @@ class ReactiveMapSessionRepositoryTests {
|
||||
@Test
|
||||
void constructorMapWhenNullThenThrowsIllegalArgumentException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ReactiveMapSessionRepository(null))
|
||||
.withMessage("sessions cannot be null");
|
||||
.withMessage("sessions cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -53,8 +53,9 @@ class CommonSessionRuntimeHintsTests {
|
||||
@Test
|
||||
void aotFactoriesContainsRegistrar() {
|
||||
boolean match = SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
|
||||
.load(RuntimeHintsRegistrar.class).stream()
|
||||
.anyMatch((registrar) -> registrar instanceof CommonSessionRuntimeHints);
|
||||
.load(RuntimeHintsRegistrar.class)
|
||||
.stream()
|
||||
.anyMatch((registrar) -> registrar instanceof CommonSessionRuntimeHints);
|
||||
assertThat(match).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,9 @@ class CommonSessionSecurityRuntimeHintsTests {
|
||||
@Test
|
||||
void aotFactoriesContainsRegistrar() {
|
||||
boolean match = SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
|
||||
.load(RuntimeHintsRegistrar.class).stream()
|
||||
.anyMatch((registrar) -> registrar instanceof CommonSessionSecurityRuntimeHints);
|
||||
.load(RuntimeHintsRegistrar.class)
|
||||
.stream()
|
||||
.anyMatch((registrar) -> registrar instanceof CommonSessionSecurityRuntimeHints);
|
||||
assertThat(match).isTrue();
|
||||
}
|
||||
|
||||
@@ -73,19 +74,19 @@ class CommonSessionSecurityRuntimeHintsTests {
|
||||
TypeReference.of("org.springframework.security.authentication.CredentialsExpiredException"),
|
||||
TypeReference.of("org.springframework.security.authentication.InsufficientAuthenticationException"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.web.authentication.session.SessionAuthenticationException"),
|
||||
TypeReference.of(
|
||||
"org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationException"),
|
||||
.of("org.springframework.security.web.authentication.session.SessionAuthenticationException"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationException"),
|
||||
TypeReference.of("org.springframework.security.core.userdetails.User$AuthorityComparator"),
|
||||
TypeReference.of("org.springframework.security.oauth2.server.resource.BearerTokenAuthenticationToken"),
|
||||
TypeReference.of(
|
||||
"org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken"),
|
||||
TypeReference.of("org.springframework.security.oauth2.core.OAuth2AuthenticationException"),
|
||||
TypeReference.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationToken"),
|
||||
TypeReference.of(
|
||||
"org.springframework.security.oauth2.client.authentication.OAuth2AuthorizationCodeAuthenticationToken"),
|
||||
.of("org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationToken"),
|
||||
TypeReference
|
||||
.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthorizationCodeAuthenticationToken"),
|
||||
TypeReference.of("org.springframework.security.oauth2.core.OAuth2AuthenticationException"));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class WebSessionSecurityRuntimeHintsTests {
|
||||
void registerHintsWhenWebSessionMissingThenDoNotRegisterHints() {
|
||||
try (MockedStatic<ClassUtils> classUtilsMock = mockStatic(ClassUtils.class)) {
|
||||
classUtilsMock.when(() -> ClassUtils.isPresent(eq("org.springframework.web.server.WebSession"), any()))
|
||||
.thenReturn(false);
|
||||
.thenReturn(false);
|
||||
this.webSessionSecurityRuntimeHints.registerHints(this.hints, getClass().getClassLoader());
|
||||
assertThat(this.hints.serialization().javaSerializationHints()).isEmpty();
|
||||
}
|
||||
@@ -62,9 +62,9 @@ class WebSessionSecurityRuntimeHintsTests {
|
||||
void registerHintsWhenDefaultCsrfTokenMissingThenDoNotRegisterHints() {
|
||||
try (MockedStatic<ClassUtils> classUtilsMock = mockStatic(ClassUtils.class)) {
|
||||
classUtilsMock
|
||||
.when(() -> ClassUtils
|
||||
.isPresent(eq("org.springframework.security.web.server.csrf.DefaultCsrfToken"), any()))
|
||||
.thenReturn(false);
|
||||
.when(() -> ClassUtils.isPresent(eq("org.springframework.security.web.server.csrf.DefaultCsrfToken"),
|
||||
any()))
|
||||
.thenReturn(false);
|
||||
this.webSessionSecurityRuntimeHints.registerHints(this.hints, getClass().getClassLoader());
|
||||
assertThat(this.hints.serialization().javaSerializationHints()).isEmpty();
|
||||
}
|
||||
@@ -73,8 +73,9 @@ class WebSessionSecurityRuntimeHintsTests {
|
||||
@Test
|
||||
void aotFactoriesContainsRegistrar() {
|
||||
boolean match = SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
|
||||
.load(RuntimeHintsRegistrar.class).stream()
|
||||
.anyMatch((registrar) -> registrar instanceof WebSessionSecurityRuntimeHints);
|
||||
.load(RuntimeHintsRegistrar.class)
|
||||
.stream()
|
||||
.anyMatch((registrar) -> registrar instanceof WebSessionSecurityRuntimeHints);
|
||||
assertThat(match).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class HttpSessionSecurityRuntimeHintsTests {
|
||||
void registerHintsWhenHttpSessionMissingThenDoNotRegisterHints() {
|
||||
try (MockedStatic<ClassUtils> classUtilsMock = mockStatic(ClassUtils.class)) {
|
||||
classUtilsMock.when(() -> ClassUtils.isPresent(eq("jakarta.servlet.http.HttpSession"), any()))
|
||||
.thenReturn(false);
|
||||
.thenReturn(false);
|
||||
this.httpSessionSecurityRuntimeHints.registerHints(this.hints, getClass().getClassLoader());
|
||||
assertThat(this.hints.serialization().javaSerializationHints()).isEmpty();
|
||||
}
|
||||
@@ -72,9 +72,9 @@ class HttpSessionSecurityRuntimeHintsTests {
|
||||
@Test
|
||||
void registerHintsWhenDefaultCsrfTokenMissingThenDoNotRegisterHints() {
|
||||
try (MockedStatic<ClassUtils> classUtilsMock = mockStatic(ClassUtils.class)) {
|
||||
classUtilsMock.when(
|
||||
() -> ClassUtils.isPresent(eq("org.springframework.security.web.csrf.DefaultCsrfToken"), any()))
|
||||
.thenReturn(false);
|
||||
classUtilsMock
|
||||
.when(() -> ClassUtils.isPresent(eq("org.springframework.security.web.csrf.DefaultCsrfToken"), any()))
|
||||
.thenReturn(false);
|
||||
this.httpSessionSecurityRuntimeHints.registerHints(this.hints, getClass().getClassLoader());
|
||||
assertThat(this.hints.serialization().javaSerializationHints()).isEmpty();
|
||||
}
|
||||
@@ -83,8 +83,9 @@ class HttpSessionSecurityRuntimeHintsTests {
|
||||
@Test
|
||||
void aotFactoriesContainsRegistrar() {
|
||||
boolean match = SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
|
||||
.load(RuntimeHintsRegistrar.class).stream()
|
||||
.anyMatch((registrar) -> registrar instanceof HttpSessionSecurityRuntimeHints);
|
||||
.load(RuntimeHintsRegistrar.class)
|
||||
.stream()
|
||||
.anyMatch((registrar) -> registrar instanceof HttpSessionSecurityRuntimeHints);
|
||||
assertThat(match).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class EnableSpringHttpSessionCustomCookieSerializerTests {
|
||||
void usesReadSessionIds() throws Exception {
|
||||
String sessionId = "sessionId";
|
||||
given(this.cookieSerializer.readCookieValues(any(HttpServletRequest.class)))
|
||||
.willReturn(Collections.singletonList(sessionId));
|
||||
.willReturn(Collections.singletonList(sessionId));
|
||||
given(this.sessionRepository.findById(anyString())).willReturn(new MapSession(sessionId));
|
||||
|
||||
this.sessionRepositoryFilter.doFilter(this.request, this.response, this.chain);
|
||||
|
||||
@@ -64,8 +64,8 @@ class SpringHttpSessionConfigurationTests {
|
||||
@Test
|
||||
void noSessionRepositoryConfiguration() {
|
||||
assertThatExceptionOfType(UnsatisfiedDependencyException.class)
|
||||
.isThrownBy(() -> registerAndRefresh(EmptyConfiguration.class))
|
||||
.withMessageContaining("org.springframework.session.SessionRepository");
|
||||
.isThrownBy(() -> registerAndRefresh(EmptyConfiguration.class))
|
||||
.withMessageContaining("org.springframework.session.SessionRepository");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,10 +84,10 @@ class SpringHttpSessionConfigurationTests {
|
||||
SessionRepositoryFilter sessionRepositoryFilter = this.context.getBean(SessionRepositoryFilter.class);
|
||||
assertThat(sessionRepositoryFilter).isNotNull();
|
||||
CookieHttpSessionIdResolver httpSessionIdResolver = (CookieHttpSessionIdResolver) ReflectionTestUtils
|
||||
.getField(sessionRepositoryFilter, "httpSessionIdResolver");
|
||||
.getField(sessionRepositoryFilter, "httpSessionIdResolver");
|
||||
assertThat(httpSessionIdResolver).isNotNull();
|
||||
DefaultCookieSerializer cookieSerializer = (DefaultCookieSerializer) ReflectionTestUtils
|
||||
.getField(httpSessionIdResolver, "cookieSerializer");
|
||||
.getField(httpSessionIdResolver, "cookieSerializer");
|
||||
assertThat(cookieSerializer).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(cookieSerializer, "cookieName")).isEqualTo("test-name");
|
||||
assertThat(ReflectionTestUtils.getField(cookieSerializer, "cookiePath")).isEqualTo("test-path");
|
||||
@@ -102,13 +102,13 @@ class SpringHttpSessionConfigurationTests {
|
||||
SessionRepositoryFilter sessionRepositoryFilter = this.context.getBean(SessionRepositoryFilter.class);
|
||||
assertThat(sessionRepositoryFilter).isNotNull();
|
||||
CookieHttpSessionIdResolver httpSessionIdResolver = (CookieHttpSessionIdResolver) ReflectionTestUtils
|
||||
.getField(sessionRepositoryFilter, "httpSessionIdResolver");
|
||||
.getField(sessionRepositoryFilter, "httpSessionIdResolver");
|
||||
assertThat(httpSessionIdResolver).isNotNull();
|
||||
DefaultCookieSerializer cookieSerializer = (DefaultCookieSerializer) ReflectionTestUtils
|
||||
.getField(httpSessionIdResolver, "cookieSerializer");
|
||||
.getField(httpSessionIdResolver, "cookieSerializer");
|
||||
assertThat(cookieSerializer).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(cookieSerializer, "rememberMeRequestAttribute"))
|
||||
.isEqualTo(SpringSessionRememberMeServices.REMEMBER_ME_LOGIN_ATTR);
|
||||
.isEqualTo(SpringSessionRememberMeServices.REMEMBER_ME_LOGIN_ATTR);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -77,8 +77,8 @@ class SpringWebSessionConfigurationTests {
|
||||
this.context.register(BadConfig.class);
|
||||
|
||||
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(this.context::refresh)
|
||||
.withMessageContaining("Error creating bean with name 'webSessionManager'").withMessageContaining(
|
||||
"No qualifying bean of type '" + ReactiveSessionRepository.class.getCanonicalName());
|
||||
.withMessageContaining("Error creating bean with name 'webSessionManager'")
|
||||
.withMessageContaining("No qualifying bean of type '" + ReactiveSessionRepository.class.getCanonicalName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -77,7 +77,7 @@ class SpringSessionBackedSessionRegistryTest {
|
||||
|
||||
assertThat(sessionInfo.getSessionId()).isEqualTo(SESSION_ID);
|
||||
assertThat(sessionInfo.getLastRequest().toInstant().truncatedTo(ChronoUnit.MILLIS))
|
||||
.isEqualTo(NOW.truncatedTo(ChronoUnit.MILLIS));
|
||||
.isEqualTo(NOW.truncatedTo(ChronoUnit.MILLIS));
|
||||
assertThat(sessionInfo.getPrincipal()).isEqualTo(USER_NAME);
|
||||
assertThat(sessionInfo.isExpired()).isFalse();
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class SpringSessionBackedSessionRegistryTest {
|
||||
|
||||
assertThat(sessionInfo.getSessionId()).isEqualTo(SESSION_ID);
|
||||
assertThat(sessionInfo.getLastRequest().toInstant().truncatedTo(ChronoUnit.MILLIS))
|
||||
.isEqualTo(NOW.truncatedTo(ChronoUnit.MILLIS));
|
||||
.isEqualTo(NOW.truncatedTo(ChronoUnit.MILLIS));
|
||||
assertThat(sessionInfo.getPrincipal()).isEqualTo(USER_NAME);
|
||||
assertThat(sessionInfo.isExpired()).isTrue();
|
||||
}
|
||||
@@ -113,7 +113,7 @@ class SpringSessionBackedSessionRegistryTest {
|
||||
void getAllSessionsForAuthenticatedPrincipal() {
|
||||
setUpSessions();
|
||||
List<SessionInformation> allSessionInfos = this.sessionRegistry
|
||||
.getAllSessions((AuthenticatedPrincipal) () -> USER_NAME, true);
|
||||
.getAllSessions((AuthenticatedPrincipal) () -> USER_NAME, true);
|
||||
assertThat(allSessionInfos).extracting("sessionId").containsExactly(SESSION_ID, SESSION_ID2);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class SpringSessionBackedSessionRegistryTest {
|
||||
ArgumentCaptor<Session> captor = ArgumentCaptor.forClass(Session.class);
|
||||
verify(this.sessionRepository).save(captor.capture());
|
||||
assertThat(captor.getValue().<Boolean>getAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR))
|
||||
.isEqualTo(Boolean.TRUE);
|
||||
.isEqualTo(Boolean.TRUE);
|
||||
}
|
||||
|
||||
private Session createSession(String sessionId, String userName, Instant lastAccessed) {
|
||||
|
||||
@@ -48,7 +48,7 @@ class SpringSessionRememberMeServicesTests {
|
||||
void create() {
|
||||
this.rememberMeServices = new SpringSessionRememberMeServices();
|
||||
assertThat(ReflectionTestUtils.getField(this.rememberMeServices, "rememberMeParameterName"))
|
||||
.isEqualTo("remember-me");
|
||||
.isEqualTo("remember-me");
|
||||
assertThat(ReflectionTestUtils.getField(this.rememberMeServices, "alwaysRemember")).isEqualTo(false);
|
||||
assertThat(ReflectionTestUtils.getField(this.rememberMeServices, "validitySeconds")).isEqualTo(2592000);
|
||||
}
|
||||
@@ -58,14 +58,14 @@ class SpringSessionRememberMeServicesTests {
|
||||
this.rememberMeServices = new SpringSessionRememberMeServices();
|
||||
this.rememberMeServices.setRememberMeParameterName("test-param");
|
||||
assertThat(ReflectionTestUtils.getField(this.rememberMeServices, "rememberMeParameterName"))
|
||||
.isEqualTo("test-param");
|
||||
.isEqualTo("test-param");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWithNullParameter() {
|
||||
this.rememberMeServices = new SpringSessionRememberMeServices();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.rememberMeServices.setRememberMeParameterName(null))
|
||||
.withMessage("rememberMeParameterName cannot be empty or null");
|
||||
.withMessage("rememberMeParameterName cannot be empty or null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -64,7 +64,7 @@ class CookieHttpSessionIdResolverTests {
|
||||
void getRequestedSessionIdNotNull() {
|
||||
setSessionCookie(this.session.getId());
|
||||
assertThat(this.strategy.resolveSessionIds(this.request))
|
||||
.isEqualTo(Collections.singletonList(this.session.getId()));
|
||||
.isEqualTo(Collections.singletonList(this.session.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,7 +72,7 @@ class CookieHttpSessionIdResolverTests {
|
||||
setCookieName("CUSTOM");
|
||||
setSessionCookie(this.session.getId());
|
||||
assertThat(this.strategy.resolveSessionIds(this.request))
|
||||
.isEqualTo(Collections.singletonList(this.session.getId()));
|
||||
.isEqualTo(Collections.singletonList(this.session.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,7 +144,7 @@ class CookieHttpSessionIdResolverTests {
|
||||
@Test
|
||||
void createSessionCookieValue() {
|
||||
assertThat(createSessionCookieValue(17))
|
||||
.isEqualToIgnoringCase("0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 a 10 b 11 c 12 d 13 e 14 f 15 10 16");
|
||||
.isEqualToIgnoringCase("0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 a 10 b 11 c 12 d 13 e 14 f 15 10 16");
|
||||
}
|
||||
|
||||
private String createSessionCookieValue(long size) {
|
||||
|
||||
@@ -200,7 +200,7 @@ class DefaultCookieSerializerTests {
|
||||
void setDomainNameAndDomainNamePatternThrows() {
|
||||
this.serializer.setDomainName("example.com");
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.serializer.setDomainNamePattern(".*"))
|
||||
.withMessage("Cannot set both domainName and domainNamePattern");
|
||||
.withMessage("Cannot set both domainName and domainNamePattern");
|
||||
}
|
||||
|
||||
// --- domainNamePattern ---
|
||||
@@ -229,7 +229,7 @@ class DefaultCookieSerializerTests {
|
||||
void setDomainNamePatternAndDomainNameThrows() {
|
||||
this.serializer.setDomainNamePattern(".*");
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.serializer.setDomainName("example.com"))
|
||||
.withMessage("Cannot set both domainName and domainNamePattern");
|
||||
.withMessage("Cannot set both domainName and domainNamePattern");
|
||||
}
|
||||
|
||||
// --- cookieName ---
|
||||
@@ -251,7 +251,7 @@ class DefaultCookieSerializerTests {
|
||||
@Test
|
||||
void setCookieNameNullThrows() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.serializer.setCookieName(null))
|
||||
.withMessage("cookieName cannot be null");
|
||||
.withMessage("cookieName cannot be null");
|
||||
}
|
||||
|
||||
// --- cookiePath ---
|
||||
|
||||
@@ -70,7 +70,7 @@ class HeaderHttpSessionIdResolverTests {
|
||||
@Test
|
||||
void createResolverWithNullHeaderName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new HeaderHttpSessionIdResolver(null))
|
||||
.withMessage("headerName cannot be null");
|
||||
.withMessage("headerName cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -40,8 +40,9 @@ class OncePerRequestFilterAopTests {
|
||||
@Test
|
||||
void doFilterOnce(@Autowired final OncePerRequestFilter filter) {
|
||||
assertThatCode(() -> filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(),
|
||||
new MockFilterChain())).as("`doFilter` does not throw NPE with the bean is being proxied by Spring AOP")
|
||||
.doesNotThrowAnyException();
|
||||
new MockFilterChain()))
|
||||
.as("`doFilter` does not throw NPE with the bean is being proxied by Spring AOP")
|
||||
.doesNotThrowAnyException();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
|
||||
@@ -998,7 +998,7 @@ class SessionRepositoryFilterTests {
|
||||
final String expectedId = "HttpSessionIdResolver-requested-id";
|
||||
|
||||
given(this.strategy.resolveSessionIds(any(HttpServletRequest.class)))
|
||||
.willReturn(Collections.singletonList(expectedId));
|
||||
.willReturn(Collections.singletonList(expectedId));
|
||||
given(sessionRepository.findById(anyString())).willReturn(new MapSession(expectedId));
|
||||
|
||||
doFilter(new DoInFilter() {
|
||||
@@ -1020,7 +1020,7 @@ class SessionRepositoryFilterTests {
|
||||
final String otherId = "HttpSessionIdResolver-requested-id2";
|
||||
|
||||
given(this.strategy.resolveSessionIds(any(HttpServletRequest.class)))
|
||||
.willReturn(Arrays.asList(expectedId, otherId));
|
||||
.willReturn(Arrays.asList(expectedId, otherId));
|
||||
|
||||
doFilter(new DoInFilter() {
|
||||
@Override
|
||||
@@ -1189,7 +1189,7 @@ class SessionRepositoryFilterTests {
|
||||
void order() {
|
||||
assertThat(
|
||||
AnnotationAwareOrderComparator.INSTANCE.compare(this.filter, new SessionRepositoryFilterDefaultOrder()))
|
||||
.isZero();
|
||||
.isZero();
|
||||
}
|
||||
|
||||
// We want the filter to work without any dependencies on Spring
|
||||
@@ -1201,7 +1201,7 @@ class SessionRepositoryFilterTests {
|
||||
@Test
|
||||
void setHttpSessionIdResolverNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.filter.setHttpSessionIdResolver(null))
|
||||
.withMessage("httpSessionIdResolver cannot be null");
|
||||
.withMessage("httpSessionIdResolver cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1329,16 +1329,18 @@ class SessionRepositoryFilterTests {
|
||||
assertThat(cookie.getValue()).isNotEqualTo("INVALID");
|
||||
assertThat(cookie.isHttpOnly()).describedAs("Cookie is expected to be HTTP Only").isTrue();
|
||||
assertThat(cookie.getSecure()).describedAs("Cookie secured is expected to be " + this.request.isSecure())
|
||||
.isEqualTo(this.request.isSecure());
|
||||
.isEqualTo(this.request.isSecure());
|
||||
assertThat(this.request.getSession(false))
|
||||
.describedAs("The original HttpServletRequest HttpSession should be null").isNull();
|
||||
.describedAs("The original HttpServletRequest HttpSession should be null")
|
||||
.isNull();
|
||||
}
|
||||
|
||||
private void assertNoSession() {
|
||||
Cookie cookie = getSessionCookie();
|
||||
assertThat(cookie).isNull();
|
||||
assertThat(this.request.getSession(false))
|
||||
.describedAs("The original HttpServletRequest HttpSession should be null").isNull();
|
||||
.describedAs("The original HttpServletRequest HttpSession should be null")
|
||||
.isNull();
|
||||
}
|
||||
|
||||
private Cookie getSessionCookie() {
|
||||
|
||||
@@ -68,7 +68,7 @@ class SpringSessionWebSessionStoreTests<S extends Session> {
|
||||
@Test
|
||||
void constructorWhenNullRepositoryThenThrowsIllegalArgumentException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new SpringSessionWebSessionStore<S>(null))
|
||||
.withMessage("reactiveSessionRepository cannot be null");
|
||||
.withMessage("reactiveSessionRepository cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -248,7 +248,7 @@ class SpringSessionWebSessionStoreTests<S extends Session> {
|
||||
@Test
|
||||
void setClockWhenNullThenException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.webSessionStore.setClock(null))
|
||||
.withMessage("clock cannot be null");
|
||||
.withMessage("clock cannot be null");
|
||||
}
|
||||
|
||||
@Test // gh-1114
|
||||
|
||||
@@ -61,7 +61,7 @@ class WebSocketConnectHandlerDecoratorFactoryTests {
|
||||
@Test
|
||||
void constructorNullEventPublisher() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new WebSocketConnectHandlerDecoratorFactory(null))
|
||||
.withMessage("eventPublisher cannot be null");
|
||||
.withMessage("eventPublisher cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +78,7 @@ class WebSocketConnectHandlerDecoratorFactoryTests {
|
||||
void decorateAfterConnectionEstablishedEventError() throws Exception {
|
||||
WebSocketHandler decorated = this.factory.decorate(this.delegate);
|
||||
willThrow(new IllegalStateException("Test throw on publishEvent")).given(this.eventPublisher)
|
||||
.publishEvent(any(ApplicationEvent.class));
|
||||
.publishEvent(any(ApplicationEvent.class));
|
||||
|
||||
decorated.afterConnectionEstablished(this.session);
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ class WebSocketRegistryListenerTests {
|
||||
this.listener.onApplicationEvent(this.disconnect);
|
||||
|
||||
Map<String, Map<String, WebSocketSession>> httpSessionIdToWsSessions = (Map<String, Map<String, WebSocketSession>>) ReflectionTestUtils
|
||||
.getField(this.listener, "httpSessionIdToWsSessions");
|
||||
.getField(this.listener, "httpSessionIdToWsSessions");
|
||||
assertThat(httpSessionIdToWsSessions).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class SessionRepositoryMessageInterceptorTests {
|
||||
@Test
|
||||
void preSendconstructorNullRepository() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new SessionRepositoryMessageInterceptor<>(null))
|
||||
.withMessage("sessionRepository cannot be null");
|
||||
.withMessage("sessionRepository cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,14 +132,14 @@ class SessionRepositoryMessageInterceptorTests {
|
||||
@Test
|
||||
void setMatchingMessageTypesNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.interceptor.setMatchingMessageTypes(null))
|
||||
.withMessage("matchingMessageTypes cannot be null or empty");
|
||||
.withMessage("matchingMessageTypes cannot be null or empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void setMatchingMessageTypesEmpty() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.interceptor.setMatchingMessageTypes(Collections.emptySet()))
|
||||
.withMessage("matchingMessageTypes cannot be null or empty");
|
||||
.isThrownBy(() -> this.interceptor.setMatchingMessageTypes(Collections.emptySet()))
|
||||
.withMessage("matchingMessageTypes cannot be null or empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user