Skip to content

Commit 7e41785

Browse files
Kehrlannrwinch
authored andcommitted
Remove trailing spaces in default UIs
- Default UIs had blank lines with only spaces. These get deleted by the spring-javaformat plugin. In order to avoid this behavior, an extra \s had been inserted in the tests. The reason for those \s is not obvious. - This commit cleans up the \s but changing the HTML templates.
1 parent 85693b2 commit 7e41785

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void loginPageThenDefaultLoginPageIsRendered() throws Exception {
105105
<div class="content">
106106
<form class="login-form" method="post" action="/login">
107107
<h2>Please sign in</h2>
108-
\s
108+
109109
<p>
110110
<label for="username" class="screenreader">Username</label>
111111
<input type="text" id="username" name="username" placeholder="Username" required autofocus>
@@ -160,7 +160,7 @@ public void loginPageWhenErrorThenDefaultLoginPageWithError() throws Exception {
160160
<div class="content">
161161
<form class="login-form" method="post" action="/login">
162162
<h2>Please sign in</h2>
163-
<div class="alert alert-danger" role="alert">Bad credentials</div>
163+
<div class="alert alert-danger" role="alert">Bad credentials</div>
164164
<p>
165165
<label for="username" class="screenreader">Username</label>
166166
<input type="text" id="username" name="username" placeholder="Username" required autofocus>
@@ -219,7 +219,7 @@ public void loginPageWhenLoggedOutThenDefaultLoginPageWithLogoutMessage() throws
219219
<div class="content">
220220
<form class="login-form" method="post" action="/login">
221221
<h2>Please sign in</h2>
222-
<div class="alert alert-success" role="alert">You have been signed out</div>
222+
<div class="alert alert-success" role="alert">You have been signed out</div>
223223
<p>
224224
<label for="username" class="screenreader">Username</label>
225225
<input type="text" id="username" name="username" placeholder="Username" required autofocus>
@@ -286,7 +286,7 @@ public void loginPageWhenRememberConfigureThenDefaultLoginPageWithRememberMeChec
286286
<div class="content">
287287
<form class="login-form" method="post" action="/login">
288288
<h2>Please sign in</h2>
289-
\s
289+
290290
<p>
291291
<label for="username" class="screenreader">Username</label>
292292
<input type="text" id="username" name="username" placeholder="Username" required autofocus>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void oneTimeTokenWhenFormLoginConfiguredThenRendersRequestTokenForm() throws Exc
150150
<div class="content">
151151
<form class="login-form" method="post" action="/login">
152152
<h2>Please sign in</h2>
153-
\s
153+
154154
<p>
155155
<label for="username" class="screenreader">Username</label>
156156
<input type="text" id="username" name="username" placeholder="Username" required autofocus>
@@ -165,12 +165,12 @@ void oneTimeTokenWhenFormLoginConfiguredThenRendersRequestTokenForm() throws Exc
165165
</form>
166166
<form id="ott-form" class="login-form" method="post" action="/ott/generate">
167167
<h2>Request a One-Time Token</h2>
168-
\s
168+
169169
<p>
170170
<label for="ott-username" class="screenreader">Username</label>
171171
<input type="text" id="ott-username" name="username" placeholder="Username" required>
172172
</p>
173-
<input name="_csrf" type="hidden" value="%s" />
173+
<input name="_csrf" type="hidden" value="%s" />
174174
<button class="primary" type="submit" form="ott-form">Send Token</button>
175175
</form>
176176

config/src/test/java/org/springframework/security/config/http/FormLoginBeanDefinitionParserTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void getLoginWhenAutoConfigThenShowsDefaultLoginPage() throws Exception {
6868
<div class="content">
6969
<form class="login-form" method="post" action="/login">
7070
<h2>Please sign in</h2>
71-
\s
71+
7272
<p>
7373
<label for="username" class="screenreader">Username</label>
7474
<input type="text" id="username" name="username" placeholder="Username" required autofocus>
@@ -115,7 +115,7 @@ public void getLoginWhenConfiguredWithCustomAttributesThenLoginPageReflects() th
115115
<div class="content">
116116
<form class="login-form" method="post" action="/signin">
117117
<h2>Please sign in</h2>
118-
\s
118+
119119
<p>
120120
<label for="username" class="screenreader">Username</label>
121121
<input type="text" id="username" name="custom_user" placeholder="Username" required autofocus>

web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ private boolean matches(HttpServletRequest request, String url) {
407407
private static final String LOGIN_FORM_TEMPLATE = """
408408
<form class="login-form" method="post" action="{{loginUrl}}">
409409
<h2>Please sign in</h2>
410-
{{errorMessage}}{{logoutMessage}}
410+
{{errorMessage}}{{logoutMessage}}
411411
<p>
412412
<label for="username" class="screenreader">Username</label>
413413
<input type="text" id="username" name="{{usernameParameter}}" placeholder="Username" required autofocus>
@@ -450,12 +450,12 @@ private boolean matches(HttpServletRequest request, String url) {
450450
private static final String ONE_TIME_TEMPLATE = """
451451
<form id="ott-form" class="login-form" method="post" action="{{generateOneTimeTokenUrl}}">
452452
<h2>Request a One-Time Token</h2>
453-
{{errorMessage}}{{logoutMessage}}
453+
{{errorMessage}}{{logoutMessage}}
454454
<p>
455455
<label for="ott-username" class="screenreader">Username</label>
456456
<input type="text" id="ott-username" name="username" placeholder="Username" required>
457457
</p>
458-
{{hiddenInputs}}
458+
{{hiddenInputs}}
459459
<button class="primary" type="submit" form="ott-form">Send Token</button>
460460
</form>
461461
""";

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,12 @@ public void generateWhenOneTimeTokenLoginThenOttForm() throws Exception {
199199
assertThat(response.getContentAsString()).contains("""
200200
<form id="ott-form" class="login-form" method="post" action="/ott/authenticate">
201201
<h2>Request a One-Time Token</h2>
202-
\s
202+
203203
<p>
204204
<label for="ott-username" class="screenreader">Username</label>
205205
<input type="text" id="ott-username" name="username" placeholder="Username" required>
206206
</p>
207-
\s
207+
208208
<button class="primary" type="submit" form="ott-form">Send Token</button>
209209
</form>
210210
""");
@@ -244,7 +244,7 @@ void generatesThenRenders() throws ServletException, IOException {
244244
<div class="content">
245245
<form class="login-form" method="post" action="null">
246246
<h2>Please sign in</h2>
247-
<div class="alert alert-danger" role="alert">Bad credentials</div>
247+
<div class="alert alert-danger" role="alert">Bad credentials</div>
248248
<p>
249249
<label for="username" class="screenreader">Username</label>
250250
<input type="text" id="username" name="username" placeholder="Username" required autofocus>

0 commit comments

Comments
 (0)