aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2022-08-08 10:55:09 +0200
committersonartech <sonartech@sonarsource.com>2022-08-09 20:03:19 +0000
commit71c6caf8e97af7015c265b2fe237fbc0df196694 (patch)
treedf529cd7caa98de8c445023cfd23bd404d22bd4c /sonar-scanner-engine/src/test/java
parent90a9791c5e3417221a269c736e3758823d8b6205 (diff)
downloadsonarqube-71c6caf8e97af7015c265b2fe237fbc0df196694.tar.gz
sonarqube-71c6caf8e97af7015c265b2fe237fbc0df196694.zip
SONAR-15915 Validate project key against forbidden phrases
Diffstat (limited to 'sonar-scanner-engine/src/test/java')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
index c2476483ef7..7c2ee0b39e9 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
@@ -87,7 +87,7 @@ public class ProjectReactorValidatorTest {
}
@Test
- public void failg_when_invalid_key() {
+ public void fail_when_invalid_key() {
ProjectReactor reactor = createProjectReactor("foo$bar");
assertThatThrownBy(() -> underTest.validate(reactor))
@@ -97,6 +97,23 @@ public class ProjectReactorValidatorTest {
}
@Test
+ public void fail_when_key_contains_invalid_phrases() {
+ ProjectReactor reactorWithBranchInKey = createProjectReactor("test:BRANCH:test");
+
+ assertThatThrownBy(() -> underTest.validate(reactorWithBranchInKey))
+ .isInstanceOf(MessageException.class)
+ .hasMessageContainingAll("\"test:BRANCH:test\" is not a valid project key. "
+ + "Project key must not contain following phrases", ":BRANCH:", ":PULLREQUEST:");
+
+ ProjectReactor reactorWithPRinKey = createProjectReactor("test:PULLREQUEST:test");
+
+ assertThatThrownBy(() -> underTest.validate(reactorWithPRinKey))
+ .isInstanceOf(MessageException.class)
+ .hasMessageContainingAll("\"test:PULLREQUEST:test\" is not a valid project key. "
+ + "Project key must not contain following phrases", ":BRANCH:", ":PULLREQUEST:");
+ }
+
+ @Test
public void fail_when_only_digits() {
ProjectReactor reactor = createProjectReactor("12345");