Skip to content

Commit

Permalink
Fix Formatting
Browse files Browse the repository at this point in the history
Issue gh-13654
  • Loading branch information
jzheaux committed Oct 2, 2023
1 parent a3227f0 commit c7ea8c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public class OAuth2AuthorizationManagersTests {
void hasScopeWhenInvalidScopeThenThrowIllegalArgument() {
String scope = "SCOPE_invalid";
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> OAuth2AuthorizationManagers.hasScope(scope))
.withMessageContaining("SCOPE_invalid should not start with SCOPE_");
.isThrownBy(() -> OAuth2AuthorizationManagers.hasScope(scope))
.withMessageContaining("SCOPE_invalid should not start with SCOPE_");
}

@Test
void hasAnyScopeWhenInvalidScopeThenThrowIllegalArgument() {
String[] scopes = { "read", "write", "SCOPE_invalid" };
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> OAuth2AuthorizationManagers.hasAnyScope(scopes))
.withMessageContaining("SCOPE_invalid should not start with SCOPE_");
.isThrownBy(() -> OAuth2AuthorizationManagers.hasAnyScope(scopes))
.withMessageContaining("SCOPE_invalid should not start with SCOPE_");
}

@Test
Expand All @@ -55,7 +55,7 @@ void hasScopeWhenValidScopeThenAuthorizationManager() {
AuthorizationManager<Object> authorizationManager = OAuth2AuthorizationManagers.hasScope(scope);
authorizationManager.verify(() -> hasScope(scope), new Object());
assertThatExceptionOfType(AccessDeniedException.class)
.isThrownBy(() -> authorizationManager.verify(() -> hasScope("wrong"), new Object()));
.isThrownBy(() -> authorizationManager.verify(() -> hasScope("wrong"), new Object()));
}

@Test
Expand All @@ -66,7 +66,7 @@ void hasAnyScopeWhenValidScopesThenAuthorizationManager() {
authorizationManager.verify(() -> hasScope(scope), new Object());
}
assertThatExceptionOfType(AccessDeniedException.class)
.isThrownBy(() -> authorizationManager.verify(() -> hasScope("wrong"), new Object()));
.isThrownBy(() -> authorizationManager.verify(() -> hasScope("wrong"), new Object()));
}

Authentication hasScope(String scope) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public class OAuth2ReactiveAuthorizationManagersTests {
void hasScopeWhenInvalidScopeThenThrowIllegalArgument() {
String scope = "SCOPE_invalid";
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> OAuth2ReactiveAuthorizationManagers.hasScope(scope))
.withMessageContaining("SCOPE_invalid should not start with SCOPE_");
.isThrownBy(() -> OAuth2ReactiveAuthorizationManagers.hasScope(scope))
.withMessageContaining("SCOPE_invalid should not start with SCOPE_");
}

@Test
void hasAnyScopeWhenInvalidScopeThenThrowIllegalArgument() {
String[] scopes = { "read", "write", "SCOPE_invalid" };
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> OAuth2ReactiveAuthorizationManagers.hasAnyScope(scopes))
.withMessageContaining("SCOPE_invalid should not start with SCOPE_");
.isThrownBy(() -> OAuth2ReactiveAuthorizationManagers.hasAnyScope(scopes))
.withMessageContaining("SCOPE_invalid should not start with SCOPE_");
}

@Test
Expand All @@ -55,19 +55,19 @@ void hasScopeWhenValidScopeThenAuthorizationManager() {
ReactiveAuthorizationManager<Object> authorizationManager = OAuth2ReactiveAuthorizationManagers.hasScope(scope);
authorizationManager.verify(hasScope(scope), new Object()).block();
assertThatExceptionOfType(AccessDeniedException.class)
.isThrownBy(() -> authorizationManager.verify(hasScope("wrong"), new Object()).block());
.isThrownBy(() -> authorizationManager.verify(hasScope("wrong"), new Object()).block());
}

@Test
void hasAnyScopeWhenValidScopesThenAuthorizationManager() {
String[] scopes = { "read", "write" };
ReactiveAuthorizationManager<Object> authorizationManager = OAuth2ReactiveAuthorizationManagers
.hasAnyScope(scopes);
.hasAnyScope(scopes);
for (String scope : scopes) {
authorizationManager.verify(hasScope(scope), new Object()).block();
}
assertThatExceptionOfType(AccessDeniedException.class)
.isThrownBy(() -> authorizationManager.verify(hasScope("wrong"), new Object()).block());
.isThrownBy(() -> authorizationManager.verify(hasScope("wrong"), new Object()).block());
}

Mono<Authentication> hasScope(String scope) {
Expand Down

0 comments on commit c7ea8c6

Please sign in to comment.