aboutsummaryrefslogtreecommitdiffstats
path: root/it/it-plugins/access-secured-props-plugin
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-14 14:49:49 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-18 09:36:10 +0200
commit2a5eea17c29c46566a13f84eead54b202a9bae83 (patch)
tree6e360aeea61672f86d090e52f281f6319953d4e2 /it/it-plugins/access-secured-props-plugin
parent48bb07308a21354e7f904a03b0c593158bde82b5 (diff)
downloadsonarqube-2a5eea17c29c46566a13f84eead54b202a9bae83.tar.gz
sonarqube-2a5eea17c29c46566a13f84eead54b202a9bae83.zip
Migrate batch ITs
Diffstat (limited to 'it/it-plugins/access-secured-props-plugin')
-rw-r--r--it/it-plugins/access-secured-props-plugin/pom.xml38
-rw-r--r--it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java12
-rw-r--r--it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java31
-rw-r--r--it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java28
4 files changed, 109 insertions, 0 deletions
diff --git a/it/it-plugins/access-secured-props-plugin/pom.xml b/it/it-plugins/access-secured-props-plugin/pom.xml
new file mode 100644
index 00000000000..61adaec8c60
--- /dev/null
+++ b/it/it-plugins/access-secured-props-plugin/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.sonarsource.it</groupId>
+ <artifactId>it-plugins</artifactId>
+ <version>5.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>access-secured-props-plugin</artifactId>
+ <packaging>sonar-plugin</packaging>
+ <name>Plugins :: Access Secured Properties</name>
+ <version>1.0-SNAPSHOT</version>
+ <description>Access .secured properties</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.12.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>AccessSecuredPropsPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java
new file mode 100644
index 00000000000..a32191e86b1
--- /dev/null
+++ b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java
@@ -0,0 +1,12 @@
+import org.sonar.api.SonarPlugin;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class AccessSecuredPropsPlugin extends SonarPlugin {
+
+ public List getExtensions() {
+ return Arrays.asList(AccessSecuredPropsSensor.class, AccessSecuredPropsTaskExtension.class);
+ }
+
+}
diff --git a/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java
new file mode 100644
index 00000000000..bb0eb46b68c
--- /dev/null
+++ b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java
@@ -0,0 +1,31 @@
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.batch.Sensor;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.config.Settings;
+import org.sonar.api.resources.Project;
+
+@Properties({
+ @Property(
+ key = "accessSecuredFromSensor",
+ name = "Property to decide if sensor should access secured properties",
+ defaultValue = "false")
+})
+public class AccessSecuredPropsSensor implements Sensor {
+
+ private Settings settings;
+
+ public AccessSecuredPropsSensor(Settings settings) {
+ this.settings = settings;
+ }
+
+ public boolean shouldExecuteOnProject(Project project) {
+ return true;
+ }
+
+ public void analyse(Project project, SensorContext sensorContext) {
+ if ("true".equals(settings.getString("accessSecuredFromSensor"))) {
+ settings.getString("foo.bar.secured");
+ }
+ }
+}
diff --git a/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java
new file mode 100644
index 00000000000..5ff17200580
--- /dev/null
+++ b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java
@@ -0,0 +1,28 @@
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.batch.Sensor;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.config.Settings;
+import org.sonar.api.task.TaskExtension;
+import org.sonar.api.resources.Project;
+
+@Properties({
+ @Property(
+ key = "accessSecuredFromTask",
+ name = "Property to decide if task extension should access secured properties",
+ defaultValue = "false")
+})
+public class AccessSecuredPropsTaskExtension implements TaskExtension {
+
+ private Settings settings;
+
+ public AccessSecuredPropsTaskExtension(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void start() {
+ if ("true".equals(settings.getString("accessSecuredFromTask"))) {
+ settings.getString("foo.bar.secured");
+ }
+ }
+}