use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class UsersActionTest method fail_if_not_admin_of_organization.
@Test
public void fail_if_not_admin_of_organization() throws Exception {
GroupDto group = db.users().insertGroup();
userSession.logIn("not-admin");
expectedException.expect(ForbiddenException.class);
newUsersRequest().setParam("id", group.getId().toString()).setParam("login", "john").execute();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class CreateActionTest method add_group_with_a_name_that_already_exists_in_another_organization.
@Test
public void add_group_with_a_name_that_already_exists_in_another_organization() throws Exception {
String name = "the-group";
OrganizationDto org1 = db.organizations().insert();
OrganizationDto org2 = db.organizations().insert();
GroupDto group = db.users().insertGroup(org1, name);
loginAsAdmin(org2);
newRequest().setParam("organization", org2.getKey()).setParam("name", name).execute().assertJson("{" + " \"group\": {" + " \"organization\": \"" + org2.getKey() + "\"," + " \"name\": \"" + group.getName() + "\"," + " }" + "}");
assertThat(db.users().selectGroups(org1)).extracting(GroupDto::getName).containsOnly(name);
assertThat(db.users().selectGroups(org2)).extracting(GroupDto::getName).containsOnly(name);
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class CreateActionTest method fail_if_group_with_same_name_already_exists_in_the_organization.
@Test
public void fail_if_group_with_same_name_already_exists_in_the_organization() throws Exception {
OrganizationDto org = db.organizations().insert();
GroupDto group = db.users().insertGroup(org, "the-group");
loginAsAdmin(org);
expectedException.expect(ServerException.class);
expectedException.expectMessage("Group '" + group.getName() + "' already exists");
newRequest().setParam("organization", org.getKey()).setParam("name", group.getName()).execute();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class CreateActionTest method create_group_on_specific_organization.
@Test
public void create_group_on_specific_organization() throws Exception {
OrganizationDto org = db.organizations().insert();
loginAsAdmin(org);
newRequest().setParam("organization", org.getKey()).setParam("name", "some-product-bu").setParam("description", "Business Unit for Some Awesome Product").execute().assertJson("{" + " \"group\": {" + " \"organization\": \"" + org.getKey() + "\"," + " \"name\": \"some-product-bu\"," + " \"description\": \"Business Unit for Some Awesome Product\"," + " \"membersCount\": 0" + " }" + "}");
GroupDto createdGroup = db.users().selectGroup(org, "some-product-bu").get();
assertThat(createdGroup.getId()).isNotNull();
assertThat(createdGroup.getOrganizationUuid()).isEqualTo(org.getUuid());
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class DeleteActionTest method delete_by_name_on_default_organization.
@Test
public void delete_by_name_on_default_organization() throws Exception {
addAdminToDefaultOrganization();
GroupDto group = db.users().insertGroup();
loginAsAdminOnDefaultOrganization();
newRequest().setParam(PARAM_GROUP_NAME, group.getName()).execute().assertNoContent();
assertThat(db.users().selectGroupById(group.getId())).isNull();
}
Aggregations