Reflecting new authentication behaviour in whois: returns namespace

Signed-off-by: Christian Bickel <cbickel@de.ibm.com>
diff --git a/tests/src/common/Wsk.scala b/tests/src/common/Wsk.scala
index 8ea9fa2..c3c1c47 100644
--- a/tests/src/common/Wsk.scala
+++ b/tests/src/common/Wsk.scala
@@ -858,11 +858,13 @@
     /**
      * returns user given the auth key
      */
-    def getUser(authKey: String): String = {
+    def getUser(authKey: String): (String, String) = {
         val wskadmin = new RunWskAdminCmd {}
         val user = wskadmin.cli(Seq("user", "whois", authKey)).stdout.trim
         assert(!user.contains("Subject id is not recognized"), s"failed to retrieve user from authkey '$authKey'")
-        user
+
+        val Seq(rawSubject, rawNamespace) = user.lines.toSeq
+        (rawSubject.replaceFirst("subject: ", ""), rawNamespace.replaceFirst("namespace: ", ""))
     }
 }
 
diff --git a/tests/src/whisk/core/admin/WskAdminTests.scala b/tests/src/whisk/core/admin/WskAdminTests.scala
index 43e433f..8b8ee24 100644
--- a/tests/src/whisk/core/admin/WskAdminTests.scala
+++ b/tests/src/whisk/core/admin/WskAdminTests.scala
@@ -53,7 +53,7 @@
         authkey.split(":")(0).length should be(36)
         authkey.split(":")(1).length should be >= 64
 
-        wskadmin.cli(Seq("user", "whois", authkey)).stdout.trim should be(subject)
+        wskadmin.cli(Seq("user", "whois", authkey)).stdout.trim should be(Seq(s"subject: $subject", s"namespace: $subject").mkString("\n"))
         wskadmin.cli(Seq("user", "delete", subject)).stdout should include("Subject deleted")
 
         val recreate = wskadmin.cli(Seq("user", "create", subject, "-u", auth.authkey.compact))
diff --git a/tests/src/whisk/core/cli/test/SequenceMigrationTests.scala b/tests/src/whisk/core/cli/test/SequenceMigrationTests.scala
index ea4921e..ce5ff85 100644
--- a/tests/src/whisk/core/cli/test/SequenceMigrationTests.scala
+++ b/tests/src/whisk/core/cli/test/SequenceMigrationTests.scala
@@ -15,7 +15,6 @@
  */
 package whisk.core.cli.test
 
-
 import java.util.Date
 import scala.concurrent.duration.DurationInt
 import org.junit.runner.RunWith
@@ -57,7 +56,7 @@
     val whiskConfig = new WhiskConfig(WhiskEntityStore.requiredProperties)
     // handle on the entity datastore
     val entityStore = WhiskEntityStore.datastore(whiskConfig)
-    val user = WskAdmin.getUser(wskprops.authKey)
+    val (user, namespace) = WskAdmin.getUser(wskprops.authKey)
     val allowedActionDuration = 120 seconds
 
     behavior of "Sequence Migration"
@@ -67,7 +66,7 @@
             // create entities to insert in the entity store
             val echo = "echo.json"
             val wc = "word_count.json"
-            val seq_echo_wc = "seq_echo_word_count.json"   // old-style sequence
+            val seq_echo_wc = "seq_echo_word_count.json" // old-style sequence
             val entities = Seq(echo, wc, seq_echo_wc)
             implicit val tid = transid() // needed for put db below
             for (entity <- entities) {
@@ -77,7 +76,7 @@
                 val jsonString = try source.mkString finally source.close()
                 val entityJson = jsonString.parseJson.asJsObject
                 // add default namespace (i.e., user) to the json object
-                val entityJsonWithNamespace = JsObject(entityJson.fields + ("namespace" -> JsString(user)))
+                val entityJsonWithNamespace = JsObject(entityJson.fields + ("namespace" -> JsString(namespace)))
                 val wskEntity = entityJsonWithNamespace.convertTo[WhiskAction]
                 put(entityStore, wskEntity)
             }
@@ -93,6 +92,6 @@
     }
 
     after {
-        cleanup()  // cleanup entities from db
+        cleanup() // cleanup entities from db
     }
 }
diff --git a/tests/src/whisk/core/cli/test/WskActionSequenceTests.scala b/tests/src/whisk/core/cli/test/WskActionSequenceTests.scala
index 1f1dde3..56be417 100644
--- a/tests/src/whisk/core/cli/test/WskActionSequenceTests.scala
+++ b/tests/src/whisk/core/cli/test/WskActionSequenceTests.scala
@@ -40,7 +40,7 @@
     implicit val wskprops = WskProps()
     val wsk = new Wsk
     val defaultNamespace = wskprops.namespace
-    val user = WskAdmin.getUser(wskprops.authKey)
+    val (user, namespace) = WskAdmin.getUser(wskprops.authKey)
 
     behavior of "Wsk Action Sequence"
 
@@ -83,5 +83,5 @@
             wsk.parseJsonString(stdout).fields("exec").asJsObject.fields("kind") shouldBe kindValue
     }
 
-    private def resolveDefaultNamespace(actionName: String) = actionName.replace("/_/", s"/$user/")
+    private def resolveDefaultNamespace(actionName: String) = actionName.replace("/_/", s"/$namespace/")
 }
diff --git a/tests/src/whisk/core/cli/test/WskBasicUsageTests.scala b/tests/src/whisk/core/cli/test/WskBasicUsageTests.scala
index f1439f5..70b6319 100644
--- a/tests/src/whisk/core/cli/test/WskBasicUsageTests.scala
+++ b/tests/src/whisk/core/cli/test/WskBasicUsageTests.scala
@@ -476,7 +476,7 @@
 
     it should "invoke an action receiving context properties" in withAssetCleaner(wskprops) {
         (wp, assetHelper) =>
-            val user = WskAdmin.getUser(wskprops.authKey)
+            val (user, namespace) = WskAdmin.getUser(wskprops.authKey)
             val name = "context"
             assetHelper.withCleaner(wsk.action, name) {
                 (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("helloContext.js")))
@@ -490,8 +490,8 @@
                     val fields = activation.response.result.get.convertTo[Map[String, String]]
                     fields("api_host") shouldBe WhiskProperties.getEdgeHost + ":" + WhiskProperties.getEdgeHostApiPort
                     fields("api_key") shouldBe wskprops.authKey
-                    fields("namespace") shouldBe user
-                    fields("action_name") shouldBe s"/$user/$name"
+                    fields("namespace") shouldBe namespace
+                    fields("action_name") shouldBe s"/$namespace/$name"
                     fields("activation_id") shouldBe activation.activationId
                     fields("deadline").toLong should be >= start
             }