-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SMM-1135 Check metadata.json and tokens.json after purging token
- Loading branch information
Showing
1 changed file
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,10 @@ | |
import com.linecorp.armeria.server.HttpResponseException; | ||
import com.linecorp.armeria.server.ServiceRequestContext; | ||
import com.linecorp.centraldogma.common.Author; | ||
import com.linecorp.centraldogma.server.command.Command; | ||
import com.linecorp.centraldogma.server.command.StandaloneCommandExecutor; | ||
import com.linecorp.centraldogma.server.metadata.MetadataService; | ||
import com.linecorp.centraldogma.server.metadata.ProjectRole; | ||
import com.linecorp.centraldogma.server.metadata.Token; | ||
import com.linecorp.centraldogma.server.metadata.User; | ||
import com.linecorp.centraldogma.testing.internal.ProjectManagerExtension; | ||
|
@@ -48,13 +51,16 @@ class TokenServiceTest { | |
private static final User guest = new User("[email protected]"); | ||
|
||
private static TokenService tokenService; | ||
private static MetadataService metadataService; | ||
|
||
private final ServiceRequestContext ctx = mock(ServiceRequestContext.class); | ||
|
||
@BeforeAll | ||
static void setUp() { | ||
metadataService = new MetadataService(manager.projectManager(), | ||
manager.executor()); | ||
tokenService = new TokenService(manager.projectManager(), manager.executor(), | ||
new MetadataService(manager.projectManager(), manager.executor())); | ||
metadataService); | ||
} | ||
|
||
@Test | ||
|
@@ -66,6 +72,11 @@ void adminToken() { | |
.join()) | ||
.isInstanceOf(IllegalArgumentException.class); | ||
|
||
final StandaloneCommandExecutor executor = (StandaloneCommandExecutor) manager.executor(); | ||
executor.execute(Command.createProject(Author.SYSTEM, "myPro")).join(); | ||
metadataService.addToken(Author.SYSTEM, "myPro", "forAdmin1", ProjectRole.OWNER).join(); | ||
assertThat(metadataService.getProject("myPro").join().tokens().containsKey("forAdmin1")).isTrue(); | ||
|
||
final Collection<Token> tokens = tokenService.listTokens(admin).join(); | ||
assertThat(tokens.stream().filter(t -> !StringUtil.isNullOrEmpty(t.secret()))).hasSize(1); | ||
|
||
|
@@ -84,6 +95,8 @@ void adminToken() { | |
assertThat(t.creation()).isEqualTo(token.creation()); | ||
assertThat(t.deactivation()).isEqualTo(token.deactivation()); | ||
}); | ||
assertThat(tokenService.listTokens(admin).join().size()).isEqualTo(0); | ||
assertThat(metadataService.getProject("myPro").join().tokens().size()).isEqualTo(0); | ||
} | ||
|
||
@Test | ||
|