use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class OrganizationActionTest method returns_non_admin_and_canDelete_false_when_user_not_logged_in_and_key_is_not_the_default_organization.
@Test
public void returns_non_admin_and_canDelete_false_when_user_not_logged_in_and_key_is_not_the_default_organization() {
OrganizationDto organization = dbTester.organizations().insert();
TestResponse response = executeRequest(organization);
verifyResponse(response, false, false, false);
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class OrganizationActionTest method returns_admin_and_canDelete_false_when_user_logged_in_and_admin_and_key_is_guarded_organization.
@Test
public void returns_admin_and_canDelete_false_when_user_logged_in_and_admin_and_key_is_guarded_organization() {
OrganizationDto organization = dbTester.organizations().insert(dto -> dto.setGuarded(true));
userSession.logIn().addPermission(ADMINISTER, organization);
TestResponse response = executeRequest(organization);
verifyResponse(response, true, false, false);
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ServerUserSessionTest method test_hasPermission_on_organization_for_anonymous_user.
@Test
public void test_hasPermission_on_organization_for_anonymous_user() {
OrganizationDto org = db.organizations().insert();
db.users().insertPermissionOnAnyone(org, PROVISION_PROJECTS);
UserSession session = newAnonymousSession();
assertThat(session.hasPermission(PROVISION_PROJECTS, org.getUuid())).isTrue();
assertThat(session.hasPermission(ADMINISTER, org.getUuid())).isFalse();
assertThat(session.hasPermission(PROVISION_PROJECTS, "another-org")).isFalse();
}
use of org.sonar.db.organization.OrganizationDto 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.organization.OrganizationDto 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();
}
Aggregations