Skip to content

Commit

Permalink
Merge branch 'develop' into aen_wx_1878
Browse files Browse the repository at this point in the history
  • Loading branch information
aednichols authored Oct 17, 2024
2 parents ed92fb4 + d59ef92 commit 86b9d2c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ trait CromIamApiService

val workflowRoutes: Route = queryGetRoute ~ queryPostRoute ~ workflowOutputsRoute ~ submitRoute ~
workflowLogsRoute ~ abortRoute ~ metadataRoute ~ timingRoute ~ statusRoute ~ backendRoute ~ labelPatchRoute ~
callCacheDiffRoute ~ labelGetRoute ~ releaseHoldRoute
callCacheDiffRoute ~ labelGetRoute ~ releaseHoldRoute ~ costRoute

val allRoutes: Route = handleExceptions(CromIamExceptionHandler)(workflowRoutes ~ engineRoutes ~ womtoolRoutes)

Expand Down Expand Up @@ -114,6 +114,7 @@ trait CromIamApiService
def timingRoute: Route = workflowGetRouteWithId("timing")
def statusRoute: Route = workflowGetRouteWithId("status")
def labelGetRoute: Route = workflowGetRouteWithId(Labels)
def costRoute: Route = workflowGetRouteWithId("cost")

def labelPatchRoute: Route =
path("api" / "workflows" / Segment / Segment / Labels) { (_, workflowId) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,49 @@ class CromIamApiServiceSpec
rejection shouldEqual MissingHeaderRejection("OIDC_CLAIM_user_id")
}
}

behavior of "Cost endpoint"
it should "return 200 for authorized user who has collection associated with root workflow" in {
Get(s"/api/workflows/$version/${cromwellClient.rootWorkflowIdWithCollection}/cost")
.withHeaders(goodAuthHeaders) ~> allRoutes ~> check {
status shouldBe OK
responseAs[String] shouldBe "Response from Cromwell"
contentType should be(ContentTypes.`text/plain(UTF-8)`)
}
}

it should "return 200 for authorized user who has collection associated with subworkflow" in {
Get(s"/api/workflows/$version/${cromwellClient.subworkflowId}/cost")
.withHeaders(goodAuthHeaders) ~> allRoutes ~> check {
status shouldBe OK
responseAs[String] shouldBe "Response from Cromwell"
contentType should be(ContentTypes.`text/plain(UTF-8)`)
}
}

it should "return 500 for authorized user who doesn't have collection associated with workflow" in {
Get(s"/api/workflows/$version/${cromwellClient.workflowIdWithoutCollection}/cost")
.withHeaders(goodAuthHeaders) ~> allRoutes ~> check {
status shouldBe InternalServerError
responseAs[
String
] shouldBe s"CromIAM unexpected error: java.lang.IllegalArgumentException: Workflow ${cromwellClient.workflowIdWithoutCollection} has no associated collection"
contentType should be(ContentTypes.`text/plain(UTF-8)`)
}
}

it should "return SamDenialException for user who doesn't have view permissions" in {
Get(s"/api/workflows/$version/${cromwellClient.subworkflowId}/cost")
.withHeaders(badAuthHeaders) ~> allRoutes ~> check {
status shouldBe Forbidden
responseAs[String] shouldBe "Access Denied"
contentType should be(ContentTypes.`text/plain(UTF-8)`)
}
}

it should "reject request if it doesn't contain OIDC_CLAIM_user_id in header" in {
Get(s"/api/workflows/$version/${cromwellClient.rootWorkflowIdWithCollection}/cost") ~> allRoutes ~> check {
rejection shouldEqual MissingHeaderRejection("OIDC_CLAIM_user_id")
}
}
}

0 comments on commit 86b9d2c

Please sign in to comment.