Skip to content

Commit 31ec450

Browse files
philwebbrwinch
authored andcommitted
Remove superfluous comments
Remove a few comments that previously add noise but don't offer a great deal of value. Issue gh-8945
1 parent 8d80166 commit 31ec450

28 files changed

Lines changed: 7 additions & 304 deletions

File tree

‎acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ public void maskPermissionGrantingStrategy() {
557557

558558
@Test
559559
public void hashCodeWithoutStackOverFlow() throws Exception {
560-
// given
561560
Sid sid = new PrincipalSid("pSid");
562561
ObjectIdentity oid = new ObjectIdentityImpl("type", 1);
563562
AclAuthorizationStrategy authStrategy = new AclAuthorizationStrategyImpl(new SimpleGrantedAuthority("role"));
@@ -570,7 +569,6 @@ public void hashCodeWithoutStackOverFlow() throws Exception {
570569
fieldAces.setAccessible(true);
571570
List<AccessControlEntryImpl> aces = (List<AccessControlEntryImpl>) fieldAces.get(acl);
572571
aces.add(ace);
573-
// when - then none StackOverFlowError been raised
574572
ace.hashCode();
575573
}
576574

‎acl/src/test/java/org/springframework/security/acls/jdbc/AclClassIdUtilsTests.java‎

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -61,119 +61,76 @@ public void setUp() {
6161

6262
@Test
6363
public void shouldReturnLongIfIdentifierIsLong() throws SQLException {
64-
// when
6564
Serializable newIdentifier = this.aclClassIdUtils.identifierFrom(DEFAULT_IDENTIFIER, this.resultSet);
66-
67-
// then
6865
assertThat(newIdentifier).isEqualTo(DEFAULT_IDENTIFIER);
6966
}
7067

7168
@Test
7269
public void shouldReturnLongIfIdentifierIsBigInteger() throws SQLException {
73-
// when
7470
Serializable newIdentifier = this.aclClassIdUtils.identifierFrom(BIGINT_IDENTIFIER, this.resultSet);
75-
76-
// then
7771
assertThat(newIdentifier).isEqualTo(DEFAULT_IDENTIFIER);
7872
}
7973

8074
@Test
8175
public void shouldReturnLongIfClassIdTypeIsNull() throws SQLException {
82-
// given
8376
given(this.resultSet.getString("class_id_type")).willReturn(null);
84-
85-
// when
8677
Serializable newIdentifier = this.aclClassIdUtils.identifierFrom(DEFAULT_IDENTIFIER_AS_STRING, this.resultSet);
87-
88-
// then
8978
assertThat(newIdentifier).isEqualTo(DEFAULT_IDENTIFIER);
9079
}
9180

9281
@Test
9382
public void shouldReturnLongIfNoClassIdTypeColumn() throws SQLException {
94-
// given
9583
given(this.resultSet.getString("class_id_type")).willThrow(SQLException.class);
96-
97-
// when
9884
Serializable newIdentifier = this.aclClassIdUtils.identifierFrom(DEFAULT_IDENTIFIER_AS_STRING, this.resultSet);
99-
100-
// then
10185
assertThat(newIdentifier).isEqualTo(DEFAULT_IDENTIFIER);
10286
}
10387

10488
@Test
10589
public void shouldReturnLongIfTypeClassNotFound() throws SQLException {
106-
// given
10790
given(this.resultSet.getString("class_id_type")).willReturn("com.example.UnknownType");
108-
109-
// when
11091
Serializable newIdentifier = this.aclClassIdUtils.identifierFrom(DEFAULT_IDENTIFIER_AS_STRING, this.resultSet);
111-
112-
// then
11392
assertThat(newIdentifier).isEqualTo(DEFAULT_IDENTIFIER);
11493
}
11594

11695
@Test
11796
public void shouldReturnLongEvenIfCustomConversionServiceDoesNotSupportLongConversion() throws SQLException {
118-
// given
11997
given(this.resultSet.getString("class_id_type")).willReturn("java.lang.Long");
12098
given(this.conversionService.canConvert(String.class, Long.class)).willReturn(false);
12199
this.aclClassIdUtils.setConversionService(this.conversionService);
122-
123-
// when
124100
Serializable newIdentifier = this.aclClassIdUtils.identifierFrom(DEFAULT_IDENTIFIER_AS_STRING, this.resultSet);
125-
126-
// then
127101
assertThat(newIdentifier).isEqualTo(DEFAULT_IDENTIFIER);
128102
}
129103

130104
@Test
131105
public void shouldReturnLongWhenLongClassIdType() throws SQLException {
132-
// given
133106
given(this.resultSet.getString("class_id_type")).willReturn("java.lang.Long");
134-
135-
// when
136107
Serializable newIdentifier = this.aclClassIdUtils.identifierFrom(DEFAULT_IDENTIFIER_AS_STRING, this.resultSet);
137-
138-
// then
139108
assertThat(newIdentifier).isEqualTo(DEFAULT_IDENTIFIER);
140109
}
141110

142111
@Test
143112
public void shouldReturnUUIDWhenUUIDClassIdType() throws SQLException {
144-
// given
145113
UUID identifier = UUID.randomUUID();
146114
given(this.resultSet.getString("class_id_type")).willReturn("java.util.UUID");
147-
148-
// when
149115
Serializable newIdentifier = this.aclClassIdUtils.identifierFrom(identifier.toString(), this.resultSet);
150-
151-
// then
152116
assertThat(newIdentifier).isEqualTo(identifier);
153117
}
154118

155119
@Test
156120
public void shouldReturnStringWhenStringClassIdType() throws SQLException {
157-
// given
158121
String identifier = "MY_STRING_IDENTIFIER";
159122
given(this.resultSet.getString("class_id_type")).willReturn("java.lang.String");
160-
161-
// when
162123
Serializable newIdentifier = this.aclClassIdUtils.identifierFrom(identifier, this.resultSet);
163-
164-
// then
165124
assertThat(newIdentifier).isEqualTo(identifier);
166125
}
167126

168127
@Test(expected = IllegalArgumentException.class)
169128
public void shouldNotAcceptNullConversionServiceInConstruction() {
170-
// when
171129
new AclClassIdUtils(null);
172130
}
173131

174132
@Test(expected = IllegalArgumentException.class)
175133
public void shouldNotAcceptNullConversionServiceInSetter() {
176-
// when
177134
this.aclClassIdUtils.setConversionService(null);
178135
}
179136

‎config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
7575

7676
private List<HeaderWriter> headerWriters = new ArrayList<>();
7777

78-
// --- default header writers ---
79-
8078
private final ContentTypeOptionsConfig contentTypeOptions = new ContentTypeOptionsConfig();
8179

8280
private final XXssConfig xssProtection = new XXssConfig();

‎config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurerTests.java‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,6 @@ public void getWhenUsingDefaultsAndKeyMatchesByKidThenOk() throws Exception {
436436
.andExpect(content().string("test-subject"));
437437
}
438438

439-
// -- Method Security
440-
441439
@Test
442440
public void getWhenUsingMethodSecurityWithValidBearerTokenThenAcceptsRequest() throws Exception {
443441

@@ -494,8 +492,6 @@ public void getWhenUsingMethodSecurityWithDenyAllThenInsufficientScopeError() th
494492
.andExpect(insufficientScopeHeader());
495493
}
496494

497-
// -- Resource Server should not engage csrf
498-
499495
@Test
500496
public void postWhenUsingDefaultsWithValidBearerTokenAndNoCsrfTokenThenOk() throws Exception {
501497

@@ -527,8 +523,6 @@ public void postWhenUsingDefaultsWithExpiredBearerTokenAndNoCsrfThenInvalidToken
527523
.andExpect(invalidTokenHeader("An error occurred while attempting to decode the Jwt"));
528524
}
529525

530-
// -- Resource Server should not create sessions
531-
532526
@Test
533527
public void requestWhenDefaultConfiguredThenSessionIsNotCreated() throws Exception {
534528

@@ -576,8 +570,6 @@ public void requestWhenSessionManagementConfiguredThenUserConfigurationOverrides
576570
assertThat(result.getRequest().getSession(false)).isNotNull();
577571
}
578572

579-
// -- custom bearer token resolver
580-
581573
@Test
582574
public void requestWhenBearerTokenResolverAllowsRequestBodyThenEitherHeaderOrRequestBodyIsAccepted()
583575
throws Exception {
@@ -693,8 +685,6 @@ public void getBearerTokenResolverWhenNoResolverSpecifiedThenTheDefaultIsUsed()
693685
assertThat(oauth2.getBearerTokenResolver()).isInstanceOf(DefaultBearerTokenResolver.class);
694686
}
695687

696-
// -- custom jwt decoder
697-
698688
@Test
699689
public void requestWhenCustomJwtDecoderWiredOnDslThenUsed() throws Exception {
700690

@@ -820,8 +810,6 @@ public void getJwtDecoderWhenTwoJwtDecoderBeansThenThrowsException() {
820810
assertThatCode(() -> jwtConfigurer.getJwtDecoder()).isInstanceOf(NoUniqueBeanDefinitionException.class);
821811
}
822812

823-
// -- exception handling
824-
825813
@Test
826814
public void requestWhenRealmNameConfiguredThenUsesOnUnauthenticated() throws Exception {
827815

@@ -861,8 +849,6 @@ public void accessDeniedHandlerWhenGivenNullThenThrowsException() {
861849
assertThatCode(() -> configurer.accessDeniedHandler(null)).isInstanceOf(IllegalArgumentException.class);
862850
}
863851

864-
// -- token validator
865-
866852
@Test
867853
public void requestWhenCustomJwtValidatorFailsThenCorrespondingErrorMessage() throws Exception {
868854

@@ -904,8 +890,6 @@ public void requestWhenClockSkewSetButJwtStillTooLateThenReportsExpired() throws
904890
.andExpect(invalidTokenHeader("Jwt expired at"));
905891
}
906892

907-
// -- converter
908-
909893
@Test
910894
public void requestWhenJwtAuthenticationConverterConfiguredOnDslThenIsUsed() throws Exception {
911895

@@ -937,8 +921,6 @@ public void requestWhenJwtAuthenticationConverterCustomizedAuthoritiesThenThoseA
937921
this.mvc.perform(get("/requires-read-scope").with(bearerToken(JWT_TOKEN))).andExpect(status().isOk());
938922
}
939923

940-
// -- single key
941-
942924
@Test
943925
public void requestWhenUsingPublicKeyAndValidTokenThenAuthenticates() throws Exception {
944926

@@ -991,8 +973,6 @@ public void getWhenCustomJwtAuthenticationManagerThenUsed() throws Exception {
991973
verifyBean(AuthenticationProvider.class).authenticate(any(Authentication.class));
992974
}
993975

994-
// -- opaque
995-
996976
@Test
997977
public void getWhenIntrospectingThenOk() throws Exception {
998978
this.spring.register(RestOperationsConfig.class, OpaqueTokenConfig.class, BasicController.class).autowire();
@@ -1099,8 +1079,6 @@ public void getIntrospectionClientWhenDslAndBeanWiredThenDslTakesPrecedence() {
10991079
assertThat(opaqueToken.getIntrospector()).isNotNull();
11001080
}
11011081

1102-
// -- In combination with other authentication providers
1103-
11041082
@Test
11051083
public void requestWhenBasicAndResourceServerEntryPointsThenMatchedByRequest() throws Exception {
11061084

@@ -1171,8 +1149,6 @@ public void getWhenAlsoUsingHttpBasicThenCorrectProviderEngages() throws Excepti
11711149
.andExpect(status().isOk()).andExpect(content().string("basic-user"));
11721150
}
11731151

1174-
// -- authentication manager
1175-
11761152
@Test
11771153
public void getAuthenticationManagerWhenConfiguredAuthenticationManagerThenTakesPrecedence() {
11781154
ApplicationContext context = mock(ApplicationContext.class);
@@ -1190,8 +1166,6 @@ public void getAuthenticationManagerWhenConfiguredAuthenticationManagerThenTakes
11901166
verify(http, never()).authenticationProvider(any(AuthenticationProvider.class));
11911167
}
11921168

1193-
// -- authentication manager resolver
1194-
11951169
@Test
11961170
public void getWhenMultipleIssuersThenUsesIssuerClaimToDifferentiate() throws Exception {
11971171
this.spring.register(WebServerConfig.class, MultipleIssuersConfig.class, BasicController.class).autowire();
@@ -1226,8 +1200,6 @@ public void getWhenMultipleIssuersThenUsesIssuerClaimToDifferentiate() throws Ex
12261200
.andExpect(invalidTokenHeader("Invalid issuer"));
12271201
}
12281202

1229-
// -- Incorrect Configuration
1230-
12311203
@Test
12321204
public void configuredWhenMissingJwtAuthenticationProviderThenWiringException() {
12331205

‎config/src/test/java/org/springframework/security/config/http/HttpHeadersConfigTests.java‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ public void requestWhenFrameOptionsConfiguredThenIncludesHeader() throws Excepti
135135
this.mvc.perform(get("/").secure(true)).andExpect(status().isOk()).andExpect(includes(headers));
136136
}
137137

138-
// -- defaults disabled
139-
140138
/**
141139
* gh-3986
142140
*/
@@ -480,8 +478,6 @@ public void requestWhenUsingHpkpReportUriThenIncludesHpkpHeaderAccordingly() thr
480478
.andExpect(excludesDefaults());
481479
}
482480

483-
// -- single-header disabled
484-
485481
@Test
486482
public void requestWhenCacheControlDisabledThenExcludesHeader() throws Exception {
487483

@@ -550,8 +546,6 @@ public void requestWhenXssProtectionDisabledThenExcludesHeader() throws Exceptio
550546
.andExpect(excludes(xssProtection));
551547
}
552548

553-
// --- disable error handling ---
554-
555549
@Test
556550
public void configureWhenHstsDisabledAndIncludeSubdomainsSpecifiedThenAutowireFails() {
557551
assertThatThrownBy(

0 commit comments

Comments
 (0)