From 4c622c4318a5786055de1cf43fb12515ef559ea0 Mon Sep 17 00:00:00 2001 From: David An Date: Thu, 6 Dec 2018 15:13:24 -0500 Subject: [PATCH] test for uri encoding on workflow metadata --- .../firecloud/mock/MockWorkspaceServer.scala | 29 +++++++++++++++++++ .../service/SubmissionServiceSpec.scala | 16 ++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/mock/MockWorkspaceServer.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/mock/MockWorkspaceServer.scala index 6d4289f7a..515a72527 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/mock/MockWorkspaceServer.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/mock/MockWorkspaceServer.scala @@ -34,6 +34,21 @@ object MockWorkspaceServer { false //locked ) + val mockSpacedWorkspace = Workspace( + "spacey", + "this workspace has spaces", + Set.empty, + "workspace_id", + "buckety_bucket", + DateTime.now(), + DateTime.now(), + "my_workspace_creator", + Map(), //attributes + Map(), //acls + Map(), //realm acls + false //locked + ) + val mockValidId = randomPositiveInt() val mockInvalidId = randomPositiveInt() @@ -214,6 +229,20 @@ object MockWorkspaceServer { .withBody(mockValidSubmission.toJson.prettyPrint) ) + MockWorkspaceServer.workspaceServer + .when( + request() + .withMethod("GET") + .withPath(s"${workspaceBasePath}/%s/%s/submissions/%s/workflows/%s" + .format(mockSpacedWorkspace.namespace, mockSpacedWorkspace.name, mockValidId, mockValidId)) + .withHeader(authHeader)) + .respond( + response() + .withHeaders(header) + .withStatusCode(OK.intValue) + .withBody(mockValidSubmission.toJson.prettyPrint) + ) + MockWorkspaceServer.workspaceServer .when( request() diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/service/SubmissionServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/service/SubmissionServiceSpec.scala index ced02145a..f4e110a63 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/service/SubmissionServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/service/SubmissionServiceSpec.scala @@ -6,6 +6,7 @@ import org.broadinstitute.dsde.firecloud.model.SubmissionRequest import spray.http.StatusCodes._ import spray.httpx.SprayJsonSupport._ import org.broadinstitute.dsde.firecloud.model.ModelJsonProtocol._ +import spray.http.Uri final class SubmissionServiceSpec extends ServiceSpec with SubmissionService { @@ -43,6 +44,12 @@ final class SubmissionServiceSpec extends ServiceSpec with SubmissionService { MockWorkspaceServer.mockValidId, MockWorkspaceServer.mockValidId) + val localSpacedWorkspaceWorkflowIdPath = FireCloudConfig.Rawls.submissionsWorkflowIdPath.format( + MockWorkspaceServer.mockSpacedWorkspace.namespace, + MockWorkspaceServer.mockSpacedWorkspace.name, + MockWorkspaceServer.mockValidId, + MockWorkspaceServer.mockValidId) + val localInvalidSubmissionWorkflowIdPath = FireCloudConfig.Rawls.submissionsWorkflowIdPath.format( MockWorkspaceServer.mockValidWorkspace.namespace, MockWorkspaceServer.mockValidWorkspace.name, @@ -179,6 +186,15 @@ final class SubmissionServiceSpec extends ServiceSpec with SubmissionService { } } + "with a valid id and a space in the workspace name, OK response is returned" in { + // the request inbound to orchestration should encoded, so we replace spaces with %20 in the test below. + // this test really verifies that the runtime orch code can accept an encoded URI and maintain the encoding + // when it passes through the request to rawls - i.e. it doesn't decode the request at any point. + Get(Uri(localSpacedWorkspaceWorkflowIdPath.replace(" ","%20"))) ~> dummyAuthHeaders ~> sealRoute(routes) ~> check { + status should equal(OK) + } + } + "with an invalid id, NotFound response is returned" in { Get(localInvalidSubmissionWorkflowIdPath) ~> dummyAuthHeaders ~> sealRoute(routes) ~> check { status should equal(NotFound)