Skip to content

Commit ac9c29b

Browse files
nor-ekjzheaux
authored andcommitted
Add UsernamePasswordAuthenticationToken factory methods
- unauthenticated factory method - authenticated factory method - test for unauthenticated factory method - test for authenticated factory method - make existing constructor protected - use newly factory methods in rest of the project - update copyright dates Closes gh-10790
1 parent d2f24ae commit ac9c29b

File tree

99 files changed

+476
-378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+476
-378
lines changed

cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ
251251
this.logger.debug("Failed to obtain an artifact (cas ticket)");
252252
password = "";
253253
}
254-
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);
254+
UsernamePasswordAuthenticationToken authRequest = UsernamePasswordAuthenticationToken.unauthenticated(username,
255+
password);
255256
authRequest.setDetails(this.authenticationDetailsSource.buildDetails(request));
256257
return this.getAuthenticationManager().authenticate(authRequest);
257258
}

cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationProviderTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public void statefulAuthenticationIsSuccessful() throws Exception {
8787
cap.setServiceProperties(makeServiceProperties());
8888
cap.setTicketValidator(new MockTicketValidator(true));
8989
cap.afterPropertiesSet();
90-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
91-
CasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER, "ST-123");
90+
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken
91+
.unauthenticated(CasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER, "ST-123");
9292
token.setDetails("details");
9393
Authentication result = cap.authenticate(token);
9494
// Confirm ST-123 was NOT added to the cache
@@ -120,8 +120,8 @@ public void statelessAuthenticationIsSuccessful() throws Exception {
120120
cap.setTicketValidator(new MockTicketValidator(true));
121121
cap.setServiceProperties(makeServiceProperties());
122122
cap.afterPropertiesSet();
123-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
124-
CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER, "ST-456");
123+
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken
124+
.unauthenticated(CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER, "ST-456");
125125
token.setDetails("details");
126126
Authentication result = cap.authenticate(token);
127127
// Confirm ST-456 was added to the cache
@@ -157,8 +157,8 @@ public void authenticateAllNullService() throws Exception {
157157
cap.setServiceProperties(serviceProperties);
158158
cap.afterPropertiesSet();
159159
String ticket = "ST-456";
160-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
161-
CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER, ticket);
160+
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken
161+
.unauthenticated(CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER, ticket);
162162
Authentication result = cap.authenticate(token);
163163
}
164164

@@ -178,8 +178,8 @@ public void authenticateAllAuthenticationIsSuccessful() throws Exception {
178178
cap.setServiceProperties(serviceProperties);
179179
cap.afterPropertiesSet();
180180
String ticket = "ST-456";
181-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
182-
CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER, ticket);
181+
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken
182+
.unauthenticated(CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER, ticket);
183183
Authentication result = cap.authenticate(token);
184184
verify(validator).validate(ticket, serviceProperties.getService());
185185
serviceProperties.setAuthenticateAllArtifacts(true);
@@ -211,8 +211,8 @@ public void missingTicketIdIsDetected() throws Exception {
211211
cap.setTicketValidator(new MockTicketValidator(true));
212212
cap.setServiceProperties(makeServiceProperties());
213213
cap.afterPropertiesSet();
214-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
215-
CasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER, "");
214+
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken
215+
.unauthenticated(CasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER, "");
216216
assertThatExceptionOfType(BadCredentialsException.class).isThrownBy(() -> cap.authenticate(token));
217217
}
218218

@@ -314,8 +314,8 @@ public void ignoresUsernamePasswordAuthenticationTokensWithoutCasIdentifiersAsPr
314314
cap.setTicketValidator(new MockTicketValidator(true));
315315
cap.setServiceProperties(makeServiceProperties());
316316
cap.afterPropertiesSet();
317-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("some_normal_user",
318-
"password", AuthorityUtils.createAuthorityList("ROLE_A"));
317+
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken
318+
.authenticated("some_normal_user", "password", AuthorityUtils.createAuthorityList("ROLE_A"));
319319
assertThat(cap.authenticate(token)).isNull();
320320
}
321321

cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationTokenTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public void testNotEqualsDueToDifferentAuthenticationClass() {
121121
final Assertion assertion = new AssertionImpl("test");
122122
CasAuthenticationToken token1 = new CasAuthenticationToken("key", makeUserDetails(), "Password", this.ROLES,
123123
makeUserDetails(), assertion);
124-
UsernamePasswordAuthenticationToken token2 = new UsernamePasswordAuthenticationToken("Test", "Password",
125-
this.ROLES);
124+
UsernamePasswordAuthenticationToken token2 = UsernamePasswordAuthenticationToken.authenticated("Test",
125+
"Password", this.ROLES);
126126
assertThat(!token1.equals(token2)).isTrue();
127127
}
128128

config/src/integration-test/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParserTests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ public void simpleProviderAuthenticatesCorrectly() {
5656
AuthenticationManager authenticationManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
5757
AuthenticationManager.class);
5858
Authentication auth = authenticationManager
59-
.authenticate(new UsernamePasswordAuthenticationToken("ben", "benspassword"));
59+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("ben", "benspassword"));
6060
UserDetails ben = (UserDetails) auth.getPrincipal();
6161
assertThat(ben.getAuthorities()).hasSize(3);
6262
}
@@ -89,7 +89,7 @@ public void supportsPasswordComparisonAuthentication() {
8989
AuthenticationManager authenticationManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
9090
AuthenticationManager.class);
9191
Authentication auth = authenticationManager
92-
.authenticate(new UsernamePasswordAuthenticationToken("ben", "benspassword"));
92+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("ben", "benspassword"));
9393

9494
assertThat(auth).isNotNull();
9595
}
@@ -104,7 +104,8 @@ public void supportsPasswordComparisonAuthenticationWithPasswordEncoder() {
104104

105105
AuthenticationManager authenticationManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
106106
AuthenticationManager.class);
107-
Authentication auth = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("ben", "ben"));
107+
Authentication auth = authenticationManager
108+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("ben", "ben"));
108109

109110
assertThat(auth).isNotNull();
110111
}
@@ -121,7 +122,7 @@ public void supportsCryptoPasswordEncoder() {
121122
AuthenticationManager authenticationManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
122123
AuthenticationManager.class);
123124
Authentication auth = authenticationManager
124-
.authenticate(new UsernamePasswordAuthenticationToken("bcrypt", "password"));
125+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("bcrypt", "password"));
125126

126127
assertThat(auth).isNotNull();
127128
}

config/src/test/java/org/springframework/security/config/annotation/authentication/AuthenticationManagerBuilderTests.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -93,8 +93,8 @@ public void customAuthenticationEventPublisherWithWeb() throws Exception {
9393
given(opp.postProcess(any())).willAnswer((a) -> a.getArgument(0));
9494
AuthenticationManager am = new AuthenticationManagerBuilder(opp).authenticationEventPublisher(aep)
9595
.inMemoryAuthentication().and().build();
96-
assertThatExceptionOfType(AuthenticationException.class)
97-
.isThrownBy(() -> am.authenticate(new UsernamePasswordAuthenticationToken("user", "password")));
96+
assertThatExceptionOfType(AuthenticationException.class).isThrownBy(
97+
() -> am.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password")));
9898
verify(aep).publishAuthenticationFailure(any(), any());
9999
}
100100

@@ -103,7 +103,8 @@ public void getAuthenticationManagerWhenGlobalPasswordEncoderBeanThenUsed() thro
103103
this.spring.register(PasswordEncoderGlobalConfig.class).autowire();
104104
AuthenticationManager manager = this.spring.getContext().getBean(AuthenticationConfiguration.class)
105105
.getAuthenticationManager();
106-
Authentication auth = manager.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
106+
Authentication auth = manager
107+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password"));
107108
assertThat(auth.getName()).isEqualTo("user");
108109
assertThat(auth.getAuthorities()).extracting(GrantedAuthority::getAuthority).containsOnly("ROLE_USER");
109110
}
@@ -113,7 +114,8 @@ public void getAuthenticationManagerWhenProtectedPasswordEncoderBeanThenUsed() t
113114
this.spring.register(PasswordEncoderGlobalConfig.class).autowire();
114115
AuthenticationManager manager = this.spring.getContext().getBean(AuthenticationConfiguration.class)
115116
.getAuthenticationManager();
116-
Authentication auth = manager.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
117+
Authentication auth = manager
118+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password"));
117119
assertThat(auth.getName()).isEqualTo("user");
118120
assertThat(auth.getAuthorities()).extracting(GrantedAuthority::getAuthority).containsOnly("ROLE_USER");
119121
}

