You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/03/27 12:03:28 UTC

[GitHub] [incubator-openwhisk] chetanmeh commented on a change in pull request #4387: Make tests working in case the "provide-api-key" feature is disabled

chetanmeh commented on a change in pull request #4387: Make tests working in case the "provide-api-key" feature is disabled
URL: https://github.com/apache/incubator-openwhisk/pull/4387#discussion_r269523474
 
 

 ##########
 File path: tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskRestBasicUsageTests.scala
 ##########
 @@ -430,13 +433,49 @@ class WskRestBasicUsageTests extends TestHelpers with WskTestHelpers with WskAct
         action.create(name, Some(TestUtils.getTestActionFilename("echo.js")), web = Some(flag.toLowerCase))
       }
 
-      val action = wsk.action.get(name)
-      action.getFieldJsValue("annotations").convertTo[Set[JsObject]] shouldBe Set(
+      val expectedSet = Set(
         JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:6")),
-        JsObject("key" -> WhiskAction.provideApiKeyAnnotationName.toJson, "value" -> JsBoolean(false)),
         JsObject("key" -> JsString("web-export"), "value" -> JsBoolean(webEnabled || rawEnabled)),
         JsObject("key" -> JsString("raw-http"), "value" -> JsBoolean(rawEnabled)),
         JsObject("key" -> JsString("final"), "value" -> JsBoolean(webEnabled || rawEnabled)))
+
+      val action = wsk.action.get(name)
+      action.getFieldJsValue("annotations").convertTo[Set[JsObject]] shouldBe (if (requireAPIKeyAnnotation) {
 
 Review comment:
   This can be simplified a bit with
   
   ```scala
         val requireApiKey = if (requireAPIKeyAnnotation) s"""{"key" :  "${WhiskAction.provideApiKeyAnnotationName}", "value": "false"},""" else ""
         val json = s"""[
                      |  {"key" :  "exec", "value": "nodejs:6"},
                      |  {"key" :  "web-export", "value": ${webEnabled || rawEnabled}},
                      |  {"key" :  "raw-http", "value": $rawEnabled},
                      |  $requireApiKey
                      |  {"key" :  "final", "value": ${webEnabled || rawEnabled}},
                      |]""".stripMargin.parseJson.asInstanceOf[JsArray]
         action.getFieldListJsObject("annotations") shouldBe json.elements
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services