diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2018-06-18 10:55:55 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-06-21 20:21:30 +0200 |
commit | 2b14abe26e05418cb9bfe6a2ec12aad8b7f1bee7 (patch) | |
tree | 55105175deedd9bf3cedd626f96fec5b44e6705e /tests/plugins/base-auth-plugin | |
parent | 7a1963f09d9ff9fb917c7c79f87e23b9a5473ab1 (diff) | |
download | sonarqube-2b14abe26e05418cb9bfe6a2ec12aad8b7f1bee7.tar.gz sonarqube-2b14abe26e05418cb9bfe6a2ec12aad8b7f1bee7.zip |
move ITs code to private directory
Diffstat (limited to 'tests/plugins/base-auth-plugin')
-rw-r--r-- | tests/plugins/base-auth-plugin/build.gradle | 25 | ||||
-rw-r--r-- | tests/plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java | 32 | ||||
-rw-r--r-- | tests/plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java | 121 | ||||
-rw-r--r-- | tests/plugins/base-auth-plugin/src/main/resources/static/base.png | bin | 3112 -> 0 bytes | |||
-rw-r--r-- | tests/plugins/base-auth-plugin/src/resources/static/base.png | bin | 3112 -> 0 bytes |
5 files changed, 0 insertions, 178 deletions
diff --git a/tests/plugins/base-auth-plugin/build.gradle b/tests/plugins/base-auth-plugin/build.gradle deleted file mode 100644 index ecafb1c6182..00000000000 --- a/tests/plugins/base-auth-plugin/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -dependencies { - compile('com.google.guava:guava:17.0') { - exclude group: 'com.google.code.findbugs', module: 'jsr305' - } - compileOnly project(path: ':sonar-plugin-api', configuration: 'shadow') - compileOnly 'javax.servlet:javax.servlet-api:3.0.1' -} - -jar { - manifest { - attributes( - 'Plugin-Key': 'baseauthplugin', - 'Plugin-Version': version, - 'Plugin-Class': 'FakeBaseAuthPlugin', - 'Plugin-ChildFirstClassLoader': 'false', - 'Sonar-Version': version, - 'SonarLint-Supported': 'false', - 'Plugin-Name': 'Plugins :: Fake Base Authentication Plugin', - 'Plugin-License': 'GNU LGPL 3' - ) - } - into('META-INF/lib') { - from configurations.compile - } -} diff --git a/tests/plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java b/tests/plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java deleted file mode 100644 index df748891151..00000000000 --- a/tests/plugins/base-auth-plugin/src/main/java/FakeBaseAuthPlugin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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 deleted file mode 100644 index 85ebde21823..00000000000 --- a/tests/plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java +++ /dev/null @@ -1,121 +0,0 @@ - -/* - * SonarQube - * Copyright (C) 2009-2018 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(emptyToNull(userInfos[0])) - .setProviderId(emptyToNull(userInfos[1])) - .setProviderLogin(emptyToNull(userInfos[2])) - .setName(emptyToNull(userInfos[3])) - .setEmail(emptyToNull(userInfos[4])); - - 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; - } - - private static String emptyToNull(String s) { - if (s == null) { - return null; - } - String trim = s.trim(); - if (trim.isEmpty()) { - return null; - } - return trim; - } -} 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 Binary files differdeleted file mode 100644 index 217d2a0bdf8..00000000000 --- a/tests/plugins/base-auth-plugin/src/main/resources/static/base.png +++ /dev/null diff --git a/tests/plugins/base-auth-plugin/src/resources/static/base.png b/tests/plugins/base-auth-plugin/src/resources/static/base.png Binary files differdeleted file mode 100644 index 217d2a0bdf8..00000000000 --- a/tests/plugins/base-auth-plugin/src/resources/static/base.png +++ /dev/null |