use of org.sonar.server.user.index.UserDoc in project sonarqube by SonarSource.
the class UsersActionTest method return_minimal_fields.
@Test
public void return_minimal_fields() throws Exception {
es.putDocuments(UserIndexDefinition.INDEX_TYPE_USER.getIndex(), UserIndexDefinition.INDEX_TYPE_USER.getType(), new UserDoc().setLogin("ada.lovelace").setName("Ada Lovelace").setActive(false), new UserDoc().setLogin("grace.hopper").setName("Grace Hopper").setActive(true));
userSessionRule.logIn("sonarqtech");
WsTester.TestRequest request = tester.newGetRequest("batch", "users").setParam("logins", "ada.lovelace,grace.hopper");
ByteArrayInputStream input = new ByteArrayInputStream(request.execute().output());
User user1 = User.parseDelimitedFrom(input);
User user2 = User.parseDelimitedFrom(input);
assertThat(User.parseDelimitedFrom(input)).isNull();
List<User> users = Arrays.asList(user1, user2);
assertThat(users).extracting("login").containsOnly("ada.lovelace", "grace.hopper");
assertThat(users).extracting("name").containsOnly("Ada Lovelace", "Grace Hopper");
}
use of org.sonar.server.user.index.UserDoc in project sonarqube by SonarSource.
the class DefaultAssigneeTest method default_assignee.
@Test
public void default_assignee() {
settings.setProperty(CoreProperties.DEFAULT_ISSUE_ASSIGNEE, "erik");
when(userIndex.getNullableByLogin("erik")).thenReturn(new UserDoc().setLogin("erik").setActive(true));
assertThat(underTest.getLogin()).isEqualTo("erik");
}
use of org.sonar.server.user.index.UserDoc in project sonarqube by SonarSource.
the class DefaultAssigneeTest method configured_login_is_disabled.
@Test
public void configured_login_is_disabled() {
settings.setProperty(CoreProperties.DEFAULT_ISSUE_ASSIGNEE, "erik");
when(userIndex.getNullableByLogin("erik")).thenReturn(new UserDoc().setLogin("erik").setActive(false));
assertThat(underTest.getLogin()).isNull();
}
use of org.sonar.server.user.index.UserDoc 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");
}
use of org.sonar.server.user.index.UserDoc 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");
}
Aggregations