Mario Petrovski hace 1 año
padre
commit
2ee8f27997

+ 8 - 5
oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/OAuth2AuthorizationManagersTests.java

@@ -17,10 +17,11 @@
 package org.springframework.security.oauth2.core;
 
 import org.junit.jupiter.api.Test;
+
 import org.springframework.security.authorization.AuthorityAuthorizationManager;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 
 /**
  * Tests for {@link OAuth2AuthorizationManagers}
@@ -32,15 +33,17 @@ public class OAuth2AuthorizationManagersTests {
 	@Test
 	void hasScope_withInvalidScope_shouldThrowIllegalArgumentException() {
 		String scope = "SCOPE_invalid";
-		assertThatThrownBy(() -> OAuth2AuthorizationManagers.hasScope(scope))
-				.isInstanceOf(IllegalArgumentException.class);
+		assertThatExceptionOfType(IllegalArgumentException.class)
+				.isThrownBy(() -> OAuth2AuthorizationManagers.hasScope(scope))
+				.withMessage("Scope 'SCOPE_invalid' start with 'SCOPE_' prefix.");
 	}
 
 	@Test
 	void hasScopes_withInvalidScope_shouldThrowIllegalArgumentException() {
 		String[] scopes = { "read", "write", "SCOPE_invalid" };
-		assertThatThrownBy(() -> OAuth2AuthorizationManagers.hasAnyScope(scopes))
-				.isInstanceOf(IllegalArgumentException.class);
+		assertThatExceptionOfType(IllegalArgumentException.class)
+				.isThrownBy(() -> OAuth2AuthorizationManagers.hasAnyScope(scopes))
+				.withMessage("Scope 'SCOPE_invalid' start with 'SCOPE_' prefix.");
 	}
 
 	@Test