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 a2ea258 refactor some tests to enable test behavior changes (#391) a2ea258 is described below commit a2ea258fca85110f23703fdc5dfebedde8c3157a Author: Mark Deuser <mdeu...@us.ibm.com> AuthorDate: Wed Dec 5 13:28:33 2018 -0500 refactor some tests to enable test behavior changes (#391) * refactor some tests to enable test behavior changes - tests run in some environments will need slight changes - test behavior changes implemented as test class extension * scala fmt --- .../core/cli/test/WskCliBasicUsageTests.scala | 11 ++++++++--- .../src/test/scala/system/basic/WskCliBasicTests.scala | 18 +++++++++++------- 2 files changed, 19 insertions(+), 10 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 ab4b4f6..27f148b 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 2acbfaf..c22ea7f 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"