18
18
19
19
import java .io .IOException ;
20
20
import java .util .Collections ;
21
- import java .util .Locale ;
22
21
23
22
import jakarta .servlet .FilterChain ;
24
23
import jakarta .servlet .ServletException ;
25
24
import org .junit .jupiter .api .Test ;
26
25
27
- import org .springframework .context .support .MessageSourceAccessor ;
28
26
import org .springframework .mock .web .MockHttpServletRequest ;
29
27
import org .springframework .mock .web .MockHttpServletResponse ;
30
28
import org .springframework .security .authentication .BadCredentialsException ;
31
- import org .springframework .security .core .SpringSecurityMessageSource ;
32
29
import org .springframework .security .web .WebAttributes ;
33
30
import org .springframework .security .web .authentication .ui .DefaultLoginPageGeneratingFilter ;
34
31
@@ -128,22 +125,6 @@ public void generatesForWithQueryNoMatch() throws Exception {
128
125
assertThat (response .getContentAsString ()).isEmpty ();
129
126
}
130
127
131
- /* SEC-1111 */
132
- @ Test
133
- public void handlesNonIso8859CharsInErrorMessage () throws Exception {
134
- DefaultLoginPageGeneratingFilter filter = new DefaultLoginPageGeneratingFilter (
135
- new UsernamePasswordAuthenticationFilter ());
136
- MockHttpServletRequest request = new MockHttpServletRequest ("GET" , "/login" );
137
- MockHttpServletResponse response = new MockHttpServletResponse ();
138
- request .setQueryString ("error" );
139
- MessageSourceAccessor messages = SpringSecurityMessageSource .getAccessor ();
140
- String message = messages .getMessage ("AbstractUserDetailsAuthenticationProvider.badCredentials" ,
141
- "Bad credentials" , Locale .KOREA );
142
- request .getSession ().setAttribute (WebAttributes .AUTHENTICATION_EXCEPTION , new BadCredentialsException (message ));
143
- filter .doFilter (request , response , this .chain );
144
- assertThat (response .getContentAsString ()).contains (message );
145
- }
146
-
147
128
// gh-5394
148
129
@ Test
149
130
public void generatesForOAuth2LoginAndEscapesClientName () throws Exception {
@@ -184,7 +165,7 @@ public void generatesWhenExceptionWithEmptyMessageThenInvalidCredentials() throw
184
165
request .getSession ().setAttribute (WebAttributes .AUTHENTICATION_EXCEPTION , new BadCredentialsException (null ));
185
166
MockHttpServletResponse response = new MockHttpServletResponse ();
186
167
filter .doFilter (request , response , this .chain );
187
- assertThat (response .getContentAsString ()).contains ("Invalid credentials " );
168
+ assertThat (response .getContentAsString ()).contains ("Invalid Credentials " );
188
169
}
189
170
190
171
@ Test
@@ -244,7 +225,7 @@ void generatesThenRenders() throws ServletException, IOException {
244
225
<div class="content">
245
226
<form class="login-form" method="post" action="null">
246
227
<h2>Please sign in</h2>
247
- <div class="alert alert-danger" role="alert">Bad credentials </div>
228
+ <div class="alert alert-danger" role="alert">Invalid Credentials </div>
248
229
<p>
249
230
<label for="username" class="screenreader">Username</label>
250
231
<input type="text" id="username" name="username" placeholder="Username" required autofocus>
@@ -259,12 +240,12 @@ void generatesThenRenders() throws ServletException, IOException {
259
240
</form>
260
241
261
242
<h2>Login with OAuth 2.0</h2>
262
- <div class="alert alert-danger" role="alert">Bad credentials </div>
243
+ <div class="alert alert-danger" role="alert">Invalid Credentials </div>
263
244
<table class="table table-striped">
264
245
<tr><td><a href="/oauth2/authorization/google">Google < > " ' &</a></td></tr>
265
246
</table>
266
247
<h2>Login with SAML 2.0</h2>
267
- <div class="alert alert-danger" role="alert">Bad credentials </div>
248
+ <div class="alert alert-danger" role="alert">Invalid Credentials </div>
268
249
<table class="table table-striped">
269
250
<tr><td><a href="/saml/sso/google">Google < > " ' &</a></td></tr>
270
251
</table>
0 commit comments