aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-09-04 16:07:22 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-09-05 12:07:45 +0200
commit46063d6f8b23ac3f133e8a844811144b692dd2c2 (patch)
treea8451fda7d520032969158f5d2326544397d7bc0 /tests
parent11faca4d8e29d95ef37da7e18b86d6e79e685eee (diff)
downloadsonarqube-46063d6f8b23ac3f133e8a844811144b692dd2c2.tar.gz
sonarqube-46063d6f8b23ac3f133e8a844811144b692dd2c2.zip
SONAR-9426 Set external identity info when reactivating local user
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java b/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java
index 662c0c22506..d5b8a50240c 100644
--- a/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java
@@ -31,6 +31,7 @@ import org.sonarqube.pageobjects.Navigation;
import org.sonarqube.tests.Category4Suite;
import org.sonarqube.tests.Tester;
import org.sonarqube.ws.WsUserTokens;
+import org.sonarqube.ws.WsUsers;
import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.HttpConnector;
@@ -38,12 +39,14 @@ import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.WsClientFactories;
import org.sonarqube.ws.client.WsResponse;
+import org.sonarqube.ws.client.user.CreateRequest;
import org.sonarqube.ws.client.usertoken.GenerateWsRequest;
import org.sonarqube.ws.client.usertoken.RevokeWsRequest;
import org.sonarqube.ws.client.usertoken.SearchWsRequest;
import org.sonarqube.ws.client.usertoken.UserTokensService;
import static java.lang.String.format;
+import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.resetSettings;
import static util.ItUtils.setServerProperty;
@@ -228,6 +231,26 @@ public class LocalAuthenticationTest {
assertThat(checkAuthenticationWithAnyWS(null, null).code()).isEqualTo(401);
}
+ @Test
+ public void authenticate_on_user_that_was_disabled() {
+ User user = tester.users().generate(u -> u.setLogin("test").setPassword("password"));
+ tester.users().service().deactivate(user.getLogin());
+
+ tester.users().service().create(CreateRequest.builder()
+ .setLogin("test")
+ .setName("Test")
+ .setEmail("test@email.com")
+ .setScmAccounts(asList("test1", "test2"))
+ .setPassword("password")
+ .build());
+
+ assertThat(checkAuthenticationWithAuthenticateWebService("test", "password")).isTrue();
+ assertThat(tester.users().getByLogin("test").get())
+ .extracting(WsUsers.SearchWsResponse.User::getLogin, WsUsers.SearchWsResponse.User::getName, WsUsers.SearchWsResponse.User::getEmail, u -> u.getScmAccounts().getScmAccountsList(),
+ WsUsers.SearchWsResponse.User::getExternalIdentity, WsUsers.SearchWsResponse.User::getExternalProvider)
+ .containsOnly("test", "Test", "test@email.com", asList("test1", "test2"), "test", "sonarqube");
+ }
+
private boolean checkAuthenticationWithAuthenticateWebService(String login, String password) {
String result = tester.as(login, password).wsClient().wsConnector().call(new PostRequest("/api/authentication/validate")).content();
return result.contains("{\"valid\":true}");