Skip to content

Commit 18f3d13

Browse files
philwebbrwinch
authored andcommitted
Fix parenthesis padding issues
Fix a few parenthesis padding issues caused by the formatter. Issue gh-8945
1 parent f1cee95 commit 18f3d13

3 files changed

Lines changed: 21 additions & 52 deletions

File tree

‎core/src/test/java/org/springframework/security/jackson2/UsernamePasswordAuthenticationTokenMixinTests.java‎

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,44 +43,32 @@
4343
*/
4444
public class UsernamePasswordAuthenticationTokenMixinTests extends AbstractMixinTests {
4545

46-
// @formatter:off
4746
private static final String AUTHENTICATED_JSON = "{"
48-
+ "\"@class\": \"org.springframework.security.authentication.UsernamePasswordAuthenticationToken\","
49-
+ "\"principal\": "+ UserDeserializerTests.USER_JSON + ", "
50-
+ "\"credentials\": \"1234\", "
51-
+ "\"authenticated\": true, "
52-
+ "\"details\": null, "
53-
+ "\"authorities\": "+ SimpleGrantedAuthorityMixinTests.AUTHORITIES_ARRAYLIST_JSON
54-
+ "}";
55-
// @formatter:on
56-
57-
// @formatter:off
58-
public static final String AUTHENTICATED_STRINGPRINCIPAL_JSON = AUTHENTICATED_JSON.replace( UserDeserializerTests.USER_JSON, "\"admin\"");
59-
// @formatter:on
60-
61-
// @formatter:off
47+
+ "\"@class\": \"org.springframework.security.authentication.UsernamePasswordAuthenticationToken\","
48+
+ "\"principal\": " + UserDeserializerTests.USER_JSON + ", " + "\"credentials\": \"1234\", "
49+
+ "\"authenticated\": true, " + "\"details\": null, " + "\"authorities\": "
50+
+ SimpleGrantedAuthorityMixinTests.AUTHORITIES_ARRAYLIST_JSON + "}";
51+
52+
public static final String AUTHENTICATED_STRINGPRINCIPAL_JSON = AUTHENTICATED_JSON
53+
.replace(UserDeserializerTests.USER_JSON, "\"admin\"");
54+
6255
private static final String NON_USER_PRINCIPAL_JSON = "{"
63-
+ "\"@class\": \"org.springframework.security.jackson2.UsernamePasswordAuthenticationTokenMixinTests$NonUserPrincipal\", "
64-
+ "\"username\": \"admin\""
65-
+ "}";
66-
// @formatter:on
56+
+ "\"@class\": \"org.springframework.security.jackson2.UsernamePasswordAuthenticationTokenMixinTests$NonUserPrincipal\", "
57+
+ "\"username\": \"admin\"" + "}";
6758

68-
// @formatter:off
69-
private static final String AUTHENTICATED_STRINGDETAILS_JSON = AUTHENTICATED_JSON.replace("\"details\": null, ", "\"details\": \"details\", ");
70-
// @formatter:on
59+
private static final String AUTHENTICATED_STRINGDETAILS_JSON = AUTHENTICATED_JSON.replace("\"details\": null, ",
60+
"\"details\": \"details\", ");
7161

72-
// @formatter:off
7362
private static final String AUTHENTICATED_NON_USER_PRINCIPAL_JSON = AUTHENTICATED_JSON
74-
.replace(UserDeserializerTests.USER_JSON, NON_USER_PRINCIPAL_JSON)
75-
.replaceAll(UserDeserializerTests.USER_PASSWORD, "null")
76-
.replace(SimpleGrantedAuthorityMixinTests.AUTHORITIES_ARRAYLIST_JSON, SimpleGrantedAuthorityMixinTests.NO_AUTHORITIES_ARRAYLIST_JSON);
77-
// @formatter:on
63+
.replace(UserDeserializerTests.USER_JSON, NON_USER_PRINCIPAL_JSON)
64+
.replaceAll(UserDeserializerTests.USER_PASSWORD, "null")
65+
.replace(SimpleGrantedAuthorityMixinTests.AUTHORITIES_ARRAYLIST_JSON,
66+
SimpleGrantedAuthorityMixinTests.NO_AUTHORITIES_ARRAYLIST_JSON);
7867

79-
// @formatter:off
8068
private static final String UNAUTHENTICATED_STRINGPRINCIPAL_JSON = AUTHENTICATED_STRINGPRINCIPAL_JSON
81-
.replace("\"authenticated\": true, ", "\"authenticated\": false, ")
82-
.replace(SimpleGrantedAuthorityMixinTests.AUTHORITIES_ARRAYLIST_JSON, SimpleGrantedAuthorityMixinTests.EMPTY_AUTHORITIES_ARRAYLIST_JSON);
83-
// @formatter:on
69+
.replace("\"authenticated\": true, ", "\"authenticated\": false, ")
70+
.replace(SimpleGrantedAuthorityMixinTests.AUTHORITIES_ARRAYLIST_JSON,
71+
SimpleGrantedAuthorityMixinTests.EMPTY_AUTHORITIES_ARRAYLIST_JSON);
8472

8573
@Test
8674
public void serializeUnauthenticatedUsernamePasswordAuthenticationTokenMixinTest()
@@ -184,30 +172,20 @@ public void deserializeAuthenticatedUsernamePasswordAuthenticationTokenWithDetai
184172

185173
@Test
186174
public void serializingThenDeserializingWithNoCredentialsOrDetailsShouldWork() throws IOException {
187-
// given
188175
UsernamePasswordAuthenticationToken original = new UsernamePasswordAuthenticationToken("Frodo", null);
189-
190-
// when
191176
String serialized = this.mapper.writeValueAsString(original);
192177
UsernamePasswordAuthenticationToken deserialized = this.mapper.readValue(serialized,
193178
UsernamePasswordAuthenticationToken.class);
194-
195-
// then
196179
assertThat(deserialized).isEqualTo(original);
197180
}
198181

199182
@Test
200183
public void serializingThenDeserializingWithConfiguredObjectMapperShouldWork() throws IOException {
201-
// given
202184
this.mapper.setDefaultPropertyInclusion(construct(ALWAYS, NON_NULL)).setSerializationInclusion(NON_ABSENT);
203185
UsernamePasswordAuthenticationToken original = new UsernamePasswordAuthenticationToken("Frodo", null);
204-
205-
// when
206186
String serialized = this.mapper.writeValueAsString(original);
207187
UsernamePasswordAuthenticationToken deserialized = this.mapper.readValue(serialized,
208188
UsernamePasswordAuthenticationToken.class);
209-
210-
// then
211189
assertThat(deserialized).isEqualTo(original);
212190
}
213191

‎etc/checkstyle/checkstyle-suppressions.xml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
44
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
55
<suppressions>
6-
<suppress files=".*" checks="ParenPad" />
76
<suppress files=".*" checks="RedundantImport" />
87
<suppress files=".*" checks="RegexpSinglelineJava" />
98
<suppress files=".*" checks="SimplifyBooleanExpression" />

‎oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/HttpSessionOAuth2AuthorizationRequestRepositoryTests.java‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,12 @@ public void saveAuthorizationRequestWhenExistingSessionAndDistributedSessionThen
197197
public void saveAuthorizationRequestWhenNullThenRemoved() {
198198
MockHttpServletRequest request = new MockHttpServletRequest();
199199
MockHttpServletResponse response = new MockHttpServletResponse();
200-
201200
OAuth2AuthorizationRequest authorizationRequest = createAuthorizationRequest().build();
202-
203-
this.authorizationRequestRepository.saveAuthorizationRequest( // Save
204-
authorizationRequest, request, response);
205-
201+
this.authorizationRequestRepository.saveAuthorizationRequest(authorizationRequest, request, response);
206202
request.addParameter(OAuth2ParameterNames.STATE, authorizationRequest.getState());
207-
this.authorizationRequestRepository.saveAuthorizationRequest( // Null value
208-
// removes
209-
null, request, response);
210-
203+
this.authorizationRequestRepository.saveAuthorizationRequest(null, request, response);
211204
OAuth2AuthorizationRequest loadedAuthorizationRequest = this.authorizationRequestRepository
212205
.loadAuthorizationRequest(request);
213-
214206
assertThat(loadedAuthorizationRequest).isNull();
215207
}
216208

0 commit comments

Comments
 (0)