use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class UpdateActionTest method update_only_scm_accounts_with_deprecated_scmAccounts_parameter.
@Test
public void update_only_scm_accounts_with_deprecated_scmAccounts_parameter() throws Exception {
createUser();
tester.newPostRequest("api/users", "update").setParam("login", "john").setParam("scmAccounts", "jon.snow").execute().assertJson(getClass(), "update_scm_accounts.json");
UserDto user = dbClient.userDao().selectByLogin(session, "john");
assertThat(user.getScmAccountsAsList()).containsOnly("jon.snow");
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class RemoveUserActionTest method remove_user_by_group_name_in_specific_organization.
@Test
public void remove_user_by_group_name_in_specific_organization() throws Exception {
OrganizationDto org = db.organizations().insert();
GroupDto group = db.users().insertGroup(org, "a_group");
UserDto user = db.users().insertUser("a_user");
db.users().insertMember(group, user);
// keep an administrator
db.users().insertAdminByUserPermission(org);
loginAsAdmin(org);
newRequest().setParam(PARAM_ORGANIZATION_KEY, org.getKey()).setParam(PARAM_GROUP_NAME, group.getName()).setParam(PARAM_LOGIN, user.getLogin()).execute().assertNoContent();
assertThat(db.users().selectGroupIdsOfUser(user)).isEmpty();
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class RemoveUserActionTest method remove_user_by_group_name_in_default_organization.
@Test
public void remove_user_by_group_name_in_default_organization() throws Exception {
insertAnAdministratorInDefaultOrganization();
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "a_group");
UserDto user = db.users().insertUser("a_user");
db.users().insertMember(group, user);
loginAsAdminOnDefaultOrganization();
newRequest().setParam(PARAM_GROUP_NAME, group.getName()).setParam(PARAM_LOGIN, user.getLogin()).execute().assertNoContent();
assertThat(db.users().selectGroupIdsOfUser(user)).isEmpty();
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class RemoveUserActionTest method throw_ForbiddenException_if_not_administrator_of_organization.
@Test
public void throw_ForbiddenException_if_not_administrator_of_organization() throws Exception {
OrganizationDto org = db.organizations().insert();
GroupDto group = db.users().insertGroup(org, "a-group");
UserDto user = db.users().insertUser();
db.users().insertMember(group, user);
loginAsAdminOnDefaultOrganization();
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("Insufficient privileges");
newRequest().setParam("id", group.getId().toString()).setParam("login", user.getLogin()).execute();
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class SearchActionTest method insertGroup.
private void insertGroup(OrganizationDto org, String name, int numberOfMembers) {
GroupDto group = newGroupDto().setName(name).setDescription(capitalize(name)).setOrganizationUuid(org.getUuid());
db.users().insertGroup(group);
for (int i = 0; i < numberOfMembers; i++) {
UserDto user = db.users().insertUser();
db.users().insertMember(group, user);
}
}
Aggregations