mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-23 06:50:49 +01:00
use preexisiting scope by default but prevent overriding of builder scope and update unit tests
This commit is contained in:
@@ -146,13 +146,19 @@ class JwtAccessTokenBuilderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleRequest() {
|
||||
void shouldCreateJwtAndUsePreviousScope() {
|
||||
JwtAccessTokenBuilder builder = factory.create().subject("dent");
|
||||
final JwtAccessToken accessToken = builder.build();
|
||||
assertThat(accessToken).isNotNull();
|
||||
assertThat(accessToken.getSubject()).isEqualTo("dent");
|
||||
assertThat((Collection<String>) accessToken.getCustom("scope").get()).containsExactly("dummy:scope:*");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenScopeAlreadyDefinedInBuilder() {
|
||||
JwtAccessTokenBuilder builder = factory.create().scope(Scope.valueOf("an:incompatible:scope")).subject("dent");
|
||||
assertThrows(AuthorizationException.class, builder::build);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user