use of org.sonar.db.user.GroupDto 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.GroupDto 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.GroupDto 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.GroupDto in project sonarqube by SonarSource.
the class SearchActionTest method search_in_organization.
@Test
public void search_in_organization() throws Exception {
OrganizationDto org = db.organizations().insert();
GroupDto group = db.users().insertGroup(org, "users");
// the group in default org is not returned
db.users().insertGroup(db.getDefaultOrganization(), "users");
loginAsDefaultOrgAdmin();
userSession.addPermission(ADMINISTER, org);
newRequest().setParam("organization", org.getKey()).execute().assertJson("{\"total\":1,\"p\":1,\"ps\":100," + "\"groups\":[{\"id\":\"" + group.getId() + "\",\"name\":\"users\"}]}\n");
}
use of org.sonar.db.user.GroupDto 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