aboutsummaryrefslogtreecommitdiffstats
path: root/tests/plugins
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-06-23 21:31:56 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-06-25 23:42:50 +0200
commit70b6899988da0d2ba0a39b846e4f1bd3fa27304f (patch)
tree1ac093a87e0fba6b07c6feb6aceae89bdd9663cf /tests/plugins
parent5dd574819854e9ce7e2f4e181e78153a7ecbf828 (diff)
downloadsonarqube-70b6899988da0d2ba0a39b846e4f1bd3fa27304f.tar.gz
sonarqube-70b6899988da0d2ba0a39b846e4f1bd3fa27304f.zip
Move integration tests to directory tests/
Diffstat (limited to 'tests/plugins')
-rw-r--r--tests/plugins/access-secured-props-plugin/pom.xml38
-rw-r--r--tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java31
-rw-r--r--tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java50
-rw-r--r--tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java47
-rw-r--r--tests/plugins/base-auth-plugin/pom.xml57
-rw-r--r--tests/plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java32
-rw-r--r--tests/plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java107
-rw-r--r--tests/plugins/base-auth-plugin/src/main/resources/static/base.pngbin0 -> 3112 bytes
-rw-r--r--tests/plugins/base-auth-plugin/src/resources/static/base.pngbin0 -> 3112 bytes
-rw-r--r--tests/plugins/batch-plugin/pom.xml37
-rw-r--r--tests/plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java47
-rw-r--r--tests/plugins/batch-plugin/src/main/java/com/sonarsource/DumpSettingsInitializer.java68
-rw-r--r--tests/plugins/batch-plugin/src/main/java/com/sonarsource/RaiseMessageException.java45
-rw-r--r--tests/plugins/batch-plugin/src/main/java/com/sonarsource/TempFolderExtension.java60
-rw-r--r--tests/plugins/batch-plugin/src/main/java/com/sonarsource/WaitingSensor.java48
-rw-r--r--tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleMeasureComputer.java53
-rw-r--r--tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleMetric.java44
-rw-r--r--tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleProperty.java32
-rw-r--r--tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleSensor.java55
-rw-r--r--tests/plugins/extension-lifecycle-plugin/pom.xml36
-rw-r--r--tests/plugins/extension-lifecycle-plugin/src/main/java/BatchService.java72
-rw-r--r--tests/plugins/extension-lifecycle-plugin/src/main/java/ExtensionLifecyclePlugin.java29
-rw-r--r--tests/plugins/extension-lifecycle-plugin/src/main/java/ProjectService.java58
-rw-r--r--tests/plugins/extension-lifecycle-plugin/src/main/java/ServerService.java23
-rw-r--r--tests/plugins/fake-billing-plugin/pom.xml44
-rw-r--r--tests/plugins/fake-billing-plugin/src/main/java/FakeBillingPlugin.java42
-rw-r--r--tests/plugins/fake-billing-plugin/src/main/java/FakeBillingValidations.java61
-rw-r--r--tests/plugins/fake-billing-plugin/src/main/resources/org/sonar/l10n/billing.properties2
-rw-r--r--tests/plugins/global-property-change-plugin/pom.xml39
-rw-r--r--tests/plugins/global-property-change-plugin/src/main/java/FakeGlobalPropertyChange.java32
-rw-r--r--tests/plugins/global-property-change-plugin/src/main/java/GlobalPropertyChangePlugin.java28
-rw-r--r--tests/plugins/issue-filter-plugin/pom.xml39
-rw-r--r--tests/plugins/issue-filter-plugin/src/main/java/IssueFilterBeforeLine5.java55
-rw-r--r--tests/plugins/issue-filter-plugin/src/main/java/IssueFilterPlugin.java36
-rw-r--r--tests/plugins/issue-filter-plugin/src/main/java/ModuleIssueFilter.java59
-rw-r--r--tests/plugins/l10n-fr-pack/pom.xml52
-rw-r--r--tests/plugins/l10n-fr-pack/src/main/java/SimpleFrenchPackPlugin.java28
-rw-r--r--tests/plugins/l10n-fr-pack/src/main/resources/org/sonar/l10n/core_fr.properties6
-rw-r--r--tests/plugins/license-plugin/pom.xml38
-rw-r--r--tests/plugins/license-plugin/src/main/java/LicensePlugin.java43
-rw-r--r--tests/plugins/oauth2-auth-plugin/pom.xml45
-rw-r--r--tests/plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2AuthPlugin.java32
-rw-r--r--tests/plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2IdProvider.java104
-rw-r--r--tests/plugins/oauth2-auth-plugin/src/main/resources/static/oauth2.pngbin0 -> 2087 bytes
-rw-r--r--tests/plugins/pom.xml62
-rw-r--r--tests/plugins/posttask-plugin/pom.xml39
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java35
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java36
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java62
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java29
-rw-r--r--tests/plugins/project-builder-plugin/pom.xml36
-rw-r--r--tests/plugins/project-builder-plugin/src/main/java/CreateSubProjects.java94
-rw-r--r--tests/plugins/project-builder-plugin/src/main/java/ProjectBuilderPlugin.java29
-rw-r--r--tests/plugins/project-builder-plugin/src/main/java/RenameProject.java66
-rw-r--r--tests/plugins/property-relocation-plugin/pom.xml39
-rw-r--r--tests/plugins/property-relocation-plugin/src/main/java/CheckProperties.java35
-rw-r--r--tests/plugins/property-relocation-plugin/src/main/java/PropertyRelocationPlugin.java33
-rw-r--r--tests/plugins/property-sets-plugin/pom.xml42
-rw-r--r--tests/plugins/property-sets-plugin/src/main/java/PropertySetsPlugin.java114
-rw-r--r--tests/plugins/security-plugin/pom.xml59
-rw-r--r--tests/plugins/security-plugin/src/main/java/FakeAuthenticator.java157
-rw-r--r--tests/plugins/security-plugin/src/main/java/FakeGroupsProvider.java36
-rw-r--r--tests/plugins/security-plugin/src/main/java/FakeRealm.java49
-rw-r--r--tests/plugins/security-plugin/src/main/java/FakeUsersProvider.java36
-rw-r--r--tests/plugins/security-plugin/src/main/java/SecurityPlugin.java30
-rw-r--r--tests/plugins/security-plugin/src/test/java/FakeAuthenticatorTest.java127
-rw-r--r--tests/plugins/server-plugin/pom.xml39
-rw-r--r--tests/plugins/server-plugin/src/main/java/ServerPlugin.java91
-rw-r--r--tests/plugins/server-plugin/src/main/java/StartupCrash.java42
-rw-r--r--tests/plugins/server-plugin/src/main/java/TempFolderExtension.java59
-rw-r--r--tests/plugins/settings-encryption-plugin/pom.xml36
-rw-r--r--tests/plugins/settings-encryption-plugin/src/main/java/EncryptionVerifier.java42
-rw-r--r--tests/plugins/settings-encryption-plugin/src/main/java/SettingsEncryptionPlugin.java29
-rw-r--r--tests/plugins/settings-plugin/pom.xml40
-rw-r--r--tests/plugins/settings-plugin/src/main/java/PropertyTypes.java35
-rw-r--r--tests/plugins/settings-plugin/src/main/java/ServerExtensionWithProperties.java43
-rw-r--r--tests/plugins/settings-plugin/src/main/java/SettingsPlugin.java28
-rw-r--r--tests/plugins/sonar-fake-plugin/pom.xml40
-rw-r--r--tests/plugins/sonar-fake-plugin/src/main/java/FakePlugin.java31
-rw-r--r--tests/plugins/sonar-subcategories-plugin/pom.xml58
-rw-r--r--tests/plugins/sonar-subcategories-plugin/src/main/java/SubCategoriesPlugin.java80
-rw-r--r--tests/plugins/sonar-subcategories-plugin/src/main/resources/org/sonar/l10n/subcategories.properties3
-rw-r--r--tests/plugins/ui-extensions-plugin/pom.xml39
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java48
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/java/UiPageDefinition.java59
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/resources/static/cute.jpgbin0 -> 23245 bytes
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/resources/static/extension.js2
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/resources/static/file.html6
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/resources/static/global_admin_page.js4
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/resources/static/global_page.js4
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/resources/static/organization_admin_page.js4
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/resources/static/organization_page.js4
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/resources/static/project_admin_page.js4
-rw-r--r--tests/plugins/ui-extensions-plugin/src/main/resources/static/project_page.js4
-rw-r--r--tests/plugins/ws-plugin/pom.xml43
-rw-r--r--tests/plugins/ws-plugin/src/main/java/LocalCallWebService.java84
-rw-r--r--tests/plugins/ws-plugin/src/main/java/WsPlugin.java29
97 files changed, 4129 insertions, 0 deletions
diff --git a/tests/plugins/access-secured-props-plugin/pom.xml b/tests/plugins/access-secured-props-plugin/pom.xml
new file mode 100644
index 00000000000..2b5c86d4065
--- /dev/null
+++ b/tests/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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>access-secured-props-plugin</artifactId>
+ <packaging>sonar-plugin</packaging>
+ <name>Plugins :: Access Secured Properties</name>
+ <version>1.0.2.42</version>
+ <description>Access .secured properties</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.18.0.372</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>AccessSecuredPropsPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java b/tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java
new file mode 100644
index 00000000000..a4e7da75764
--- /dev/null
+++ b/tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java
@@ -0,0 +1,31 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+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/tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java b/tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java
new file mode 100644
index 00000000000..9aca5155bb9
--- /dev/null
+++ b/tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java
@@ -0,0 +1,50 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+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/tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java b/tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java
new file mode 100644
index 00000000000..0132b56eefb
--- /dev/null
+++ b/tests/plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java
@@ -0,0 +1,47 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+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");
+ }
+ }
+}
diff --git a/tests/plugins/base-auth-plugin/pom.xml b/tests/plugins/base-auth-plugin/pom.xml
new file mode 100644
index 00000000000..b9ba09d79ab
--- /dev/null
+++ b/tests/plugins/base-auth-plugin/pom.xml
@@ -0,0 +1,57 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>base-auth-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>Plugins :: Fake Base Authentication Plugin</name>
+ <description>Test for base authentication plugin (like openid)</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>17.0</version>
+ <exclusions>
+ <exclusion>
+ <!-- should be declared with scope provided -->
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <configuration>
+ <pluginClass>FakeBaseAuthPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java b/tests/plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java
new file mode 100644
index 00000000000..ee04f716930
--- /dev/null
+++ b/tests/plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.ArrayList;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public final class FakeBaseAuthPlugin extends SonarPlugin {
+
+ public List getExtensions() {
+ List extensions = new ArrayList();
+ extensions.add(FakeBaseIdProvider.class);
+ return extensions;
+ }
+
+}
diff --git a/tests/plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java b/tests/plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java
new file mode 100644
index 00000000000..2e191e1e306
--- /dev/null
+++ b/tests/plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java
@@ -0,0 +1,107 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.io.IOException;
+import org.sonar.api.config.Settings;
+import org.sonar.api.server.authentication.BaseIdentityProvider;
+import org.sonar.api.server.authentication.Display;
+import org.sonar.api.server.authentication.UnauthorizedException;
+import org.sonar.api.server.authentication.UserIdentity;
+
+import static com.google.common.collect.Sets.newHashSet;
+
+public class FakeBaseIdProvider implements BaseIdentityProvider {
+
+ private static final String ENABLED = "sonar.auth.fake-base-id-provider.enabled";
+ private static final String ALLOWS_USERS_TO_SIGN_UP = "sonar.auth.fake-base-id-provider.allowsUsersToSignUp";
+ private static final String ENABLED_GROUPS_SYNC = "sonar.auth.fake-base-id-provider.enabledGroupsSync";
+ private static final String GROUPS = "sonar.auth.fake-base-id-provider.groups";
+
+ private static final String USER_INFO = "sonar.auth.fake-base-id-provider.user";
+
+ private static final String THROW_UNAUTHORIZED_EXCEPTION = "sonar.auth.fake-base-id-provider.throwUnauthorizedMessage";
+
+ private final Settings settings;
+
+ public FakeBaseIdProvider(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public void init(Context context) {
+ String userInfoProperty = settings.getString(USER_INFO);
+ if (userInfoProperty == null) {
+ throw new IllegalStateException(String.format("The property %s is required", USER_INFO));
+ }
+ boolean throwUnauthorizedException = settings.getBoolean(THROW_UNAUTHORIZED_EXCEPTION);
+ if (throwUnauthorizedException) {
+ throw new UnauthorizedException("A functional error has happened");
+ }
+
+ String[] userInfos = userInfoProperty.split(",");
+ UserIdentity.Builder builder = UserIdentity.builder()
+ .setLogin(userInfos[0])
+ .setProviderLogin(userInfos[1])
+ .setName(userInfos[2])
+ .setEmail(userInfos[3]);
+
+ if (settings.getBoolean(ENABLED_GROUPS_SYNC)) {
+ builder.setGroups(newHashSet(settings.getStringArray(GROUPS)));
+ }
+
+ context.authenticate(builder.build());
+ try {
+ context.getResponse().sendRedirect("/");
+ } catch (IOException e) {
+ throw new IllegalStateException("Fail to redirect to home", e);
+ }
+ }
+
+ @Override
+ public String getKey() {
+ return "fake-base-id-provider";
+ }
+
+ @Override
+ public String getName() {
+ return "Fake base identity provider";
+ }
+
+ @Override
+ public Display getDisplay() {
+ return Display.builder()
+ .setIconPath("/static/baseauthplugin/base.png")
+ .setBackgroundColor("#205081")
+ .build();
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return settings.getBoolean(ENABLED);
+ }
+
+ @Override
+ public boolean allowsUsersToSignUp() {
+ if (settings.hasKey(ALLOWS_USERS_TO_SIGN_UP)) {
+ return settings.getBoolean(ALLOWS_USERS_TO_SIGN_UP);
+ }
+ // If property is not defined, default behaviour is not always allow users to sign up
+ return true;
+ }
+}
diff --git a/tests/plugins/base-auth-plugin/src/main/resources/static/base.png b/tests/plugins/base-auth-plugin/src/main/resources/static/base.png
new file mode 100644
index 00000000000..217d2a0bdf8
--- /dev/null
+++ b/tests/plugins/base-auth-plugin/src/main/resources/static/base.png
Binary files differ
diff --git a/tests/plugins/base-auth-plugin/src/resources/static/base.png b/tests/plugins/base-auth-plugin/src/resources/static/base.png
new file mode 100644
index 00000000000..217d2a0bdf8
--- /dev/null
+++ b/tests/plugins/base-auth-plugin/src/resources/static/base.png
Binary files differ
diff --git a/tests/plugins/batch-plugin/pom.xml b/tests/plugins/batch-plugin/pom.xml
new file mode 100644
index 00000000000..98b839b6bde
--- /dev/null
+++ b/tests/plugins/batch-plugin/pom.xml
@@ -0,0 +1,37 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>batch-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>SonarQube Integration Tests :: Plugins :: Batch</name>
+ <description>Main plugin for batch tests</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>com.sonarsource.BatchPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java
new file mode 100644
index 00000000000..08f533ecea0
--- /dev/null
+++ b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java
@@ -0,0 +1,47 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonarsource;
+
+import com.sonarsource.decimal_scale_of_measures.DecimalScaleMeasureComputer;
+import com.sonarsource.decimal_scale_of_measures.DecimalScaleMetric;
+import com.sonarsource.decimal_scale_of_measures.DecimalScaleProperty;
+import com.sonarsource.decimal_scale_of_measures.DecimalScaleSensor;
+import org.sonar.api.Plugin;
+
+import static java.util.Arrays.asList;
+
+public class BatchPlugin implements Plugin {
+
+ @Override
+ public void define(Context context) {
+ context.addExtensions(asList(
+ // SONAR-6939 decimal_scale_of_measures
+ DecimalScaleMeasureComputer.class,
+ DecimalScaleMetric.class,
+ DecimalScaleSensor.class,
+ DecimalScaleProperty.definition(),
+
+ DumpSettingsInitializer.class,
+ RaiseMessageException.class,
+ TempFolderExtension.class,
+ WaitingSensor.class
+ ));
+ }
+}
diff --git a/tests/plugins/batch-plugin/src/main/java/com/sonarsource/DumpSettingsInitializer.java b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/DumpSettingsInitializer.java
new file mode 100644
index 00000000000..5149d72779c
--- /dev/null
+++ b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/DumpSettingsInitializer.java
@@ -0,0 +1,68 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonarsource;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.batch.Initializer;
+import org.sonar.api.config.Settings;
+import org.sonar.api.resources.Project;
+
+@Properties({
+ @Property(
+ key = DumpSettingsInitializer.SONAR_SHOW_SETTINGS,
+ type = PropertyType.STRING,
+ name = "Property to decide if it should output settings",
+ multiValues = true,
+ defaultValue = "")
+})
+public class DumpSettingsInitializer extends Initializer {
+
+ public static final String SONAR_SHOW_SETTINGS = "sonar.showSettings";
+ private Settings settings;
+
+ public DumpSettingsInitializer(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public boolean shouldExecuteOnProject(Project project) {
+ return true;
+ }
+
+ @Override
+ public void execute(Project project) {
+ Set<String> settingsToDump = new HashSet<>(Arrays.asList(settings.getStringArray(SONAR_SHOW_SETTINGS)));
+ if (!settingsToDump.isEmpty()) {
+ TreeMap<String, String> treemap = new TreeMap<String, String>(settings.getProperties());
+ for (Entry<String, String> prop : treemap.entrySet()) {
+ if (settingsToDump.contains(prop.getKey())) {
+ System.out.println(" o " + project.getKey() + ":" + prop.getKey() + " = " + prop.getValue());
+ }
+ }
+ }
+ }
+}
diff --git a/tests/plugins/batch-plugin/src/main/java/com/sonarsource/RaiseMessageException.java b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/RaiseMessageException.java
new file mode 100644
index 00000000000..a1acf47fb39
--- /dev/null
+++ b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/RaiseMessageException.java
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonarsource;
+
+import org.sonar.api.batch.Sensor;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.config.Settings;
+import org.sonar.api.resources.Project;
+import org.sonar.api.utils.MessageException;
+
+public class RaiseMessageException implements Sensor {
+
+ private final Settings settings;
+
+ public RaiseMessageException(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public boolean shouldExecuteOnProject(Project project) {
+ return settings.getBoolean("raiseMessageException");
+ }
+
+ @Override
+ public void analyse(Project project, SensorContext sensorContext) {
+ throw MessageException.of("Error message from plugin");
+ }
+} \ No newline at end of file
diff --git a/tests/plugins/batch-plugin/src/main/java/com/sonarsource/TempFolderExtension.java b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/TempFolderExtension.java
new file mode 100644
index 00000000000..1549471ff0f
--- /dev/null
+++ b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/TempFolderExtension.java
@@ -0,0 +1,60 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonarsource;
+
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.batch.Initializer;
+import org.sonar.api.config.Settings;
+import org.sonar.api.resources.Project;
+import org.sonar.api.utils.TempFolder;
+
+@Properties({
+ @Property(
+ key = TempFolderExtension.CREATE_TEMP_FILES,
+ type = PropertyType.BOOLEAN,
+ name = "Property to decide if it should create temp files",
+ defaultValue = "false")
+})
+public class TempFolderExtension extends Initializer {
+
+ public static final String CREATE_TEMP_FILES = "sonar.createTempFiles";
+ private Settings settings;
+ private TempFolder tempFolder;
+
+ public TempFolderExtension(Settings settings, TempFolder tempFolder) {
+ this.settings = settings;
+ this.tempFolder = tempFolder;
+ }
+
+ @Override
+ public boolean shouldExecuteOnProject(Project project) {
+ return true;
+ }
+
+ @Override
+ public void execute(Project project) {
+ if (settings.getBoolean(CREATE_TEMP_FILES)) {
+ System.out.println("Creating temp directory: " + tempFolder.newDir("sonar-it").getAbsolutePath());
+ System.out.println("Creating temp file: " + tempFolder.newFile("sonar-it", ".txt").getAbsolutePath());
+ }
+ }
+}
diff --git a/tests/plugins/batch-plugin/src/main/java/com/sonarsource/WaitingSensor.java b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/WaitingSensor.java
new file mode 100644
index 00000000000..a498e8534aa
--- /dev/null
+++ b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/WaitingSensor.java
@@ -0,0 +1,48 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonarsource;
+
+import org.sonar.api.batch.Sensor;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.config.Settings;
+import org.sonar.api.resources.Project;
+
+public class WaitingSensor implements Sensor {
+ private Settings settings;
+
+ public WaitingSensor(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public boolean shouldExecuteOnProject(Project project) {
+ return settings.getBoolean("sonar.it.enableWaitingSensor");
+ }
+
+ @Override
+ public void analyse(Project module, SensorContext context) {
+ try {
+ Thread.sleep(10_000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleMeasureComputer.java b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleMeasureComputer.java
new file mode 100644
index 00000000000..38140cd597f
--- /dev/null
+++ b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleMeasureComputer.java
@@ -0,0 +1,53 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonarsource.decimal_scale_of_measures;
+
+import org.sonar.api.ce.measure.Measure;
+import org.sonar.api.ce.measure.MeasureComputer;
+
+public class DecimalScaleMeasureComputer implements MeasureComputer {
+
+ @Override
+ public MeasureComputerDefinition define(MeasureComputerDefinitionContext defContext) {
+ return defContext.newDefinitionBuilder()
+ // Output metrics must contains at least one metric
+ .setOutputMetrics(DecimalScaleMetric.KEY)
+
+ .build();
+ }
+
+ @Override
+ public void compute(MeasureComputerContext context) {
+ if (context.getMeasure(DecimalScaleMetric.KEY) == null) {
+ Iterable<Measure> childMeasures = context.getChildrenMeasures(DecimalScaleMetric.KEY);
+ int count = 0;
+ double total = 0.0;
+ for (Measure childMeasure : childMeasures) {
+ count++;
+ total += childMeasure.getDoubleValue();
+ }
+ double value = 0.0;
+ if (count > 0) {
+ value = total / count;
+ }
+ context.addMeasure(DecimalScaleMetric.KEY, value);
+ }
+ }
+}
diff --git a/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleMetric.java b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleMetric.java
new file mode 100644
index 00000000000..aa2454b2a89
--- /dev/null
+++ b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleMetric.java
@@ -0,0 +1,44 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonarsource.decimal_scale_of_measures;
+
+import java.util.Collections;
+import java.util.List;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.measures.Metrics;
+
+public class DecimalScaleMetric implements Metrics {
+
+ public static final String KEY = "decimal_scale";
+
+ private static final Metric METRIC = new Metric.Builder(KEY, "Decimal Scale", Metric.ValueType.FLOAT)
+ .setDescription("Numeric metric with overridden decimal scale")
+ .setDecimalScale(4)
+ .create();
+
+ @Override
+ public List getMetrics() {
+ return Collections.singletonList(definition());
+ }
+
+ public static Metric definition() {
+ return METRIC;
+ }
+}
diff --git a/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleProperty.java b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleProperty.java
new file mode 100644
index 00000000000..c070434eeec
--- /dev/null
+++ b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleProperty.java
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonarsource.decimal_scale_of_measures;
+
+import org.sonar.api.PropertyType;
+import org.sonar.api.config.PropertyDefinition;
+
+public class DecimalScaleProperty {
+
+ public static final String KEY = "sonar.scanner.feedDecimalScaleMetric";
+
+ public static PropertyDefinition definition() {
+ return PropertyDefinition.builder(KEY).name("Enable test decimal_scale_of_measures").type(PropertyType.BOOLEAN).defaultValue(String.valueOf(false)).build();
+ }
+}
diff --git a/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleSensor.java b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleSensor.java
new file mode 100644
index 00000000000..788627bb920
--- /dev/null
+++ b/tests/plugins/batch-plugin/src/main/java/com/sonarsource/decimal_scale_of_measures/DecimalScaleSensor.java
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonarsource.decimal_scale_of_measures;
+
+import org.sonar.api.batch.Sensor;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.batch.fs.FilePredicate;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.resources.Project;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+public class DecimalScaleSensor implements Sensor {
+ private static final Logger LOG = Loggers.get(DecimalScaleSensor.class);
+
+ @Override
+ public boolean shouldExecuteOnProject(Project project) {
+ return true;
+ }
+
+ @Override
+ public void analyse(Project module, SensorContext context) {
+ if (context.settings().getBoolean(DecimalScaleProperty.KEY)) {
+ FilePredicate all = context.fileSystem().predicates().all();
+ Iterable<InputFile> files = context.fileSystem().inputFiles(all);
+ double value = 0.0001;
+ for (InputFile file : files) {
+ LOG.info("Value for {}: {}", file.relativePath(), value);
+ context.newMeasure()
+ .on(file)
+ .forMetric(DecimalScaleMetric.definition())
+ .withValue(value)
+ .save();
+ value += 0.0001;
+ }
+ }
+ }
+}
diff --git a/tests/plugins/extension-lifecycle-plugin/pom.xml b/tests/plugins/extension-lifecycle-plugin/pom.xml
new file mode 100644
index 00000000000..4d8adecd830
--- /dev/null
+++ b/tests/plugins/extension-lifecycle-plugin/pom.xml
@@ -0,0 +1,36 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>extension-lifecycle-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Extension Lifecycle</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>ExtensionLifecyclePlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/extension-lifecycle-plugin/src/main/java/BatchService.java b/tests/plugins/extension-lifecycle-plugin/src/main/java/BatchService.java
new file mode 100644
index 00000000000..3ab267e6f16
--- /dev/null
+++ b/tests/plugins/extension-lifecycle-plugin/src/main/java/BatchService.java
@@ -0,0 +1,72 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.BatchExtension;
+import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.config.Settings;
+
+@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
+public class BatchService implements BatchExtension {
+ private boolean started=false;
+ private int projectServices=0;
+ private Settings settings;
+
+ public BatchService(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void start() {
+ if (!settings.getBoolean("extension.lifecycle")) {
+ return;
+ }
+ System.out.println("Start BatchService");
+ if (started) {
+ throw new IllegalStateException("Already started");
+ }
+ if (projectServices>0) {
+ throw new IllegalStateException("BatchService must be started before ProjectServices");
+ }
+ started=true;
+ }
+
+ public boolean isStarted() {
+ return started;
+ }
+
+ public void stop() {
+ if (!settings.getBoolean("extension.lifecycle")) {
+ return;
+ }
+ System.out.println("Stop BatchService");
+ if (!started) {
+ System.out.println("BatchService is not started !");
+ System.exit(1);
+ }
+ if (projectServices!=3) {
+ // there are three maven modules in the project extension-lifecycle (pom + 2 modules)
+ System.out.println("Invalid nb of ProjectServices: " + projectServices);
+ System.exit(1);
+ }
+ started=false;
+ }
+
+ public void incrementProjectService() {
+ projectServices++;
+ }
+}
diff --git a/tests/plugins/extension-lifecycle-plugin/src/main/java/ExtensionLifecyclePlugin.java b/tests/plugins/extension-lifecycle-plugin/src/main/java/ExtensionLifecyclePlugin.java
new file mode 100644
index 00000000000..4c12f9f519b
--- /dev/null
+++ b/tests/plugins/extension-lifecycle-plugin/src/main/java/ExtensionLifecyclePlugin.java
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.SonarPlugin;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class ExtensionLifecyclePlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(BatchService.class, ProjectService.class, ServerService.class);
+ }
+}
diff --git a/tests/plugins/extension-lifecycle-plugin/src/main/java/ProjectService.java b/tests/plugins/extension-lifecycle-plugin/src/main/java/ProjectService.java
new file mode 100644
index 00000000000..93fcfe61403
--- /dev/null
+++ b/tests/plugins/extension-lifecycle-plugin/src/main/java/ProjectService.java
@@ -0,0 +1,58 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.BatchExtension;
+import org.sonar.api.config.Settings;
+
+/**
+ * As many instances as projects (maven modules)
+ */
+public class ProjectService implements BatchExtension {
+
+ private BatchService batchService;
+ private Settings settings;
+
+ public ProjectService(BatchService batchService, Settings settings) {
+ this.batchService = batchService;
+ this.settings = settings;
+ }
+
+ public void start() {
+ if (!settings.getBoolean("extension.lifecycle")) {
+ return;
+ }
+ System.out.println("Start ProjectService");
+
+ if (!batchService.isStarted()) {
+ throw new IllegalStateException("ProjectService must be started after BatchService");
+ }
+ batchService.incrementProjectService();
+ }
+
+ public void stop() {
+ if (!settings.getBoolean("extension.lifecycle")) {
+ return;
+ }
+ System.out.println("Stop ProjectService");
+ if (!batchService.isStarted()) {
+ System.out.println("ProjectService must be stopped before BatchService");
+ System.exit(1);
+ }
+ }
+}
diff --git a/tests/plugins/extension-lifecycle-plugin/src/main/java/ServerService.java b/tests/plugins/extension-lifecycle-plugin/src/main/java/ServerService.java
new file mode 100644
index 00000000000..f4db1a98555
--- /dev/null
+++ b/tests/plugins/extension-lifecycle-plugin/src/main/java/ServerService.java
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.ServerExtension;
+
+public class ServerService implements ServerExtension {
+}
diff --git a/tests/plugins/fake-billing-plugin/pom.xml b/tests/plugins/fake-billing-plugin/pom.xml
new file mode 100644
index 00000000000..6236c8cf5c4
--- /dev/null
+++ b/tests/plugins/fake-billing-plugin/pom.xml
@@ -0,0 +1,44 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>fake-billing-plugin</artifactId>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Fake Billing Plugin</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-server</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>FakeBillingPlugin</pluginClass>
+ <pluginKey>billing</pluginKey>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingPlugin.java b/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingPlugin.java
new file mode 100644
index 00000000000..910dfc9998a
--- /dev/null
+++ b/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingPlugin.java
@@ -0,0 +1,42 @@
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import org.sonar.api.Plugin;
+
+public class FakeBillingPlugin implements Plugin {
+
+ @Override
+ public void define(Context context) {
+ // Nothing should be loaded when the plugin is running within by the scanner
+ if (isRunningInSQ()) {
+ context.addExtension(FakeBillingValidations.class);
+ }
+ }
+
+ private static boolean isRunningInSQ() {
+ try {
+ Class.forName("org.sonar.plugin.PrivilegedPluginBridge");
+ return true;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+}
diff --git a/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingValidations.java b/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingValidations.java
new file mode 100644
index 00000000000..8ce39311117
--- /dev/null
+++ b/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingValidations.java
@@ -0,0 +1,61 @@
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import org.sonar.api.config.Settings;
+import org.sonar.server.organization.BillingValidationsExtension;
+
+import static java.lang.String.format;
+
+public class FakeBillingValidations implements BillingValidationsExtension {
+
+ private static final String PREVENT_PROJECT_ANALYSIS_SETTING = "sonar.billing.preventProjectAnalysis";
+ private static final String PREVENT_UPDATING_PROJECTS_VISIBILITY_TO_PRIVATE_SETTING = "sonar.billing.preventUpdatingProjectsVisibilityToPrivate";
+
+ private final Settings settings;
+
+ public FakeBillingValidations(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public void checkOnProjectAnalysis(Organization organization) {
+ boolean preventProjectAnalysis = settings.getBoolean(PREVENT_PROJECT_ANALYSIS_SETTING);
+ if (preventProjectAnalysis) {
+ throw new BillingValidationsException(format("Organization %s cannot perform analysis", organization.getKey()));
+ }
+ }
+
+ @Override
+ public void checkCanUpdateProjectVisibility(Organization organization, boolean updateToPrivate) {
+ boolean preventUpdatingProjectsToPrivate = settings.getBoolean(PREVENT_UPDATING_PROJECTS_VISIBILITY_TO_PRIVATE_SETTING);
+ if (preventUpdatingProjectsToPrivate) {
+ throw new BillingValidationsException(format("Organization %s cannot use private project", organization.getKey()));
+ }
+ }
+
+ @Override
+ public boolean canUpdateProjectVisibilityToPrivate(Organization organization) {
+ if (!settings.hasKey(PREVENT_UPDATING_PROJECTS_VISIBILITY_TO_PRIVATE_SETTING)) {
+ return true;
+ }
+ return !settings.getBoolean(PREVENT_UPDATING_PROJECTS_VISIBILITY_TO_PRIVATE_SETTING);
+ }
+}
diff --git a/tests/plugins/fake-billing-plugin/src/main/resources/org/sonar/l10n/billing.properties b/tests/plugins/fake-billing-plugin/src/main/resources/org/sonar/l10n/billing.properties
new file mode 100644
index 00000000000..f8ac8fcaef5
--- /dev/null
+++ b/tests/plugins/fake-billing-plugin/src/main/resources/org/sonar/l10n/billing.properties
@@ -0,0 +1,2 @@
+billing.upgrade_box.header=The fake billing plugin is installed
+billing.upgrade_box.text=It shows how to change the wording and hide the "Upgrade" button. \ No newline at end of file
diff --git a/tests/plugins/global-property-change-plugin/pom.xml b/tests/plugins/global-property-change-plugin/pom.xml
new file mode 100644
index 00000000000..7ab52654091
--- /dev/null
+++ b/tests/plugins/global-property-change-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>global-property-change-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Global Property Change</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>GlobalPropertyChangePlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/global-property-change-plugin/src/main/java/FakeGlobalPropertyChange.java b/tests/plugins/global-property-change-plugin/src/main/java/FakeGlobalPropertyChange.java
new file mode 100644
index 00000000000..551ed92f676
--- /dev/null
+++ b/tests/plugins/global-property-change-plugin/src/main/java/FakeGlobalPropertyChange.java
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.config.GlobalPropertyChangeHandler;
+import org.sonar.api.utils.log.Loggers;
+
+@Properties(@Property(key = "globalPropertyChange.received", name = "Check that extension has correctly been notified by global property change", category = "fake"))
+public final class FakeGlobalPropertyChange extends GlobalPropertyChangeHandler {
+
+ @Override
+ public void onChange(PropertyChange propertyChange) {
+ Loggers.get(FakeGlobalPropertyChange.class).info("Received change: " + propertyChange);
+ }
+}
diff --git a/tests/plugins/global-property-change-plugin/src/main/java/GlobalPropertyChangePlugin.java b/tests/plugins/global-property-change-plugin/src/main/java/GlobalPropertyChangePlugin.java
new file mode 100644
index 00000000000..5332fc9a3a5
--- /dev/null
+++ b/tests/plugins/global-property-change-plugin/src/main/java/GlobalPropertyChangePlugin.java
@@ -0,0 +1,28 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public class GlobalPropertyChangePlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(FakeGlobalPropertyChange.class);
+ }
+}
diff --git a/tests/plugins/issue-filter-plugin/pom.xml b/tests/plugins/issue-filter-plugin/pom.xml
new file mode 100644
index 00000000000..9b492158abf
--- /dev/null
+++ b/tests/plugins/issue-filter-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>issue-filter-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>IT :: Issue Filter</name>
+ <description>IT :: Issue Filter</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>IssueFilterPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/issue-filter-plugin/src/main/java/IssueFilterBeforeLine5.java b/tests/plugins/issue-filter-plugin/src/main/java/IssueFilterBeforeLine5.java
new file mode 100644
index 00000000000..44d34cba722
--- /dev/null
+++ b/tests/plugins/issue-filter-plugin/src/main/java/IssueFilterBeforeLine5.java
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.scan.issue.filter.IssueFilterChain;
+
+import org.sonar.api.scan.issue.filter.FilterableIssue;
+import org.sonar.api.config.Settings;
+import org.sonar.api.scan.issue.filter.IssueFilter;
+
+/**
+ * This filter removes the issues that are on line < 5
+ * <p/>
+ * Issue filters have been introduced in 3.6.
+ */
+public class IssueFilterBeforeLine5 implements IssueFilter {
+
+ private final Settings settings;
+
+ public IssueFilterBeforeLine5(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public boolean accept(FilterableIssue issue, IssueFilterChain chain) {
+ if (issue.componentKey() == null) {
+ throw new IllegalStateException("Issue component is not set");
+ }
+ if (issue.ruleKey() == null) {
+ throw new IllegalStateException("Issue rule is not set");
+ }
+
+ boolean b = !settings.getBoolean("enableIssueFilters") || issue.line() == null || issue.line() >= 5;
+ if (!b) {
+ return false;
+ }
+
+ return chain.accept(issue);
+ }
+}
diff --git a/tests/plugins/issue-filter-plugin/src/main/java/IssueFilterPlugin.java b/tests/plugins/issue-filter-plugin/src/main/java/IssueFilterPlugin.java
new file mode 100644
index 00000000000..94d5b87396e
--- /dev/null
+++ b/tests/plugins/issue-filter-plugin/src/main/java/IssueFilterPlugin.java
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.SonarPlugin;
+
+@Properties(@Property(
+ key = "enableIssueFilters",
+ name = "Enable Issue Filters",
+ defaultValue = "false",
+ type = PropertyType.BOOLEAN))
+public class IssueFilterPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(IssueFilterBeforeLine5.class, ModuleIssueFilter.class);
+ }
+}
diff --git a/tests/plugins/issue-filter-plugin/src/main/java/ModuleIssueFilter.java b/tests/plugins/issue-filter-plugin/src/main/java/ModuleIssueFilter.java
new file mode 100644
index 00000000000..48f549a264e
--- /dev/null
+++ b/tests/plugins/issue-filter-plugin/src/main/java/ModuleIssueFilter.java
@@ -0,0 +1,59 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.scan.issue.filter.FilterableIssue;
+
+import org.sonar.api.scan.issue.filter.IssueFilterChain;
+import org.sonar.api.config.Settings;
+import org.sonar.api.scan.issue.filter.IssueFilter;
+import org.sonar.api.rule.RuleKey;
+
+/**
+ * This filter removes the issues that are raised by Xoo plugin on modules.
+ * <p/>
+ * Issue filters have been introduced in 3.6.
+ */
+public class ModuleIssueFilter implements IssueFilter {
+
+ private static final RuleKey ONE_ISSUE_PER_MODULE_RULEKEY = RuleKey.of("xoo", "OneIssuePerModule");
+
+ private final Settings settings;
+
+ public ModuleIssueFilter(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public boolean accept(FilterableIssue issue, IssueFilterChain chain) {
+ if (issue.componentKey() == null) {
+ throw new IllegalStateException("Issue component is not set");
+ }
+ if (issue.ruleKey() == null) {
+ throw new IllegalStateException("Issue rule is not set");
+ }
+
+ boolean b = !settings.getBoolean("enableIssueFilters") || !ONE_ISSUE_PER_MODULE_RULEKEY.equals(issue.ruleKey());
+
+ if (!b) {
+ return false;
+ }
+
+ return chain.accept(issue);
+ }
+}
diff --git a/tests/plugins/l10n-fr-pack/pom.xml b/tests/plugins/l10n-fr-pack/pom.xml
new file mode 100644
index 00000000000..c952197ed95
--- /dev/null
+++ b/tests/plugins/l10n-fr-pack/pom.xml
@@ -0,0 +1,52 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>l10n-fr-pack</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>IT :: Simple French Language Pack</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <basePlugin>l10nen</basePlugin>
+ <pluginClass>SimpleFrenchPackPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>native2ascii-maven-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>native2ascii</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/l10n-fr-pack/src/main/java/SimpleFrenchPackPlugin.java b/tests/plugins/l10n-fr-pack/src/main/java/SimpleFrenchPackPlugin.java
new file mode 100644
index 00000000000..221e7131a90
--- /dev/null
+++ b/tests/plugins/l10n-fr-pack/src/main/java/SimpleFrenchPackPlugin.java
@@ -0,0 +1,28 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Collections;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public final class SimpleFrenchPackPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Collections.emptyList();
+ }
+}
diff --git a/tests/plugins/l10n-fr-pack/src/main/resources/org/sonar/l10n/core_fr.properties b/tests/plugins/l10n-fr-pack/src/main/resources/org/sonar/l10n/core_fr.properties
new file mode 100644
index 00000000000..2d28afe84f0
--- /dev/null
+++ b/tests/plugins/l10n-fr-pack/src/main/resources/org/sonar/l10n/core_fr.properties
@@ -0,0 +1,6 @@
+metric.ncloc.name=Lignes de code
+metric.ncloc.description=Lignes de code (non commentaire)
+widget.size.lines_of_code=Lignes de code
+
+layout.login=Se connecter
+layout.powered_by=Propulsé par
diff --git a/tests/plugins/license-plugin/pom.xml b/tests/plugins/license-plugin/pom.xml
new file mode 100644
index 00000000000..784132bf658
--- /dev/null
+++ b/tests/plugins/license-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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>license-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: License</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>LicensePlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/license-plugin/src/main/java/LicensePlugin.java b/tests/plugins/license-plugin/src/main/java/LicensePlugin.java
new file mode 100644
index 00000000000..9bd74374f37
--- /dev/null
+++ b/tests/plugins/license-plugin/src/main/java/LicensePlugin.java
@@ -0,0 +1,43 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Collections;
+import java.util.List;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.SonarPlugin;
+
+@Properties({
+ @Property(
+ key = "untyped.license.secured",
+ name = "Property without license type",
+ category = CoreProperties.CATEGORY_GENERAL),
+ @Property(
+ key = "typed.license.secured",
+ name = "Typed property",
+ category = CoreProperties.CATEGORY_GENERAL,
+ type = PropertyType.LICENSE)
+})
+public class LicensePlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Collections.emptyList();
+ }
+}
diff --git a/tests/plugins/oauth2-auth-plugin/pom.xml b/tests/plugins/oauth2-auth-plugin/pom.xml
new file mode 100644
index 00000000000..565b1445bf4
--- /dev/null
+++ b/tests/plugins/oauth2-auth-plugin/pom.xml
@@ -0,0 +1,45 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>oauth2-auth-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>Plugins :: Fake OAuth2 Authentication Plugin</name>
+ <description>Test for OAuth2 authentication plugin (like openid)</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <configuration>
+ <pluginClass>FakeOAuth2AuthPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2AuthPlugin.java b/tests/plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2AuthPlugin.java
new file mode 100644
index 00000000000..5fa419d3289
--- /dev/null
+++ b/tests/plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2AuthPlugin.java
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.ArrayList;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public final class FakeOAuth2AuthPlugin extends SonarPlugin {
+
+ public List getExtensions() {
+ List extensions = new ArrayList();
+ extensions.add(FakeOAuth2IdProvider.class);
+ return extensions;
+ }
+
+}
diff --git a/tests/plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2IdProvider.java b/tests/plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2IdProvider.java
new file mode 100644
index 00000000000..deb426145c4
--- /dev/null
+++ b/tests/plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2IdProvider.java
@@ -0,0 +1,104 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.config.Settings;
+import org.sonar.api.server.authentication.Display;
+import org.sonar.api.server.authentication.OAuth2IdentityProvider;
+import org.sonar.api.server.authentication.UnauthorizedException;
+import org.sonar.api.server.authentication.UserIdentity;
+
+public class FakeOAuth2IdProvider implements OAuth2IdentityProvider {
+
+ private static final String ENABLED = "sonar.auth.fake-oauth2-id-provider.enabled";
+ private static final String ALLOWS_USERS_TO_SIGN_UP = "sonar.auth.fake-oauth2-id-provider.allowsUsersToSignUp";
+ private static final String URL = "sonar.auth.fake-oauth2-id-provider.url";
+ private static final String USER_INFO = "sonar.auth.fake-oauth2-id-provider.user";
+
+ private static final String THROW_UNAUTHORIZED_EXCEPTION = "sonar.auth.fake-oauth2-id-provider.throwUnauthorizedMessage";
+
+ private final Settings settings;
+
+ public FakeOAuth2IdProvider(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public void init(InitContext context) {
+ String url = settings.getString(URL);
+ if (url == null) {
+ throw new IllegalStateException(String.format("The property %s is required", URL));
+ }
+ context.redirectTo(url);
+ }
+
+ @Override
+ public void callback(CallbackContext context) {
+ String userInfoProperty = settings.getString(USER_INFO);
+ if (userInfoProperty == null) {
+ throw new IllegalStateException(String.format("The property %s is required", USER_INFO));
+ }
+ boolean throwUnauthorizedException = settings.getBoolean(THROW_UNAUTHORIZED_EXCEPTION);
+ if (throwUnauthorizedException) {
+ throw new UnauthorizedException("A functional error has happened");
+ }
+
+ String[] userInfos = userInfoProperty.split(",");
+ context.authenticate(UserIdentity.builder()
+ .setLogin(userInfos[0])
+ .setProviderLogin(userInfos[1])
+ .setName(userInfos[2])
+ .setEmail(userInfos[3])
+ .build());
+ context.redirectToRequestedPage();
+ }
+
+ @Override
+ public String getKey() {
+ return "fake-oauth2-id-provider";
+ }
+
+ @Override
+ public String getName() {
+ return "Fake oauth2 identity provider";
+ }
+
+ @Override
+ public Display getDisplay() {
+ return Display.builder()
+ .setIconPath("/static/oauth2authplugin/oauth2.png")
+ .setBackgroundColor("#444444")
+ .build();
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return settings.getBoolean(ENABLED);
+ }
+
+ @Override
+ public boolean allowsUsersToSignUp() {
+ if (settings.hasKey(ALLOWS_USERS_TO_SIGN_UP)) {
+ return settings.getBoolean(ALLOWS_USERS_TO_SIGN_UP);
+ }
+ // If property is not defined, default behaviour is not always allow users to sign up
+ return true;
+
+ }
+
+}
diff --git a/tests/plugins/oauth2-auth-plugin/src/main/resources/static/oauth2.png b/tests/plugins/oauth2-auth-plugin/src/main/resources/static/oauth2.png
new file mode 100644
index 00000000000..28a3e01698c
--- /dev/null
+++ b/tests/plugins/oauth2-auth-plugin/src/main/resources/static/oauth2.png
Binary files differ
diff --git a/tests/plugins/pom.xml b/tests/plugins/pom.xml
new file mode 100644
index 00000000000..2f41319fe52
--- /dev/null
+++ b/tests/plugins/pom.xml
@@ -0,0 +1,62 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonarqube</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <groupId>org.sonarsource.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <name>SonarQube Integration Tests :: Plugins</name>
+ <description>The fake plugins used by integration tests</description>
+ <packaging>pom</packaging>
+
+ <properties>
+ <skipSanityChecks>true</skipSanityChecks>
+ <enforcer.skip>true</enforcer.skip>
+ <maven.deploy.skip>true</maven.deploy.skip>
+ <source.skip>true</source.skip>
+ <apiVersion>${project.parent.version}</apiVersion>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>access-secured-props-plugin</module>
+ <module>base-auth-plugin</module>
+ <module>batch-plugin</module>
+ <module>extension-lifecycle-plugin</module>
+ <module>fake-billing-plugin</module>
+ <module>global-property-change-plugin</module>
+ <module>issue-filter-plugin</module>
+ <module>l10n-fr-pack</module>
+ <module>license-plugin</module>
+ <module>oauth2-auth-plugin</module>
+ <module>project-builder-plugin</module>
+ <module>property-relocation-plugin</module>
+ <module>property-sets-plugin</module>
+ <module>security-plugin</module>
+ <module>server-plugin</module>
+ <module>settings-encryption-plugin</module>
+ <module>settings-plugin</module>
+ <module>sonar-fake-plugin</module>
+ <module>sonar-subcategories-plugin</module>
+ <module>ui-extensions-plugin</module>
+ <module>posttask-plugin</module>
+ <module>ws-plugin</module>
+ </modules>
+</project>
diff --git a/tests/plugins/posttask-plugin/pom.xml b/tests/plugins/posttask-plugin/pom.xml
new file mode 100644
index 00000000000..a7fa06d39b8
--- /dev/null
+++ b/tests/plugins/posttask-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>posttask-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>SonarQube Integration Tests :: Plugins :: PostTask</name>
+ <description>Plugin testing the Compute Engine Post Task API</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>PostTaskPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java b/tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java
new file mode 100644
index 00000000000..7013a6707a8
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java
@@ -0,0 +1,35 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.batch.sensor.Sensor;
+import org.sonar.api.batch.sensor.SensorContext;
+import org.sonar.api.batch.sensor.SensorDescriptor;
+
+public class AddScannerContextSensor implements Sensor {
+ @Override
+ public void execute(SensorContext context) {
+ context.addContextProperty("foo1", "bar1");
+ context.addContextProperty("foo2", "bar2");
+ }
+
+ @Override
+ public void describe(SensorDescriptor descriptor) {
+
+ }
+}
diff --git a/tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java b/tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java
new file mode 100644
index 00000000000..120610a2da2
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Map;
+import org.sonar.api.ce.posttask.PostProjectAnalysisTask;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+public class LogScannerContextPostTask implements PostProjectAnalysisTask {
+ private static final Logger LOG = Loggers.get(LogScannerContextPostTask.class);
+
+ @Override
+ public void finished(ProjectAnalysis analysis) {
+ for (Map.Entry<String, String> prop : analysis.getScannerContext().getProperties().entrySet()) {
+ LOG.info("POSTASKPLUGIN: ScannerProperty {}={}",
+ prop.getKey(),
+ prop.getValue());
+ }
+ }
+}
diff --git a/tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java b/tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java
new file mode 100644
index 00000000000..0c288ec01d5
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java
@@ -0,0 +1,62 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.ce.posttask.CeTask;
+import org.sonar.api.ce.posttask.PostProjectAnalysisTask;
+import org.sonar.api.ce.posttask.Project;
+import org.sonar.api.ce.posttask.QualityGate;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+public class PostProjectAnalysisTaskImpl implements PostProjectAnalysisTask {
+ private static final Logger LOG = Loggers.get(PostProjectAnalysisTaskImpl.class);
+
+ @Override
+ public void finished(ProjectAnalysis analysis) {
+ CeTask ceTask = analysis.getCeTask();
+ Project project = analysis.getProject();
+ QualityGate qualityGate = analysis.getQualityGate();
+ LOG.info("POSTASKPLUGIN: finished() CeTask[{}][{}] Project[{}] Date[{}] QualityGate[{}]",
+ ceTask.getStatus(),
+ ceTask.getId(),
+ project.getKey(),
+ analysis.getDate().getTime(),
+ qualityGate == null ? null : qualityGate.getStatus());
+ }
+}
diff --git a/tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java b/tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java
new file mode 100644
index 00000000000..07ce105ff4e
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public class PostTaskPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(PostProjectAnalysisTaskImpl.class,
+ LogScannerContextPostTask.class, AddScannerContextSensor.class);
+ }
+}
diff --git a/tests/plugins/project-builder-plugin/pom.xml b/tests/plugins/project-builder-plugin/pom.xml
new file mode 100644
index 00000000000..9afdc7a8993
--- /dev/null
+++ b/tests/plugins/project-builder-plugin/pom.xml
@@ -0,0 +1,36 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>project-builder-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Project Builder</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency> </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>ProjectBuilderPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/project-builder-plugin/src/main/java/CreateSubProjects.java b/tests/plugins/project-builder-plugin/src/main/java/CreateSubProjects.java
new file mode 100644
index 00000000000..e1fe412282d
--- /dev/null
+++ b/tests/plugins/project-builder-plugin/src/main/java/CreateSubProjects.java
@@ -0,0 +1,94 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.io.File;
+import org.sonar.api.batch.bootstrap.ProjectBuilder;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.config.Settings;
+
+/**
+ * This plugin relates to projects/project-builder sample
+ */
+public final class CreateSubProjects extends ProjectBuilder {
+
+ private Settings settings;
+
+ public CreateSubProjects(Settings settings) {
+ // A real implementation should for example use the configuration
+ this.settings = settings;
+ }
+
+ @Override
+ protected void build(ProjectReactor reactor) {
+ if (!settings.getBoolean("sonar.enableProjectBuilder")) {
+ return;
+ }
+ System.out.println("---> Creating sub-projects");
+ ProjectDefinition root = reactor.getRoot();
+
+ // add two modules
+ createSubProjectWithSourceDir(root);
+ createSubProjectWithSourceFiles(root);
+ }
+
+ private ProjectDefinition createSubProjectWithSourceDir(ProjectDefinition root) {
+ File baseDir = new File(root.getBaseDir(), "module_a");
+ ProjectDefinition subProject = ProjectDefinition.create();
+ subProject.setBaseDir(baseDir).setWorkDir(new File(baseDir, "target/.sonar"));
+ subProject.setKey("com.sonarsource.it.projects.batch:project-builder-module-a");
+ subProject.setVersion(root.getVersion());
+ subProject.setName("Module A");
+ subProject.addSources("src");
+ root.addSubProject(subProject);
+ return subProject;
+ }
+
+ private ProjectDefinition createSubProjectWithSourceFiles(ProjectDefinition root) {
+ File baseDir = new File(root.getBaseDir(), "module_b");
+ ProjectDefinition subProject = ProjectDefinition.create();
+ subProject.setBaseDir(baseDir).setWorkDir(new File(baseDir, "target/.sonar"));
+ subProject.setKey("com.sonarsource.it.projects.batch:project-builder-module-b");
+ subProject.setVersion(root.getVersion());
+ subProject.setName("Module B");
+ subProject.addSources("src/HelloB.java");
+ root.addSubProject(subProject);
+ return subProject;
+ }
+}
diff --git a/tests/plugins/project-builder-plugin/src/main/java/ProjectBuilderPlugin.java b/tests/plugins/project-builder-plugin/src/main/java/ProjectBuilderPlugin.java
new file mode 100644
index 00000000000..f57669929d3
--- /dev/null
+++ b/tests/plugins/project-builder-plugin/src/main/java/ProjectBuilderPlugin.java
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.SonarPlugin;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class ProjectBuilderPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(CreateSubProjects.class, RenameProject.class);
+ }
+}
diff --git a/tests/plugins/project-builder-plugin/src/main/java/RenameProject.java b/tests/plugins/project-builder-plugin/src/main/java/RenameProject.java
new file mode 100644
index 00000000000..22d1dd3cccb
--- /dev/null
+++ b/tests/plugins/project-builder-plugin/src/main/java/RenameProject.java
@@ -0,0 +1,66 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.batch.bootstrap.ProjectBuilder;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.config.Settings;
+
+/**
+ * This plugin relates to projects/project-builder sample
+ */
+public final class RenameProject extends ProjectBuilder {
+
+ private Settings settings;
+
+ public RenameProject(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ protected void build(ProjectReactor reactor) {
+ if (!settings.getBoolean("sonar.enableProjectBuilder")) {
+ return;
+ }
+ System.out.println("---> Renaming project");
+ // change name of root project
+ ProjectDefinition root = reactor.getRoot();
+ root.setName("Name changed by plugin");
+ }
+}
diff --git a/tests/plugins/property-relocation-plugin/pom.xml b/tests/plugins/property-relocation-plugin/pom.xml
new file mode 100644
index 00000000000..28699399fd5
--- /dev/null
+++ b/tests/plugins/property-relocation-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>property-relocation-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Property Relocation</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>PropertyRelocationPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/property-relocation-plugin/src/main/java/CheckProperties.java b/tests/plugins/property-relocation-plugin/src/main/java/CheckProperties.java
new file mode 100644
index 00000000000..b4e7ec1b185
--- /dev/null
+++ b/tests/plugins/property-relocation-plugin/src/main/java/CheckProperties.java
@@ -0,0 +1,35 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.BatchExtension;
+import org.sonar.api.config.Settings;
+
+public class CheckProperties implements BatchExtension {
+ private Settings settings;
+
+ public CheckProperties(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void start() {
+ if (settings.getBoolean("sonar.newKey") != true) {
+ throw new IllegalStateException("Property not found: sonar.newKey");
+ }
+ }
+}
diff --git a/tests/plugins/property-relocation-plugin/src/main/java/PropertyRelocationPlugin.java b/tests/plugins/property-relocation-plugin/src/main/java/PropertyRelocationPlugin.java
new file mode 100644
index 00000000000..aa0ebbfae38
--- /dev/null
+++ b/tests/plugins/property-relocation-plugin/src/main/java/PropertyRelocationPlugin.java
@@ -0,0 +1,33 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.SonarPlugin;
+
+@Properties({
+ @Property(key = "sonar.newKey", deprecatedKey = "sonar.deprecatedKey", name = "New Key", category = "general")
+})
+public class PropertyRelocationPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(CheckProperties.class);
+ }
+}
diff --git a/tests/plugins/property-sets-plugin/pom.xml b/tests/plugins/property-sets-plugin/pom.xml
new file mode 100644
index 00000000000..36c61ea2cc9
--- /dev/null
+++ b/tests/plugins/property-sets-plugin/pom.xml
@@ -0,0 +1,42 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>property-sets-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Property Sets</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>PropertySetsPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/property-sets-plugin/src/main/java/PropertySetsPlugin.java b/tests/plugins/property-sets-plugin/src/main/java/PropertySetsPlugin.java
new file mode 100644
index 00000000000..357411d6980
--- /dev/null
+++ b/tests/plugins/property-sets-plugin/src/main/java/PropertySetsPlugin.java
@@ -0,0 +1,114 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Collections;
+import java.util.List;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyField;
+import org.sonar.api.PropertyType;
+import org.sonar.api.SonarPlugin;
+
+@Properties({
+ @Property(
+ key = "sonar.test.jira.servers",
+ name = "Jira Servers",
+ description = "List of jira server definitions",
+ global = true,
+ project = true,
+ category = "DEV",
+ fields = {
+ @PropertyField(
+ key = "key",
+ name = "Key",
+ type = PropertyType.STRING,
+ indicativeSize = 10),
+ @PropertyField(
+ key = "url",
+ name = "Url",
+ description = "l'url du serveur jira",
+ type = PropertyType.STRING,
+ indicativeSize = 20),
+ @PropertyField(
+ key = "port",
+ name = "Port",
+ type = PropertyType.INTEGER,
+ indicativeSize = 5)}),
+ @Property(
+ key = "sonar.demo",
+ name = "Demo",
+ global = true,
+ project = true,
+ category = "DEV",
+ fields = {
+ @PropertyField(
+ key = "text",
+ name = "text",
+ type = PropertyType.TEXT),
+ @PropertyField(
+ key = "boolean",
+ name = "boolean",
+ type = PropertyType.BOOLEAN),
+ @PropertyField(
+ key = "float",
+ name = "float",
+ type = PropertyType.FLOAT),
+ @PropertyField(
+ key = "license",
+ name = "license",
+ type = PropertyType.LICENSE),
+ @PropertyField(
+ key = "metric",
+ name = "metric",
+ type = PropertyType.METRIC),
+ @PropertyField(
+ key = "password",
+ name = "password",
+ type = PropertyType.PASSWORD),
+ @PropertyField(
+ key = "regexp",
+ name = "regexp",
+ type = PropertyType.REGULAR_EXPRESSION),
+ @PropertyField(
+ key = "list",
+ name = "list",
+ type = PropertyType.SINGLE_SELECT_LIST,
+ options = {"AAA", "BBB"})}),
+ @Property(
+ key = "sonar.autogenerated",
+ name = "Auto-generated",
+ global = true,
+ project = true,
+ category = "DEV",
+ fields = {
+ @PropertyField(
+ key = "value",
+ name = "value",
+ type = PropertyType.STRING)}),
+ @Property(
+ key = "sonar.test.jira",
+ name = "Jira",
+ project = true,
+ category = "DEV",
+ propertySetKey = "sonar.test.jira.servers")})
+public class PropertySetsPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Collections.emptyList();
+ }
+}
diff --git a/tests/plugins/security-plugin/pom.xml b/tests/plugins/security-plugin/pom.xml
new file mode 100644
index 00000000000..bc4885967e6
--- /dev/null
+++ b/tests/plugins/security-plugin/pom.xml
@@ -0,0 +1,59 @@
+<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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>security-plugin</artifactId>
+ <packaging>sonar-plugin</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <description>Plugins :: Security</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-guava</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>SecurityPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tests/plugins/security-plugin/src/main/java/FakeAuthenticator.java b/tests/plugins/security-plugin/src/main/java/FakeAuthenticator.java
new file mode 100644
index 00000000000..890263b0fbf
--- /dev/null
+++ b/tests/plugins/security-plugin/src/main/java/FakeAuthenticator.java
@@ -0,0 +1,157 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Splitter;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.config.Settings;
+import org.sonar.api.security.LoginPasswordAuthenticator;
+import org.sonar.api.security.UserDetails;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+@Properties({
+ @Property(
+ key = FakeAuthenticator.DATA_PROPERTY,
+ name = "Fake Users", type = PropertyType.TEXT
+ )
+})
+public class FakeAuthenticator implements LoginPasswordAuthenticator {
+
+ private static final Logger LOG = Loggers.get(FakeAuthenticator.class);
+
+ /**
+ * Example:
+ * <pre>
+ * evgeny.password=foo
+ * evgeny.name=Evgeny Mandrikov
+ * evgeny.email=evgeny@example.org
+ * evgeny.groups=sonar-users
+ *
+ * simon.password=bar
+ * simon.groups=sonar-users,sonar-developers
+ * </pre>
+ */
+ public static final String DATA_PROPERTY = "sonar.fakeauthenticator.users";
+
+ private final Settings settings;
+
+ private Map<String, String> data;
+
+ public FakeAuthenticator(Settings settings) {
+ this.settings = settings;
+ }
+
+ public boolean authenticate(String username, String password) {
+ // Never touch admin
+ if (isAdmin(username)) {
+ return true;
+ }
+
+ reloadData();
+ checkExistence(username);
+
+ String expectedPassword = data.get(username + ".password");
+ if (StringUtils.equals(password, expectedPassword)) {
+ LOG.info("user {} with password {}", username, password);
+ return true;
+ } else {
+ LOG.info("user " + username + " expected password " + expectedPassword + " , but was " + password);
+ return false;
+ }
+ }
+
+ private void checkExistence(String username) {
+ if (!data.containsKey(username + ".password")) {
+ throw new IllegalArgumentException("No such user : " + username);
+ }
+ }
+
+ public UserDetails doGetUserDetails(String username) {
+ // Never touch admin
+ if (isAdmin(username)) {
+ return null;
+ }
+
+ reloadData();
+ checkExistence(username);
+
+ UserDetails result = new UserDetails();
+ result.setName(Strings.nullToEmpty(data.get(username + ".name")));
+ result.setEmail(Strings.nullToEmpty(data.get(username + ".email")));
+ LOG.info("details for user {} : {}", username, result);
+ return result;
+ }
+
+ public Collection<String> doGetGroups(String username) {
+ // Never touch admin
+ if (isAdmin(username)) {
+ return null;
+ }
+
+ reloadData();
+ checkExistence(username);
+
+ Collection<String> result = parseList(data.get(username + ".groups"));
+ LOG.info("groups for user {} : {}", username, result);
+ return result;
+ }
+
+ private static boolean isAdmin(String username) {
+ return StringUtils.equals(username, "admin");
+ }
+
+ private void reloadData() {
+ data = parse(settings.getString(DATA_PROPERTY));
+ }
+
+ private static final Splitter LIST_SPLITTER = Splitter.on(',').omitEmptyStrings().trimResults();
+ private static final Splitter LINE_SPLITTER = Splitter.on(Pattern.compile("\r?\n")).omitEmptyStrings().trimResults();
+
+ @VisibleForTesting
+ static List<String> parseList(String data) {
+ return ImmutableList.copyOf(LIST_SPLITTER.split(Strings.nullToEmpty(data)));
+ }
+
+ @VisibleForTesting
+ static Map<String, String> parse(String data) {
+ Map<String, String> result = Maps.newHashMap();
+ for (String entry : LINE_SPLITTER.split(Strings.nullToEmpty(data))) {
+ Iterator<String> keyValue = Splitter.on('=').split(entry).iterator();
+ result.put(keyValue.next(), keyValue.next());
+ }
+ return result;
+ }
+
+ public void init() {
+ // nothing to do
+ }
+
+}
diff --git a/tests/plugins/security-plugin/src/main/java/FakeGroupsProvider.java b/tests/plugins/security-plugin/src/main/java/FakeGroupsProvider.java
new file mode 100644
index 00000000000..3ab14818a34
--- /dev/null
+++ b/tests/plugins/security-plugin/src/main/java/FakeGroupsProvider.java
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Collection;
+import org.sonar.api.security.ExternalGroupsProvider;
+
+public class FakeGroupsProvider extends ExternalGroupsProvider {
+
+ private final FakeAuthenticator instance;
+
+ public FakeGroupsProvider(FakeAuthenticator instance) {
+ this.instance = instance;
+ }
+
+ @Override
+ public Collection<String> doGetGroups(String username) {
+ return instance.doGetGroups(username);
+ }
+
+}
diff --git a/tests/plugins/security-plugin/src/main/java/FakeRealm.java b/tests/plugins/security-plugin/src/main/java/FakeRealm.java
new file mode 100644
index 00000000000..152ea921b21
--- /dev/null
+++ b/tests/plugins/security-plugin/src/main/java/FakeRealm.java
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.config.Settings;
+import org.sonar.api.security.ExternalGroupsProvider;
+import org.sonar.api.security.ExternalUsersProvider;
+import org.sonar.api.security.LoginPasswordAuthenticator;
+import org.sonar.api.security.SecurityRealm;
+
+public class FakeRealm extends SecurityRealm {
+
+ private FakeAuthenticator instance;
+
+ public FakeRealm(Settings settings) {
+ this.instance = new FakeAuthenticator(settings);
+ }
+
+ @Override
+ public LoginPasswordAuthenticator getLoginPasswordAuthenticator() {
+ return instance;
+ }
+
+ @Override
+ public ExternalGroupsProvider getGroupsProvider() {
+ return new FakeGroupsProvider(instance);
+ }
+
+ @Override
+ public ExternalUsersProvider getUsersProvider() {
+ return new FakeUsersProvider(instance);
+ }
+
+}
diff --git a/tests/plugins/security-plugin/src/main/java/FakeUsersProvider.java b/tests/plugins/security-plugin/src/main/java/FakeUsersProvider.java
new file mode 100644
index 00000000000..90c95de3e1c
--- /dev/null
+++ b/tests/plugins/security-plugin/src/main/java/FakeUsersProvider.java
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.security.ExternalUsersProvider;
+import org.sonar.api.security.UserDetails;
+
+public class FakeUsersProvider extends ExternalUsersProvider {
+
+ private final FakeAuthenticator instance;
+
+ public FakeUsersProvider(FakeAuthenticator instance) {
+ this.instance = instance;
+ }
+
+ @Override
+ public UserDetails doGetUserDetails(String username) {
+ return instance.doGetUserDetails(username);
+ }
+
+}
diff --git a/tests/plugins/security-plugin/src/main/java/SecurityPlugin.java b/tests/plugins/security-plugin/src/main/java/SecurityPlugin.java
new file mode 100644
index 00000000000..c1cf7cd3b9e
--- /dev/null
+++ b/tests/plugins/security-plugin/src/main/java/SecurityPlugin.java
@@ -0,0 +1,30 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public class SecurityPlugin extends SonarPlugin {
+
+ public List getExtensions() {
+ return Arrays.asList(FakeRealm.class, FakeAuthenticator.class);
+ }
+
+}
diff --git a/tests/plugins/security-plugin/src/test/java/FakeAuthenticatorTest.java b/tests/plugins/security-plugin/src/test/java/FakeAuthenticatorTest.java
new file mode 100644
index 00000000000..e55aacb9478
--- /dev/null
+++ b/tests/plugins/security-plugin/src/test/java/FakeAuthenticatorTest.java
@@ -0,0 +1,127 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.Settings;
+import org.sonar.api.security.UserDetails;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+
+public class FakeAuthenticatorTest {
+
+ private Settings settings;
+ private FakeAuthenticator authenticator;
+
+ @Before
+ public void setUp() {
+ settings = new MapSettings();
+ authenticator = new FakeAuthenticator(settings);
+ authenticator.init();
+ }
+
+ @Test
+ public void shouldNeverTouchAdmin() {
+ assertThat(authenticator.authenticate("admin", "admin")).isTrue();
+ assertThat(authenticator.doGetGroups("admin")).isNull();
+ assertThat(authenticator.doGetUserDetails("admin")).isNull();
+ }
+
+ @Test
+ public void shouldAuthenticateFakeUsers() {
+ settings.setProperty(FakeAuthenticator.DATA_PROPERTY, "evgeny.password=foo");
+
+ assertThat(authenticator.authenticate("evgeny", "foo")).isTrue();
+ assertThat(authenticator.authenticate("evgeny", "bar")).isFalse();
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void shouldNotAuthenticateNotExistingUsers() {
+ authenticator.authenticate("evgeny", "foo");
+ }
+
+ @Test
+ public void shouldGetUserDetails() {
+ settings.setProperty(FakeAuthenticator.DATA_PROPERTY, "evgeny.password=foo\n" +
+ "evgeny.name=Tester Testerovich\n" +
+ "evgeny.email=evgeny@example.org");
+
+ UserDetails details = authenticator.doGetUserDetails("evgeny");
+ assertThat(details.getName()).isEqualTo("Tester Testerovich");
+ assertThat(details.getEmail()).isEqualTo("evgeny@example.org");
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void shouldNotReturnDetailsForNotExistingUsers() {
+ authenticator.doGetUserDetails("evgeny");
+ }
+
+ @Test
+ public void shouldGetGroups() {
+ settings.setProperty(FakeAuthenticator.DATA_PROPERTY, "evgeny.password=foo\n" +
+ "evgeny.groups=sonar-users,sonar-developers");
+
+ assertThat(authenticator.doGetGroups("evgeny")).containsOnly("sonar-users", "sonar-developers");
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void shouldNotReturnGroupsForNotExistingUsers() {
+ authenticator.doGetGroups("evgeny");
+ }
+
+ @Test
+ public void shouldParseList() {
+ assertThat(FakeAuthenticator.parseList(null)).isEmpty();
+ assertThat(FakeAuthenticator.parseList("")).isEmpty();
+ assertThat(FakeAuthenticator.parseList(",,,")).isEmpty();
+ assertThat(FakeAuthenticator.parseList("a,b")).containsOnly("a", "b");
+ }
+
+ @Test
+ public void shouldParseMap() {
+ Map<String, String> map = FakeAuthenticator.parse(null);
+ assertThat(map).isEmpty();
+
+ map = FakeAuthenticator.parse("");
+ assertThat(map).isEmpty();
+
+ map = FakeAuthenticator.parse("foo=bar");
+ assertThat(map).hasSize(1);
+ assertThat(map.get("foo")).isEqualTo("bar");
+
+ map = FakeAuthenticator.parse("foo=bar\r\nbaz=qux");
+ assertThat(map).hasSize(2);
+ assertThat(map.get("foo")).isEqualTo("bar");
+ assertThat(map.get("baz")).isEqualTo("qux");
+
+ map = FakeAuthenticator.parse("foo=bar\nbaz=qux");
+ assertThat(map).hasSize(2);
+ assertThat(map.get("foo")).isEqualTo("bar");
+ assertThat(map.get("baz")).isEqualTo("qux");
+
+ map = FakeAuthenticator.parse("foo=bar\n\n\nbaz=qux");
+ assertThat(map).hasSize(2);
+ assertThat(map.get("foo")).isEqualTo("bar");
+ assertThat(map.get("baz")).isEqualTo("qux");
+ }
+
+}
diff --git a/tests/plugins/server-plugin/pom.xml b/tests/plugins/server-plugin/pom.xml
new file mode 100644
index 00000000000..5d436a95a67
--- /dev/null
+++ b/tests/plugins/server-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>server-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>SonarQube Integration Tests :: Plugins :: Server</name>
+ <description>Main plugin for Server tests</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>ServerPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/server-plugin/src/main/java/ServerPlugin.java b/tests/plugins/server-plugin/src/main/java/ServerPlugin.java
new file mode 100644
index 00000000000..07aa1f861a2
--- /dev/null
+++ b/tests/plugins/server-plugin/src/main/java/ServerPlugin.java
@@ -0,0 +1,91 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyField;
+import org.sonar.api.SonarPlugin;
+
+import static org.sonar.api.PropertyType.BOOLEAN;
+import static org.sonar.api.PropertyType.FLOAT;
+import static org.sonar.api.PropertyType.INTEGER;
+import static org.sonar.api.PropertyType.LICENSE;
+import static org.sonar.api.PropertyType.LONG;
+import static org.sonar.api.PropertyType.METRIC;
+import static org.sonar.api.PropertyType.METRIC_LEVEL;
+import static org.sonar.api.PropertyType.PASSWORD;
+import static org.sonar.api.PropertyType.PROPERTY_SET;
+import static org.sonar.api.PropertyType.SINGLE_SELECT_LIST;
+import static org.sonar.api.PropertyType.STRING;
+import static org.sonar.api.PropertyType.TEXT;
+import static org.sonar.api.PropertyType.USER_LOGIN;
+
+@Properties({
+ @Property(key = "some-property", name = "Some Property", defaultValue = "aDefaultValue", global = true, project = false),
+ @Property(key = "boolean", name = "Boolean", defaultValue = "true", type = BOOLEAN, global = true, project = false),
+ @Property(key = "user", name = "User", type = USER_LOGIN, global = true, project = false),
+ @Property(key = "list", name = "List", type = SINGLE_SELECT_LIST, options = {"A", "B", "C"}, global = true, project = false),
+ @Property(key = "metric", name = "Metric", type = METRIC, global = true, project = false),
+ @Property(key = "metric_level", name = "Metric Level", type = METRIC_LEVEL, global = true, project = false),
+ @Property(key = "float", name = "Float", type = FLOAT, global = true, project = false),
+ @Property(key = "int", name = "Integer", type = INTEGER, global = true, project = false),
+ @Property(key = "string", name = "String", type = STRING, global = true, project = false),
+ @Property(key = "setting.license.secured", name = "License", type = LICENSE, global = true, project = false),
+ @Property(key = "long", name = "Long", type = LONG, global = true, project = false),
+ @Property(key = "password", name = "Password", type = PASSWORD, global = true, project = false),
+ @Property(key = "text", name = "Text", type = TEXT, global = true, project = false),
+ @Property(key = "multi", name = "Multi", type = STRING, multiValues = true, global = true, project = false),
+ @Property(key = "hidden", name = "Hidden", type = STRING, global = false, project = false),
+ @Property(key = "project.setting", name = "Project setting", type = STRING, global = false, project = true),
+ @Property(key = "setting.secured", name = "Secured", type = STRING, global = true, project = false),
+ @Property(key = "sonar.jira", name = "Jira Server", type = PROPERTY_SET, propertySetKey = "jira", fields = {
+ @PropertyField(key = "key", name = "Key", description = "Server key"),
+ @PropertyField(key = "type", name = "Type", options = {"A", "B"}),
+ @PropertyField(key = "url", name = "URL"),
+ @PropertyField(key = "port", name = "Port", type = INTEGER)}),
+})
+public class ServerPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(
+ StartupCrash.class, TempFolderExtension.class);
+ }
+}
diff --git a/tests/plugins/server-plugin/src/main/java/StartupCrash.java b/tests/plugins/server-plugin/src/main/java/StartupCrash.java
new file mode 100644
index 00000000000..cf57ccbc653
--- /dev/null
+++ b/tests/plugins/server-plugin/src/main/java/StartupCrash.java
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.config.Settings;
+import org.sonar.api.server.ServerSide;
+
+
+@ServerSide
+public class StartupCrash {
+
+ private final Settings settings;
+
+ public StartupCrash(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void start() {
+ if (settings.getBoolean("failAtStartup")) {
+ throw new IllegalStateException("Error in plugin [server]");
+ }
+ }
+
+ public void stop() {
+
+ }
+}
diff --git a/tests/plugins/server-plugin/src/main/java/TempFolderExtension.java b/tests/plugins/server-plugin/src/main/java/TempFolderExtension.java
new file mode 100644
index 00000000000..ddddf9d44de
--- /dev/null
+++ b/tests/plugins/server-plugin/src/main/java/TempFolderExtension.java
@@ -0,0 +1,59 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.config.Settings;
+import org.sonar.api.utils.TempFolder;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+@Properties({
+ @Property(
+ key = TempFolderExtension.CREATE_TEMP_FILES,
+ type = PropertyType.BOOLEAN,
+ name = "Property to decide if it should create temp files",
+ defaultValue = "false")
+})
+public class TempFolderExtension implements ServerExtension {
+
+ private static final Logger LOG = Loggers.get(TempFolderExtension.class);
+
+ public static final String CREATE_TEMP_FILES = "sonar.createTempFiles";
+
+ private Settings settings;
+
+ private TempFolder tempFolder;
+
+ public TempFolderExtension(Settings settings, TempFolder tempFolder) {
+ this.settings = settings;
+ this.tempFolder = tempFolder;
+ start();
+ }
+
+ public void start() {
+ if (settings.getBoolean(CREATE_TEMP_FILES)) {
+ LOG.info("Creating temp directory: " + tempFolder.newDir("sonar-it").getAbsolutePath());
+ LOG.info("Creating temp file: " + tempFolder.newFile("sonar-it", ".txt").getAbsolutePath());
+ }
+ }
+
+}
diff --git a/tests/plugins/settings-encryption-plugin/pom.xml b/tests/plugins/settings-encryption-plugin/pom.xml
new file mode 100644
index 00000000000..de124bc6ea3
--- /dev/null
+++ b/tests/plugins/settings-encryption-plugin/pom.xml
@@ -0,0 +1,36 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>settings-encryption-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Settings Encryption</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>SettingsEncryptionPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/settings-encryption-plugin/src/main/java/EncryptionVerifier.java b/tests/plugins/settings-encryption-plugin/src/main/java/EncryptionVerifier.java
new file mode 100644
index 00000000000..64a5f686a9a
--- /dev/null
+++ b/tests/plugins/settings-encryption-plugin/src/main/java/EncryptionVerifier.java
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.BatchExtension;
+import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.config.Settings;
+
+@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
+public class EncryptionVerifier implements BatchExtension {
+ private Settings settings;
+
+ public EncryptionVerifier(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void start() {
+ if (settings.hasKey("encryptedProperty")) {
+ System.out.println("Start EncryptionVerifier");
+
+ String decryptedValue = settings.getString("encryptedProperty");
+ if (!"this is a secret".equals(decryptedValue)) {
+ throw new IllegalStateException("The property 'encryptedProperty' can not be decrypted");
+ }
+ }
+ }
+}
diff --git a/tests/plugins/settings-encryption-plugin/src/main/java/SettingsEncryptionPlugin.java b/tests/plugins/settings-encryption-plugin/src/main/java/SettingsEncryptionPlugin.java
new file mode 100644
index 00000000000..f387aa353a1
--- /dev/null
+++ b/tests/plugins/settings-encryption-plugin/src/main/java/SettingsEncryptionPlugin.java
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.SonarPlugin;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class SettingsEncryptionPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(EncryptionVerifier.class);
+ }
+}
diff --git a/tests/plugins/settings-plugin/pom.xml b/tests/plugins/settings-plugin/pom.xml
new file mode 100644
index 00000000000..3712468e44f
--- /dev/null
+++ b/tests/plugins/settings-plugin/pom.xml
@@ -0,0 +1,40 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>settings-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Settings</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>SettingsPlugin</pluginClass>
+ <pluginName>Settings</pluginName>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/settings-plugin/src/main/java/PropertyTypes.java b/tests/plugins/settings-plugin/src/main/java/PropertyTypes.java
new file mode 100644
index 00000000000..6af745cf3a3
--- /dev/null
+++ b/tests/plugins/settings-plugin/src/main/java/PropertyTypes.java
@@ -0,0 +1,35 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.ServerExtension;
+
+@Properties({
+ @Property(key = "boolean", name = "Boolean", type=PropertyType.BOOLEAN),
+ @Property(key = "integer", name = "Integer", type=PropertyType.INTEGER),
+ @Property(key = "float", name = "Float", type=PropertyType.FLOAT),
+ @Property(key = "password", name = "Password", type=PropertyType.PASSWORD, defaultValue = "sonar"),
+ @Property(key = "text", name = "Text", type=PropertyType.TEXT),
+ @Property(key = "metric", name = "Metric", type=PropertyType.METRIC),
+ @Property(key = "single_select_list", name = "Single Select List", type=PropertyType.SINGLE_SELECT_LIST, options = {"de", "en", "nl"})
+})
+public class PropertyTypes implements ServerExtension {
+}
diff --git a/tests/plugins/settings-plugin/src/main/java/ServerExtensionWithProperties.java b/tests/plugins/settings-plugin/src/main/java/ServerExtensionWithProperties.java
new file mode 100644
index 00000000000..c01936636a5
--- /dev/null
+++ b/tests/plugins/settings-plugin/src/main/java/ServerExtensionWithProperties.java
@@ -0,0 +1,43 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.config.Settings;
+
+@Properties({
+ @Property(key = "settings.extension.hidden", name = "Hidden Property", description = "Hidden Property defined on extension but not plugin", global = false, project = false, module = false, defaultValue = "teahupoo"),
+ @Property(key = "settings.extension.global", name = "Global Property", global = true, project = false, module = false)
+})
+public final class ServerExtensionWithProperties implements ServerExtension {
+
+ private Settings settings;
+
+ public ServerExtensionWithProperties(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void start() {
+ System.out.println("Test that the default value of properties are automatically injected by the component Settings");
+ if (!"teahupoo".equals(settings.getString("settings.extension.hidden"))) {
+ throw new IllegalStateException("The property settings.extension.hidden is not registered");
+ }
+ }
+}
diff --git a/tests/plugins/settings-plugin/src/main/java/SettingsPlugin.java b/tests/plugins/settings-plugin/src/main/java/SettingsPlugin.java
new file mode 100644
index 00000000000..919c2960f2c
--- /dev/null
+++ b/tests/plugins/settings-plugin/src/main/java/SettingsPlugin.java
@@ -0,0 +1,28 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public class SettingsPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(ServerExtensionWithProperties.class, PropertyTypes.class);
+ }
+}
diff --git a/tests/plugins/sonar-fake-plugin/pom.xml b/tests/plugins/sonar-fake-plugin/pom.xml
new file mode 100644
index 00000000000..3865b628fa5
--- /dev/null
+++ b/tests/plugins/sonar-fake-plugin/pom.xml
@@ -0,0 +1,40 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>sonar-fake-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>Plugins :: Fake</name>
+ <description>SonarQube Integration Tests :: Fake Plugin</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <configuration>
+ <pluginClass>FakePlugin</pluginClass>
+ <pluginKey>fake</pluginKey>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/sonar-fake-plugin/src/main/java/FakePlugin.java b/tests/plugins/sonar-fake-plugin/src/main/java/FakePlugin.java
new file mode 100644
index 00000000000..9cb009a8f1e
--- /dev/null
+++ b/tests/plugins/sonar-fake-plugin/src/main/java/FakePlugin.java
@@ -0,0 +1,31 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.SonarPlugin;
+
+import java.util.Collections;
+import java.util.List;
+
+public final class FakePlugin extends SonarPlugin {
+
+ public List getExtensions() {
+ return Collections.emptyList();
+ }
+
+}
diff --git a/tests/plugins/sonar-subcategories-plugin/pom.xml b/tests/plugins/sonar-subcategories-plugin/pom.xml
new file mode 100644
index 00000000000..b5c4d007667
--- /dev/null
+++ b/tests/plugins/sonar-subcategories-plugin/pom.xml
@@ -0,0 +1,58 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>sonar-subcategories-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+
+ <name>Plugins :: SubCategories</name>
+ <description>Plugins :: SubCategories</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>SubCategoriesPlugin</pluginClass>
+ </configuration>
+ </plugin>
+
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>native2ascii-maven-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>native2ascii</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/sonar-subcategories-plugin/src/main/java/SubCategoriesPlugin.java b/tests/plugins/sonar-subcategories-plugin/src/main/java/SubCategoriesPlugin.java
new file mode 100644
index 00000000000..51681289401
--- /dev/null
+++ b/tests/plugins/sonar-subcategories-plugin/src/main/java/SubCategoriesPlugin.java
@@ -0,0 +1,80 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+import org.sonar.api.config.PropertyDefinition;
+import org.sonar.api.resources.Qualifiers;
+
+public class SubCategoriesPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(
+ PropertyDefinition.builder("prop1")
+ .index(2)
+ .category("Category 1")
+ .subCategory("Sub category 1")
+ .description("Foo")
+ .onQualifiers(Qualifiers.PROJECT)
+ .build(),
+ PropertyDefinition.builder("prop2")
+ .index(1)
+ // SONAR-4501 category are case insensitive
+ .category("category 1")
+ .subCategory("Sub category 1")
+ .description("Foo")
+ .onQualifiers(Qualifiers.PROJECT)
+ .build(),
+ PropertyDefinition.builder("prop3")
+ .category("Category 1")
+ .subCategory("Sub category 2")
+ .description("Foo")
+ .onQualifiers(Qualifiers.PROJECT)
+ .build(),
+ PropertyDefinition.builder("prop5")
+ .category("Category 1")
+ // SONAR-4501 subcategory are case insensitive
+ .subCategory("sub category 2")
+ .description("Foo")
+ .onQualifiers(Qualifiers.PROJECT)
+ .build(),
+ PropertyDefinition.builder("prop4")
+ .category("Category 1")
+ .description("Foo")
+ .onQualifiers(Qualifiers.PROJECT)
+ .build(),
+ PropertyDefinition.builder("prop2_1")
+ .category("Category 2")
+ .subCategory("Sub category 1 of 2")
+ .description("Foo")
+ .onQualifiers(Qualifiers.PROJECT)
+ .build(),
+ PropertyDefinition.builder("prop2_2")
+ .category("Category 2")
+ .subCategory("Sub category 2 of 2")
+ .description("Foo")
+ .onQualifiers(Qualifiers.PROJECT)
+ .build(),
+ PropertyDefinition.builder("prop_only_on_project")
+ .category("project-only")
+ .description("Foo")
+ .onlyOnQualifiers(Qualifiers.PROJECT)
+ .build());
+ }
+}
diff --git a/tests/plugins/sonar-subcategories-plugin/src/main/resources/org/sonar/l10n/subcategories.properties b/tests/plugins/sonar-subcategories-plugin/src/main/resources/org/sonar/l10n/subcategories.properties
new file mode 100644
index 00000000000..c5cba9d826c
--- /dev/null
+++ b/tests/plugins/sonar-subcategories-plugin/src/main/resources/org/sonar/l10n/subcategories.properties
@@ -0,0 +1,3 @@
+property.category.category\ 1=Category 1
+property.category.category\ 1.sub\ category\ 1=Sub category 1
+property.category.category\ 1.sub\ category\ 2=Sub category 2
diff --git a/tests/plugins/ui-extensions-plugin/pom.xml b/tests/plugins/ui-extensions-plugin/pom.xml
new file mode 100644
index 00000000000..8862aa011da
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>ui-extensions-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>SonarQube Integration Tests :: Plugins :: UI extensions</name>
+ <description>Main plugin for UT extensions tests</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>UiExtensionsPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java b/tests/plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java
new file mode 100644
index 00000000000..8c26c046b0b
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java
@@ -0,0 +1,48 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import org.sonar.api.Plugin;
+
+public class UiExtensionsPlugin implements Plugin {
+ @Override
+ public void define(Context context) {
+ context.addExtension(UiPageDefinition.class);
+ }
+}
diff --git a/tests/plugins/ui-extensions-plugin/src/main/java/UiPageDefinition.java b/tests/plugins/ui-extensions-plugin/src/main/java/UiPageDefinition.java
new file mode 100644
index 00000000000..6bcddd7c721
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/java/UiPageDefinition.java
@@ -0,0 +1,59 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import org.sonar.api.web.page.Context;
+import org.sonar.api.web.page.Page;
+import org.sonar.api.web.page.PageDefinition;
+
+import static org.sonar.api.web.page.Page.Scope.COMPONENT;
+import static org.sonar.api.web.page.Page.Scope.ORGANIZATION;
+
+public class UiPageDefinition implements PageDefinition {
+ @Override
+ public void define(Context context) {
+ context
+ .addPage(Page.builder("uiextensionsplugin/global_page").setName("Global Page").build())
+ .addPage(Page.builder("uiextensionsplugin/global_admin_page").setName("Global Admin Page").setAdmin(true).build())
+ .addPage(Page.builder("uiextensionsplugin/project_page").setName("Project Page").setScope(COMPONENT).build())
+ .addPage(Page.builder("uiextensionsplugin/project_admin_page").setName("Project Admin Page").setScope(COMPONENT).setAdmin(true).build())
+ .addPage(Page.builder("uiextensionsplugin/organization_page").setName("Organization Page").setScope(ORGANIZATION).build())
+ .addPage(Page.builder("uiextensionsplugin/organization_admin_page").setName("Organization Admin Page").setScope(ORGANIZATION).setAdmin(true).build());
+ }
+}
diff --git a/tests/plugins/ui-extensions-plugin/src/main/resources/static/cute.jpg b/tests/plugins/ui-extensions-plugin/src/main/resources/static/cute.jpg
new file mode 100644
index 00000000000..20f59bc1c42
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/resources/static/cute.jpg
Binary files differ
diff --git a/tests/plugins/ui-extensions-plugin/src/main/resources/static/extension.js b/tests/plugins/ui-extensions-plugin/src/main/resources/static/extension.js
new file mode 100644
index 00000000000..fd35455a4ea
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/resources/static/extension.js
@@ -0,0 +1,2 @@
+function hello() {
+}
diff --git a/tests/plugins/ui-extensions-plugin/src/main/resources/static/file.html b/tests/plugins/ui-extensions-plugin/src/main/resources/static/file.html
new file mode 100644
index 00000000000..6b0300e5f19
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/resources/static/file.html
@@ -0,0 +1,6 @@
+<html>
+ <body>
+ Text from static resource
+ <img id="cute-image" src="cute.jpg"/>
+ </body>
+</html>
diff --git a/tests/plugins/ui-extensions-plugin/src/main/resources/static/global_admin_page.js b/tests/plugins/ui-extensions-plugin/src/main/resources/static/global_admin_page.js
new file mode 100644
index 00000000000..18c70548fa8
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/resources/static/global_admin_page.js
@@ -0,0 +1,4 @@
+window.registerExtension('uiextensionsplugin/global_admin_page', function (options) {
+ options.el.textContent = 'uiextensionsplugin/global_admin_page';
+ return function () {};
+});
diff --git a/tests/plugins/ui-extensions-plugin/src/main/resources/static/global_page.js b/tests/plugins/ui-extensions-plugin/src/main/resources/static/global_page.js
new file mode 100644
index 00000000000..b60b5588c03
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/resources/static/global_page.js
@@ -0,0 +1,4 @@
+window.registerExtension('uiextensionsplugin/global_page', function (options) {
+ options.el.textContent = 'uiextensionsplugin/global_page';
+ return function () {};
+});
diff --git a/tests/plugins/ui-extensions-plugin/src/main/resources/static/organization_admin_page.js b/tests/plugins/ui-extensions-plugin/src/main/resources/static/organization_admin_page.js
new file mode 100644
index 00000000000..a3f740d8823
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/resources/static/organization_admin_page.js
@@ -0,0 +1,4 @@
+window.registerExtension('uiextensionsplugin/organization_admin_page', function (options) {
+ options.el.textContent = 'uiextensionsplugin/organization_admin_page';
+ return function () {};
+});
diff --git a/tests/plugins/ui-extensions-plugin/src/main/resources/static/organization_page.js b/tests/plugins/ui-extensions-plugin/src/main/resources/static/organization_page.js
new file mode 100644
index 00000000000..50c7e242f12
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/resources/static/organization_page.js
@@ -0,0 +1,4 @@
+window.registerExtension('uiextensionsplugin/organization_page', function (options) {
+ options.el.textContent = 'uiextensionsplugin/organization_page';
+ return function () {};
+}); \ No newline at end of file
diff --git a/tests/plugins/ui-extensions-plugin/src/main/resources/static/project_admin_page.js b/tests/plugins/ui-extensions-plugin/src/main/resources/static/project_admin_page.js
new file mode 100644
index 00000000000..bc632ea0a85
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/resources/static/project_admin_page.js
@@ -0,0 +1,4 @@
+window.registerExtension('uiextensionsplugin/project_admin_page', function (options) {
+ options.el.textContent = 'uiextensionsplugin/project_admin_page';
+ return function () {};
+});
diff --git a/tests/plugins/ui-extensions-plugin/src/main/resources/static/project_page.js b/tests/plugins/ui-extensions-plugin/src/main/resources/static/project_page.js
new file mode 100644
index 00000000000..1e28dace449
--- /dev/null
+++ b/tests/plugins/ui-extensions-plugin/src/main/resources/static/project_page.js
@@ -0,0 +1,4 @@
+window.registerExtension('uiextensionsplugin/project_page', function (options) {
+ options.el.textContent = 'uiextensionsplugin/project_page';
+ return function () {};
+}); \ No newline at end of file
diff --git a/tests/plugins/ws-plugin/pom.xml b/tests/plugins/ws-plugin/pom.xml
new file mode 100644
index 00000000000..ff9df700886
--- /dev/null
+++ b/tests/plugins/ws-plugin/pom.xml
@@ -0,0 +1,43 @@
+<?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.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>ws-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>SonarQube Integration Tests :: Plugins :: Ws</name>
+ <description>Plugin for WS tests</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-ws</artifactId>
+ <version>${apiVersion}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>WsPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/ws-plugin/src/main/java/LocalCallWebService.java b/tests/plugins/ws-plugin/src/main/java/LocalCallWebService.java
new file mode 100644
index 00000000000..7de752bba25
--- /dev/null
+++ b/tests/plugins/ws-plugin/src/main/java/LocalCallWebService.java
@@ -0,0 +1,84 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.RequestHandler;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonarqube.ws.MediaTypes;
+import org.sonarqube.ws.WsCe;
+import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.LocalWsClientFactory;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.WsResponse;
+
+public final class LocalCallWebService implements WebService {
+
+ private final LocalWsClientFactory wsClientFactory;
+
+ public LocalCallWebService(LocalWsClientFactory wsClientFactory) {
+ this.wsClientFactory = wsClientFactory;
+ }
+
+ @Override
+ public void define(Context context) {
+ NewController controller = context.createController("local_ws_call");
+ controller.createAction("protobuf_data").setHandler(new ProtobufHandler());
+ controller.createAction("json_data").setHandler(new JsonHandler());
+ controller.createAction("require_permission").setHandler(new RequirePermissionHandler());
+ controller.done();
+ }
+
+ private class ProtobufHandler implements RequestHandler {
+ @Override
+ public void handle(Request request, Response response) throws Exception {
+ WsClient client = wsClientFactory.newClient(request.localConnector());
+
+ WsCe.TaskTypesWsResponse ceTaskTypes = client.ce().taskTypes();
+ response.stream().setStatus(ceTaskTypes.getTaskTypesCount() > 0 ? 200 : 500);
+ }
+ }
+
+ private class JsonHandler implements RequestHandler {
+ @Override
+ public void handle(Request request, Response response) throws Exception {
+ WsClient client = wsClientFactory.newClient(request.localConnector());
+
+ WsResponse jsonResponse = client.wsConnector().call(new GetRequest("api/issues/search"));
+ boolean ok = jsonResponse.contentType().equals(MediaTypes.JSON)
+ && jsonResponse.isSuccessful()
+ && jsonResponse.content().contains("\"issues\":");
+ response.stream().setStatus(ok ? 200 : 500);
+ }
+ }
+
+ private class RequirePermissionHandler implements RequestHandler {
+ @Override
+ public void handle(Request request, Response response) throws Exception {
+ WsClient client = wsClientFactory.newClient(request.localConnector());
+
+ WsResponse jsonResponse = client.wsConnector().call(new GetRequest("api/system/info"));
+
+ boolean ok = MediaTypes.JSON.equals(jsonResponse.contentType())
+ && jsonResponse.isSuccessful()
+ && jsonResponse.content().startsWith("{");
+ response.stream().setStatus(ok ? 200 : 500);
+ }
+ }
+}
diff --git a/tests/plugins/ws-plugin/src/main/java/WsPlugin.java b/tests/plugins/ws-plugin/src/main/java/WsPlugin.java
new file mode 100644
index 00000000000..e36a8551d0e
--- /dev/null
+++ b/tests/plugins/ws-plugin/src/main/java/WsPlugin.java
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+import org.sonarqube.ws.client.WsClientFactories;
+
+public class WsPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(LocalCallWebService.class, WsClientFactories.getLocal());
+ }
+}