Skip to content

Commit

Permalink
Fix test getting stuck
Browse files Browse the repository at this point in the history
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 gh-6025
  • Loading branch information
marcusdacoregio authored and jzheaux committed Jul 27, 2021
1 parent 16e17d2 commit 662ab10
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ public void saml2LoginWhenCustomAuthenticationRequestContextResolverThenUses() t
this.spring.register(CustomAuthenticationRequestContextResolver.class).autowire();
Saml2AuthenticationRequestContext context = TestSaml2AuthenticationRequestContexts
.authenticationRequestContext().build();
Saml2AuthenticationRequestContextResolver resolver = CustomAuthenticationRequestContextResolver.resolver;
Saml2AuthenticationRequestContextResolver resolver = this.spring.getContext()
.getBean(Saml2AuthenticationRequestContextResolver.class);
given(resolver.resolve(any(HttpServletRequest.class))).willReturn(context);
this.mvc.perform(get("/saml2/authenticate/registration-id")).andExpect(status().isFound());
verify(resolver).resolve(any(HttpServletRequest.class));
Expand Down Expand Up @@ -381,7 +382,7 @@ protected void configure(HttpSecurity http) throws Exception {
@Import(Saml2LoginConfigBeans.class)
static class CustomAuthenticationRequestContextResolver extends WebSecurityConfigurerAdapter {

private static final Saml2AuthenticationRequestContextResolver resolver = mock(
private final Saml2AuthenticationRequestContextResolver resolver = mock(
Saml2AuthenticationRequestContextResolver.class);

@Override
Expand Down Expand Up @@ -450,7 +451,7 @@ protected void configure(HttpSecurity http) throws Exception {
@Import(Saml2LoginConfigBeans.class)
static class CustomAuthenticationRequestRepository {

private static final Saml2AuthenticationRequestRepository<AbstractSaml2AuthenticationRequest> repository = mock(
private final Saml2AuthenticationRequestRepository<AbstractSaml2AuthenticationRequest> repository = mock(
Saml2AuthenticationRequestRepository.class);

@Bean
Expand Down

0 comments on commit 662ab10

Please sign in to comment.