Skip to content

Commit

Permalink
Merge pull request #14 from DNAstack/186091347-create-endpoint-to-cle…
Browse files Browse the repository at this point in the history
…anup-run

[#186091347] Fix failing e2e tests
  • Loading branch information
Sean-DNAstack authored Oct 27, 2023
2 parents 7a68da7 + 4708096 commit 692a014
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
46 changes: 22 additions & 24 deletions e2e-tests/src/main/java/com/dnastack/wes/service/WesE2ETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,10 @@ public void getRunFilesReturnsNonEmptyCollection(String runId) {
given()
.log().uri()
.log().method()
.header(getHeader(getResource(getRootPath() + "/runs/" + runId)))
.header(getHeader(getResource(path)))
.accept(ContentType.JSON)
.get(path)
.then()
.get(path)
.then()
.assertThat()
.statusCode(200)
.body("runFiles.size()", greaterThan(0))
Expand All @@ -598,17 +598,16 @@ public void getRunFilesReturnsNonEmptyCollection(String runId) {
@Test
@DisplayName("Get Run Files for non-existent run fails with status 401 or 404")
public void getRunFilesForNonExistentRunShouldFail() {
String resourcePath = getRootPath() + "/runs/" + UUID.randomUUID();
String path = resourcePath + "/files";
String path = getRootPath() + "/runs/" + UUID.randomUUID() + "/files";

//@formatter:off
given()
.log().uri()
.log().method()
.header(getHeader(getResource(resourcePath)))
.header(getHeader(getResource(path)))
.accept(ContentType.JSON)
.get(path)
.then()
.get(path)
.then()
.assertThat()
.statusCode(anyOf(equalTo(404), equalTo(401)));
//@formatter:on
Expand All @@ -625,10 +624,10 @@ public void deleteRunFilesReturnsNonEmptyCollection(String runId) {
given()
.log().uri()
.log().method()
.header(getHeader(getResource(getRootPath() + "/runs/" + runId)))
.header(getHeader(getResource(path)))
.accept(ContentType.JSON)
.delete(path)
.then()
.delete(path)
.then()
.assertThat()
.statusCode(200)
.body("deletions.size()", greaterThan(0))
Expand All @@ -647,11 +646,11 @@ public void deleteRunFilesAsyncReturnsNonEmptyCollection(String runId) {
given()
.log().uri()
.log().method()
.header(getHeader(getResource(getRootPath() + "/runs/" + runId)))
.header(getHeader(getResource(path)))
.accept(ContentType.JSON)
.queryParam("async", true)
.delete(path)
.then()
.delete(path)
.then()
.assertThat()
.statusCode(200)
.body("deletions.size()", greaterThan(0))
Expand All @@ -666,10 +665,10 @@ public void deleteRunFilesAsyncReturnsNonEmptyCollection(String runId) {
given()
.log().uri()
.log().method()
.header(getHeader(getResource(getRootPath() + "/runs/" + runId)))
.header(getHeader(getResource(path)))
.accept(ContentType.JSON)
.get(path)
.then()
.get(path)
.then()
.assertThat()
.statusCode(200)
.body("runFiles.size()", greaterThan(0))
Expand All @@ -681,17 +680,16 @@ public void deleteRunFilesAsyncReturnsNonEmptyCollection(String runId) {
@Test
@DisplayName("Delete Run Files for non-existent run fails with status 401 or 404")
public void deleteRunFilesForNonExistentRunShouldFail() {
String resourcePath = getRootPath() + "/runs/" + UUID.randomUUID();
String path = resourcePath + "/files";
String path = getRootPath() + "/runs/" + UUID.randomUUID() + "/files";

//@formatter:off
given()
.log().uri()
.log().method()
.header(getHeader(getResource(resourcePath)))
.header(getHeader(getResource(path)))
.accept(ContentType.JSON)
.delete(path)
.then()
.delete(path)
.then()
.assertThat()
.statusCode(anyOf(equalTo(404),equalTo(401)));
//@formatter:on
Expand All @@ -710,8 +708,8 @@ private Stream<Arguments> completeWorkflowWithFilesProvider() throws Exception {
.multiPart(getWorkflowUrlMultipart("echo.wdl"))
.multiPart(getMultipartAttachment("echo.wdl", supplier.getFileContent(WdlSupplier.WORKFLOW_WITH_ALL_OUTPUT_TYPES).getBytes()))
.multiPart(getJsonMultipart("workflow_params", inputs))
.post(path)
.then()
.post(path)
.then()
.assertThat()
.statusCode(200)
.body("run_id", is(notNullValue()))
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dnastack/wes/api/WesV1Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ public RunListResponse getRuns(
}

@AuditActionUri("wes:run:read")
@PreAuthorize("@accessEvaluator.canAccessResource('/ga4gh/wes/v1/runs/'+#runId, 'wes:runs:read', 'wes')")
@PreAuthorize("@accessEvaluator.canAccessResource('/ga4gh/wes/v1/runs/' + #runId, 'wes:runs:read', 'wes')")
@GetMapping(value = "/runs/{run_id}", produces = { MediaType.APPLICATION_JSON_VALUE })
public RunLog getRun(@PathVariable("run_id") String runId) {
return adapter.getRun(runId);
}

@AuditActionUri("wes:run:status")
@PreAuthorize("@accessEvaluator.canAccessResource('/ga4gh/wes/v1/runs/' + #runId , 'wes:runs:read', 'wes')")
@PreAuthorize("@accessEvaluator.canAccessResource('/ga4gh/wes/v1/runs/' + #runId, 'wes:runs:read', 'wes')")
@GetMapping(value = "/runs/{run_id}/status", produces = { MediaType.APPLICATION_JSON_VALUE })
public RunStatus getRunStatus(@PathVariable("run_id") String runId) {
return adapter.getRunStatus(runId);
Expand Down

0 comments on commit 692a014

Please sign in to comment.