use of org.sonar.api.web.UserRole.USER in project sonarqube by SonarSource.
the class ListActionTest method status_on_branch.
@Test
public void status_on_branch() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(USER, project);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(org.sonar.db.component.BranchType.BRANCH));
db.measures().insertLiveMeasure(branch, qualityGateStatus, m -> m.setData("OK"));
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getBranchesList()).extracting(b -> b.getStatus().hasQualityGateStatus(), b -> b.getStatus().getQualityGateStatus()).containsExactlyInAnyOrder(tuple(false, ""), tuple(true, "OK"));
}
use of org.sonar.api.web.UserRole.USER in project sonarqube by SonarSource.
the class PermissionTemplateDaoTest method delete_user_permissions_by_user_uuid.
@Test
public void delete_user_permissions_by_user_uuid() {
UserDto user = db.users().insertUser();
UserDto anotherUser = db.users().insertUser();
PermissionTemplateDto template = db.permissionTemplates().insertTemplate();
String permission = "PERMISSION";
db.permissionTemplates().addUserToTemplate(template.getUuid(), user.getUuid(), permission, template.getName(), user.getLogin());
db.permissionTemplates().addUserToTemplate(template.getUuid(), anotherUser.getUuid(), permission, template.getName(), anotherUser.getLogin());
underTest.deleteUserPermissionsByUserUuid(dbSession, user.getUuid(), user.getLogin());
db.commit();
assertThat(db.select("select template_uuid as \"templateUuid\", user_uuid as \"userUuid\", permission_reference as \"permission\" from perm_templates_users")).extracting((row) -> row.get("templateUuid"), (row) -> row.get("userUuid"), (row) -> row.get("permission")).containsOnly(tuple(template.getUuid(), anotherUser.getUuid(), permission));
}
use of org.sonar.api.web.UserRole.USER in project sonarqube by SonarSource.
the class ListActionTest method response_contains_date_of_last_analysis.
@Test
public void response_contains_date_of_last_analysis() {
Long lastAnalysisBranch = dateToLong(parseDateTime("2017-04-01T00:00:00+0100"));
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(USER, project);
ComponentDto branch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(org.sonar.db.component.BranchType.BRANCH));
db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(branch2).setCreatedAt(lastAnalysisBranch));
db.commit();
indexIssues();
permissionIndexerTester.allowOnlyAnyone(project);
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getBranchesList()).extracting(ProjectBranches.Branch::getType, ProjectBranches.Branch::hasAnalysisDate, b -> "".equals(b.getAnalysisDate()) ? null : dateToLong(parseDateTime(b.getAnalysisDate()))).containsExactlyInAnyOrder(tuple(BranchType.BRANCH, false, null), tuple(BranchType.BRANCH, true, lastAnalysisBranch));
}
Aggregations