Skip to content

Commit 2473378

Browse files
committed
Use RequiredFactorErrors
Closes gh-18002
1 parent d1ff983 commit 2473378

File tree

16 files changed

+126
-54
lines changed

16 files changed

+126
-54
lines changed

config/src/test/java/org/springframework/security/config/annotation/web/configurers/FormLoginConfigurerTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ void requestWhenUnauthenticatedThenRequiresTwoSteps() throws Exception {
403403
UserDetails user = PasswordEncodedUser.user();
404404
this.mockMvc.perform(get("/profile").with(user(user)))
405405
.andExpect(status().is3xxRedirection())
406-
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
406+
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
407407
this.mockMvc
408408
.perform(post("/ott/generate").param("username", "rod")
409409
.with(user(user))
@@ -421,13 +421,13 @@ void requestWhenUnauthenticatedThenRequiresTwoSteps() throws Exception {
421421
.build();
422422
this.mockMvc.perform(get("/profile").with(user(user)))
423423
.andExpect(status().is3xxRedirection())
424-
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
424+
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
425425
user = PasswordEncodedUser.withUserDetails(user)
426426
.authorities("profile:read", GrantedAuthorities.FACTOR_PASSWORD_AUTHORITY)
427427
.build();
428428
this.mockMvc.perform(get("/profile").with(user(user)))
429429
.andExpect(status().is3xxRedirection())
430-
.andExpect(redirectedUrl("http://localhost/login?factor=ott"));
430+
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
431431
user = PasswordEncodedUser.withUserDetails(user)
432432
.authorities("profile:read", GrantedAuthorities.FACTOR_PASSWORD_AUTHORITY,
433433
GrantedAuthorities.FACTOR_OTT_AUTHORITY)
@@ -444,7 +444,7 @@ void requestWhenUnauthenticatedX509ThenRequiresTwoSteps() throws Exception {
444444
this.mockMvc.perform(get("/login")).andExpect(status().isOk());
445445
this.mockMvc.perform(get("/profile").with(SecurityMockMvcRequestPostProcessors.x509("rod.cer")))
446446
.andExpect(status().is3xxRedirection())
447-
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
447+
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
448448
this.mockMvc
449449
.perform(post("/login").param("username", "rod")
450450
.param("password", "password")

docs/src/test/java/org/springframework/security/docs/servlet/authentication/authorizationmanagerfactory/AuthorizationManagerFactoryTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void getWhenAuthenticatedWithPasswordThenRedirectsToOtt() throws Exception {
6969
// @formatter:off
7070
this.mockMvc.perform(get("/"))
7171
.andExpect(status().is3xxRedirection())
72-
.andExpect(redirectedUrl("http://localhost/login?factor=ott"));
72+
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
7373
// @formatter:on
7474
}
7575

@@ -80,7 +80,7 @@ void getWhenAuthenticatedWithOttThenRedirectsToPassword() throws Exception {
8080
// @formatter:off
8181
this.mockMvc.perform(get("/"))
8282
.andExpect(status().is3xxRedirection())
83-
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
83+
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
8484
// @formatter:on
8585
}
8686

@@ -91,7 +91,7 @@ void getWhenAuthenticatedThenRedirectsToPassword() throws Exception {
9191
// @formatter:off
9292
this.mockMvc.perform(get("/"))
9393
.andExpect(status().is3xxRedirection())
94-
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
94+
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
9595
// @formatter:on
9696
}
9797

docs/src/test/java/org/springframework/security/docs/servlet/authentication/customauthorizationmanagerfactory/CustomAuthorizationManagerFactoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void getWhenAdminThenRedirectsToOtt() throws Exception {
5858
// @formatter:off
5959
this.mockMvc.perform(get("/"))
6060
.andExpect(status().is3xxRedirection())
61-
.andExpect(redirectedUrl("http://localhost/login?factor=ott"));
61+
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
6262
// @formatter:on
6363
}
6464

docs/src/test/java/org/springframework/security/docs/servlet/authentication/enableglobalmfa/EnableGlobalMultiFactorAuthenticationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void getWhenAuthenticatedWithPasswordThenRedirectsToOtt() throws Exception {
6969
// @formatter:off
7070
this.mockMvc.perform(get("/"))
7171
.andExpect(status().is3xxRedirection())
72-
.andExpect(redirectedUrl("http://localhost/login?factor=ott"));
72+
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
7373
// @formatter:on
7474
}
7575

@@ -80,7 +80,7 @@ void getWhenAuthenticatedWithOttThenRedirectsToPassword() throws Exception {
8080
// @formatter:off
8181
this.mockMvc.perform(get("/"))
8282
.andExpect(status().is3xxRedirection())
83-
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
83+
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
8484
// @formatter:on
8585
}
8686

@@ -91,7 +91,7 @@ void getWhenAuthenticatedThenRedirectsToPassword() throws Exception {
9191
// @formatter:off
9292
this.mockMvc.perform(get("/"))
9393
.andExpect(status().is3xxRedirection())
94-
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
94+
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
9595
// @formatter:on
9696
}
9797

docs/src/test/java/org/springframework/security/docs/servlet/authentication/multifactorauthentication/MultiFactorAuthenticationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void getWhenAuthenticatedWithPasswordThenRedirectsToOtt() throws Exception {
6969
// @formatter:off
7070
this.mockMvc.perform(get("/"))
7171
.andExpect(status().is3xxRedirection())
72-
.andExpect(redirectedUrl("http://localhost/login?factor=ott"));
72+
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
7373
// @formatter:on
7474
}
7575

@@ -80,7 +80,7 @@ void getWhenAuthenticatedWithOttThenRedirectsToPassword() throws Exception {
8080
// @formatter:off
8181
this.mockMvc.perform(get("/"))
8282
.andExpect(status().is3xxRedirection())
83-
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
83+
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
8484
// @formatter:on
8585
}
8686

@@ -91,7 +91,7 @@ void getWhenAuthenticatedThenRedirectsToPassword() throws Exception {
9191
// @formatter:off
9292
this.mockMvc.perform(get("/"))
9393
.andExpect(status().is3xxRedirection())
94-
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
94+
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
9595
// @formatter:on
9696
}
9797

docs/src/test/java/org/springframework/security/docs/servlet/authentication/reauthentication/ReauthenticationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void formLoginWhenRequireOttConfigurationThenRedirectsToOtt() throws Exception {
6969
// @formatter:off
7070
this.mockMvc.perform(get("/profile"))
7171
.andExpect(status().is3xxRedirection())
72-
.andExpect(redirectedUrl("http://localhost/login?factor=ott"));
72+
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
7373
// @formatter:on
7474
}
7575

docs/src/test/kotlin/org/springframework/security/kt/docs/servlet/authentication/authorizationmanagerfactory/AuthorizationManagerFactoryTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class AuthorizationManagerFactoryTests {
6868
// @formatter:off
6969
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
7070
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
71-
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor=ott"))
71+
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
7272
// @formatter:on
7373
}
7474

@@ -81,7 +81,7 @@ class AuthorizationManagerFactoryTests {
8181
// @formatter:off
8282
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
8383
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
84-
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor=password"))
84+
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
8585
// @formatter:on
8686
}
8787

@@ -94,7 +94,7 @@ class AuthorizationManagerFactoryTests {
9494
// @formatter:off
9595
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
9696
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
97-
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor=password"))
97+
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
9898
// @formatter:on
9999
}
100100

docs/src/test/kotlin/org/springframework/security/kt/docs/servlet/authentication/customauthorizationmanagerfactory/CustomAuthorizationManagerFactoryTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CustomAuthorizationManagerFactoryTests {
5555
// @formatter:off
5656
this.mockMvc!!.perform(get("/"))
5757
.andExpect(status().is3xxRedirection())
58-
.andExpect(redirectedUrl("http://localhost/login?factor=ott"))
58+
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
5959
// @formatter:on
6060
}
6161

docs/src/test/kotlin/org/springframework/security/kt/docs/servlet/authentication/enableglobalmfa/AuthorizationManagerFactoryTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class AuthorizationManagerFactoryTests {
6868
// @formatter:off
6969
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
7070
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
71-
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor=ott"))
71+
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
7272
// @formatter:on
7373
}
7474

@@ -81,7 +81,7 @@ class AuthorizationManagerFactoryTests {
8181
// @formatter:off
8282
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
8383
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
84-
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor=password"))
84+
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
8585
// @formatter:on
8686
}
8787

@@ -94,7 +94,7 @@ class AuthorizationManagerFactoryTests {
9494
// @formatter:off
9595
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
9696
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
97-
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor=password"))
97+
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
9898
// @formatter:on
9999
}
100100

docs/src/test/kotlin/org/springframework/security/kt/docs/servlet/authentication/multifactorauthentication/MultiFactorAuthenticationTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class MultiFactorAuthenticationTests {
6666
// @formatter:off
6767
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
6868
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
69-
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor=ott"))
69+
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
7070
// @formatter:on
7171
}
7272

@@ -78,7 +78,7 @@ class MultiFactorAuthenticationTests {
7878
// @formatter:off
7979
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
8080
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
81-
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor=password"))
81+
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
8282
// @formatter:on
8383
}
8484

@@ -90,7 +90,7 @@ class MultiFactorAuthenticationTests {
9090
// @formatter:off
9191
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
9292
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
93-
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor=password"))
93+
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
9494
// @formatter:on
9595
}
9696

0 commit comments

Comments
 (0)