Ensure tests clear AuthorizationServerContextHolder

Closes gh-18768
This commit is contained in:
Robert Winch 2026-02-19 15:07:11 -06:00
parent f2aef5168c
commit 2eb948d9b5
No known key found for this signature in database
4 changed files with 24 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.OctetSequenceKey;
import com.nimbusds.jose.jwk.source.JWKSource;
import com.nimbusds.jose.proc.SecurityContext;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -112,6 +113,11 @@ public class JwtClientAssertionAuthenticationProviderTests {
.setContext(new TestAuthorizationServerContext(this.authorizationServerSettings, null));
}
@AfterEach
public void tearDown() {
AuthorizationServerContextHolder.resetContext();
}
@Test
public void constructorWhenRegisteredClientRepositoryNullThenThrowIllegalArgumentException() {
assertThatExceptionOfType(IllegalArgumentException.class)

View File

@ -25,6 +25,7 @@ import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
@ -111,6 +112,11 @@ public class OAuth2AuthorizationCodeRequestAuthenticationProviderTests {
.setContext(new TestAuthorizationServerContext(authorizationServerSettings, null));
}
@AfterEach
public void tearDown() {
AuthorizationServerContextHolder.resetContext();
}
@Test
public void constructorWhenRegisteredClientRepositoryNullThenThrowIllegalArgumentException() {
assertThatExceptionOfType(IllegalArgumentException.class)

View File

@ -22,6 +22,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
@ -95,6 +96,11 @@ public class OAuth2AuthorizationConsentAuthenticationProviderTests {
.setContext(new TestAuthorizationServerContext(authorizationServerSettings, null));
}
@AfterEach
public void tearDown() {
AuthorizationServerContextHolder.resetContext();
}
@Test
public void constructorWhenRegisteredClientRepositoryNullThenThrowIllegalArgumentException() {
assertThatExceptionOfType(IllegalArgumentException.class)

View File

@ -25,6 +25,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
@ -96,6 +97,11 @@ public class OAuth2DeviceVerificationAuthenticationProviderTests {
mockAuthorizationServerContext();
}
@AfterEach
public void tearDown() {
AuthorizationServerContextHolder.resetContext();
}
@Test
public void constructorWhenRegisteredClientRepositoryIsNullThenThrowIllegalArgumentException() {
// @formatter:off