diff options
author | Matteo Mara <matteo.mara@sonarsource.com> | 2022-04-13 17:50:20 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-04-29 20:03:18 +0000 |
commit | 1c106da878005b75e1a01c139476bc11de201519 (patch) | |
tree | a8542d50c8d43a964cbe3b7234635b64e53b7023 /server/sonar-webserver-auth | |
parent | 9c72e2d880627bb333325f44ade24ec1cbbbbc61 (diff) | |
download | sonarqube-1c106da878005b75e1a01c139476bc11de201519.tar.gz sonarqube-1c106da878005b75e1a01c139476bc11de201519.zip |
SONAR-16260 - Add project and global analysis token types
Diffstat (limited to 'server/sonar-webserver-auth')
2 files changed, 20 insertions, 4 deletions
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenType.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenType.java index 8251bc8015c..8581b9ad6b6 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenType.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenType.java @@ -20,7 +20,9 @@ package org.sonar.server.usertoken; public enum TokenType { - USER_TOKEN("u"); + USER_TOKEN("u"), + GLOBAL_ANALYSIS_TOKEN("a"), + PROJECT_ANALYSIS_TOKEN("p"); private final String identifier; diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/TokenGeneratorImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/TokenGeneratorImplTest.java index 2a45c30a4a5..d0816bca086 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/TokenGeneratorImplTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/TokenGeneratorImplTest.java @@ -24,7 +24,7 @@ import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; public class TokenGeneratorImplTest { - private TokenGeneratorImpl underTest = new TokenGeneratorImpl(); + private final TokenGeneratorImpl underTest = new TokenGeneratorImpl(); @Test public void generate_different_tokens() { @@ -39,10 +39,24 @@ public class TokenGeneratorImplTest { } @Test - public void generate_tokenShouldHaveSonarQubePrefix() { + public void generated_userToken_should_have_squ_prefix() { String token = underTest.generate(TokenType.USER_TOKEN); - assertThat(token).matches("squ_.*"); + assertThat(token).matches("squ_.{40}"); + } + + @Test + public void generated_projectAnalysisToken_should_have_sqp_prefix() { + String token = underTest.generate(TokenType.PROJECT_ANALYSIS_TOKEN); + + assertThat(token).matches("sqp_.{40}"); + } + + @Test + public void generated_globalAnalysisToken_should_have_sqa_prefix() { + String token = underTest.generate(TokenType.GLOBAL_ANALYSIS_TOKEN); + + assertThat(token).matches("sqa_.{40}"); } @Test |