added option to define extra groups for AccessToken

This commit is contained in:
Sebastian Sdorra
2019-01-21 14:27:14 +01:00
parent 07963bc583
commit 3bd1cbf53d
9 changed files with 319 additions and 59 deletions

View File

@@ -47,8 +47,7 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -135,6 +134,7 @@ public class JwtAccessTokenBuilderTest {
.issuer("https://www.scm-manager.org")
.expiresIn(5, TimeUnit.SECONDS)
.custom("a", "b")
.groups("one", "two", "three")
.scope(Scope.valueOf("repo:*"))
.build();
@@ -161,5 +161,6 @@ public class JwtAccessTokenBuilderTest {
assertEquals(token.getIssuer().get(), "https://www.scm-manager.org");
assertEquals("b", token.getCustom("a").get());
assertEquals("[\"repo:*\"]", token.getScope().toString());
assertThat(token.getGroups(), containsInAnyOrder("one", "two", "three"));
}
}