SEC-2915: Fix defaut login page tests with tabs
This commit is contained in:
parent
4fdfb8caba
commit
0bfbd2923a
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2013 the original author or authors.
|
||||||
*
|
*
|
||||||
|
@ -57,12 +55,12 @@ public class DefaultLoginPageConfigurerTests extends BaseSpringSpec {
|
||||||
then:
|
then:
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
||||||
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
||||||
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
||||||
</table>
|
</table>
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
when: "fail to log in"
|
when: "fail to log in"
|
||||||
super.setup()
|
super.setup()
|
||||||
|
@ -81,12 +79,12 @@ public class DefaultLoginPageConfigurerTests extends BaseSpringSpec {
|
||||||
then:
|
then:
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
||||||
<p><font color='red'>Your login attempt was not successful, try again.<br/><br/>Reason: Bad credentials</font></p><h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
<p><font color='red'>Your login attempt was not successful, try again.<br/><br/>Reason: Bad credentials</font></p><h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
||||||
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
||||||
</table>
|
</table>
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
when: "login success"
|
when: "login success"
|
||||||
super.setup()
|
super.setup()
|
||||||
|
@ -110,12 +108,12 @@ public class DefaultLoginPageConfigurerTests extends BaseSpringSpec {
|
||||||
then: "sent to default success page"
|
then: "sent to default success page"
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
||||||
<p><font color='green'>You have been logged out</font></p><h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
<p><font color='green'>You have been logged out</font></p><h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
||||||
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
||||||
</table>
|
</table>
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,13 +193,13 @@ public class DefaultLoginPageConfigurerTests extends BaseSpringSpec {
|
||||||
then:
|
then:
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
||||||
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
||||||
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
||||||
<tr><td><input type='checkbox' name='remember-me'/></td><td>Remember me on this computer.</td></tr>
|
<tr><td><input type='checkbox' name='remember-me'/></td><td>Remember me on this computer.</td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
||||||
</table>
|
</table>
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,10 +225,10 @@ public class DefaultLoginPageConfigurerTests extends BaseSpringSpec {
|
||||||
springSecurityFilterChain.doFilter(request,response,chain)
|
springSecurityFilterChain.doFilter(request,response,chain)
|
||||||
then:
|
then:
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><h3>Login with OpenID Identity</h3><form name='oidf' action='/login/openid' method='POST'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><h3>Login with OpenID Identity</h3><form name='oidf' action='/login/openid' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>Identity:</td><td><input type='text' size='30' name='openid_identifier'/></td></tr>
|
<tr><td>Identity:</td><td><input type='text' size='30' name='openid_identifier'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
</table>
|
</table>
|
||||||
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
}
|
}
|
||||||
|
@ -256,19 +254,19 @@ public class DefaultLoginPageConfigurerTests extends BaseSpringSpec {
|
||||||
then:
|
then:
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
||||||
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
||||||
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
||||||
<tr><td><input type='checkbox' name='remember-me'/></td><td>Remember me on this computer.</td></tr>
|
<tr><td><input type='checkbox' name='remember-me'/></td><td>Remember me on this computer.</td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
||||||
</table>
|
</table>
|
||||||
</form><h3>Login with OpenID Identity</h3><form name='oidf' action='/login/openid' method='POST'>
|
</form><h3>Login with OpenID Identity</h3><form name='oidf' action='/login/openid' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>Identity:</td><td><input type='text' size='30' name='openid_identifier'/></td></tr>
|
<tr><td>Identity:</td><td><input type='text' size='30' name='openid_identifier'/></td></tr>
|
||||||
<tr><td><input type='checkbox' name='remember-me'></td><td>Remember me on this computer.</td></tr>
|
<tr><td><input type='checkbox' name='remember-me'></td><td>Remember me on this computer.</td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
</table>
|
</table>
|
||||||
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
<input name="${csrfToken.parameterName}" type="hidden" value="${csrfToken.token}" />
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,11 @@ class FormLoginBeanDefinitionParserTests extends AbstractHttpConfigTests {
|
||||||
then:
|
then:
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
||||||
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
||||||
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,11 +47,11 @@ class FormLoginBeanDefinitionParserTests extends AbstractHttpConfigTests {
|
||||||
then:
|
then:
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.custom_user.focus();'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.custom_user.focus();'>
|
||||||
<h3>Login with Username and Password</h3><form name='f' action='/login_custom' method='POST'>
|
<h3>Login with Username and Password</h3><form name='f' action='/login_custom' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>User:</td><td><input type='text' name='custom_user' value=''></td></tr>
|
<tr><td>User:</td><td><input type='text' name='custom_user' value=''></td></tr>
|
||||||
<tr><td>Password:</td><td><input type='password' name='custom_password'/></td></tr>
|
<tr><td>Password:</td><td><input type='password' name='custom_password'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,16 +70,16 @@ class FormLoginBeanDefinitionParserTests extends AbstractHttpConfigTests {
|
||||||
then:
|
then:
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
||||||
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
||||||
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</form><h3>Login with OpenID Identity</h3><form name='oidf' action='/login/openid' method='POST'>
|
</form><h3>Login with OpenID Identity</h3><form name='oidf' action='/login/openid' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>Identity:</td><td><input type='text' size='30' name='openid_identifier'/></td></tr>
|
<tr><td>Identity:</td><td><input type='text' size='30' name='openid_identifier'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,16 +98,16 @@ class FormLoginBeanDefinitionParserTests extends AbstractHttpConfigTests {
|
||||||
then:
|
then:
|
||||||
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
response.getContentAsString() == """<html><head><title>Login Page</title></head><body onload='document.f.username.focus();'>
|
||||||
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
<h3>Login with Username and Password</h3><form name='f' action='/login' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
|
||||||
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</form><h3>Login with OpenID Identity</h3><form name='oidf' action='/login_custom' method='POST'>
|
</form><h3>Login with OpenID Identity</h3><form name='oidf' action='/login_custom' method='POST'>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>Identity:</td><td><input type='text' size='30' name='openid_identifier'/></td></tr>
|
<tr><td>Identity:</td><td><input type='text' size='30' name='openid_identifier'/></td></tr>
|
||||||
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</form></body></html>"""
|
</form></body></html>"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,21 +199,21 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||||
sb.append("<h3>Login with Username and Password</h3>");
|
sb.append("<h3>Login with Username and Password</h3>");
|
||||||
sb.append("<form name='f' action='").append(request.getContextPath())
|
sb.append("<form name='f' action='").append(request.getContextPath())
|
||||||
.append(authenticationUrl).append("' method='POST'>\n");
|
.append(authenticationUrl).append("' method='POST'>\n");
|
||||||
sb.append(" <table>\n");
|
sb.append("<table>\n");
|
||||||
sb.append(" <tr><td>User:</td><td><input type='text' name='");
|
sb.append(" <tr><td>User:</td><td><input type='text' name='");
|
||||||
sb.append(usernameParameter).append("' value='").append("'></td></tr>\n");
|
sb.append(usernameParameter).append("' value='").append("'></td></tr>\n");
|
||||||
sb.append(" <tr><td>Password:</td><td><input type='password' name='")
|
sb.append(" <tr><td>Password:</td><td><input type='password' name='")
|
||||||
.append(passwordParameter).append("'/></td></tr>\n");
|
.append(passwordParameter).append("'/></td></tr>\n");
|
||||||
|
|
||||||
if (rememberMeParameter != null) {
|
if (rememberMeParameter != null) {
|
||||||
sb.append(" <tr><td><input type='checkbox' name='")
|
sb.append(" <tr><td><input type='checkbox' name='")
|
||||||
.append(rememberMeParameter)
|
.append(rememberMeParameter)
|
||||||
.append("'/></td><td>Remember me on this computer.</td></tr>\n");
|
.append("'/></td><td>Remember me on this computer.</td></tr>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(" <tr><td colspan='2'><input name=\"submit\" type=\"submit\" value=\"Login\"/></td></tr>\n");
|
sb.append(" <tr><td colspan='2'><input name=\"submit\" type=\"submit\" value=\"Login\"/></td></tr>\n");
|
||||||
renderHiddenInputs(sb, request);
|
renderHiddenInputs(sb, request);
|
||||||
sb.append(" </table>\n");
|
sb.append("</table>\n");
|
||||||
sb.append("</form>");
|
sb.append("</form>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,18 +221,18 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||||
sb.append("<h3>Login with OpenID Identity</h3>");
|
sb.append("<h3>Login with OpenID Identity</h3>");
|
||||||
sb.append("<form name='oidf' action='").append(request.getContextPath())
|
sb.append("<form name='oidf' action='").append(request.getContextPath())
|
||||||
.append(openIDauthenticationUrl).append("' method='POST'>\n");
|
.append(openIDauthenticationUrl).append("' method='POST'>\n");
|
||||||
sb.append(" <table>\n");
|
sb.append("<table>\n");
|
||||||
sb.append(" <tr><td>Identity:</td><td><input type='text' size='30' name='");
|
sb.append(" <tr><td>Identity:</td><td><input type='text' size='30' name='");
|
||||||
sb.append(openIDusernameParameter).append("'/></td></tr>\n");
|
sb.append(openIDusernameParameter).append("'/></td></tr>\n");
|
||||||
|
|
||||||
if (openIDrememberMeParameter != null) {
|
if (openIDrememberMeParameter != null) {
|
||||||
sb.append(" <tr><td><input type='checkbox' name='")
|
sb.append(" <tr><td><input type='checkbox' name='")
|
||||||
.append(openIDrememberMeParameter)
|
.append(openIDrememberMeParameter)
|
||||||
.append("'></td><td>Remember me on this computer.</td></tr>\n");
|
.append("'></td><td>Remember me on this computer.</td></tr>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(" <tr><td colspan='2'><input name=\"submit\" type=\"submit\" value=\"Login\"/></td></tr>\n");
|
sb.append(" <tr><td colspan='2'><input name=\"submit\" type=\"submit\" value=\"Login\"/></td></tr>\n");
|
||||||
sb.append(" </table>\n");
|
sb.append("</table>\n");
|
||||||
renderHiddenInputs(sb, request);
|
renderHiddenInputs(sb, request);
|
||||||
sb.append("</form>");
|
sb.append("</form>");
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||||
CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName());
|
CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName());
|
||||||
|
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
sb.append(" <input name=\"" + token.getParameterName()
|
sb.append(" <input name=\"" + token.getParameterName()
|
||||||
+ "\" type=\"hidden\" value=\"" + token.getToken() + "\" />\n");
|
+ "\" type=\"hidden\" value=\"" + token.getToken() + "\" />\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue