Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CromIAM check user authorization before forwarding request to Cromwell #4348

Merged
merged 5 commits into from
Nov 2, 2018

Conversation

salonishah11
Copy link
Contributor

Closes #4284

@@ -165,8 +165,6 @@ trait QuerySupport extends RequestSupport {
}

object QuerySupport {
def hasCollectionLabel(labels: Iterable[String]): Boolean = labels exists { _.startsWith(s"$CollectionLabelName:") }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this function as it was not being used anymore

@geoffjentry
Copy link
Contributor

geoffjentry commented Nov 2, 2018

👍

Approved with PullApprove

@@ -19,7 +19,7 @@ class QuerySupportSpec extends FlatSpec with Matchers with ScalatestRouteTest wi

val queryPath = "/api/workflows/v1/query"
val getQuery = s"$queryPath?status=Submitted&label=foo:bar&label=foo:baz"
val badGetQuery = s"$queryPath?status=Submitted?labelor=foo:bar&label=foo:baz"
val badGetQuery = s"$queryPath?status=Submitted&labelor=foo:bar&label=foo:baz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh wrong kind of bad 😬

val helloWorldWdl = HelloWorld.workflowSource()
val helloWorldInputs = HelloWorld.rawInputs

val workflowSource = Multipart.FormData.BodyPart("workflowSource", HttpEntity(MediaTypes.`application/json`, helloWorldWdl))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDL is not JSON...


"Submit query" should "forward the request to Cromwell for authorized SAM user" in {
Post(submitPath).withHeaders(goodAuthHeaders).withEntity(formData) ~> submitRoute ~> check {
status shouldEqual StatusCodes.InternalServerError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't dug into the mocks here but a 500 seems strange for a "success" expectation. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it did seem strange to me as well, but I didn't change it as QuerySupportSpec also uses forwardToCromwell and expects InternalServerError. I will try and do what @Horneth mentioned in the comment below. Thanks!


"Submit query" should "forward the request to Cromwell for authorized SAM user" in {
Post(submitPath).withHeaders(goodAuthHeaders).withEntity(formData) ~> submitRoute ~> check {
status shouldEqual StatusCodes.InternalServerError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TOL: Looking at the mock code I was able to figure out that this is the expected response because the mock Cromwell client always returns 500, but it's not very obvious here IMO that a test for "user is authorized" should return 500.
I think it would be nice if possible to have the mock cromwell client respond differently based on the request (like you did for SAM). It could send back 200 for authorized and maybe throw an exception otherwise.
This would also have the added benefit to fail any test where Cromwell receives a request that wasn't authorized by CromIAM. For instance in the test below, it would make sure that on top of CromIAM responding with 400, it really didn't send the request to Cromwell.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I will try that. Thanks!

@salonishah11 salonishah11 merged commit f0c5b16 into develop Nov 2, 2018
@salonishah11 salonishah11 deleted the ss_cromiam_submit_bug branch November 15, 2018 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants