rabbah commented on a change in pull request #4494: Akka http server responds
HEAD request as GET
URL:
https://github.com/apache/incubator-openwhisk/pull/4494#discussion_r297306428
##########
File path:
tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskWebActionsTests.scala
##########
@@ -305,6 +305,34 @@ class WskWebActionsTests extends TestHelpers with
WskTestHelpers with RestUtil w
response.body.asByteArray shouldBe Base64.getDecoder().decode(png)
}
+ /**
+ * Tests web action for HEAD requests
+ */
+ it should "create a web action making a HEAD request" in
withAssetCleaner(wskprops) { (wp, assetHelper) =>
+ val name = "webaction"
+ val file = Some(TestUtils.getTestActionFilename("echo.js"))
+ val host = getServiceURL()
+ val url = s"$host$testRoutePath/$namespace/default/$name.text/__ow_user"
+
+ assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+ action.create(name, file, web = Some("true"), annotations =
Map("require-whisk-auth" -> true.toJson))
+ }
+
+ val unauthorizedResponse = RestAssured.given().config(sslconfig).get(url)
+ unauthorizedResponse.statusCode shouldBe 401
+
+ val authorizedResponse = RestAssured
+ .given()
+ .config(sslconfig)
+ .auth()
+ .preemptive()
+ .basic(wskprops.authKey.split(":")(0), wskprops.authKey.split(":")(1))
+ .head(url)
+
+ authorizedResponse.statusCode shouldBe 200
+ authorizedResponse.body.asString() shouldBe ""
Review comment:
you'll want to test that the `__ow_method` received was HEAD not GET.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services