Skip to content

Commit abd51f7

Browse files
twosomjzheaux
authored andcommitted
Polished DefaultLoginPageGeneratingFilterTests Validation
Closes gh-12694
1 parent 4154ed5 commit abd51f7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

web/src/test/java/org/springframework/security/web/authentication/DefaultLoginPageGeneratingFilterTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -143,12 +143,14 @@ public void handlesNonIso8859CharsInErrorMessage() throws Exception {
143143
DefaultLoginPageGeneratingFilter filter = new DefaultLoginPageGeneratingFilter(
144144
new UsernamePasswordAuthenticationFilter());
145145
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/login");
146-
request.addParameter("login_error", "true");
146+
MockHttpServletResponse response = new MockHttpServletResponse();
147+
request.setQueryString("error");
147148
MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
148149
String message = messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials",
149150
"Bad credentials", Locale.KOREA);
150151
request.getSession().setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, new BadCredentialsException(message));
151-
filter.doFilter(request, new MockHttpServletResponse(), this.chain);
152+
filter.doFilter(request, response, this.chain);
153+
assertThat(response.getContentAsString()).contains(message);
152154
}
153155

154156
// gh-5394

0 commit comments

Comments
 (0)