Enable API GW routemgmt action tests
diff --git a/tests/build.gradle b/tests/build.gradle
index 24c17b8..6c0a7ba 100644
--- a/tests/build.gradle
+++ b/tests/build.gradle
@@ -18,7 +18,6 @@
}
test {
- exclude '**/apigw/**'
systemProperty 'testthreads', System.getProperty('testthreads', '1')
testLogging {
events "passed", "skipped", "failed"
diff --git a/tests/src/common/Wsk.scala b/tests/src/common/Wsk.scala
index ab8f6dc..8448ee5 100644
--- a/tests/src/common/Wsk.scala
+++ b/tests/src/common/Wsk.scala
@@ -80,6 +80,7 @@
implicit val activation = new WskActivation
implicit val pkg = new WskPackage
implicit val namespace = new WskNamespace
+ implicit val api = new WskApi
}
trait FullyQualifiedNames {
@@ -743,6 +744,91 @@
}
}
+class WskApi()
+ extends RunWskCmd {
+ protected val noun = "api-experimental"
+
+ /**
+ * Creates and API endpoint. Parameters mirror those available in the CLI.
+ *
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ def create(
+ basepath: Option[String] = Some("/"),
+ relpath: String,
+ operation: String,
+ action: String,
+ apiname: Option[String] = None,
+ swagger: Option[String] = None,
+ expectedExitCode: Int = SUCCESS_EXIT)(
+ implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "create", "--auth", wp.authKey, basepath.get, relpath, operation, action) ++
+ { apiname map { a => Seq("--apiname", a) } getOrElse Seq() } ++
+ { swagger map { s => Seq("--config-file", s) } getOrElse Seq() }
+ cli(wp.overrides ++ params, expectedExitCode, showCmd = true)
+ }
+
+ /**
+ * Retrieve a list of API endpoints. Parameters mirror those available in the CLI.
+ *
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ def list(
+ basepathOrApiName: Option[String] = None,
+ relpath: Option[String] = None,
+ operation: Option[String] = None,
+ limit: Option[Int] = None,
+ since: Option[Instant] = None,
+ expectedExitCode: Int = SUCCESS_EXIT)(
+ implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "list", "--auth", wp.authKey) ++
+ { basepathOrApiName map { b => Seq(b) } getOrElse Seq() } ++
+ { relpath map { r => Seq(r) } getOrElse Seq() } ++
+ { operation map { o => Seq(o) } getOrElse Seq() } ++
+ { limit map { l => Seq("--limit", l.toString) } getOrElse Seq() } ++
+ { since map { i => Seq("--since", i.toEpochMilli.toString) } getOrElse Seq() }
+ cli(wp.overrides ++ params, expectedExitCode, showCmd = true)
+ }
+
+ /**
+ * Retieves an API's configuration. Parameters mirror those available in the CLI.
+ * Runs a command wsk [params] where the arguments come in as a sequence.
+ *
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ def get(
+ basepathOrApiName: Option[String] = None,
+ full: Option[Boolean] = None,
+ expectedExitCode: Int = SUCCESS_EXIT)(
+ implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "get", "--auth", wp.authKey) ++
+ { basepathOrApiName map { b => Seq(b) } getOrElse Seq() } ++
+ { full map { f => if (f) Seq("--full") else Seq() } getOrElse Seq() }
+ cli(wp.overrides ++ params, expectedExitCode, showCmd = true)
+ }
+
+ /**
+ * Delete an entire API or a subset of API endpoints. Parameters mirror those available in the CLI.
+ *
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ def delete(
+ basepathOrApiName: String,
+ relpath: Option[String] = None,
+ operation: Option[String] = None,
+ expectedExitCode: Int = SUCCESS_EXIT)(
+ implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "delete", "--auth", wp.authKey, basepathOrApiName) ++
+ { relpath map { r => Seq(r) } getOrElse Seq() } ++
+ { operation map { o => Seq(o) } getOrElse Seq() }
+ cli(wp.overrides ++ params, expectedExitCode, showCmd = true)
+ }
+}
+
trait WaitFor {
/**
* Waits up to totalWait seconds for a 'step' to return value.
diff --git a/tests/src/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala b/tests/src/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
index 5e2c4eb..64856e0 100644
--- a/tests/src/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
+++ b/tests/src/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
@@ -31,6 +31,7 @@
import common.TestUtils.SUCCESS_EXIT
import common.TestUtils.RunResult
import common.Wsk
+import common.WskAdmin
import common.WskActorSystem
import common.WskProps
import common.WskTestHelpers
@@ -71,6 +72,7 @@
implicit val wskprops = WskProps()
val wsk = new Wsk
+ val (cliuser, clinamespace) = WskAdmin.getUser(wskprops.authKey)
// Use the whisk.system authentication id and pwd for invoking whisk.system private actions
val config = new WhiskConfig(WhiskAuthStore.requiredProperties ++ WhiskEntityStore.requiredProperties)
@@ -91,7 +93,7 @@
operation: Option[String] = None,
docid: Option[String] = None): Vector[JsValue] = {
val parms = Map[String,JsValue]() ++
- Map("namespace" -> "_".toJson) ++
+ Map("__ow_meta_namespace" -> "guest".toJson) ++
{ bpOrName map { b => Map("basepath" -> b.toJson) } getOrElse Map[String,JsValue]() } ++
{ relpath map { r => Map("relpath" -> r.toJson) } getOrElse Map[String,JsValue]() } ++
{ operation map { o => Map("operation" -> o.toJson) } getOrElse Map[String,JsValue]() } ++
@@ -158,7 +160,8 @@
{ apiname map { an => Map("apiName" -> an.toJson) } getOrElse Map[String,JsValue]() } ++
{ action map { a => Map("action" -> a.toJson) } getOrElse Map[String,JsValue]() } ++
{ swagger map { s => Map("swagger" -> s.toJson) } getOrElse Map[String,JsValue]() }
- val parm = Map[String,JsValue]("apidoc" -> JsObject(parms))
+ val parm = Map[String,JsValue]("apidoc" -> JsObject(parms)) ++
+ { namespace map { n => Map("__ow_meta_namespace" -> n.toJson) } getOrElse Map[String,JsValue]() }
val wskprops = new WskProps(authKey = whisksystemAuthId+":"+whisksystemAuthPwd)
val rr = wsk.action.invoke(
name = "routemgmt/createRoute",
@@ -179,7 +182,7 @@
expectedExitCode: Int = SUCCESS_EXIT): RunResult ={
val parms = Map[String,JsValue]() ++
Map("force" -> force.toJson) ++
- { namespace map { n => Map("namespace" -> n.toJson) } getOrElse Map[String,JsValue]() } ++
+ { namespace map { n => Map("__ow_meta_namespace" -> n.toJson) } getOrElse Map[String,JsValue]() } ++
{ basepath map { b => Map("basepath" -> b.toJson) } getOrElse Map[String,JsValue]() } ++
{ relpath map { r => Map("relpath" -> r.toJson) } getOrElse Map[String,JsValue]() } ++
{ operation map { o => Map("operation" -> o.toJson) } getOrElse Map[String,JsValue]() } ++
@@ -254,13 +257,14 @@
val testurlop = "get"
val testapiname = testName+" API Name"
val actionName = testName+"_action"
- val actionNamespace = testName+"_ns"
+ val actionNamespace = clinamespace
val actionUrl = "http://some.whisk.host/api/v1/namespaces/"+actionNamespace+"/actions/"+actionName
val actionAuthKey = testName+"_authkey"
val testaction = ApiAction(name = actionName, namespace = actionNamespace, backendUrl = actionUrl, authkey = actionAuthKey)
+
try {
- val createResult = createRoute(namespace = Some("_"), basepath = Some(testbasepath), relpath = Some(testrelpath),
+ val createResult = createRoute(namespace = Some(clinamespace), basepath = Some(testbasepath), relpath = Some(testrelpath),
operation = Some(testurlop), apiname = Some(testapiname), action = Some(testaction))
JsObjectHelper(createResult.stdout.parseJson.asJsObject).fieldPathExists("apidoc") should be(true)
val apiVector = getApis(bpOrName = Some(testbasepath), relpath = Some(testrelpath), operation = Some(testurlop))
@@ -268,7 +272,7 @@
apiMatch(apiVector, testbasepath, testrelpath, testurlop, testapiname, testaction) should be(true)
}
finally {
- val deleteResult = deleteApi(namespace = Some("_"), basepath = Some(testbasepath), force = true, expectedExitCode = DONTCARE_EXIT)
+ val deleteResult = deleteApi(namespace = Some(clinamespace), basepath = Some(testbasepath), force = true, expectedExitCode = DONTCARE_EXIT)
}
}
@@ -279,24 +283,24 @@
val testurlop = "get"
val testapiname = testName+" API Name"
val actionName = testName+"_action"
- val actionNamespace = testName+"_ns"
+ val actionNamespace = clinamespace
val actionUrl = "http://some.whisk.host/api/v1/namespaces/"+actionNamespace+"/actions/"+actionName
val actionAuthKey = testName+"_authkey"
val testaction = ApiAction(name = actionName, namespace = actionNamespace, backendUrl = actionUrl, authkey = actionAuthKey)
try {
- val createResult = createRoute(namespace = Some("_"), basepath = Some(testbasepath), relpath = Some(testrelpath),
+ val createResult = createRoute(namespace = Some(clinamespace), basepath = Some(testbasepath), relpath = Some(testrelpath),
operation = Some(testurlop), apiname = Some(testapiname), action = Some(testaction))
JsObjectHelper(createResult.stdout.parseJson.asJsObject).fieldPathExists("apidoc") should be(true)
var apiVector = getApis(bpOrName = Some(testbasepath), relpath = Some(testrelpath), operation = Some(testurlop))
apiVector.size should be > 0
apiMatch(apiVector, testbasepath, testrelpath, testurlop, testapiname, testaction) should be(true)
- val deleteResult = deleteApi(namespace = Some("_"), basepath = Some(testbasepath), force = true)
+ val deleteResult = deleteApi(namespace = Some(clinamespace), basepath = Some(testbasepath), force = true)
apiVector = getApis(bpOrName = Some(testbasepath), relpath = Some(testrelpath), operation = Some(testurlop))
apiMatch(apiVector, testbasepath, testrelpath, testurlop, testapiname, testaction) should be(false)
}
finally {
- val deleteResult = deleteApi(namespace = Some("_"), basepath = Some(testbasepath), force = true, expectedExitCode = DONTCARE_EXIT)
+ val deleteResult = deleteApi(namespace = Some(clinamespace), basepath = Some(testbasepath), force = true, expectedExitCode = DONTCARE_EXIT)
}
}
@@ -309,15 +313,15 @@
val testnewurlop = "delete"
val testapiname = testName+" API Name"
val actionName = testName+"_action"
- val actionNamespace = testName+"_ns"
+ val actionNamespace = clinamespace
val actionUrl = "http://some.whisk.host/api/v1/namespaces/"+actionNamespace+"/actions/"+actionName
val actionAuthKey = testName+"_authkey"
val testaction = ApiAction(name = actionName, namespace = actionNamespace, backendUrl = actionUrl, authkey = actionAuthKey)
try {
- var createResult = createRoute(namespace = Some("_"), basepath = Some(testbasepath), relpath = Some(testrelpath),
+ var createResult = createRoute(namespace = Some(clinamespace), basepath = Some(testbasepath), relpath = Some(testrelpath),
operation = Some(testurlop), apiname = Some(testapiname), action = Some(testaction))
- createResult = createRoute(namespace = Some("_"), basepath = Some(testbasepath), relpath = Some(testnewrelpath),
+ createResult = createRoute(namespace = Some(clinamespace), basepath = Some(testbasepath), relpath = Some(testnewrelpath),
operation = Some(testnewurlop), apiname = Some(testapiname), action = Some(testaction))
JsObjectHelper(createResult.stdout.parseJson.asJsObject).fieldPathExists("apidoc") should be(true)
var apiVector = getApis(bpOrName = Some(testbasepath))
@@ -326,7 +330,7 @@
apiMatch(apiVector, testbasepath, testnewrelpath, testnewurlop, testapiname, testaction) should be(true)
}
finally {
- val deleteResult = deleteApi(namespace = Some("_"), basepath = Some(testbasepath), force = true, expectedExitCode = DONTCARE_EXIT)
+ val deleteResult = deleteApi(namespace = Some(clinamespace), basepath = Some(testbasepath), force = true, expectedExitCode = DONTCARE_EXIT)
}
}
@@ -337,9 +341,9 @@
//deleteApi
("/whisk.system/routemgmt/deleteApi", ANY_ERROR_EXIT, "namespace is required", Seq("-p", "basepath", "/ApiGwRoutemgmtActionTests_bp")),
- ("/whisk.system/routemgmt/deleteApi", ANY_ERROR_EXIT, "basepath is required", Seq("-p", "namespace", "_")),
+ ("/whisk.system/routemgmt/deleteApi", ANY_ERROR_EXIT, "basepath is required", Seq("-p", "__ow_meta_namespace", "_")),
("/whisk.system/routemgmt/deleteApi", ANY_ERROR_EXIT, "When specifying an operation, the relpath is required",
- Seq("-p", "namespace", "_", "-p", "basepath", "/ApiGwRoutemgmtActionTests_bp", "-p", "operation", "get")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "basepath", "/ApiGwRoutemgmtActionTests_bp", "-p", "operation", "get")),
//deactivateApi
("/whisk.system/routemgmt/deactivateApi", ANY_ERROR_EXIT, "namespace is required", Seq("-p", "basepath", "/ApiGwRoutemgmtActionTests_bp")),
@@ -426,32 +430,32 @@
Seq("-p", "namespace", "_", "-p", "basepath", "/ApiGwRoutemgmtActionTests_bp", "-p", "swagger", "{}")),
//createRoute
- ("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "apidoc is required", Seq()),
+ ("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "apidoc is required", Seq("-p", "__ow_meta_namespace", "_")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "apidoc is missing the namespace field",
- Seq("-p", "apidoc", "{}")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", "{}")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "apidoc is missing the gatewayBasePath field",
- Seq("-p", "apidoc", """{"namespace":"_"}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_"}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "apidoc is missing the gatewayPath field",
- Seq("-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp"}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp"}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "apidoc is missing the gatewayMethod field",
- Seq("-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp"}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp"}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "apidoc is missing the action field",
- Seq("-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get"}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get"}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "action is missing the backendMethod field",
- Seq("-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{}}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{}}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "action is missing the backendUrl field",
- Seq("-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post"}}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post"}}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "action is missing the namespace field",
- Seq("-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post","backendUrl":"URL"}}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post","backendUrl":"URL"}}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "action is missing the name field",
- Seq("-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post","backendUrl":"URL","namespace":"_"}}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post","backendUrl":"URL","namespace":"_"}}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "action is missing the authkey field",
- Seq("-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post","backendUrl":"URL","namespace":"_","name":"N"}}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post","backendUrl":"URL","namespace":"_","name":"N"}}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "swagger and gatewayBasePath are mutually exclusive and cannot be specified together",
- Seq("-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post","backendUrl":"URL","namespace":"_","name":"N","authkey":"XXXX"},"swagger":{}}""")),
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", """{"namespace":"_","gatewayBasePath":"/ApiGwRoutemgmtActionTests_bp","gatewayPath":"ApiGwRoutemgmtActionTests_rp","gatewayMethod":"get","action":{"backendMethod":"post","backendUrl":"URL","namespace":"_","name":"N","authkey":"XXXX"},"swagger":{}}""")),
("/whisk.system/routemgmt/createRoute", ANY_ERROR_EXIT, "apidoc field cannot be parsed. Ensure it is valid JSON",
- Seq("-p", "namespace", "_", "-p", "apidoc", "{1:[}}}"))
+ Seq("-p", "__ow_meta_namespace", "_", "-p", "apidoc", "{1:[}}}"))
)
invalidArgs foreach {
diff --git a/tests/src/whisk/core/cli/test/ApiGwTests.scala b/tests/src/whisk/core/cli/test/ApiGwTests.scala
new file mode 100644
index 0000000..adbbc2d
--- /dev/null
+++ b/tests/src/whisk/core/cli/test/ApiGwTests.scala
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2015-2016 IBM Corporation
+ *
+ * Licensed 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 org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import common.TestHelpers
+import common.TestUtils._
+import common.Wsk
+import common.WskAdmin
+import common.WskProps
+import common.WskTestHelpers
+
+/**
+ * Tests for testing the CLI "api" subcommand. Most of these tests require a deployed backend.
+ */
+@RunWith(classOf[JUnitRunner])
+class ApiGwTests
+ extends TestHelpers
+ with WskTestHelpers {
+
+ implicit val wskprops = WskProps()
+ val wsk = new Wsk
+ val (cliuser, clinamespace) = WskAdmin.getUser(wskprops.authKey)
+
+ behavior of "Wsk api"
+
+ it should "reject an api commands with an invalid path parameter" in {
+ val badpath = "badpath"
+
+ var rr = wsk.api.create(basepath = Some("/basepath"), relpath = badpath, operation = "GET", action = "action", expectedExitCode = ANY_ERROR_EXIT)
+ rr.stderr should include (s"'${badpath}' must begin with '/'")
+
+ rr = wsk.api.delete(basepathOrApiName = "/basepath", relpath = Some(badpath), operation = Some("GET"), expectedExitCode = ANY_ERROR_EXIT)
+ rr.stderr should include (s"'${badpath}' must begin with '/'")
+
+ rr = wsk.api.list(basepathOrApiName = Some("/basepath"), relpath = Some(badpath), operation = Some("GET"), expectedExitCode = ANY_ERROR_EXIT)
+ rr.stderr should include (s"'${badpath}' must begin with '/'")
+ }
+
+ it should "verify successful creation of a new API" in {
+ val testName = "CLI_APIGWTEST1"
+ val testbasepath = "/"+testName+"_bp"
+ val testrelpath = "/path"
+ val testnewrelpath = "/path_new"
+ val testurlop = "get"
+ val testapiname = testName+" API Name"
+ val actionName = testName+"_action"
+
+ // List result will look like:
+ // ok: APIs
+ // Action Verb API Name URL
+ // /_/CLI_APIGWTEST1_action get CLI_APIGWTEST1 API Name http://172.17.0.1:9001/api/ab9082cd-ea8e-465a-8a65-b491725cc4ef/CLI_APIGWTEST1_bp/path
+ try {
+ var rr = wsk.api.create(basepath = Some(testbasepath), relpath = testrelpath, operation = testurlop, action = actionName, apiname = Some(testapiname))
+ rr.stdout should include("ok: created API")
+ rr = wsk.api.list(basepathOrApiName = Some(testbasepath), relpath = Some(testrelpath), operation = Some(testurlop))
+ rr.stdout should include("ok: APIs")
+ rr.stdout should include regex (s"/${clinamespace}/${actionName}\\s+${testurlop}\\s+${testapiname}\\s+")
+ rr.stdout should include(testbasepath + testrelpath)
+ }
+ finally {
+ val deleteresult = wsk.api.delete(basepathOrApiName = testbasepath, relpath = Some(testrelpath), operation = Some(testurlop), expectedExitCode = DONTCARE_EXIT)
+ }
+ }
+}