Rename SessionIdGenerationStrategy to SessionIdGenerator
Closes gh-2391
This commit is contained in:
@@ -440,7 +440,7 @@ class ReactiveRedisSessionRepositoryTests {
|
||||
|
||||
@Test
|
||||
void createSessionWhenSessionIdGenerationStrategyThenUses() {
|
||||
this.repository.setSessionIdGenerationStrategy(() -> "test");
|
||||
this.repository.setSessionIdGenerator(() -> "test");
|
||||
|
||||
this.repository.createSession().as(StepVerifier::create).assertNext((redisSession) -> {
|
||||
assertThat(redisSession.getId()).isEqualTo("test");
|
||||
@@ -450,14 +450,14 @@ class ReactiveRedisSessionRepositoryTests {
|
||||
|
||||
@Test
|
||||
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.repository.setSessionIdGenerationStrategy(null))
|
||||
.withMessage("sessionIdGenerationStrategy cannot be null");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.repository.setSessionIdGenerator(null))
|
||||
.withMessage("sessionIdGenerator cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
|
||||
this.repository.setSessionIdGenerationStrategy(() -> "changed-session-id");
|
||||
this.repository.setSessionIdGenerator(() -> "changed-session-id");
|
||||
given(this.redisOperations.opsForHash()).willReturn(this.hashOperations);
|
||||
String attribute1 = "attribute1";
|
||||
String attribute2 = "attribute2";
|
||||
|
||||
@@ -912,7 +912,7 @@ class RedisIndexedSessionRepositoryTests {
|
||||
|
||||
@Test
|
||||
void createSessionWhenSessionIdGenerationStrategyThenUses() {
|
||||
this.redisRepository.setSessionIdGenerationStrategy(() -> "test");
|
||||
this.redisRepository.setSessionIdGenerator(() -> "test");
|
||||
RedisSession session = this.redisRepository.createSession();
|
||||
assertThat(session.getId()).isEqualTo("test");
|
||||
assertThat(session.changeSessionId()).isEqualTo("test");
|
||||
@@ -920,13 +920,13 @@ class RedisIndexedSessionRepositoryTests {
|
||||
|
||||
@Test
|
||||
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.redisRepository.setSessionIdGenerationStrategy(null))
|
||||
.withMessage("sessionIdGenerationStrategy cannot be null");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.redisRepository.setSessionIdGenerator(null))
|
||||
.withMessage("sessionIdGenerator cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
|
||||
this.redisRepository.setSessionIdGenerationStrategy(() -> "test");
|
||||
this.redisRepository.setSessionIdGenerator(() -> "test");
|
||||
String attribute1 = "attribute1";
|
||||
String attribute2 = "attribute2";
|
||||
MapSession expected = new MapSession("original");
|
||||
|
||||
@@ -375,7 +375,7 @@ class RedisSessionRepositoryTests {
|
||||
|
||||
@Test
|
||||
void createSessionWhenSessionIdGenerationStrategyThenUses() {
|
||||
this.sessionRepository.setSessionIdGenerationStrategy(() -> "test");
|
||||
this.sessionRepository.setSessionIdGenerator(() -> "test");
|
||||
RedisSessionRepository.RedisSession session = this.sessionRepository.createSession();
|
||||
assertThat(session.getId()).isEqualTo("test");
|
||||
assertThat(session.changeSessionId()).isEqualTo("test");
|
||||
@@ -383,14 +383,13 @@ class RedisSessionRepositoryTests {
|
||||
|
||||
@Test
|
||||
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.sessionRepository.setSessionIdGenerationStrategy(null))
|
||||
.withMessage("sessionIdGenerationStrategy cannot be null");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.sessionRepository.setSessionIdGenerator(null))
|
||||
.withMessage("sessionIdGenerator cannot be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
|
||||
this.sessionRepository.setSessionIdGenerationStrategy(() -> "test");
|
||||
this.sessionRepository.setSessionIdGenerator(() -> "test");
|
||||
Instant now = Instant.now().truncatedTo(ChronoUnit.MILLIS);
|
||||
given(this.sessionHashOperations.entries(eq(TEST_SESSION_KEY)))
|
||||
.willReturn(mapOf(RedisSessionMapper.CREATION_TIME_KEY, Instant.EPOCH.toEpochMilli(),
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.springframework.data.redis.core.RedisOperations;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
import org.springframework.session.FlushMode;
|
||||
import org.springframework.session.SaveMode;
|
||||
import org.springframework.session.SessionIdGenerationStrategy;
|
||||
import org.springframework.session.UuidSessionIdGenerationStrategy;
|
||||
import org.springframework.session.SessionIdGenerator;
|
||||
import org.springframework.session.UuidSessionIdGenerator;
|
||||
import org.springframework.session.config.SessionRepositoryCustomizer;
|
||||
import org.springframework.session.data.redis.RedisSessionRepository;
|
||||
import org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory;
|
||||
@@ -212,16 +212,14 @@ class RedisHttpsSessionConfigurationTests {
|
||||
void registerWhenSessionIdGenerationStrategyBeanThenUses() {
|
||||
registerAndRefresh(RedisConfig.class, SessionIdGenerationStrategyConfiguration.class);
|
||||
RedisSessionRepository sessionRepository = this.context.getBean(RedisSessionRepository.class);
|
||||
assertThat(sessionRepository).extracting("sessionIdGenerationStrategy")
|
||||
.isInstanceOf(TestSessionIdGenerationStrategy.class);
|
||||
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(TestSessionIdGenerator.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerWhenNoSessionIdGenerationStrategyBeanThenDefault() {
|
||||
registerAndRefresh(RedisConfig.class, DefaultConfiguration.class);
|
||||
RedisSessionRepository sessionRepository = this.context.getBean(RedisSessionRepository.class);
|
||||
assertThat(sessionRepository).extracting("sessionIdGenerationStrategy")
|
||||
.isInstanceOf(UuidSessionIdGenerationStrategy.class);
|
||||
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(UuidSessionIdGenerator.class);
|
||||
}
|
||||
|
||||
private void registerAndRefresh(Class<?>... annotatedClasses) {
|
||||
@@ -404,8 +402,8 @@ class RedisHttpsSessionConfigurationTests {
|
||||
static class SessionIdGenerationStrategyConfiguration {
|
||||
|
||||
@Bean
|
||||
SessionIdGenerationStrategy sessionIdGenerationStrategy() {
|
||||
return new TestSessionIdGenerationStrategy();
|
||||
SessionIdGenerator sessionIdGenerationStrategy() {
|
||||
return new TestSessionIdGenerator();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -416,7 +414,7 @@ class RedisHttpsSessionConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
static class TestSessionIdGenerationStrategy implements SessionIdGenerationStrategy {
|
||||
static class TestSessionIdGenerator implements SessionIdGenerator {
|
||||
|
||||
@Override
|
||||
public String generate() {
|
||||
|
||||
@@ -43,8 +43,8 @@ import org.springframework.session.FlushMode;
|
||||
import org.springframework.session.IndexResolver;
|
||||
import org.springframework.session.SaveMode;
|
||||
import org.springframework.session.Session;
|
||||
import org.springframework.session.SessionIdGenerationStrategy;
|
||||
import org.springframework.session.UuidSessionIdGenerationStrategy;
|
||||
import org.springframework.session.SessionIdGenerator;
|
||||
import org.springframework.session.UuidSessionIdGenerator;
|
||||
import org.springframework.session.config.SessionRepositoryCustomizer;
|
||||
import org.springframework.session.data.redis.RedisIndexedSessionRepository;
|
||||
import org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory;
|
||||
@@ -246,16 +246,14 @@ class RedisIndexedHttpSessionConfigurationTests {
|
||||
void registerWhenSessionIdGenerationStrategyBeanThenUses() {
|
||||
registerAndRefresh(RedisConfig.class, SessionIdGenerationStrategyConfiguration.class);
|
||||
RedisIndexedSessionRepository sessionRepository = this.context.getBean(RedisIndexedSessionRepository.class);
|
||||
assertThat(sessionRepository).extracting("sessionIdGenerationStrategy")
|
||||
.isInstanceOf(TestSessionIdGenerationStrategy.class);
|
||||
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(TestSessionIdGenerator.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerWhenNoSessionIdGenerationStrategyBeanThenDefault() {
|
||||
registerAndRefresh(RedisConfig.class, DefaultConfiguration.class);
|
||||
RedisIndexedSessionRepository sessionRepository = this.context.getBean(RedisIndexedSessionRepository.class);
|
||||
assertThat(sessionRepository).extracting("sessionIdGenerationStrategy")
|
||||
.isInstanceOf(UuidSessionIdGenerationStrategy.class);
|
||||
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(UuidSessionIdGenerator.class);
|
||||
}
|
||||
|
||||
private void registerAndRefresh(Class<?>... annotatedClasses) {
|
||||
@@ -467,8 +465,8 @@ class RedisIndexedHttpSessionConfigurationTests {
|
||||
static class SessionIdGenerationStrategyConfiguration {
|
||||
|
||||
@Bean
|
||||
SessionIdGenerationStrategy sessionIdGenerationStrategy() {
|
||||
return new TestSessionIdGenerationStrategy();
|
||||
SessionIdGenerator sessionIdGenerationStrategy() {
|
||||
return new TestSessionIdGenerator();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -479,7 +477,7 @@ class RedisIndexedHttpSessionConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
static class TestSessionIdGenerationStrategy implements SessionIdGenerationStrategy {
|
||||
static class TestSessionIdGenerator implements SessionIdGenerator {
|
||||
|
||||
@Override
|
||||
public String generate() {
|
||||
|
||||
Reference in New Issue
Block a user