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 2018/12/05 18:28:35 UTC

[GitHub] dubee closed pull request #391: refactor some tests to enable test behavior changes

dubee closed pull request #391: refactor some tests to enable test behavior changes
URL: https://github.com/apache/incubator-openwhisk-cli/pull/391
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 ab4b4f6b..27f148bd 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
@@ -63,6 +63,9 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
   // Set apiHostCheck to false to avoid apihost check
   val apiHostCheck = true
 
+  // Some action invocation environments will not have an api key; so allow this check to be conditionally skipped
+  val apiKeyCheck = true
+
   behavior of "Wsk CLI usage"
 
   it should "show help and usage info" in {
@@ -514,7 +517,7 @@ 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")))
+      action.create(name, Some(TestUtils.getTestActionFilename("helloOpenwhiskPackage.js")), kind = Some("nodejs:8"))
     }
 
     val run = wsk.action
@@ -543,7 +546,9 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
       if (apiHostCheck) {
         fields("api_host") shouldBe WhiskProperties.getApiHostForAction
       }
-      fields("api_key") shouldBe wskprops.authKey
+      if (apiKeyCheck) {
+        fields("api_key") shouldBe wskprops.authKey
+      }
       fields("namespace") shouldBe namespace
       fields("action_name") shouldBe s"/$namespace/$name"
       fields("activation_id") shouldBe activation.activationId
@@ -969,7 +974,7 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
 
     wsk.action.get(nonExistentActionName, url = Some(true), expectedExitCode = NOT_FOUND)
 
-    val httpsProps = WskProps(apihost = "https://" + wskprops.apihost)
+    val httpsProps = WskProps(apihost = "https://" + wskprops.apihost, authKey = wskprops.authKey)
     wsk.action
       .get(actionName, url = Some(true))(httpsProps)
       .stdout should include(
diff --git a/tests/src/test/scala/system/basic/WskCliBasicTests.scala b/tests/src/test/scala/system/basic/WskCliBasicTests.scala
index 2acbfaf8..c22ea7f1 100644
--- a/tests/src/test/scala/system/basic/WskCliBasicTests.scala
+++ b/tests/src/test/scala/system/basic/WskCliBasicTests.scala
@@ -64,10 +64,12 @@ class WskCliBasicTests extends TestHelpers with WskTestHelpers {
     wsk.action.delete(name, expectedExitCode = CONFLICT)
   }
 
+  val WskCLI_RejUnauthAccess_exitCode = UNAUTHORIZED
+  val WskCLI_RejUnauthAccess_stderr = "The supplied authentication is invalid"
   it should "reject unauthenticated access" in {
-    implicit val wskprops = WskProps("xxx") // shadow properties
-    val errormsg = "The supplied authentication is invalid"
-    wsk.namespace.get(expectedExitCode = UNAUTHORIZED).stderr should include(errormsg)
+    implicit val new_wskprops = wskprops.copy(authKey = "xxx") //WskProps("xxx") // shadow properties
+    wsk.namespace.get(expectedExitCode = WskCLI_RejUnauthAccess_exitCode)(new_wskprops).stderr should include(
+      WskCLI_RejUnauthAccess_stderr)
   }
 
   behavior of "Wsk Package CLI"
@@ -907,16 +909,18 @@ class WskCliBasicTests extends TestHelpers with WskTestHelpers {
 
   behavior of "Wsk Namespace CLI"
 
-  it should "return a list of exactly one namespace" in {
-    val lines = wsk.namespace.list().stdout.lines.toSeq
+  def WskNsCLI_RetListOneNs_test(wsk: Wsk, wp: WskProps): Unit = {
+    val lines = wsk.namespace.list()(wp).stdout.lines.toSeq
     lines should have size 2
     lines.head shouldBe "namespaces"
     lines(1).trim should not be empty
   }
+  it should "return a list of exactly one namespace" in {
+    WskNsCLI_RetListOneNs_test(wsk, wskprops)
+  }
 
   it should "list entities in default namespace" in {
-    // use a fresh wsk props instance that is guaranteed to use the default namespace
-    wsk.namespace.get(expectedExitCode = SUCCESS_EXIT)(WskProps()).stdout should include("default")
+    wsk.namespace.get(expectedExitCode = SUCCESS_EXIT)(wskprops).stdout should include("default")
   }
 
   behavior of "Wsk Activation CLI"


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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