This is an automated email from the ASF dual-hosted git repository. houshengbo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit 5b47f4f5c3d844e331c658985b65227e952c9060 Author: Mark Deuser <[email protected]> AuthorDate: Wed Jul 12 12:46:04 2017 -0400 API GW V2 updates (#2436) - Do not enforce need for gwUrl parameter in api gw actions - Enable http redirect forwarding - Add automated test to validate rejection of api creation with invalid auth key --- .../actions/test/ApiGwRoutemgmtActionTests.scala | 8 ++--- .../scala/whisk/core/cli/test/ApiGwTests.scala | 35 ++++++++++++++++++++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala index 5e8b5dd..5a0f97c 100644 --- a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala +++ b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala @@ -427,10 +427,10 @@ class ApiGwRoutemgmtActionTests it should "reject routemgmt actions that are invoked with not enough parameters" in { val invalidArgs = Seq( //getApi - ("/whisk.system/routemgmt/getApi", ANY_ERROR_EXIT, "__ow_user is required", Seq()), + ("/whisk.system/routemgmt/getApi", ANY_ERROR_EXIT, "Invalid authentication.", Seq()), //deleteApi - ("/whisk.system/routemgmt/deleteApi", ANY_ERROR_EXIT, "__ow_user is required", Seq("-p", "basepath", "/ApiGwRoutemgmtActionTests_bp")), + ("/whisk.system/routemgmt/deleteApi", ANY_ERROR_EXIT, "Invalid authentication.", Seq("-p", "basepath", "/ApiGwRoutemgmtActionTests_bp")), ("/whisk.system/routemgmt/deleteApi", ANY_ERROR_EXIT, "basepath is required", Seq("-p", "__ow_user", "_")), ("/whisk.system/routemgmt/deleteApi", ANY_ERROR_EXIT, "When specifying an operation, the path is required", Seq("-p", "__ow_user", "_", "-p", "basepath", "/ApiGwRoutemgmtActionTests_bp", "-p", "operation", "get")), @@ -560,10 +560,10 @@ class ApiGwRoutemgmtActionTests it should "reject apimgmt actions that are invoked with not enough parameters" in { val invalidArgs = Seq( //getApi - ("/whisk.system/apimgmt/getApi", ANY_ERROR_EXIT, "__ow_user is required", Seq()), + ("/whisk.system/apimgmt/getApi", ANY_ERROR_EXIT, "Invalid authentication.", Seq()), //deleteApi - ("/whisk.system/apimgmt/deleteApi", ANY_ERROR_EXIT, "__ow_user is required", Seq("-p", "basepath", "/ApiGwRoutemgmtActionTests_bp")), + ("/whisk.system/apimgmt/deleteApi", ANY_ERROR_EXIT, "Invalid authentication.", Seq("-p", "basepath", "/ApiGwRoutemgmtActionTests_bp")), ("/whisk.system/apimgmt/deleteApi", ANY_ERROR_EXIT, "basepath is required", Seq("-p", "__ow_user", "_", "-p", "accesstoken", "TOKEN")), ("/whisk.system/apimgmt/deleteApi", ANY_ERROR_EXIT, "When specifying an operation, the path is required", Seq("-p", "__ow_user", "_", "-p", "accesstoken", "TOKEN", "-p", "basepath", "/ApiGwRoutemgmtActionTests_bp", "-p", "operation", "get")), diff --git a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala index 2a0a1d5..aadb929 100644 --- a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala +++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala @@ -43,7 +43,7 @@ class ApiGwTests with WskTestHelpers with BeforeAndAfterAll { - implicit val wskprops = WskProps() + implicit var wskprops = WskProps() val wsk = new Wsk val (cliuser, clinamespace) = WskAdmin.getUser(wskprops.authKey) @@ -1194,7 +1194,7 @@ class ApiGwTests it should "reject creation of an API from invalid YAML formatted API configuration file" in { val testName = "CLI_APIGWTEST22" - val testbasepath = "/bp" + val testbasepath = "/"+testName+"_bp" val swaggerPath = TestCLIUtils.getTestApiGwFilename(s"local.api.bad.yaml") try { var rr = apiCreate(swagger = Some(swaggerPath), expectedExitCode = ANY_ERROR_EXIT) @@ -1245,4 +1245,35 @@ class ApiGwTests val deleteresult = apiDelete(basepathOrApiName = testbasepath, expectedExitCode = DONTCARE_EXIT) } } + + it should "reject creation of an API with invalid auth key" in { + val testName = "CLI_APIGWTEST24" + val testbasepath = "/" + testName + "_bp" + val testrelpath = "/path" + val testurlop = "get" + val testapiname = testName + " API Name" + val actionName = testName + "_action" + val wskpropsBackup = wskprops + try { + // Create the action for the API. + val file = TestUtils.getTestActionFilename(s"echo.js") + wsk.action.create(name = actionName, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + + // Set an invalid auth key + wskprops = WskProps(authKey = "bad-auth-key") + + var rr = apiCreate( + basepath = Some(testbasepath), + relpath = Some(testrelpath), + operation = Some(testurlop), + action = Some(actionName), + apiname = Some(testapiname), + expectedExitCode = ANY_ERROR_EXIT) + rr.stderr should include("The supplied authentication is invalid") + } finally { + wskprops = wskpropsBackup + val finallydeleteActionResult = wsk.action.delete(name = actionName, expectedExitCode = DONTCARE_EXIT) + var deleteresult = apiDelete(basepathOrApiName = testbasepath, expectedExitCode = DONTCARE_EXIT) + } + } } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
