import org.sonar.db.component.SnapshotDto;
import org.sonar.db.measure.LiveMeasureDto;
import org.sonar.db.measure.MeasureDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.component.ComponentFinder.ParamNames;
import org.sonar.server.exceptions.BadRequestException;
.setSince("5.4")
.setDescription("Project key")
.setExampleValue(KeyExamples.KEY_PROJECT_EXAMPLE_001);
-
- wsSupport.createOrganizationParam(action);
}
@Override
MSG_ONE_PARAMETER_ONLY);
try (DbSession dbSession = dbClient.openSession(false)) {
- OrganizationDto organization = wsSupport.getOrganization(dbSession, request);
- ProjectStatusResponse projectStatusResponse = doHandle(dbSession, organization, analysisId, projectId, projectKey);
+ ProjectStatusResponse projectStatusResponse = doHandle(dbSession, analysisId, projectId, projectKey);
writeProtobuf(projectStatusResponse, request, response);
}
}
- private ProjectStatusResponse doHandle(DbSession dbSession, OrganizationDto organization, @Nullable String analysisId, @Nullable String projectId, @Nullable String projectKey) {
+ private ProjectStatusResponse doHandle(DbSession dbSession, @Nullable String analysisId, @Nullable String projectId, @Nullable String projectKey) {
ProjectAndSnapshot projectAndSnapshot = getProjectAndSnapshot(dbSession, analysisId, projectId, projectKey);
- wsSupport.checkProjectBelongsToOrganization(organization, projectAndSnapshot.project);
checkPermission(projectAndSnapshot.project);
Optional<String> measureData = loadQualityGateDetails(dbSession, projectAndSnapshot, analysisId != null);
.containsExactlyInAnyOrder(
tuple("analysisId", false),
tuple("projectKey", false),
- tuple("projectId", false),
- tuple("organization", false));
+ tuple("projectId", false));
}
@Test
String response = ws.newRequest()
.setParam("analysisId", snapshot.getUuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute().getInput();
assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
String response = ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, pastAnalysis.getUuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute().getInput();
assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
String response = ws.newRequest()
.setParam(PARAM_PROJECT_ID, project.uuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute().getInput();
assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
String response = ws.newRequest()
.setParam(PARAM_PROJECT_KEY, project.getKey())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute().getInput();
assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
ProjectStatusResponse result = ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
ProjectStatusResponse result = ws.newRequest()
.setParam(PARAM_PROJECT_ID, project.uuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
}
ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
}
assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
}
- @Test
- public void fail_when_project_does_not_not_belong_to_organization() {
- OrganizationDto organization = db.organizations().insert();
- OrganizationDto otherOrganization = db.organizations().insert();
- ComponentDto project = db.components().insertPrivateProject(otherOrganization);
- SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
- dbSession.commit();
- userSession.addProjectPermission(UserRole.ADMIN, project);
-
- expectedException.expect(NotFoundException.class);
- expectedException.expectMessage(String.format("Project '%s' doesn't exist in organization '%s'", project.getKey(), organization.getKey()));
-
- ws.newRequest()
- .setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
- .executeProtobuf(ProjectStatusResponse.class);
- }
-
@Test
public void fail_if_no_snapshot_id_found() {
OrganizationDto organization = db.organizations().insert();
ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, ANALYSIS_ID)
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
}
ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
}
ws.newRequest()
.setParam("projectId", branch.uuid())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute();
}