Fix imports in tests

This commit is contained in:
Mario Petrovski 2023-09-13 15:08:31 +02:00 committed by Josh Cummings
parent e1db108cb9
commit 97ec5c921e

View File

@ -19,8 +19,8 @@ package org.springframework.security.oauth2.core;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.security.authorization.AuthorityAuthorizationManager; import org.springframework.security.authorization.AuthorityAuthorizationManager;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Tests for {@link OAuth2AuthorizationManagers} * Tests for {@link OAuth2AuthorizationManagers}
@ -32,27 +32,29 @@ public class OAuth2AuthorizationManagersTests {
@Test @Test
void hasScope_withInvalidScope_shouldThrowIllegalArgumentException() { void hasScope_withInvalidScope_shouldThrowIllegalArgumentException() {
String scope = "SCOPE_invalid"; String scope = "SCOPE_invalid";
assertThrows(IllegalArgumentException.class, () -> OAuth2AuthorizationManagers.hasScope(scope)); assertThatThrownBy(() -> OAuth2AuthorizationManagers.hasScope(scope))
.isInstanceOf(IllegalArgumentException.class);
} }
@Test @Test
void hasScopes_withInvalidScope_shouldThrowIllegalArgumentException() { void hasScopes_withInvalidScope_shouldThrowIllegalArgumentException() {
String[] scopes = { "read", "write", "SCOPE_invalid" }; String[] scopes = { "read", "write", "SCOPE_invalid" };
assertThrows(IllegalArgumentException.class, () -> OAuth2AuthorizationManagers.hasAnyScope(scopes)); assertThatThrownBy(() -> OAuth2AuthorizationManagers.hasAnyScope(scopes))
.isInstanceOf(IllegalArgumentException.class);
} }
@Test @Test
void hasScope_withValidScope_shouldPass() { void hasScope_withValidScope_shouldPass() {
String scope = "read"; String scope = "read";
AuthorityAuthorizationManager<Object> authorizationManager = OAuth2AuthorizationManagers.hasScope(scope); AuthorityAuthorizationManager<Object> authorizationManager = OAuth2AuthorizationManagers.hasScope(scope);
assertNotNull(authorizationManager); assertThat(authorizationManager).isNotNull();
} }
@Test @Test
void hasScope_withValidScopes_shouldPass() { void hasScope_withValidScopes_shouldPass() {
String[] scopes = { "read", "write" }; String[] scopes = { "read", "write" };
AuthorityAuthorizationManager<Object> authorizationManager = OAuth2AuthorizationManagers.hasAnyScope(scopes); AuthorityAuthorizationManager<Object> authorizationManager = OAuth2AuthorizationManagers.hasAnyScope(scopes);
assertNotNull(authorizationManager); assertThat(authorizationManager).isNotNull();
} }
} }