Skip to content

Commit

Permalink
test for uri encoding on workflow metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
davidangb committed Dec 6, 2018
1 parent 1b35e5b commit 4c622c4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4c622c4

Please sign in to comment.