1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -45,6 +45,141 @@ public class FormLoginBeanDefinitionParserTests {
45
45
46
46
private static final String CONFIG_LOCATION_PREFIX = "classpath:org/springframework/security/config/http/FormLoginBeanDefinitionParserTests" ;
47
47
48
+ //@formatter:off
49
+ public static final String EXPECTED_HTML_HEAD = " <head>\n "
50
+ + " <meta charset=\" utf-8\" >\n "
51
+ + " <meta name=\" viewport\" content=\" width=device-width, initial-scale=1, shrink-to-fit=no\" >\n "
52
+ + " <meta name=\" description\" content=\" \" >\n "
53
+ + " <meta name=\" author\" content=\" \" >\n "
54
+ + " <title>Please sign in</title>\n "
55
+ + " <style>\n "
56
+ + " /* General layout */\n "
57
+ + " body {\n "
58
+ + " font-family: system-ui, \" Segoe UI\" , Roboto, \" Helvetica Neue\" , Arial, sans-serif;\n "
59
+ + " background-color: #eee;\n "
60
+ + " padding: 40px 0;\n "
61
+ + " margin: 0;\n "
62
+ + " line-height: 1.5;\n "
63
+ + " }\n "
64
+ + " \n "
65
+ + " h2 {\n "
66
+ + " margin-top: 0;\n "
67
+ + " margin-bottom: 0.5rem;\n "
68
+ + " font-size: 2rem;\n "
69
+ + " font-weight: 500;\n "
70
+ + " line-height: 2rem;\n "
71
+ + " }\n "
72
+ + " \n "
73
+ + " .content {\n "
74
+ + " margin-right: auto;\n "
75
+ + " margin-left: auto;\n "
76
+ + " padding-right: 15px;\n "
77
+ + " padding-left: 15px;\n "
78
+ + " width: 100%;\n "
79
+ + " box-sizing: border-box;\n "
80
+ + " }\n "
81
+ + " \n "
82
+ + " @media (min-width: 800px) {\n "
83
+ + " .content {\n "
84
+ + " max-width: 760px;\n "
85
+ + " }\n "
86
+ + " }\n "
87
+ + " \n "
88
+ + " /* Components */\n "
89
+ + " a,\n "
90
+ + " a:visited {\n "
91
+ + " text-decoration: none;\n "
92
+ + " color: #06f;\n "
93
+ + " }\n "
94
+ + " \n "
95
+ + " a:hover {\n "
96
+ + " text-decoration: underline;\n "
97
+ + " color: #003c97;\n "
98
+ + " }\n "
99
+ + " \n "
100
+ + " input[type=\" text\" ],\n "
101
+ + " input[type=\" password\" ] {\n "
102
+ + " height: auto;\n "
103
+ + " width: 100%;\n "
104
+ + " font-size: 1rem;\n "
105
+ + " padding: 0.5rem;\n "
106
+ + " box-sizing: border-box;\n "
107
+ + " }\n "
108
+ + " \n "
109
+ + " button {\n "
110
+ + " padding: 0.5rem 1rem;\n "
111
+ + " font-size: 1.25rem;\n "
112
+ + " line-height: 1.5;\n "
113
+ + " border: none;\n "
114
+ + " border-radius: 0.1rem;\n "
115
+ + " width: 100%;\n "
116
+ + " }\n "
117
+ + " \n "
118
+ + " button.primary {\n "
119
+ + " color: #fff;\n "
120
+ + " background-color: #06f;\n "
121
+ + " }\n "
122
+ + " \n "
123
+ + " .alert {\n "
124
+ + " padding: 0.75rem 1rem;\n "
125
+ + " margin-bottom: 1rem;\n "
126
+ + " line-height: 1.5;\n "
127
+ + " border-radius: 0.1rem;\n "
128
+ + " width: 100%;\n "
129
+ + " box-sizing: border-box;\n "
130
+ + " border-width: 1px;\n "
131
+ + " border-style: solid;\n "
132
+ + " }\n "
133
+ + " \n "
134
+ + " .alert.alert-danger {\n "
135
+ + " color: #6b1922;\n "
136
+ + " background-color: #f7d5d7;\n "
137
+ + " border-color: #eab6bb;\n "
138
+ + " }\n "
139
+ + " \n "
140
+ + " .alert.alert-success {\n "
141
+ + " color: #145222;\n "
142
+ + " background-color: #d1f0d9;\n "
143
+ + " border-color: #c2ebcb;\n "
144
+ + " }\n "
145
+ + " \n "
146
+ + " .screenreader {\n "
147
+ + " position: absolute;\n "
148
+ + " clip: rect(0 0 0 0);\n "
149
+ + " height: 1px;\n "
150
+ + " width: 1px;\n "
151
+ + " padding: 0;\n "
152
+ + " border: 0;\n "
153
+ + " overflow: hidden;\n "
154
+ + " }\n "
155
+ + " \n "
156
+ + " table {\n "
157
+ + " width: 100%;\n "
158
+ + " max-width: 100%;\n "
159
+ + " margin-bottom: 2rem;\n "
160
+ + " }\n "
161
+ + " \n "
162
+ + " .table-striped tr:nth-of-type(2n + 1) {\n "
163
+ + " background-color: #e1e1e1;\n "
164
+ + " }\n "
165
+ + " \n "
166
+ + " td {\n "
167
+ + " padding: 0.75rem;\n "
168
+ + " vertical-align: top;\n "
169
+ + " }\n "
170
+ + " \n "
171
+ + " /* Login / logout layouts */\n "
172
+ + " .login-form,\n "
173
+ + " .logout-form {\n "
174
+ + " max-width: 340px;\n "
175
+ + " padding: 0 15px 15px 15px;\n "
176
+ + " margin: 0 auto 2rem auto;\n "
177
+ + " box-sizing: border-box;\n "
178
+ + " }\n "
179
+ + " </style>\n "
180
+ + " </head>\n " ;
181
+ //@formatter:on
182
+
48
183
public final SpringTestContext spring = new SpringTestContext (this );
49
184
50
185
@ Autowired
@@ -56,28 +191,20 @@ public void getLoginWhenAutoConfigThenShowsDefaultLoginPage() throws Exception {
56
191
// @formatter:off
57
192
String expectedContent = "<!DOCTYPE html>\n "
58
193
+ "<html lang=\" en\" >\n "
59
- + " <head>\n "
60
- + " <meta charset=\" utf-8\" >\n "
61
- + " <meta name=\" viewport\" content=\" width=device-width, initial-scale=1, shrink-to-fit=no\" >\n "
62
- + " <meta name=\" description\" content=\" \" >\n "
63
- + " <meta name=\" author\" content=\" \" >\n "
64
- + " <title>Please sign in</title>\n "
65
- + " <link href=\" https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css\" rel=\" stylesheet\" integrity=\" sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M\" crossorigin=\" anonymous\" >\n "
66
- + " <link href=\" https://getbootstrap.com/docs/4.0/examples/signin/signin.css\" rel=\" stylesheet\" integrity=\" sha384-oOE/3m0LUMPub4kaC09mrdEhIc+e3exm4xOGxAmuFXhBNF4hcg/6MiAXAf5p0P56\" crossorigin=\" anonymous\" />\n "
67
- + " </head>\n "
194
+ + EXPECTED_HTML_HEAD
68
195
+ " <body>\n "
69
- + " <div class=\" container \" >\n "
70
- + " <form class=\" form-signin \" method=\" post\" action=\" /login\" >\n "
71
- + " <h2 class= \" form-signin-heading \" >Please sign in</h2>\n "
196
+ + " <div class=\" content \" >\n "
197
+ + " <form class=\" login-form \" method=\" post\" action=\" /login\" >\n "
198
+ + " <h2>Please sign in</h2>\n "
72
199
+ " <p>\n "
73
- + " <label for=\" username\" class=\" sr-only \" >Username</label>\n "
74
- + " <input type=\" text\" id=\" username\" name=\" username\" class= \" form-control \" placeholder=\" Username\" required autofocus>\n "
200
+ + " <label for=\" username\" class=\" screenreader \" >Username</label>\n "
201
+ + " <input type=\" text\" id=\" username\" name=\" username\" placeholder=\" Username\" required autofocus>\n "
75
202
+ " </p>\n "
76
203
+ " <p>\n "
77
- + " <label for=\" password\" class=\" sr-only \" >Password</label>\n "
78
- + " <input type=\" password\" id=\" password\" name=\" password\" class= \" form-control \" placeholder=\" Password\" required>\n "
204
+ + " <label for=\" password\" class=\" screenreader \" >Password</label>\n "
205
+ + " <input type=\" password\" id=\" password\" name=\" password\" placeholder=\" Password\" required>\n "
79
206
+ " </p>\n "
80
- + " <button class =\" btn btn-lg btn-primary btn-block \" type =\" submit \" >Sign in</button>\n "
207
+ + " <button type =\" submit \" class =\" primary \" >Sign in</button>\n "
81
208
+ " </form>\n "
82
209
+ "</div>\n "
83
210
+ "</body></html>" ;
@@ -97,28 +224,20 @@ public void getLoginWhenConfiguredWithCustomAttributesThenLoginPageReflects() th
97
224
// @formatter:off
98
225
String expectedContent = "<!DOCTYPE html>\n "
99
226
+ "<html lang=\" en\" >\n "
100
- + " <head>\n "
101
- + " <meta charset=\" utf-8\" >\n "
102
- + " <meta name=\" viewport\" content=\" width=device-width, initial-scale=1, shrink-to-fit=no\" >\n "
103
- + " <meta name=\" description\" content=\" \" >\n "
104
- + " <meta name=\" author\" content=\" \" >\n "
105
- + " <title>Please sign in</title>\n "
106
- + " <link href=\" https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css\" rel=\" stylesheet\" integrity=\" sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M\" crossorigin=\" anonymous\" >\n "
107
- + " <link href=\" https://getbootstrap.com/docs/4.0/examples/signin/signin.css\" rel=\" stylesheet\" integrity=\" sha384-oOE/3m0LUMPub4kaC09mrdEhIc+e3exm4xOGxAmuFXhBNF4hcg/6MiAXAf5p0P56\" crossorigin=\" anonymous\" />\n "
108
- + " </head>\n "
227
+ + EXPECTED_HTML_HEAD
109
228
+ " <body>\n "
110
- + " <div class=\" container \" >\n "
111
- + " <form class=\" form-signin \" method=\" post\" action=\" /signin\" >\n "
112
- + " <h2 class= \" form-signin-heading \" >Please sign in</h2>\n "
229
+ + " <div class=\" content \" >\n "
230
+ + " <form class=\" login-form \" method=\" post\" action=\" /signin\" >\n "
231
+ + " <h2>Please sign in</h2>\n "
113
232
+ " <p>\n "
114
- + " <label for=\" username\" class=\" sr-only \" >Username</label>\n "
115
- + " <input type=\" text\" id=\" username\" name=\" custom_user\" class= \" form-control \" placeholder=\" Username\" required autofocus>\n "
233
+ + " <label for=\" username\" class=\" screenreader \" >Username</label>\n "
234
+ + " <input type=\" text\" id=\" username\" name=\" custom_user\" placeholder=\" Username\" required autofocus>\n "
116
235
+ " </p>\n "
117
236
+ " <p>\n "
118
- + " <label for=\" password\" class=\" sr-only \" >Password</label>\n "
119
- + " <input type=\" password\" id=\" password\" name=\" custom_pass\" class= \" form-control \" placeholder=\" Password\" required>\n "
237
+ + " <label for=\" password\" class=\" screenreader \" >Password</label>\n "
238
+ + " <input type=\" password\" id=\" password\" name=\" custom_pass\" placeholder=\" Password\" required>\n "
120
239
+ " </p>\n "
121
- + " <button class =\" btn btn-lg btn-primary btn-block \" type =\" submit \" >Sign in</button>\n "
240
+ + " <button type =\" submit \" class =\" primary \" >Sign in</button>\n "
122
241
+ " </form>\n "
123
242
+ "</div>\n "
124
243
+ "</body></html>" ;
0 commit comments