diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-05-17 11:02:51 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-05-18 11:04:36 +0200 |
commit | 9d89994a759f888b3b4490ba33d15d4ee3ff46ba (patch) | |
tree | 054eed25be067d1b13338926b397d1df8cbc833c /sonar-core | |
parent | ae43e3beb8b066e030086266cb4ee0ea753e99e9 (diff) | |
download | sonarqube-9d89994a759f888b3b4490ba33d15d4ee3ff46ba.tar.gz sonarqube-9d89994a759f888b3b4490ba33d15d4ee3ff46ba.zip |
Add definition of property sonar.jdbc.password
so that its type is set to PropertyType.PASSWORD.
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java | 6 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java | 27 |
2 files changed, 33 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java index fd46e85fae0..3369492cdc9 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java +++ b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java @@ -28,6 +28,8 @@ import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; import org.sonar.api.resources.Qualifiers; +import static org.sonar.api.database.DatabaseProperties.PROP_PASSWORD; + public class CorePropertyDefinitions { /* Time machine periods */ @@ -57,6 +59,10 @@ public class CorePropertyDefinitions { defs.addAll(PurgeProperties.all()); defs.addAll(ImmutableList.of( + PropertyDefinition.builder(PROP_PASSWORD) + .type(PropertyType.PASSWORD) + .hidden() + .build(), PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL) .name("Server base URL") .description("HTTP URL of this SonarQube server, such as <i>http://yourhost.yourdomain/sonar</i>. This value is used i.e. to create links in emails.") diff --git a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java index 4e3e2550cde..3791869abe1 100644 --- a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java @@ -19,10 +19,16 @@ */ package org.sonar.core.config; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; import java.util.List; +import javax.annotation.Nonnull; import org.junit.Test; +import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; +import org.sonar.api.database.DatabaseProperties; +import static com.google.common.collect.FluentIterable.from; import static org.assertj.core.api.Assertions.assertThat; public class CorePropertyDefinitionsTest { @@ -31,4 +37,25 @@ public class CorePropertyDefinitionsTest { List<PropertyDefinition> defs = CorePropertyDefinitions.all(); assertThat(defs.size()).isGreaterThan(9); } + + @Test + public void jdbc_password_property_has_password_type() { + List<PropertyDefinition> defs = CorePropertyDefinitions.all(); + Optional<PropertyDefinition> prop = from(defs).filter(new HasKeyPredicate(DatabaseProperties.PROP_PASSWORD)).first(); + assertThat(prop.isPresent()).isTrue(); + assertThat(prop.get().type()).isEqualTo(PropertyType.PASSWORD); + } + + private final class HasKeyPredicate implements Predicate<PropertyDefinition> { + private final String key; + + HasKeyPredicate(String key) { + this.key = key; + } + + @Override + public boolean apply(@Nonnull PropertyDefinition input) { + return key.equals(input.key()); + } + } } |