config/src/test/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfigurationPublishTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,7 +47,8 @@ public class AuthenticationConfigurationPublishTests {
4747
// gh-4940
4848
@Test
4949
public void authenticationEventPublisherBeanUsedByDefault() {
50-
this.authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
50+
this.authenticationManager
51+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password"));
5152
assertThat(this.listener.getEvents()).hasSize(1);
5253
}
5354

config/src/test/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfigurationTests.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -129,7 +129,8 @@ public void getAuthenticationManagerWhenNoOpGlobalAuthenticationConfigurerAdapte
129129

130130
@Test
131131
public void getAuthenticationWhenGlobalAuthenticationConfigurerAdapterThenAuthenticates() throws Exception {
132-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("user", "password");
132+
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken.unauthenticated("user",
133+
"password");
133134
this.spring.register(AuthenticationConfiguration.class, ObjectPostProcessorConfiguration.class,
134135
UserGlobalAuthenticationConfigurerAdapter.class).autowire();
135136
AuthenticationManager authentication = this.spring.getContext().getBean(AuthenticationConfiguration.class)
@@ -139,7 +140,8 @@ public void getAuthenticationWhenGlobalAuthenticationConfigurerAdapterThenAuthen
139140

140141
@Test
141142
public void getAuthenticationWhenAuthenticationManagerBeanThenAuthenticates() throws Exception {
142-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("user", "password");
143+
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken.unauthenticated("user",
144+
"password");
143145
this.spring.register(AuthenticationConfiguration.class, ObjectPostProcessorConfiguration.class,
144146
AuthenticationManagerBeanConfig.class).autowire();
145147
AuthenticationManager authentication = this.spring.getContext().getBean(AuthenticationConfiguration.class)
@@ -165,9 +167,9 @@ public void getAuthenticationWhenConfiguredThenBootNotTrigger() throws Exception
165167
config.setGlobalAuthenticationConfigurers(Arrays.asList(new ConfiguresInMemoryConfigurerAdapter(),
166168
new BootGlobalAuthenticationConfigurerAdapter()));
167169
AuthenticationManager authenticationManager = config.getAuthenticationManager();
168-
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
169-
assertThatExceptionOfType(AuthenticationException.class).isThrownBy(
170-
() -> authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("boot", "password")));
170+
authenticationManager.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password"));
171+
assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> authenticationManager
172+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("boot", "password")));
171173
}
172174

173175
@Test
@@ -176,7 +178,7 @@ public void getAuthenticationWhenNotConfiguredThenBootTrigger() throws Exception
176178
AuthenticationConfiguration config = this.spring.getContext().getBean(AuthenticationConfiguration.class);
177179
config.setGlobalAuthenticationConfigurers(Arrays.asList(new BootGlobalAuthenticationConfigurerAdapter()));
178180
AuthenticationManager authenticationManager = config.getAuthenticationManager();
179-
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("boot", "password"));
181+
authenticationManager.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("boot", "password"));
180182
}
181183

182184
// gh-2531
@@ -206,9 +208,9 @@ public void getAuthenticationWhenUserDetailsServiceBeanThenAuthenticationManager
206208
AuthenticationManager am = this.spring.getContext().getBean(AuthenticationConfiguration.class)
207209
.getAuthenticationManager();
208210
given(uds.loadUserByUsername("user")).willReturn(PasswordEncodedUser.user(), PasswordEncodedUser.user());
209-
am.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
210-
assertThatExceptionOfType(AuthenticationException.class)
211-
.isThrownBy(() -> am.authenticate(new UsernamePasswordAuthenticationToken("user", "invalid")));
211+
am.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password"));
212+
assertThatExceptionOfType(AuthenticationException.class).isThrownBy(
213+
() -> am.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "invalid")));
212214
}
213215

214216
@Test
@@ -221,9 +223,9 @@ public void getAuthenticationWhenUserDetailsServiceAndPasswordEncoderBeanThenEnc
221223
.getAuthenticationManager();
222224
given(uds.loadUserByUsername("user")).willReturn(User.withUserDetails(user).build(),
223225
User.withUserDetails(user).build());
224-
am.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
225-
assertThatExceptionOfType(AuthenticationException.class)
226-
.isThrownBy(() -> am.authenticate(new UsernamePasswordAuthenticationToken("user", "invalid")));
226+
am.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password"));
227+
assertThatExceptionOfType(AuthenticationException.class).isThrownBy(
228+
() -> am.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "invalid")));
227229
}
228230

