Reduce logging of ApiTokenRealm

This commit is contained in:
Sebastian Sdorra
2020-10-22 14:39:09 +02:00
parent 49607236e5
commit 7b91cf82bf
4 changed files with 19 additions and 7 deletions

View File

@@ -25,6 +25,7 @@
package sonia.scm.security;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.AuthorizationException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -105,6 +106,15 @@ class ApiKeyRealmTest {
assertThat(supports).isFalse();
}
@Test
void shouldIgnoreNonBase64Tokens() {
UsernamePasswordToken token = new UsernamePasswordToken("trillian", "My&SecretPassword");
boolean supports = realm.supports(token);
assertThat(supports).isFalse();
}
void verifyScopeSet(String... permissions) {
verify(authenticationInfoBuilder).withScope(argThat(scope -> {
assertThat(scope).containsExactly(permissions);