Search in sources :

Example 1 with UserIndex

use of org.sonar.server.user.index.UserIndex in project sonarqube by SonarSource.

the class ScmAccountToUserLoaderTest method load_by_multiple_scm_accounts_is_not_supported_yet.

@Test
public void load_by_multiple_scm_accounts_is_not_supported_yet() {
    UserIndex index = new UserIndex(esTester.client());
    ScmAccountToUserLoader underTest = new ScmAccountToUserLoader(index);
    try {
        underTest.loadAll(Collections.<String>emptyList());
        fail();
    } catch (UnsupportedOperationException ignored) {
    }
}
Also used : UserIndex(org.sonar.server.user.index.UserIndex) Test(org.junit.Test)

Example 2 with UserIndex

use of org.sonar.server.user.index.UserIndex in project sonarqube by SonarSource.

the class ScmAccountToUserLoaderTest method load_login_for_scm_account.

@Test
public void load_login_for_scm_account() throws Exception {
    UserDoc user = new UserDoc().setLogin("charlie").setName("Charlie").setEmail("charlie@hebdo.com").setActive(true).setScmAccounts(asList("charlie", "jesuis@charlie.com"));
    esTester.putDocuments(UserIndexDefinition.INDEX_TYPE_USER.getIndex(), UserIndexDefinition.INDEX_TYPE_USER.getType(), user);
    UserIndex index = new UserIndex(esTester.client());
    ScmAccountToUserLoader underTest = new ScmAccountToUserLoader(index);
    assertThat(underTest.load("missing")).isNull();
    assertThat(underTest.load("jesuis@charlie.com")).isEqualTo("charlie");
}
Also used : UserIndex(org.sonar.server.user.index.UserIndex) UserDoc(org.sonar.server.user.index.UserDoc) Test(org.junit.Test)

Example 3 with UserIndex

use of org.sonar.server.user.index.UserIndex in project sonarqube by SonarSource.

the class ScmAccountToUserLoaderTest method warn_if_multiple_users_share_the_same_scm_account.

@Test
public void warn_if_multiple_users_share_the_same_scm_account() throws Exception {
    UserDoc user1 = new UserDoc().setLogin("charlie").setName("Charlie").setEmail("charlie@hebdo.com").setActive(true).setScmAccounts(asList("charlie", "jesuis@charlie.com"));
    esTester.putDocuments(UserIndexDefinition.INDEX_TYPE_USER.getIndex(), UserIndexDefinition.INDEX_TYPE_USER.getType(), user1);
    UserDoc user2 = new UserDoc().setLogin("another.charlie").setName("Another Charlie").setActive(true).setScmAccounts(asList("charlie"));
    esTester.putDocuments(UserIndexDefinition.INDEX_TYPE_USER.getIndex(), UserIndexDefinition.INDEX_TYPE_USER.getType(), user2);
    UserIndex index = new UserIndex(esTester.client());
    ScmAccountToUserLoader underTest = new ScmAccountToUserLoader(index);
    assertThat(underTest.load("charlie")).isNull();
    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Multiple users share the SCM account 'charlie': another.charlie, charlie");
}
Also used : UserIndex(org.sonar.server.user.index.UserIndex) UserDoc(org.sonar.server.user.index.UserDoc) Test(org.junit.Test)

Example 4 with UserIndex

use of org.sonar.server.user.index.UserIndex in project sonarqube by SonarSource.

the class DeactivateActionTest method setUp.

@Before
public void setUp() {
    userIndexer = new UserIndexer(dbClient, esTester.client());
    index = new UserIndex(esTester.client());
    userIndexer = new UserIndexer(dbClient, esTester.client());
    ws = new WsActionTester(new DeactivateAction(dbClient, userIndexer, userSession, new UserJsonWriter(userSession), defaultOrganizationProvider));
}
Also used : UserIndex(org.sonar.server.user.index.UserIndex) UserIndexer(org.sonar.server.user.index.UserIndexer) WsActionTester(org.sonar.server.ws.WsActionTester) Before(org.junit.Before)

Example 5 with UserIndex

use of org.sonar.server.user.index.UserIndex in project sonarqube by SonarSource.

the class UsersActionTest method before.

@Before
public void before() {
    userIndex = new UserIndex(es.client());
    usersAction = new UsersAction(userIndex, userSessionRule);
    tester = new WsTester(new BatchWs(usersAction));
}
Also used : UserIndex(org.sonar.server.user.index.UserIndex) WsTester(org.sonar.server.ws.WsTester) Before(org.junit.Before)

Aggregations

UserIndex (org.sonar.server.user.index.UserIndex)7 Before (org.junit.Before)4 UserDoc (org.sonar.server.user.index.UserDoc)4 Test (org.junit.Test)3 Locale (java.util.Locale)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 EmailSettings (org.sonar.api.config.EmailSettings)2 DefaultI18n (org.sonar.core.i18n.DefaultI18n)2 Date (java.util.Date)1 UserIndexer (org.sonar.server.user.index.UserIndexer)1 WsActionTester (org.sonar.server.ws.WsActionTester)1 WsTester (org.sonar.server.ws.WsTester)1