Skip to content

Commit f4cd1d0

Browse files
committed
#3299: adjust test so that it fails when username contains a special character
1 parent 3c5da80 commit f4cd1d0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
spring.security.user.name=rüdiger
12
spring.security.user.password=password
23
spring.session.jdbc.schema=classpath:schema.sql
34
spring.session.jdbc.initialize-schema=always

spring-session-samples/spring-session-sample-boot-jdbc-json-attribute/src/test/java/sample/JdbcJsonAttributeTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void setup() {
4747

4848
@Test
4949
void loginShouldSaveSecurityContextAsJson() throws Exception {
50-
Cookie sessionCookie = this.mvc.perform(formLogin().user("user").password("password"))
50+
Cookie sessionCookie = this.mvc.perform(formLogin().user("rüdiger").password("password"))
5151
.andExpect(authenticated())
5252
.andReturn()
5353
.getResponse()
@@ -62,20 +62,20 @@ void loginShouldSaveSecurityContextAsJson() throws Exception {
6262
SecurityContext securityContext = this.objectMapperWithModules.readValue((String) attributeBytes,
6363
SecurityContext.class);
6464
assertThat(securityContext).isNotNull();
65-
assertThat(securityContext.getAuthentication().getName()).isEqualTo("user");
65+
assertThat(securityContext.getAuthentication().getName()).isEqualTo("rüdiger");
6666
}
6767

6868
@Test
6969
void loginWhenQueryUsingJsonbOperatorThenReturns() throws Exception {
70-
this.mvc.perform(formLogin().user("user").password("password")).andExpect(authenticated());
70+
this.mvc.perform(formLogin().user("rüdiger").password("password")).andExpect(authenticated());
7171
Object attributeBytes = this.jdbcClient.queryForObject("""
7272
SELECT attribute_bytes::text FROM spring_session_attributes
73-
WHERE attribute_bytes -> 'authentication' -> 'principal' ->> 'username' = 'user'
73+
WHERE attribute_bytes -> 'authentication' -> 'principal' ->> 'username' = 'rüdiger'
7474
""", Object.class);
7575
SecurityContext securityContext = this.objectMapperWithModules.readValue((String) attributeBytes,
7676
SecurityContext.class);
7777
assertThat(securityContext).isNotNull();
78-
assertThat(securityContext.getAuthentication().getName()).isEqualTo("user");
78+
assertThat(securityContext.getAuthentication().getName()).isEqualTo("rüdiger");
7979
}
8080

8181
}

0 commit comments

Comments
 (0)