use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class QualityGateFinderTest method fail_when_project_qgate_defined_does_not_exist.
@Test
public void fail_when_project_qgate_defined_does_not_exist() {
ProjectDto project = db.components().insertPrivateProjectDto();
QualityGateDto dbQualityGate = db.qualityGates().insertQualityGate(qg -> qg.setName("My team QG"));
db.qualityGates().setDefaultQualityGate(dbQualityGate);
db.qualityGates().associateProjectToQualityGate(project, dbQualityGate);
db.getDbClient().qualityGateDao().delete(dbQualityGate, dbSession);
assertThatThrownBy(() -> underTest.getQualityGate(dbSession, project)).isInstanceOf(IllegalStateException.class).hasMessage("Default quality gate is missing");
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class QualityGateFinderTest method return_project_quality_gate_over_default.
@Test
public void return_project_quality_gate_over_default() {
ProjectDto project = db.components().insertPrivateProjectDto();
db.qualityGates().createDefaultQualityGate(qg -> qg.setName("Sonar way"));
QualityGateDto dbQualityGate = db.qualityGates().insertQualityGate(qg -> qg.setName("My team QG"));
db.qualityGates().associateProjectToQualityGate(project, dbQualityGate);
QualityGateFinder.QualityGateData result = underTest.getQualityGate(dbSession, project);
assertThat(result.getQualityGate().getUuid()).isEqualTo(dbQualityGate.getUuid());
assertThat(result.isDefault()).isFalse();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class QualityGateFinderTest method fail_when_default_qgate_defined_does_not_exist.
@Test
public void fail_when_default_qgate_defined_does_not_exist() {
ProjectDto project = db.components().insertPrivateProjectDto();
QualityGateDto dbQualityGate = db.qualityGates().createDefaultQualityGate(qg -> qg.setName("Sonar way"));
db.getDbClient().qualityGateDao().delete(dbQualityGate, dbSession);
db.commit();
assertThatThrownBy(() -> underTest.getQualityGate(dbSession, project)).isInstanceOf(IllegalStateException.class).hasMessage("Default quality gate is missing");
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ThreadLocalUserSessionTest method throw_ForbiddenException_when_no_access_to_applications_projects.
@Test
public void throw_ForbiddenException_when_no_access_to_applications_projects() {
GroupDto group = GroupTesting.newGroupDto();
MockUserSession expected = new MockUserSession("karadoc").setUuid("karadoc-uuid").setResetPassword(true).setLastSonarlintConnectionDate(1000L).setGroups(group);
threadLocalUserSession.set(expected);
ComponentDto componentDto = new ComponentDto().setQualifier(Qualifiers.APP).setMainBranchProjectUuid("component-uuid");
ProjectDto projectDto = new ProjectDto().setQualifier(Qualifiers.APP).setUuid("project-uuid");
assertThatThrownBy(() -> threadLocalUserSession.checkChildProjectsPermission(USER, componentDto)).isInstanceOf(ForbiddenException.class);
assertThatThrownBy(() -> threadLocalUserSession.checkChildProjectsPermission(USER, projectDto)).isInstanceOf(ForbiddenException.class);
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ThreadLocalUserSessionTest method checkChildProjectsPermission_gets_session_when_user_has_access_to_applications_projects.
@Test
public void checkChildProjectsPermission_gets_session_when_user_has_access_to_applications_projects() {
GroupDto group = GroupTesting.newGroupDto();
MockUserSession expected = new MockUserSession("karadoc").setUuid("karadoc-uuid").setResetPassword(true).setLastSonarlintConnectionDate(1000L).setGroups(group);
ProjectDto subProjectDto = new ProjectDto().setQualifier(Qualifiers.PROJECT).setUuid("subproject-uuid");
ComponentDto applicationAsComponentDto = new ComponentDto().setQualifier(Qualifiers.APP).setUuid("application-component-uuid").setProjectUuid("application-project-uuid");
ProjectDto applicationAsProjectDto = new ProjectDto().setQualifier(Qualifiers.APP).setUuid("application-project-uuid");
expected.registerProjects(subProjectDto);
expected.registerApplication(applicationAsProjectDto, subProjectDto);
expected.registerComponents(applicationAsComponentDto);
threadLocalUserSession.set(expected);
assertThat(threadLocalUserSession.checkChildProjectsPermission(USER, applicationAsComponentDto)).isEqualTo(threadLocalUserSession);
assertThat(threadLocalUserSession.checkChildProjectsPermission(USER, applicationAsProjectDto)).isEqualTo(threadLocalUserSession);
}
Aggregations