@@ -66,6 +66,8 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
6666 // Some action invocation environments will not have an api key; so allow this check to be conditionally skipped
6767 val apiKeyCheck = true
6868
69+ val requireAPIKeyAnnotation = WhiskProperties .getBooleanProperty(" whisk.feature.requireApiKeyAnnotation" , true );
70+
6971 behavior of " Wsk CLI usage"
7072
7173 it should " show help and usage info" in {
@@ -620,15 +622,20 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
620622
621623 wsk.action.create(name, file, web = Some (flag), update = true )
622624
623- val stdout =
624- wsk.action.get(name, fieldFilter = Some (" annotations" )).stdout
625- assert(stdout.startsWith(s " ok: got action $name, displaying field annotations \n " ))
626- removeCLIHeader(stdout).parseJson shouldBe JsArray (
627- JsObject (" key" -> JsString (" web-export" ), " value" -> JsBoolean (webEnabled || rawEnabled)),
628- JsObject (" key" -> JsString (" raw-http" ), " value" -> JsBoolean (rawEnabled)),
629- JsObject (" key" -> JsString (" final" ), " value" -> JsBoolean (webEnabled || rawEnabled)),
630- JsObject (" key" -> JsString (WhiskAction .provideApiKeyAnnotationName), " value" -> JsBoolean (false )),
631- JsObject (" key" -> JsString (" exec" ), " value" -> JsString (" nodejs:6" )))
625+ val action = wsk.action.get(name)
626+
627+ val baseAnnotations = Parameters (" web-export" , JsBoolean (webEnabled || rawEnabled)) ++
628+ Parameters (" raw-http" , JsBoolean (rawEnabled)) ++
629+ Parameters (" final" , JsBoolean (webEnabled || rawEnabled)) ++
630+ Parameters (" exec" , " nodejs:6" )
631+ val testAnnotations = if (requireAPIKeyAnnotation) {
632+ baseAnnotations ++ Parameters (WhiskAction .provideApiKeyAnnotationName, JsFalse )
633+ } else baseAnnotations
634+
635+ removeCLIHeader(action.stdout).parseJson.asJsObject
636+ .fields(" annotations" )
637+ .convertTo[Set [JsObject ]] shouldBe testAnnotations.toJsArray
638+ .convertTo[Set [JsObject ]]
632639 }
633640 }
634641
@@ -688,14 +695,25 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
688695 action.create(name, file, web = Some (" true" ), update = true )
689696 }
690697
691- val stdout = wsk.action.get(name, fieldFilter = Some (" annotations" )).stdout
692- assert(stdout.startsWith(s " ok: got action $name, displaying field annotations \n " ))
693- removeCLIHeader(stdout).parseJson shouldBe JsArray (
694- JsObject (" key" -> JsString (" web-export" ), " value" -> JsBoolean (true )),
695- JsObject (" key" -> JsString (" raw-http" ), " value" -> JsBoolean (false )),
696- JsObject (" key" -> JsString (" final" ), " value" -> JsBoolean (true )),
697- JsObject (" key" -> JsString (WhiskAction .provideApiKeyAnnotationName), " value" -> JsBoolean (false )),
698- JsObject (" key" -> JsString (" exec" ), " value" -> JsString (" nodejs:6" )))
698+ val baseAnnotations =
699+ Parameters (" web-export" , JsBoolean (true )) ++
700+ Parameters (" raw-http" , JsBoolean (false )) ++
701+ Parameters (" final" , JsBoolean (true ))
702+
703+ val testAnnotations = if (requireAPIKeyAnnotation) {
704+ baseAnnotations ++
705+ Parameters (WhiskAction .provideApiKeyAnnotationName, JsBoolean (false )) ++
706+ Parameters (" exec" , " nodejs:6" )
707+ } else {
708+ baseAnnotations ++
709+ Parameters (" exec" , " nodejs:6" )
710+ }
711+
712+ val action = wsk.action.get(name)
713+ removeCLIHeader(action.stdout).parseJson.asJsObject
714+ .fields(" annotations" )
715+ .convertTo[Set [JsObject ]] shouldBe testAnnotations.toJsArray
716+ .convertTo[Set [JsObject ]]
699717 }
700718
701719 it should " reject action create and update with invalid --web flag input" in withAssetCleaner(wskprops) {
0 commit comments