Skip to content

Commit 9024e86

Browse files
Fix test getting stuck
The tests are getting stuck when running a single test class and the mock is performed in a static variable inside an inner class Issue spring-projectsgh-6025
1 parent 377160d commit 9024e86

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ public void saml2LoginWhenCustomAuthenticationRequestContextResolverThenUses() t
186186
this.spring.register(CustomAuthenticationRequestContextResolver.class).autowire();
187187
Saml2AuthenticationRequestContext context = TestSaml2AuthenticationRequestContexts
188188
.authenticationRequestContext().build();
189-
Saml2AuthenticationRequestContextResolver resolver = CustomAuthenticationRequestContextResolver.resolver;
189+
Saml2AuthenticationRequestContextResolver resolver = this.spring.getContext()
190+
.getBean(Saml2AuthenticationRequestContextResolver.class);
190191
given(resolver.resolve(any(HttpServletRequest.class))).willReturn(context);
191192
this.mvc.perform(get("/saml2/authenticate/registration-id")).andExpect(status().isFound());
192193
verify(resolver).resolve(any(HttpServletRequest.class));
@@ -381,7 +382,7 @@ protected void configure(HttpSecurity http) throws Exception {
381382
@Import(Saml2LoginConfigBeans.class)
382383
static class CustomAuthenticationRequestContextResolver extends WebSecurityConfigurerAdapter {
383384

384-
private static final Saml2AuthenticationRequestContextResolver resolver = mock(
385+
private final Saml2AuthenticationRequestContextResolver resolver = mock(
385386
Saml2AuthenticationRequestContextResolver.class);
386387

387388
@Override
@@ -450,7 +451,7 @@ protected void configure(HttpSecurity http) throws Exception {
450451
@Import(Saml2LoginConfigBeans.class)
451452
static class CustomAuthenticationRequestRepository {
452453

453-
private static final Saml2AuthenticationRequestRepository<AbstractSaml2AuthenticationRequest> repository = mock(
454+
private final Saml2AuthenticationRequestRepository<AbstractSaml2AuthenticationRequest> repository = mock(
454455
Saml2AuthenticationRequestRepository.class);
455456

456457
@Bean

0 commit comments

Comments
 (0)