use of org.sonar.db.user.UserDto 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.UserDto 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.UserDto in project sonarqube by SonarSource.
the class PermissionIndexerTest method permissions_on_anyone_should_not_conflict_between_organizations.
@Test
public void permissions_on_anyone_should_not_conflict_between_organizations() {
ComponentDto projectOnOrg1 = createAndIndexProject(dbTester.organizations().insert());
ComponentDto projectOnOrg2 = createAndIndexProject(dbTester.organizations().insert());
UserDto user = userDbTester.insertUser();
userDbTester.insertProjectPermissionOnAnyone(USER, projectOnOrg1);
userDbTester.insertProjectPermissionOnUser(user, USER, projectOnOrg2);
indexOnStartup();
verifyAnyoneAuthorized(projectOnOrg1);
verifyAnyoneNotAuthorized(projectOnOrg2);
// because anyone
verifyAuthorized(projectOnOrg1, user);
verifyAuthorized(projectOnOrg2, user);
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class UsersActionTest method search_only_for_users_with_permission_when_no_search_query.
@Test
public void search_only_for_users_with_permission_when_no_search_query() throws Exception {
// User have permission on project
ComponentDto project = db.components().insertProject();
UserDto user = db.users().insertUser();
db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
// User has no permission
UserDto withoutPermission = db.users().insertUser();
loginAsAdmin(db.getDefaultOrganization());
String result = newRequest().setParam(PARAM_PROJECT_ID, project.uuid()).execute().getInput();
assertThat(result).contains(user.getLogin()).doesNotContain(withoutPermission.getLogin());
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class TemplateUsersActionTest method empty_result_when_no_user_on_template.
@Test
public void empty_result_when_no_user_on_template() throws Exception {
UserDto user = insertUser(newUserDto().setLogin("login-1").setName("name-1").setEmail("email-1"));
PermissionTemplateDto template = addTemplateToDefaultOrganization();
PermissionTemplateDto anotherTemplate = addTemplateToDefaultOrganization();
addUserToTemplate(newPermissionTemplateUser(USER, anotherTemplate, user));
loginAsAdmin(db.getDefaultOrganization());
InputStream bytes = newRequest(null, null).setParam(PARAM_TEMPLATE_NAME, template.getName()).setMediaType(PROTOBUF).execute().getInputStream();
WsPermissions.UsersWsResponse response = WsPermissions.UsersWsResponse.parseFrom(bytes);
assertThat(response.getUsersList()).isEmpty();
}
Aggregations