use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class AddGroupActionTest method fail_if_administrator_of_other_organization_only.
@Test
public void fail_if_administrator_of_other_organization_only() throws Exception {
OrganizationDto org1 = db.organizations().insert();
OrganizationDto org2 = db.organizations().insert();
GroupDto group = db.users().insertGroup(org1, "the-group");
loginAsAdmin(org2);
expectedException.expect(ForbiddenException.class);
newRequest().setParam(PARAM_GROUP_ID, group.getId().toString()).setParam(PARAM_PERMISSION, PROVISIONING).execute();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class AddGroupActionTest method fail_when_project_uuid_and_project_key_are_provided.
@Test
public void fail_when_project_uuid_and_project_key_are_provided() throws Exception {
GroupDto group = db.users().insertGroup();
ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()));
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Project id or project key can be provided, not both.");
newRequest().setParam(PARAM_GROUP_NAME, group.getName()).setParam(PARAM_PERMISSION, SYSTEM_ADMIN).setParam(PARAM_PROJECT_ID, project.uuid()).setParam(PARAM_PROJECT_KEY, project.key()).execute();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class AddGroupActionTest method fail_if_not_administrator_of_organization.
@Test
public void fail_if_not_administrator_of_organization() throws Exception {
GroupDto group = db.users().insertGroup();
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(IllegalArgumentException.class);
newRequest().setParam(PARAM_GROUP_NAME, group.getName()).execute();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class AddGroupActionTest method adding_global_permission_fails_if_not_administrator_of_organization.
@Test
public void adding_global_permission_fails_if_not_administrator_of_organization() throws Exception {
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
// user is administrator of another organization
userSession.logIn().addPermission(ADMINISTER, "anotherOrg");
expectedException.expect(ForbiddenException.class);
newRequest().setParam(PARAM_GROUP_NAME, group.getName()).setParam(PARAM_PERMISSION, PROVISIONING).execute();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class AddGroupActionTest method add_permission_to_group_referenced_by_its_id.
@Test
public void add_permission_to_group_referenced_by_its_id() throws Exception {
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
loginAsAdmin(db.getDefaultOrganization());
newRequest().setParam(PARAM_GROUP_ID, group.getId().toString()).setParam(PARAM_PERMISSION, SYSTEM_ADMIN).execute();
assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(SYSTEM_ADMIN);
}
Aggregations