You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/08/01 22:11:59 UTC
[incubator-openwhisk-cli] branch master updated (0f9a418 -> e78e761)
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git.
from 0f9a418 Move tests of --last tag to BasicUsageTests (#2518)
new 2f2bbb1 Add PHP 7.1 as a kind (#2415)
new 7d1f83a Add rule status to CLI rule list (#2474)
new 1b8c7d9 Move CLI Config Tests into Separate Suite (#2534)
new 4b9ef6c Add a database flag to completely block a given subject. (#2530)
new 74dea20 Update open api gw end-to-end test with increased timeout and improved logging (#2523)
new e78e761 Add rule status to CLI rule list (#2474)
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
commands/action.go | 2 +
commands/rule.go | 13 +
commands/util.go | 2 +-
.../apigw/healthtests/ApiGwEndToEndTests.scala | 15 +-
.../test/scala/system/basic/WskBasicTests.scala | 16 --
.../src/test/scala/system/basic/WskRuleTests.scala | 20 +-
.../scala/whisk/core/admin/WskAdminTests.scala | 62 +++++
.../whisk/core/cli/test/WskBasicUsageTests.scala | 205 +---------------
.../scala/whisk/core/cli/test/WskConfigTests.scala | 261 +++++++++++++++++++++
wski18n/i18n_resources.go | 20 +-
10 files changed, 380 insertions(+), 236 deletions(-)
create mode 100644 tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].
[incubator-openwhisk-cli] 01/06: Add PHP 7.1 as a kind (#2415)
Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit 2f2bbb1dfcb88350618848da02bdbcdf871a7094
Author: Rob Allen <ro...@akrabat.com>
AuthorDate: Mon Jul 24 17:38:34 2017 +0100
Add PHP 7.1 as a kind (#2415)
* Implement PHP 7.1 kind
* Add tests for PHP 7.1 action
* Add PHP action documentation
Build the Docker container from php:7.1-alpine and implement the HTTP
server using PHP's built in server.
Note that when using a zip file, the router requires that the `main`
function is stored in `index.php`.
Note about the runner:
The runner sets the exit code to 1 if it has set the last line of stdout
to a string suitable for presentation to the user. Therefore, if the
exit code is not one, then display a generic message.
If there's a runtime error in the action (i.e. not spotted by linter),
then looking for the main() function will find it. Render the error to
the logs so that the user knows what's happened.
Note about vendor folder in a PHP zip:
If the PHP vendor file has a vendor directory, then this directory needs
to be used rather than the one supplied in the action container.
To do this, we require src/vendor/autoload.php which will exist if the
zip file contains it. For the two cases where (1) zip file does not contain a
vendor folder, or (2) when running a non-binary code action, we move the
container's vendor folder into src/.
---
commands/action.go | 2 ++
1 file changed, 2 insertions(+)
diff --git a/commands/action.go b/commands/action.go
index 786e6f1..78d9174 100644
--- a/commands/action.go
+++ b/commands/action.go
@@ -466,6 +466,8 @@ func getExec(args []string, params ActionFlags) (*whisk.Exec, error) {
exec.Kind = "python:default"
} else if ext == ".jar" {
exec.Kind = "java:default"
+ } else if ext == ".php" {
+ exec.Kind = "php:default"
} else {
if ext == ".zip" {
return nil, zipKindError()
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.
[incubator-openwhisk-cli] 04/06: Add a database flag to completely
block a given subject. (#2530)
Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit 4b9ef6c757cb6f98b8d0f9e294d2470c978d2f66
Author: Markus Thömmes <ma...@me.com>
AuthorDate: Fri Jul 28 15:59:40 2017 +0200
Add a database flag to completely block a given subject. (#2530)
There was no preservative way of blocking a user from the system temporarily before. This adds the functionality to provide a flag in the user's subject entry to block its keys from further usage.
---
.../scala/whisk/core/admin/WskAdminTests.scala | 62 ++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
index ec4cf59..0d31758 100644
--- a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
+++ b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
@@ -30,6 +30,7 @@ import common.WskAdmin
import common.WskProps
import whisk.core.entity.AuthKey
import whisk.core.entity.Subject
+import common.TestUtils
@RunWith(classOf[JUnitRunner])
class WskAdminTests
@@ -91,4 +92,65 @@ class WskAdminTests
val ns = wsk.namespace.whois()
wskadmin.cli(Seq("user", "get", ns)).stdout.trim should be(wskprops.authKey)
}
+
+ it should "block and unblock a user respectively" in {
+ val wskadmin = new RunWskAdminCmd {}
+ val auth = AuthKey()
+ val subject1 = Subject().asString
+ val subject2 = Subject().asString
+ val commonNamespace = "testspace"
+ try {
+ wskadmin.cli(Seq("user", "create", subject1, "-ns", commonNamespace, "-u", auth.compact))
+ wskadmin.cli(Seq("user", "create", subject2, "-ns", commonNamespace))
+
+ whisk.utils.retry({
+ // reverse lookup by namespace
+ val out = wskadmin.cli(Seq("user", "list", "-p", "2", "-k", commonNamespace)).stdout.trim
+ out should include(auth.compact)
+ out.lines should have size 2
+ }, 10, Some(1.second))
+
+ // block the user
+ wskadmin.cli(Seq("user", "block", subject1))
+
+ // wait until the user can no longer be found
+ whisk.utils.retry({
+ wskadmin.cli(Seq("user", "list", "-p", "2", "-k", commonNamespace)).stdout.trim.lines should have size 1
+ }, 10, Some(1.second))
+
+ // unblock the user
+ wskadmin.cli(Seq("user", "unblock", subject1))
+
+ // wait until the user can be found again
+ whisk.utils.retry({
+ val out = wskadmin.cli(Seq("user", "list", "-p", "2", "-k", commonNamespace)).stdout.trim
+ out should include(auth.compact)
+ out.lines should have size 2
+ }, 10, Some(1.second))
+ } finally {
+ wskadmin.cli(Seq("user", "delete", subject1)).stdout should include("Subject deleted")
+ wskadmin.cli(Seq("user", "delete", subject2)).stdout should include("Subject deleted")
+ }
+ }
+
+ it should "not allow edits on a blocked subject" in {
+ val wskadmin = new RunWskAdminCmd {}
+ val subject = Subject().asString
+ try {
+ // initially create the subject
+ wskadmin.cli(Seq("user", "create", subject))
+ // editing works
+ wskadmin.cli(Seq("user", "create", subject, "-ns", "testspace1"))
+ // block it
+ wskadmin.cli(Seq("user", "block", subject))
+ // Try to add a namespace, doesn't work
+ wskadmin.cli(Seq("user", "create", subject, "-ns", "testspace2"), expectedExitCode = TestUtils.ERROR_EXIT)
+ // Unblock the user
+ wskadmin.cli(Seq("user", "unblock", subject))
+ // Adding a namespace works
+ wskadmin.cli(Seq("user", "create", subject, "-ns", "testspace2"))
+ } finally {
+ wskadmin.cli(Seq("user", "delete", subject)).stdout should include("Subject deleted")
+ }
+ }
}
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.
[incubator-openwhisk-cli] 05/06: Update open api gw end-to-end test
with increased timeout and improved logging (#2523)
Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit 74dea20757411bd034b971d4a03efb0e6ad2e8c4
Author: Mark Deuser <md...@us.ibm.com>
AuthorDate: Fri Jul 28 16:35:21 2017 -0400
Update open api gw end-to-end test with increased timeout and improved logging (#2523)
---
.../test/scala/apigw/healthtests/ApiGwEndToEndTests.scala | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
index 49cfbf7..9e8ecd0 100644
--- a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
+++ b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
@@ -151,7 +151,7 @@ class ApiGwEndToEndTests
val testapiname = testName + " API Name"
val actionName = testName + "_echo"
val urlqueryparam = "name"
- val urlqueryvalue = "test"
+ val urlqueryvalue = testName
try {
println("cli namespace: " + clinamespace)
@@ -214,14 +214,21 @@ class ApiGwEndToEndTests
)
rr.stdout should include("ok: created API")
val swaggerapiurl = rr.stdout.split("\n")(1)
- println(s"apiurl: '${swaggerapiurl}'")
+ println(s"Returned api url: '${swaggerapiurl}'")
// Call the API URL and validate the results
+ val start = java.lang.System.currentTimeMillis
+ val apiToInvoke = s"$swaggerapiurl?$urlqueryparam=$urlqueryvalue&guid=$start"
+ println(s"Invoking: '${apiToInvoke}'")
val response = whisk.utils.retry({
- val response = RestAssured.given().config(sslconfig).get(s"$swaggerapiurl?$urlqueryparam=$urlqueryvalue")
+ val response = RestAssured.given().config(sslconfig).get(s"$apiToInvoke")
+ println("URL invocation response status: " + response.statusCode)
response.statusCode should be(200)
response
- }, 5, Some(1.second))
+ }, 6, Some(2.second))
+ val end = java.lang.System.currentTimeMillis
+ val elapsed = end - start
+ println("Elapsed time (milliseconds) for a successful response: " + elapsed)
val responseString = response.body.asString
println("URL invocation response: " + responseString)
responseString.parseJson.asJsObject.fields(urlqueryparam).convertTo[String] should be(urlqueryvalue)
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.
[incubator-openwhisk-cli] 02/06: Add rule status to CLI rule list
(#2474)
Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit 7d1f83a39e54866f043bcaba7ab8894b7067da98
Author: Jesus Alva <ja...@us.ibm.com>
AuthorDate: Mon Jul 31 13:50:31 2017 -0500
Add rule status to CLI rule list (#2474)
---
commands/rule.go | 13 +++++++++++++
commands/util.go | 2 +-
wski18n/i18n_resources.go | 20 ++++++++++----------
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/commands/rule.go b/commands/rule.go
index bc9ee1d..3ff0133 100644
--- a/commands/rule.go
+++ b/commands/rule.go
@@ -388,6 +388,19 @@ var ruleListCmd = &cobra.Command{
map[string]interface{}{"name": getClientNamespace(), "err": err})
werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
return werr
+ } else {
+ //No errors, lets attempt to retrieve the status of each rule #312
+ for index, rule := range rules {
+ ruleStatus, _, err := client.Rules.Get(rule.Name)
+ if err != nil {
+ errStr := wski18n.T("Unable to get status of rule '{{.name}}': {{.err}}",
+ map[string]interface{}{"name": rule.Name, "err": err})
+ fmt.Println(errStr)
+ werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
+ return werr
+ }
+ rules[index].Status = ruleStatus.Status
+ }
}
printList(rules)
return nil
diff --git a/commands/util.go b/commands/util.go
index e010914..d6278bd 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -333,7 +333,7 @@ func printRuleList(rules []whisk.Rule) {
fmt.Fprintf(color.Output, "%s\n", boldString("rules"))
for _, rule := range rules {
publishState := wski18n.T("private")
- fmt.Printf("%-70s %s\n", fmt.Sprintf("/%s/%s", rule.Namespace, rule.Name), publishState)
+ fmt.Printf("%-70s %-20s %s\n", fmt.Sprintf("/%s/%s", rule.Namespace, rule.Name), publishState, rule.Status)
}
}
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index 01dd9b6..cb46bda 100644
--- a/wski18n/i18n_resources.go
+++ b/wski18n/i18n_resources.go
@@ -109,7 +109,7 @@ func wski18nResourcesDe_deAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500649425, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -129,7 +129,7 @@ func wski18nResourcesEn_usAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 49861, mode: os.FileMode(420), modTime: time.Unix(1500649503, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 49861, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -149,7 +149,7 @@ func wski18nResourcesEs_esAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500649425, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -169,7 +169,7 @@ func wski18nResourcesFr_frAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1500649425, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -189,7 +189,7 @@ func wski18nResourcesIt_itAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500649425, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -209,7 +209,7 @@ func wski18nResourcesJa_jaAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500649425, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -229,7 +229,7 @@ func wski18nResourcesKo_krAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500649425, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -249,7 +249,7 @@ func wski18nResourcesPt_brAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500649425, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -269,7 +269,7 @@ func wski18nResourcesZh_hansAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500649425, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -289,7 +289,7 @@ func wski18nResourcesZh_hantAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500649425, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1501622069, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.
[incubator-openwhisk-cli] 03/06: Move CLI Config Tests into
Separate Suite (#2534)
Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit 1b8c7d9930fec99ad2aac6aa6b31e9d867366deb
Author: James Dubee <jw...@us.ibm.com>
AuthorDate: Thu Jul 27 10:10:18 2017 -0400
Move CLI Config Tests into Separate Suite (#2534)
---
.../test/scala/system/basic/WskBasicTests.scala | 16 --
.../whisk/core/cli/test/WskBasicUsageTests.scala | 205 +---------------
.../scala/whisk/core/cli/test/WskConfigTests.scala | 261 +++++++++++++++++++++
3 files changed, 262 insertions(+), 220 deletions(-)
diff --git a/tests/src/test/scala/system/basic/WskBasicTests.scala b/tests/src/test/scala/system/basic/WskBasicTests.scala
index b82dd2d..be17527 100644
--- a/tests/src/test/scala/system/basic/WskBasicTests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicTests.scala
@@ -17,7 +17,6 @@
package system.basic
-import java.io.File
import java.time.Instant
import scala.concurrent.duration.DurationInt
@@ -51,21 +50,6 @@ class WskBasicTests
Wsk.exists
}
- it should "show api build details" in {
- val tmpProps = File.createTempFile("wskprops", ".tmp")
- try {
- val env = Map("WSK_CONFIG_FILE" -> tmpProps.getAbsolutePath())
- wsk.cli(Seq("property", "set", "-i") ++ wskprops.overrides, env = env)
- val rr = wsk.cli(Seq("property", "get", "--apibuild", "--apibuildno", "-i"), env = env)
- rr.stderr should not include ("https:///api/v1: http: no Host in request URL")
- rr.stdout should not include regex("Cannot determine API build")
- rr.stdout should include regex ("""(?i)whisk API build\s+201.*""")
- rr.stdout should include regex ("""(?i)whisk API build number\s+.*""")
- } finally {
- tmpProps.delete()
- }
- }
-
it should "reject creating duplicate entity" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val name = "testDuplicateCreate"
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
index ad8de5d..e0dd977 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
@@ -30,7 +30,6 @@ import scala.concurrent.duration.Duration
import scala.concurrent.duration.DurationInt
import scala.util.Random
-import org.apache.commons.io.FileUtils
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@@ -72,7 +71,7 @@ class WskBasicUsageTests
}
it should "show help and usage info" in {
- val stdout = wsk.cli(Seq("-h")).stdout
+ val stdout = wsk.cli(Seq()).stdout
stdout should include regex ("""(?i)Usage:""")
stdout should include regex ("""(?i)Flags""")
stdout should include regex ("""(?i)Available commands""")
@@ -95,200 +94,11 @@ class WskBasicUsageTests
stdout should include regex ("""(?i)whisk API version\s+v1""")
}
- it should "set apihost, auth, and namespace" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- try {
- val namespace = wsk.namespace.whois()
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- val stdout = wsk.cli(Seq("property", "set", "-i",
- "--apihost", wskprops.apihost,
- "--auth", wskprops.authKey,
- "--namespace", namespace),
- env = env).stdout
- stdout should include(s"ok: whisk auth set")
- stdout should include(s"ok: whisk API host set to ${wskprops.apihost}")
- stdout should include(s"ok: whisk namespace set to ${namespace}")
- } finally {
- tmpwskprops.delete()
- }
- }
-
- // If client certificate verification is off, should ingore run below tests.
- if (!WhiskProperties.getProperty("whisk.ssl.client.verification").equals("off")) {
- it should "set valid cert key to get expected success result for client certificate verification" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- try {
- val namespace = wsk.namespace.list().stdout.trim.split("\n").last
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- // Send request to https://<apihost>/api/v1/namespaces, wsk client passes client certificate to nginx, nginx will
- // verify it by client ca's openwhisk-client-ca-cert.pem
- val stdout = wsk.cli(Seq("property", "set", "-i", "--apihost", wskprops.apihost, "--auth", wskprops.authKey,
- "--cert", wskprops.cert, "--key", wskprops.key, "--namespace", namespace), env = env).stdout
- stdout should include(s"ok: client cert set")
- stdout should include(s"ok: client key set")
- stdout should include(s"ok: whisk auth set")
- stdout should include(s"ok: whisk API host set to ${wskprops.apihost}")
- stdout should include(s"ok: whisk namespace set to ${namespace}")
- } finally {
- tmpwskprops.delete()
- }
- }
-
- it should "set invalid cert key to get expected exception result for client certificate verification" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- try {
- val namespace = wsk.namespace.list().stdout.trim.split("\n").last
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- val thrown = the[Exception] thrownBy wsk.cli(Seq("property", "set", "-i", "--apihost", wskprops.apihost, "--auth", wskprops.authKey,
- "--cert", "invalid-cert.pem", "--key", "invalid-key.pem", "--namespace", namespace), env = env)
- thrown.getMessage should include("cannot validate certificate")
- } finally {
- tmpwskprops.delete()
- }
- }
- }
-
- it should "ensure default namespace is used when a blank namespace is set" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- try {
- val writer = new BufferedWriter(new FileWriter(tmpwskprops))
- writer.write(s"NAMESPACE=")
- writer.close()
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- val stdout = wsk.cli(Seq("property", "get", "-i", "--namespace"), env = env).stdout
- stdout should include regex ("whisk namespace\\s+_")
- } finally {
- tmpwskprops.delete()
- }
- }
-
- it should "show api build version using property file" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- try {
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- wsk.cli(Seq("property", "set", "-i") ++ wskprops.overrides, env = env)
- val stdout = wsk.cli(Seq("property", "get", "--apibuild", "-i"), env = env).stdout
- stdout should include regex ("""(?i)whisk API build\s+201.*""")
- } finally {
- tmpwskprops.delete()
- }
- }
-
- it should "fail to show api build when setting apihost to bogus value" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- try {
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- wsk.cli(Seq("property", "set", "-i", "--apihost", "xxxx.yyyy"), env = env)
- val rr = wsk.cli(Seq("property", "get", "--apibuild", "-i"), env = env, expectedExitCode = ANY_ERROR_EXIT)
- rr.stdout should include regex ("""whisk API build\s*Unknown""")
- rr.stderr should include regex ("Unable to obtain API build information")
- } finally {
- tmpwskprops.delete()
- }
- }
-
- it should "show api build using http apihost" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- try {
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- val apihost = s"http://${WhiskProperties.getBaseControllerAddress()}"
- wsk.cli(Seq("property", "set", "--apihost", apihost), env = env)
- val rr = wsk.cli(Seq("property", "get", "--apibuild", "-i"), env = env)
- rr.stdout should not include regex("""whisk API build\s*Unknown""")
- rr.stderr should not include regex("Unable to obtain API build information")
- rr.stdout should include regex ("""(?i)whisk API build\s+201.*""")
- } finally {
- tmpwskprops.delete()
- }
- }
-
- it should "validate default property values" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- val stdout = wsk.cli(Seq("property", "unset", "--auth", "--cert", "--key", "--apihost", "--apiversion", "--namespace"), env = env).stdout
- try {
- stdout should include regex ("ok: whisk auth unset")
- stdout should include regex ("ok: client cert unset")
- stdout should include regex ("ok: client key unset")
- stdout should include regex ("ok: whisk API host unset")
- stdout should include regex ("ok: whisk API version unset")
- stdout should include regex ("ok: whisk namespace unset")
-
- wsk.cli(Seq("property", "get", "--auth"), env = env).
- stdout should include regex ("""(?i)whisk auth\s*$""") // default = empty string
- wsk.cli(Seq("property", "get", "--cert"), env = env).
- stdout should include regex ("""(?i)client cert\s*$""") // default = empty string
- wsk.cli(Seq("property", "get", "--key"), env = env).
- stdout should include regex ("""(?i)client key\s*$""") // default = empty string
- wsk.cli(Seq("property", "get", "--apihost"), env = env).
- stdout should include regex ("""(?i)whisk API host\s*$""") // default = empty string
- wsk.cli(Seq("property", "get", "--namespace"), env = env).
- stdout should include regex ("""(?i)whisk namespace\s*_$""") // default = _
- } finally {
- tmpwskprops.delete()
- }
- }
-
- it should "set auth in property file" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- wsk.cli(Seq("property", "set", "--auth", "testKey"), env = env)
- try {
- val fileContent = FileUtils.readFileToString(tmpwskprops)
- fileContent should include("AUTH=testKey")
- } finally {
- tmpwskprops.delete()
- }
- }
-
- it should "set multiple property values with single command" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- val stdout = wsk.cli(Seq("property", "set", "--auth", "testKey", "--cert", "cert.pem", "--key", "key.pem", "--apihost", "openwhisk.ng.bluemix.net", "--apiversion", "v1"), env = env).stdout
- try {
- stdout should include regex ("ok: whisk auth set")
- stdout should include regex ("ok: client cert set")
- stdout should include regex ("ok: client key set")
- stdout should include regex ("ok: whisk API host set")
- stdout should include regex ("ok: whisk API version set")
- val fileContent = FileUtils.readFileToString(tmpwskprops)
- fileContent should include("AUTH=testKey")
- fileContent should include("APIHOST=openwhisk.ng.bluemix.net")
- fileContent should include("APIVERSION=v1")
- } finally {
- tmpwskprops.delete()
- }
- }
-
it should "reject bad command" in {
val result = wsk.cli(Seq("bogus"), expectedExitCode = ERROR_EXIT)
result.stderr should include regex ("""(?i)Run 'wsk --help' for usage""")
}
- it should "reject authenticated command when no auth key is given" in {
- // override wsk props file in case it exists
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- val stderr = wsk.cli(Seq("list") ++ wskprops.overrides, env = env, expectedExitCode = MISUSE_EXIT).stderr
- try {
- stderr should include regex (s"usage[:.]") // Python CLI: "usage:", Go CLI: "usage."
- stderr should include("--auth is required")
- } finally {
- tmpwskprops.delete()
- }
- }
-
- it should "reject a command when the API host is not set" in {
- val tmpwskprops = File.createTempFile("wskprops", ".tmp")
- try {
- val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
- val stderr = wsk.cli(Seq("property", "get", "-i"), env = env, expectedExitCode = ERROR_EXIT).stderr
- stderr should include("The API host is not valid: An API host must be provided.")
- } finally {
- tmpwskprops.delete()
- }
- }
-
behavior of "Wsk actions"
it should "reject creating entities with invalid names" in withAssetCleaner(wskprops) {
@@ -1509,17 +1319,4 @@ class WskBasicUsageTests
testLimit(None, Some(32768.MB), None, BAD_REQUEST)
testLimit(None, None, Some(32768.MB), BAD_REQUEST)
}
-
- it should "create a trigger using property file" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val name = "listTriggers"
- val tmpProps = File.createTempFile("wskprops", ".tmp")
- val env = Map("WSK_CONFIG_FILE" -> tmpProps.getAbsolutePath())
- wsk.cli(Seq("property", "set", "--auth", wp.authKey) ++ wskprops.overrides, env = env)
- assetHelper.withCleaner(wsk.trigger, name) {
- (trigger, _) =>
- wsk.cli(Seq("-i", "trigger", "create", name), env = env)
- }
- tmpProps.delete()
- }
}
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala
new file mode 100644
index 0000000..fbe1631
--- /dev/null
+++ b/tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package whisk.core.cli.test
+
+import java.io.File
+import java.io.BufferedWriter
+import java.io.FileWriter
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import org.apache.commons.io.FileUtils
+
+import common.WhiskProperties
+import common.TestHelpers
+import common.TestUtils._
+import common.Wsk
+import common.WskProps
+import common.WskTestHelpers
+
+@RunWith(classOf[JUnitRunner])
+class WskConfigTests
+ extends TestHelpers
+ with WskTestHelpers {
+
+ implicit val wskprops = WskProps()
+ val wsk = new Wsk
+
+ behavior of "Wsk CLI config"
+
+ it should "fail to show api build when setting apihost to bogus value" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ try {
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ wsk.cli(Seq("property", "set", "-i", "--apihost", "xxxx.yyyy"), env = env)
+ val rr = wsk.cli(Seq("property", "get", "--apibuild", "-i"), env = env, expectedExitCode = ANY_ERROR_EXIT)
+ rr.stdout should include regex ("""whisk API build\s*Unknown""")
+ rr.stderr should include regex ("Unable to obtain API build information")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "validate default property values" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ val stdout = wsk.cli(Seq("property", "unset", "--auth", "--cert", "--key", "--apihost", "--apiversion", "--namespace"), env = env).stdout
+ try {
+ stdout should include regex ("ok: whisk auth unset")
+ stdout should include regex ("ok: client cert unset")
+ stdout should include regex ("ok: client key unset")
+ stdout should include regex ("ok: whisk API host unset")
+ stdout should include regex ("ok: whisk API version unset")
+ stdout should include regex ("ok: whisk namespace unset")
+
+ wsk.cli(Seq("property", "get", "--auth"), env = env).
+ stdout should include regex ("""(?i)whisk auth\s*$""") // default = empty string
+ wsk.cli(Seq("property", "get", "--cert"), env = env).
+ stdout should include regex ("""(?i)client cert\s*$""") // default = empty string
+ wsk.cli(Seq("property", "get", "--key"), env = env).
+ stdout should include regex ("""(?i)client key\s*$""") // default = empty string
+ wsk.cli(Seq("property", "get", "--apihost"), env = env).
+ stdout should include regex ("""(?i)whisk API host\s*$""") // default = empty string
+ wsk.cli(Seq("property", "get", "--namespace"), env = env).
+ stdout should include regex ("""(?i)whisk namespace\s*_$""") // default = _
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "reject authenticated command when no auth key is given" in {
+ // override wsk props file in case it exists
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ val stderr = wsk.cli(Seq("list") ++ wskprops.overrides, env = env, expectedExitCode = MISUSE_EXIT).stderr
+ try {
+ stderr should include regex (s"usage[:.]")
+ stderr should include("--auth is required")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "reject a command when the API host is not set" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ try {
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ val stderr = wsk.cli(Seq("property", "get", "-i"), env = env, expectedExitCode = ERROR_EXIT).stderr
+ stderr should include("The API host is not valid: An API host must be provided.")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "show api build details" in {
+ val tmpProps = File.createTempFile("wskprops", ".tmp")
+ try {
+ val env = Map("WSK_CONFIG_FILE" -> tmpProps.getAbsolutePath())
+ wsk.cli(Seq("property", "set", "-i") ++ wskprops.overrides, env = env)
+ val rr = wsk.cli(Seq("property", "get", "--apibuild", "--apibuildno", "-i"), env = env)
+ rr.stderr should not include ("https:///api/v1: http: no Host in request URL")
+ rr.stdout should not include regex("Cannot determine API build")
+ rr.stdout should include regex ("""(?i)whisk API build\s+201.*""")
+ rr.stdout should include regex ("""(?i)whisk API build number\s+.*""")
+ } finally {
+ tmpProps.delete()
+ }
+ }
+
+ it should "set apihost, auth, and namespace" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ try {
+ val namespace = wsk.namespace.whois()
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ val stdout = wsk.cli(Seq("property", "set", "-i",
+ "--apihost", wskprops.apihost,
+ "--auth", wskprops.authKey,
+ "--namespace", namespace),
+ env = env).stdout
+ stdout should include(s"ok: whisk auth set")
+ stdout should include(s"ok: whisk API host set to ${wskprops.apihost}")
+ stdout should include(s"ok: whisk namespace set to ${namespace}")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ // If client certificate verification is off, should ingore run below tests.
+ if (!WhiskProperties.getProperty("whisk.ssl.client.verification").equals("off")) {
+ it should "set valid cert key to get expected success result for client certificate verification" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ try {
+ val namespace = wsk.namespace.list().stdout.trim.split("\n").last
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ // Send request to https://<apihost>/api/v1/namespaces, wsk client passes client certificate to nginx, nginx will
+ // verify it by client ca's openwhisk-client-ca-cert.pem
+ val stdout = wsk.cli(Seq("property", "set", "-i", "--apihost", wskprops.apihost, "--auth", wskprops.authKey,
+ "--cert", wskprops.cert, "--key", wskprops.key, "--namespace", namespace), env = env).stdout
+ stdout should include(s"ok: client cert set")
+ stdout should include(s"ok: client key set")
+ stdout should include(s"ok: whisk auth set")
+ stdout should include(s"ok: whisk API host set to ${wskprops.apihost}")
+ stdout should include(s"ok: whisk namespace set to ${namespace}")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "set invalid cert key to get expected exception result for client certificate verification" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ try {
+ val namespace = wsk.namespace.list().stdout.trim.split("\n").last
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ val thrown = the[Exception] thrownBy wsk.cli(Seq("property", "set", "-i", "--apihost", wskprops.apihost, "--auth", wskprops.authKey,
+ "--cert", "invalid-cert.pem", "--key", "invalid-key.pem", "--namespace", namespace), env = env)
+ thrown.getMessage should include("cannot validate certificate")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+ }
+
+ it should "ensure default namespace is used when a blank namespace is set" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ try {
+ val writer = new BufferedWriter(new FileWriter(tmpwskprops))
+ writer.write(s"NAMESPACE=")
+ writer.close()
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ val stdout = wsk.cli(Seq("property", "get", "-i", "--namespace"), env = env).stdout
+ stdout should include regex ("whisk namespace\\s+_")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "show api build version using property file" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ try {
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ wsk.cli(Seq("property", "set", "-i") ++ wskprops.overrides, env = env)
+ val stdout = wsk.cli(Seq("property", "get", "--apibuild", "-i"), env = env).stdout
+ stdout should include regex ("""(?i)whisk API build\s+201.*""")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "show api build using http apihost" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ try {
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ val apihost = s"http://${WhiskProperties.getBaseControllerAddress()}"
+ wsk.cli(Seq("property", "set", "--apihost", apihost), env = env)
+ val rr = wsk.cli(Seq("property", "get", "--apibuild", "-i"), env = env)
+ rr.stdout should not include regex("""whisk API build\s*Unknown""")
+ rr.stderr should not include regex("Unable to obtain API build information")
+ rr.stdout should include regex ("""(?i)whisk API build\s+201.*""")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "set auth in property file" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ wsk.cli(Seq("property", "set", "--auth", "testKey"), env = env)
+ try {
+ val fileContent = FileUtils.readFileToString(tmpwskprops)
+ fileContent should include("AUTH=testKey")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "set multiple property values with single command" in {
+ val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+ val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+ val stdout = wsk.cli(Seq("property", "set", "--auth", "testKey", "--cert", "cert.pem", "--key", "key.pem", "--apihost", "openwhisk.ng.bluemix.net", "--apiversion", "v1"), env = env).stdout
+ try {
+ stdout should include regex ("ok: whisk auth set")
+ stdout should include regex ("ok: client cert set")
+ stdout should include regex ("ok: client key set")
+ stdout should include regex ("ok: whisk API host set")
+ stdout should include regex ("ok: whisk API version set")
+ val fileContent = FileUtils.readFileToString(tmpwskprops)
+ fileContent should include("AUTH=testKey")
+ fileContent should include("APIHOST=openwhisk.ng.bluemix.net")
+ fileContent should include("APIVERSION=v1")
+ } finally {
+ tmpwskprops.delete()
+ }
+ }
+
+ it should "create a trigger using property file" in withAssetCleaner(wskprops) {
+ (wp, assetHelper) =>
+ val name = "listTriggers"
+ val tmpProps = File.createTempFile("wskprops", ".tmp")
+ val env = Map("WSK_CONFIG_FILE" -> tmpProps.getAbsolutePath())
+ wsk.cli(Seq("property", "set", "--auth", wp.authKey) ++ wskprops.overrides, env = env)
+ assetHelper.withCleaner(wsk.trigger, name) {
+ (trigger, _) =>
+ wsk.cli(Seq("-i", "trigger", "create", name), env = env)
+ }
+ tmpProps.delete()
+ }
+}
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.
[incubator-openwhisk-cli] 06/06: Add rule status to CLI rule list
(#2474)
Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit e78e76128e19b72bdeeec2e2b405f6e17c8bf521
Author: Jesus Alva <ja...@us.ibm.com>
AuthorDate: Mon Jul 31 13:50:31 2017 -0500
Add rule status to CLI rule list (#2474)
---
tests/src/test/scala/system/basic/WskRuleTests.scala | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/tests/src/test/scala/system/basic/WskRuleTests.scala b/tests/src/test/scala/system/basic/WskRuleTests.scala
index 3bfacd2..ae8768d 100644
--- a/tests/src/test/scala/system/basic/WskRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRuleTests.scala
@@ -19,7 +19,6 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
import common.TestHelpers
import common.TestCLIUtils
import common.Wsk
@@ -371,4 +370,23 @@ class WskRuleTests
}
}
+ it should "disable a rule and check its status is displayed when listed" in withAssetCleaner(wskprops) {
+ (wp, assetHelper) =>
+ val ruleName = withTimestamp("ruleDisable")
+ val ruleName2 = withTimestamp("ruleEnable")
+ val triggerName = withTimestamp("ruleDisableTrigger")
+ val actionName = withTimestamp("ruleDisableAction")
+
+ ruleSetup(Seq(
+ (ruleName, triggerName, (actionName, actionName, defaultAction)),
+ (ruleName2, triggerName, (actionName, actionName, defaultAction))),
+ assetHelper)
+
+ wsk.rule.disable(ruleName)
+ val listOutput = wsk.rule.list().stdout.lines
+ listOutput.find(_.contains(ruleName2)).get should (include(ruleName2) and include("active"))
+ listOutput.find(_.contains(ruleName)).get should (include(ruleName) and include("inactive"))
+ wsk.rule.list().stdout should not include ("Unknown")
+ }
+
}
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.