use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class CreateActionTest method request_creates_default_template_for_owner_group_and_anyone.
@Test
public void request_creates_default_template_for_owner_group_and_anyone() {
mockForSuccessfulInsert(SOME_UUID, SOME_DATE);
UserDto user = dbTester.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
executeRequest("orgFoo");
OrganizationDto organization = dbClient.organizationDao().selectByKey(dbSession, "orgfoo").get();
GroupDto ownersGroup = dbClient.groupDao().selectByName(dbSession, organization.getUuid(), "Owners").get();
PermissionTemplateDto defaultTemplate = dbClient.permissionTemplateDao().selectByName(dbSession, organization.getUuid(), "default template");
assertThat(defaultTemplate.getName()).isEqualTo("Default template");
assertThat(defaultTemplate.getDescription()).isEqualTo("Default permission template of organization orgFoo");
DefaultTemplates defaultTemplates = dbClient.organizationDao().getDefaultTemplates(dbSession, organization.getUuid()).get();
assertThat(defaultTemplates.getProjectUuid()).isEqualTo(defaultTemplate.getUuid());
assertThat(defaultTemplates.getViewUuid()).isNull();
assertThat(dbClient.permissionTemplateDao().selectGroupPermissionsByTemplateId(dbSession, defaultTemplate.getId())).extracting(PermissionTemplateGroupDto::getGroupId, PermissionTemplateGroupDto::getPermission).containsOnly(tuple(ownersGroup.getId(), UserRole.ADMIN), tuple(ownersGroup.getId(), UserRole.ISSUE_ADMIN), tuple(ownersGroup.getId(), GlobalPermissions.SCAN_EXECUTION), tuple(0, UserRole.USER), tuple(0, UserRole.CODEVIEWER));
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class PermissionIndexerTest method initializeOnStartup_does_not_grant_access_to_anybody.
@Test
public void initializeOnStartup_does_not_grant_access_to_anybody() {
ComponentDto project = createAndIndexProject();
UserDto user = userDbTester.insertUser();
GroupDto group = userDbTester.insertGroup();
indexOnStartup();
verifyAnyoneNotAuthorized(project);
verifyNotAuthorized(project, user);
verifyNotAuthorized(project, user, group);
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class PermissionIndexerTest method initializeOnStartup_grants_access_to_group.
@Test
public void initializeOnStartup_grants_access_to_group() {
ComponentDto project = createAndIndexProject();
UserDto user1 = userDbTester.insertUser();
UserDto user2 = userDbTester.insertUser();
UserDto user3 = userDbTester.insertUser();
GroupDto group1 = userDbTester.insertGroup();
GroupDto group2 = userDbTester.insertGroup();
userDbTester.insertProjectPermissionOnGroup(group1, USER, project);
userDbTester.insertProjectPermissionOnGroup(group2, ADMIN, project);
indexOnStartup();
// anonymous
verifyAnyoneNotAuthorized(project);
// group1 has access
verifyAuthorized(project, user1, group1);
// group2 has not access (only USER permission is accepted)
verifyNotAuthorized(project, user2, group2);
// user3 is not in any group
verifyNotAuthorized(project, user3);
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class PermissionIndexerTest method initializeOnStartup_grants_access_to_user_and_group.
@Test
public void initializeOnStartup_grants_access_to_user_and_group() {
ComponentDto project = createAndIndexProject();
UserDto user1 = userDbTester.insertUser();
UserDto user2 = userDbTester.insertUser();
GroupDto group = userDbTester.insertGroup();
userDbTester.insertMember(group, user2);
userDbTester.insertProjectPermissionOnUser(user1, USER, project);
userDbTester.insertProjectPermissionOnGroup(group, USER, project);
indexOnStartup();
// anonymous
verifyAnyoneNotAuthorized(project);
// has direct access
verifyAuthorized(project, user1);
// has access through group
verifyAuthorized(project, user1, group);
// no access
verifyNotAuthorized(project, user2);
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class PermissionTemplateServiceTest method would_user_have_scan_permission_with_default_permission_template.
@Test
public void would_user_have_scan_permission_with_default_permission_template() {
OrganizationDto organization = dbTester.organizations().insert();
UserDto user = dbTester.users().insertUser();
GroupDto group = dbTester.users().insertGroup(organization);
dbTester.users().insertMember(group, user);
PermissionTemplateDto template = templateDb.insertTemplate(organization);
dbTester.organizations().setDefaultTemplates(template, null);
templateDb.addProjectCreatorToTemplate(template.getId(), SCAN_EXECUTION);
templateDb.addUserToTemplate(template.getId(), user.getId(), UserRole.USER);
templateDb.addGroupToTemplate(template.getId(), group.getId(), UserRole.CODEVIEWER);
templateDb.addGroupToTemplate(template.getId(), null, UserRole.ISSUE_ADMIN);
// authenticated user
checkWouldUserHaveScanPermission(organization, user.getId(), true);
// anonymous user
checkWouldUserHaveScanPermission(organization, null, false);
}
Aggregations