229231
@Test
@@ -237,7 +239,7 @@ public void getAuthenticationWhenUserDetailsServiceAndPasswordManagerThenManager
237239
given(manager.loadUserByUsername("user")).willReturn(User.withUserDetails(user).build(),
238240
User.withUserDetails(user).build());
239241
given(manager.updatePassword(any(), any())).willReturn(user);
240-
am.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
242+
am.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password"));
241243
verify(manager).updatePassword(eq(user), startsWith("{bcrypt}"));
242244
}
243245

@@ -250,7 +252,7 @@ public void getAuthenticationWhenAuthenticationProviderAndUserDetailsBeanThenAut
250252
.getAuthenticationManager();
251253
given(ap.supports(any())).willReturn(true);
252254
given(ap.authenticate(any())).willReturn(TestAuthentication.authenticatedUser());
253-
am.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
255+
am.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password"));
254256
}
255257

256258
// gh-3091
@@ -262,7 +264,7 @@ public void getAuthenticationWhenAuthenticationProviderBeanThenUsed() throws Exc
262264
.getAuthenticationManager();
263265
given(ap.supports(any())).willReturn(true);
264266
given(ap.authenticate(any())).willReturn(TestAuthentication.authenticatedUser());
265-
am.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
267+
am.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("user", "password"));
266268
}
267269

268270
@Test

config/src/test/java/org/springframework/security/config/annotation/issue50/Issue50Tests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -75,21 +75,21 @@ public void loadWhenGlobalMethodSecurityConfigurationThenAuthenticationManagerLa
7575
@Test
7676
public void authenticateWhenMissingUserThenUsernameNotFoundException() {
7777
assertThatExceptionOfType(UsernameNotFoundException.class).isThrownBy(() -> this.authenticationManager
78-
.authenticate(new UsernamePasswordAuthenticationToken("test", "password")));
78+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("test", "password")));
7979
}
8080

8181
@Test
8282
public void authenticateWhenInvalidPasswordThenBadCredentialsException() {
8383
this.userRepo.save(User.withUsernameAndPassword("test", "password"));
8484
assertThatExceptionOfType(BadCredentialsException.class).isThrownBy(() -> this.authenticationManager
85-
.authenticate(new UsernamePasswordAuthenticationToken("test", "invalid")));
85+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("test", "invalid")));
8686
}
8787

8888
@Test
8989
public void authenticateWhenValidUserThenAuthenticates() {
9090
this.userRepo.save(User.withUsernameAndPassword("test", "password"));
9191
Authentication result = this.authenticationManager
92-
.authenticate(new UsernamePasswordAuthenticationToken("test", "password"));
92+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("test", "password"));
9393
assertThat(result.getName()).isEqualTo("test");
9494
}
9595

@@ -98,7 +98,7 @@ public void globalMethodSecurityIsEnabledWhenNotAllowedThenAccessDenied() {
9898
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("test", null, "ROLE_USER"));
9999
this.userRepo.save(User.withUsernameAndPassword("denied", "password"));
100100
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(() -> this.authenticationManager
101-
.authenticate(new UsernamePasswordAuthenticationToken("test", "password")));
101+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("test", "password")));
102102
}
103103

104104
}

config/src/test/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -106,8 +106,8 @@ public void configureWhenGlobalMethodSecurityHasCustomMetadataSourceThenNoEnabli
106106
@Test
107107
public void methodSecurityAuthenticationManagerPublishesEvent() {
108108
this.spring.register(InMemoryAuthWithGlobalMethodSecurityConfig.class).autowire();
109-
assertThatExceptionOfType(AuthenticationException.class).isThrownBy(
110-
() -> this.authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("foo", "bar")));
109+
assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> this.authenticationManager
110+
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated("foo", "bar")));
111111
assertThat(this.events.getEvents()).extracting(Object::getClass)
112112
.containsOnly((Class) AuthenticationFailureBadCredentialsEvent.class);
113113
}

0 commit comments

Comments
 (0)