diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2020-03-04 18:06:32 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-03-12 20:04:29 +0000 |
commit | ec384a1e6926c801dc5167807f26b1f2ef6baf84 (patch) | |
tree | ffa22fe9324d16006a61ef8739cf277d99092e76 /sonar-core/src/test | |
parent | 0433161433a5f234790fae5eba2cf438cbde5d36 (diff) | |
download | sonarqube-ec384a1e6926c801dc5167807f26b1f2ef6baf84.tar.gz sonarqube-ec384a1e6926c801dc5167807f26b1f2ef6baf84.zip |
SONAR-13160 Fix display of Portfolio Admin page when project contains UTF-8 characters
Diffstat (limited to 'sonar-core/src/test')
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java b/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java index 05848ac1c56..eef16fac229 100644 --- a/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java +++ b/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java @@ -37,12 +37,18 @@ public class ComponentKeysTest { } @Test - public void isValidProjectKey() { + public void valid_project_key() { assertThat(ComponentKeys.isValidProjectKey("abc")).isTrue(); - assertThat(ComponentKeys.isValidProjectKey("0123")).isTrue(); assertThat(ComponentKeys.isValidProjectKey("ab_12")).isTrue(); - assertThat(ComponentKeys.isValidProjectKey("ab/12")).isTrue(); - assertThat(ComponentKeys.isValidProjectKey("코드품질")).isTrue(); + } + + @Test + public void invalid_project_key() { + assertThat(ComponentKeys.isValidProjectKey("0123")).isFalse(); + + assertThat(ComponentKeys.isValidProjectKey("ab/12")).isFalse(); + assertThat(ComponentKeys.isValidProjectKey("코드품질")).isFalse(); + assertThat(ComponentKeys.isValidProjectKey("")).isFalse(); assertThat(ComponentKeys.isValidProjectKey(" ")).isFalse(); assertThat(ComponentKeys.isValidProjectKey("ab 12")).isFalse(); @@ -69,4 +75,19 @@ public class ComponentKeysTest { ComponentKeys.checkProjectKey("ab 12"); } + + @Test + public void checkProjectKey_fail_if_only_digit() { + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage("Malformed key for '0123'. Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit."); + + ComponentKeys.checkProjectKey("0123"); + } + + @Test + public void checkProjectKey_fail_if_special_characters_not_allowed() { + expectedException.expect(IllegalArgumentException.class); + + ComponentKeys.checkProjectKey("ab/12"); + } } |