openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dube...@apache.org
Subject [incubator-openwhisk-cli] branch master updated: Fix broken tests around API key changes (#420)
Date Fri, 08 Mar 2019 22:04:07 GMT
This is an automated email from the ASF dual-hosted git repository.

dubeejw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new ce3c886  Fix broken tests around API key changes (#420)
ce3c886 is described below

commit ce3c886167da2c69aade190f29af094c17148cce
Author: James Dubee <jwdubee@us.ibm.com>
AuthorDate: Fri Mar 8 17:04:02 2019 -0500

    Fix broken tests around API key changes (#420)
    
    * Fix broken tests around API key changes
---
 .../core/cli/test/WskCliBasicUsageTests.scala      | 38 ++++++++++------------
 .../test/scala/system/basic/WskCliBasicTests.scala |  4 +--
 2 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
index 70019cb..a65c11e 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
@@ -514,28 +514,21 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers
{
       }
   }
 
-  it should "invoke an action using npm openwhisk" in withAssetCleaner(wskprops) { (wp, assetHelper)
=>
-    val name = "hello npm openwhisk"
-    assetHelper.withCleaner(wsk.action, name, confirmDelete = false) { (action, _) =>
-      action.create(name, Some(TestUtils.getTestActionFilename("helloOpenwhiskPackage.js")),
kind = Some("nodejs:8"))
-    }
-
-    val run = wsk.action
-      .invoke(name, Map("ignore_certs" -> true.toJson, "name" -> name.toJson))
-    withActivation(wsk.activation, run) { activation =>
-      activation.response.status shouldBe "success"
-      activation.response.result shouldBe Some(JsObject("delete" -> true.toJson))
-      activation.logs.get.mkString(" ") should include("action list has this many actions")
-    }
-
-    wsk.action.delete(name, expectedExitCode = NOT_FOUND)
-  }
-
   it should "invoke an action receiving context properties" in withAssetCleaner(wskprops)
{ (wp, assetHelper) =>
     val namespace = wsk.namespace.whois()
     val name = "context"
-    assetHelper.withCleaner(wsk.action, name) { (action, _) =>
-      action.create(name, Some(TestUtils.getTestActionFilename("helloContext.js")))
+
+    if (apiKeyCheck) {
+      assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+        action.create(
+          name,
+          Some(TestUtils.getTestActionFilename("helloContext.js")),
+          annotations = Map(WhiskAction.provideApiKeyAnnotationName -> JsBoolean(true)))
+      }
+    } else {
+      assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+        action.create(name, Some(TestUtils.getTestActionFilename("helloContext.js")))
+      }
     }
 
     val start = Instant.now(Clock.systemUTC()).toEpochMilli
@@ -631,10 +624,11 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers
{
           wsk.action.get(name, fieldFilter = Some("annotations")).stdout
         assert(stdout.startsWith(s"ok: got action $name, displaying field annotations\n"))
         removeCLIHeader(stdout).parseJson shouldBe JsArray(
-          JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:6")),
           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)))
+          JsObject("key" -> JsString("final"), "value" -> JsBoolean(webEnabled || rawEnabled)),
+          JsObject("key" -> JsString(WhiskAction.provideApiKeyAnnotationName), "value"
-> JsBoolean(false)),
+          JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:6")))
       }
   }
 
@@ -668,6 +662,7 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
       JsObject("key" -> JsString("raw-http"), "value" -> JsBoolean(false)),
       JsObject("key" -> JsString("final"), "value" -> JsBoolean(true)),
       JsObject("key" -> JsString(createKey), "value" -> createValue),
+      JsObject("key" -> JsString(WhiskAction.provideApiKeyAnnotationName), "value" ->
JsBoolean(false)),
       JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:6")))
 
     wsk.action.create(name, file, web = Some("true"), update = true, annotations = updateAnnots)
@@ -699,6 +694,7 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
         JsObject("key" -> JsString("web-export"), "value" -> JsBoolean(true)),
         JsObject("key" -> JsString("raw-http"), "value" -> JsBoolean(false)),
         JsObject("key" -> JsString("final"), "value" -> JsBoolean(true)),
+        JsObject("key" -> JsString(WhiskAction.provideApiKeyAnnotationName), "value" ->
JsBoolean(false)),
         JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:6")))
   }
 
diff --git a/tests/src/test/scala/system/basic/WskCliBasicTests.scala b/tests/src/test/scala/system/basic/WskCliBasicTests.scala
index c22ea7f..1c76ce5 100644
--- a/tests/src/test/scala/system/basic/WskCliBasicTests.scala
+++ b/tests/src/test/scala/system/basic/WskCliBasicTests.scala
@@ -304,7 +304,7 @@ class WskCliBasicTests extends TestHelpers with WskTestHelpers {
 
       wsk.action.get(name, fieldFilter = Some("name")).stdout should include(s"""$successMsg
name\n"$name"""")
       wsk.action.get(name, fieldFilter = Some("version")).stdout should include(s"""$successMsg
version\n"0.0.1"""")
-      wsk.action.get(name, fieldFilter = Some("exec")).stdout should include(s"""$successMsg""")
+      wsk.action.get(name, fieldFilter = Some("exec")).stdout should include(successMsg)
       wsk.action
         .get(name, fieldFilter = Some("exec"))
         .stdout should include regex (s"""$successMsg exec\n\\{\\s+"kind":\\s+"nodejs:6",\\s+"binary":\\s+false\\s+\\}""")
@@ -313,7 +313,7 @@ class WskCliBasicTests extends TestHelpers with WskTestHelpers {
         .stdout should include regex (s"""$successMsg parameters\n\\[\\s+\\{\\s+"key":\\s+"payload",\\s+"value":\\s+"test"\\s+\\}\\s+\\]""")
       wsk.action
         .get(name, fieldFilter = Some("annotations"))
-        .stdout should include regex (s"""$successMsg annotations\n\\[\\s+\\{\\s+"key":\\s+"exec",\\s+"value":\\s+"nodejs:6"\\s+\\}\\s+\\]""")
+        .stdout should include regex (s"""$successMsg annotations\n\\[\\s+\\{\\s+"key":\\s+"provide-api-key",\\s+"value":\\s+false\\s+\\},\\s+\\{\\s+"key":\\s+"exec",\\s+"value":\\s+"nodejs:6"\\s+\\}\\s+\\]""")
       wsk.action
         .get(name, fieldFilter = Some("limits")) //
         .stdout should include regex (s"""$successMsg limits\n\\{\\s+"timeout":\\s+60000,\\s+"memory":\\s+256,\\s+"logs":\\s+10,\\s+"concurrency":\\s+1\\s+\\}""")


Mime
View raw message