aboutsummaryrefslogtreecommitdiffstats
path: root/it/it-plugins
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-01-27 12:01:39 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-01-27 15:21:37 +0100
commit19e115ff1613edce231d59367c569993f0f4eb55 (patch)
tree8b8bef19643063a0890136e2430674222c3380a7 /it/it-plugins
parent354260c08f3a5246b4f937cd45ee55b21dcb7444 (diff)
downloadsonarqube-19e115ff1613edce231d59367c569993f0f4eb55.tar.gz
sonarqube-19e115ff1613edce231d59367c569993f0f4eb55.zip
SONAR-6226 Add ITs
Diffstat (limited to 'it/it-plugins')
-rw-r--r--it/it-plugins/base-auth-plugin/pom.xml45
-rw-r--r--it/it-plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java32
-rw-r--r--it/it-plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java80
-rw-r--r--it/it-plugins/base-auth-plugin/src/resources/static/base.pngbin0 -> 3112 bytes
-rw-r--r--it/it-plugins/oauth2-auth-plugin/pom.xml45
-rw-r--r--it/it-plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2AuthPlugin.java32
-rw-r--r--it/it-plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2IdProvider.java87
-rw-r--r--it/it-plugins/oauth2-auth-plugin/src/resources/static/base.pngbin0 -> 3112 bytes
-rw-r--r--it/it-plugins/pom.xml2
9 files changed, 323 insertions, 0 deletions
diff --git a/it/it-plugins/base-auth-plugin/pom.xml b/it/it-plugins/base-auth-plugin/pom.xml
new file mode 100644
index 00000000000..1674c8bab01
--- /dev/null
+++ b/it/it-plugins/base-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</groupId>
+ <artifactId>it-plugins</artifactId>
+ <version>5.4-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>
+ </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/it/it-plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java b/it/it-plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java
new file mode 100644
index 00000000000..b8638ada633
--- /dev/null
+++ b/it/it-plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java
@@ -0,0 +1,32 @@
+/*
+ * 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.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/it/it-plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java b/it/it-plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java
new file mode 100644
index 00000000000..e3d1051f3e2
--- /dev/null
+++ b/it/it-plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java
@@ -0,0 +1,80 @@
+/*
+ * 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.IOException;
+import org.sonar.api.config.Settings;
+import org.sonar.api.server.authentication.BaseIdentityProvider;
+import org.sonar.api.server.authentication.UserIdentity;
+
+public class FakeBaseIdProvider implements BaseIdentityProvider {
+
+ private static final String ENABLED = "sonar.auth.fake-base-id-provider.enabled";
+ private static final String USER_INFO = "sonar.auth.fake-base-id-provider.user";
+
+ 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));
+ }
+ String[] userInfos = userInfoProperty.split(",");
+ context.authenticate(UserIdentity.builder()
+ .setId(userInfos[0])
+ .setName(userInfos[1])
+ .setEmail(userInfos[2])
+ .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 String getIconPath() {
+ return "/static/baseauthplugin/base.png";
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return settings.getBoolean(ENABLED);
+ }
+
+ @Override
+ public boolean allowsUsersToSignUp() {
+ return true;
+ }
+}
diff --git a/it/it-plugins/base-auth-plugin/src/resources/static/base.png b/it/it-plugins/base-auth-plugin/src/resources/static/base.png
new file mode 100644
index 00000000000..217d2a0bdf8
--- /dev/null
+++ b/it/it-plugins/base-auth-plugin/src/resources/static/base.png
Binary files differ
diff --git a/it/it-plugins/oauth2-auth-plugin/pom.xml b/it/it-plugins/oauth2-auth-plugin/pom.xml
new file mode 100644
index 00000000000..ebf41114422
--- /dev/null
+++ b/it/it-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</groupId>
+ <artifactId>it-plugins</artifactId>
+ <version>5.4-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/it/it-plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2AuthPlugin.java b/it/it-plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2AuthPlugin.java
new file mode 100644
index 00000000000..5ad389cf78e
--- /dev/null
+++ b/it/it-plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2AuthPlugin.java
@@ -0,0 +1,32 @@
+/*
+ * 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.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/it/it-plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2IdProvider.java b/it/it-plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2IdProvider.java
new file mode 100644
index 00000000000..1044796442c
--- /dev/null
+++ b/it/it-plugins/oauth2-auth-plugin/src/main/java/FakeOAuth2IdProvider.java
@@ -0,0 +1,87 @@
+/*
+ * 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.config.Settings;
+import org.sonar.api.server.authentication.OAuth2IdentityProvider;
+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 URL = "sonar.auth.fake-oauth2-id-provider.url";
+ private static final String USER_INFO = "sonar.auth.fake-oauth2-id-provider.user";
+
+ 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));
+ }
+ String[] userInfos = userInfoProperty.split(",");
+ context.authenticate(UserIdentity.builder()
+ .setId(userInfos[0])
+ .setName(userInfos[1])
+ .setEmail(userInfos[2])
+ .build());
+ context.redirectToRequestedPage();
+ }
+
+ @Override
+ public String getKey() {
+ return "fake-oauth2-id-provider";
+ }
+
+ @Override
+ public String getName() {
+ return "Fake oauth2 identity provider";
+ }
+
+ @Override
+ public String getIconPath() {
+ return "/static/baseauthplugin/base.png";
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return settings.getBoolean(ENABLED);
+ }
+
+ @Override
+ public boolean allowsUsersToSignUp() {
+ return true;
+ }
+
+}
diff --git a/it/it-plugins/oauth2-auth-plugin/src/resources/static/base.png b/it/it-plugins/oauth2-auth-plugin/src/resources/static/base.png
new file mode 100644
index 00000000000..217d2a0bdf8
--- /dev/null
+++ b/it/it-plugins/oauth2-auth-plugin/src/resources/static/base.png
Binary files differ
diff --git a/it/it-plugins/pom.xml b/it/it-plugins/pom.xml
index 3e8bfca62ff..2c1733c29b8 100644
--- a/it/it-plugins/pom.xml
+++ b/it/it-plugins/pom.xml
@@ -31,12 +31,14 @@
<modules>
<module>access-secured-props-plugin</module>
+ <module>base-auth-plugin</module>
<module>batch-plugin</module>
<module>extension-lifecycle-plugin</module>
<module>global-property-change-plugin</module>
<module>issue-action-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>