use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method do_not_fail_when_group_name_exists_in_multiple_organizations.
@Test
public void do_not_fail_when_group_name_exists_in_multiple_organizations() {
PermissionTemplateDto template = addTemplateToDefaultOrganization();
String groupName = "group-name";
GroupDto group1 = db.users().insertGroup(db.getDefaultOrganization(), groupName);
addGroupToTemplate(newPermissionTemplateGroup(CODEVIEWER, template.getId(), group1.getId()));
addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getId(), group1.getId()));
OrganizationDto otherOrganization = db.organizations().insert();
db.users().insertGroup(otherOrganization, groupName);
loginAsAdmin(db.getDefaultOrganization());
newRequest().setMediaType(PROTOBUF).setParam(PARAM_TEMPLATE_ID, template.getUuid()).setParam(TEXT_QUERY, "-nam").execute().getInputStream();
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method search_by_permission.
@Test
public void search_by_permission() throws Exception {
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group1 = db.users().insertGroup(db.getDefaultOrganization(), "group-1-name");
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getId(), group1.getId()));
addGroupToTemplate(newPermissionTemplateGroup(CODEVIEWER, template.getId(), group1.getId()));
GroupDto group2 = db.users().insertGroup(db.getDefaultOrganization(), "group-2-name");
addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getId(), group2.getId()));
GroupDto group3 = db.users().insertGroup(db.getDefaultOrganization(), "group-3-name");
// Anyone
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getId(), null));
PermissionTemplateDto anotherTemplate = addTemplateToDefaultOrganization();
addGroupToTemplate(newPermissionTemplateGroup(ADMIN, anotherTemplate.getId(), group3.getId()));
commit();
loginAsAdmin(db.getDefaultOrganization());
InputStream output = newRequest().setMediaType(PROTOBUF).setParam(PARAM_PERMISSION, USER).setParam(PARAM_TEMPLATE_ID, template.getUuid()).execute().getInputStream();
WsGroupsResponse response = WsGroupsResponse.parseFrom(output);
assertThat(response.getGroupsList()).extracting("name").containsExactly("Anyone", "group-1-name");
assertThat(response.getGroups(0).getPermissionsList()).containsOnly("user");
assertThat(response.getGroups(1).getPermissionsList()).containsOnly("user", "codeviewer");
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method search_with_pagination.
@Test
public void search_with_pagination() throws Exception {
OrganizationDto defaultOrg = db.getDefaultOrganization();
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group1 = db.users().insertGroup(defaultOrg, "group-1-name");
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getId(), group1.getId()));
GroupDto group2 = db.users().insertGroup(defaultOrg, "group-2-name");
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getId(), group2.getId()));
commit();
loginAsAdmin(db.getDefaultOrganization());
InputStream output = newRequest().setMediaType(PROTOBUF).setParam(PARAM_PERMISSION, USER).setParam(PARAM_TEMPLATE_NAME, template.getName()).setParam(PAGE, "2").setParam(PAGE_SIZE, "1").execute().getInputStream();
WsGroupsResponse response = WsGroupsResponse.parseFrom(output);
assertThat(response.getGroupsList()).extracting("name").containsExactly("group-2-name");
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method search_by_template_name.
@Test
public void search_by_template_name() throws Exception {
OrganizationDto defaultOrg = db.getDefaultOrganization();
GroupDto group1 = db.users().insertGroup(defaultOrg, "group-1-name");
GroupDto group2 = db.users().insertGroup(defaultOrg, "group-2-name");
GroupDto group3 = db.users().insertGroup(defaultOrg, "group-3-name");
PermissionTemplateDto template = addTemplateToDefaultOrganization();
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getId(), group1.getId()));
addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getId(), group2.getId()));
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getId(), null));
PermissionTemplateDto anotherTemplate = addTemplateToDefaultOrganization();
addGroupToTemplate(newPermissionTemplateGroup(USER, anotherTemplate.getId(), group1.getId()));
commit();
loginAsAdmin(db.getDefaultOrganization());
InputStream output = newRequest().setMediaType(PROTOBUF).setParam(PARAM_TEMPLATE_NAME, template.getName()).execute().getInputStream();
WsGroupsResponse response = WsGroupsResponse.parseFrom(output);
assertThat(response.getGroupsList()).extracting("name").containsExactly("Anyone", "group-1-name", "group-2-name");
}
use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.
the class TemplateGroupsActionTest method search_with_text_query.
@Test
public void search_with_text_query() throws Exception {
OrganizationDto defaultOrg = db.getDefaultOrganization();
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group1 = db.users().insertGroup(defaultOrg, "group-1-name");
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getId(), group1.getId()));
GroupDto group2 = db.users().insertGroup(defaultOrg, "group-2-name");
GroupDto group3 = db.users().insertGroup(defaultOrg, "group-3");
commit();
loginAsAdmin(db.getDefaultOrganization());
InputStream output = newRequest().setMediaType(PROTOBUF).setParam(PARAM_TEMPLATE_NAME, template.getName()).setParam(TEXT_QUERY, "-nam").execute().getInputStream();
WsGroupsResponse response = WsGroupsResponse.parseFrom(output);
assertThat(response.getGroupsList()).extracting("name").containsExactly("group-1-name", "group-2-name");
}
Aggregations