use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class UserUpdaterTest method update_only_user_password.
@Test
public void update_only_user_password() {
db.users().insertUser(newLocalUser(DEFAULT_LOGIN, "Marius", "marius@lesbronzes.fr").setScmAccounts(asList("ma", "marius33")).setSalt("salt").setCryptedPassword("crypted password").setCreatedAt(PAST).setUpdatedAt(PAST));
createDefaultGroup();
underTest.update(session, UpdateUser.create(DEFAULT_LOGIN).setPassword("password2"));
session.commit();
UserDto dto = dbClient.userDao().selectByLogin(session, DEFAULT_LOGIN);
assertThat(dto.getSalt()).isNotEqualTo("salt");
assertThat(dto.getCryptedPassword()).isNotEqualTo("crypted password");
// Following fields has not changed
assertThat(dto.getName()).isEqualTo("Marius");
assertThat(dto.getScmAccountsAsList()).containsOnly("ma", "marius33");
assertThat(dto.getEmail()).isEqualTo("marius@lesbronzes.fr");
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class DeactivateActionTest method cannot_deactivate_self.
@Test
public void cannot_deactivate_self() throws Exception {
UserDto user = createUser();
userSession.logIn(user.getLogin()).setSystemAdministrator();
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Self-deactivation is not possible");
deactivate(user.getLogin());
verifyThatUserExists(user.getLogin());
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class GroupsActionTest method selected_groups.
@Test
public void selected_groups() throws Exception {
UserDto user = createUser();
GroupDto usersGroup = createGroup("sonar-users", "Sonar Users");
createGroup("sonar-admins", "Sonar Admins");
addUserToGroup(user, usersGroup);
session.commit();
tester.newGetRequest("api/users", "groups").setParam("login", "john").execute().assertJson(getClass(), "selected.json");
tester.newGetRequest("api/users", "groups").setParam("login", "john").setParam(Param.SELECTED, SelectionMode.SELECTED.value()).execute().assertJson(getClass(), "selected.json");
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class GroupsActionTest method all_groups.
@Test
public void all_groups() throws Exception {
UserDto user = createUser();
GroupDto usersGroup = createGroup("sonar-users", "Sonar Users");
createGroup("sonar-admins", "Sonar Admins");
addUserToGroup(user, usersGroup);
session.commit();
tester.newGetRequest("api/users", "groups").setParam("login", "john").setParam(Param.SELECTED, SelectionMode.ALL.value()).execute().assertJson(getClass(), "all.json");
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class SearchActionTest method search_with_groups.
@Test
public void search_with_groups() throws Exception {
loginAsSystemAdministrator();
List<UserDto> users = injectUsers(1);
GroupDto group1 = dbClient.groupDao().insert(dbSession, newGroupDto().setName("sonar-users"));
GroupDto group2 = dbClient.groupDao().insert(dbSession, newGroupDto().setName("sonar-admins"));
dbClient.userGroupDao().insert(dbSession, new UserGroupDto().setGroupId(group1.getId()).setUserId(users.get(0).getId()));
dbClient.userGroupDao().insert(dbSession, new UserGroupDto().setGroupId(group2.getId()).setUserId(users.get(0).getId()));
dbSession.commit();
ws.newGetRequest("api/users", "search").execute().assertJson(getClass(), "user_with_groups.json");
}
Aggregations