]> source.dussan.org Git - sonarqube.git/commitdiff
Add definition of property sonar.jdbc.password
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 17 May 2016 09:02:51 +0000 (11:02 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 18 May 2016 09:04:36 +0000 (11:04 +0200)
so that its type is set to PropertyType.PASSWORD.

server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java

index 66d1080984f9df796e0bbf36dd22fccb085a1fe6..81ec0f8e478e561a76d462da3db4dc99f082b87d 100644 (file)
@@ -102,7 +102,7 @@ public class ComputeEngineContainerImplTest {
         + 22 // level 1
         + 45 // content of DaoModule
         + 1 // content of EsSearchModule
-        + 56 // content of CorePropertyDefinitions
+        + 57 // content of CorePropertyDefinitions
         + 1 // content of CePropertyDefinitions
     );
     assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull();
index fd46e85fae07b14e862ce739af73d63e3659f944..3369492cdc9fe812a1fa348962d33fe7747103ea 100644 (file)
@@ -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.")
index 4e3e2550cde49df1f5d4cbc46d0c6b5d9087866b..3791869abe1e74bb79dd7bfffb8c2172001757e6 100644 (file)
  */
 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());
+    }
+  }
 }