diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-22 12:48:42 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-22 14:15:27 +0100 |
commit | 0958d15fb30f976e53dfc7492f2f361aaa412f47 (patch) | |
tree | d666497612162430d522600d9570bc2c836e0c65 /it/it-plugins | |
parent | 0cd6464c0bd4a472dc439a5cb62841ed48b9be9e (diff) | |
download | sonarqube-0958d15fb30f976e53dfc7492f2f361aaa412f47.tar.gz sonarqube-0958d15fb30f976e53dfc7492f2f361aaa412f47.zip |
SONAR-7448 Add ITs
Diffstat (limited to 'it/it-plugins')
-rw-r--r-- | it/it-plugins/base-auth-plugin/pom.xml | 12 | ||||
-rw-r--r-- | it/it-plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java | 15 |
2 files changed, 24 insertions, 3 deletions
diff --git a/it/it-plugins/base-auth-plugin/pom.xml b/it/it-plugins/base-auth-plugin/pom.xml index 7c1077d65da..4e2f631194d 100644 --- a/it/it-plugins/base-auth-plugin/pom.xml +++ b/it/it-plugins/base-auth-plugin/pom.xml @@ -28,6 +28,18 @@ <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> 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 index a7d897b137f..6a915d32b65 100644 --- a/it/it-plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java +++ b/it/it-plugins/base-auth-plugin/src/main/java/FakeBaseIdProvider.java @@ -24,10 +24,15 @@ 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"; @@ -50,13 +55,17 @@ public class FakeBaseIdProvider implements BaseIdentityProvider { } String[] userInfos = userInfoProperty.split(","); - context.authenticate(UserIdentity.builder() + UserIdentity.Builder builder = UserIdentity.builder() .setLogin(userInfos[0]) .setProviderLogin(userInfos[1]) .setName(userInfos[2]) - .setEmail(userInfos[3]) - .build()); + .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) { |