This is an automated email from the ASF dual-hosted git repository.
rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new 2036548 Factor out subjects view name for identities (#4611)
2036548 is described below
commit 2036548e62dbf959d91c2328e86318bd7cfa656f
Author: rodric rabbah <[email protected]>
AuthorDate: Mon Sep 16 06:12:33 2019 -0400
Factor out subjects view name for identities (#4611)
* Rename class.
* Factor our identities view.
* Code cleanup using Identity.
* Add test for subjects view deserializer. Fix bug in helper method.
* Factor out view name for wskadmin.
---
ansible/roles/controller/tasks/deploy.yml | 1 +
ansible/roles/invoker/tasks/deploy.yml | 1 +
common/scala/src/main/resources/application.conf | 1 +
.../database/cosmosdb/CosmosDBViewMapper.scala | 2 +-
.../core/database/memory/MemoryViewMapper.scala | 4 ++--
.../openwhisk/core/entity/GenericAuthKey.scala | 4 ++--
.../apache/openwhisk/core/entity/Identity.scala | 14 +++++++++-----
.../openwhisk/core/entity/WhiskActivation.scala | 12 +++---------
.../openwhisk/core/entity/WhiskPackage.scala | 2 +-
.../apache/openwhisk/core/entity/WhiskStore.scala | 20 +++++++++++++-------
.../core/loadBalancer/InvokerSupervision.scala | 7 +------
.../logging/ElasticSearchLogStoreTests.scala | 2 +-
.../logging/SplunkLogStoreTests.scala | 2 +-
.../test/DockerToActivationLogStoreTests.scala | 2 +-
.../containerpool/test/ContainerPoolTests.scala | 2 +-
.../containerpool/test/ContainerProxyTests.scala | 2 +-
.../controller/test/BasicAuthenticateTests.scala | 4 ++--
.../controller/test/EntitlementProviderTests.scala | 2 +-
.../core/controller/test/WebActionsApiTests.scala | 3 ++-
.../core/controller/test/WhiskAuthHelpers.scala | 8 ++++++--
...tifactWithFileStorageActivationStoreTests.scala | 2 +-
.../cosmosdb/CosmosDBArtifactStoreTests.scala | 2 +-
.../openwhisk/core/database/test/DbUtils.scala | 4 ++--
.../ArtifactStoreActivationsQueryBehaviors.scala | 2 +-
.../behavior/ArtifactStoreQueryBehaviors.scala | 2 +-
.../ArtifactStoreWhisksQueryBehaviors.scala | 2 +-
.../openwhisk/core/entity/test/SchemaTests.scala | 22 ++++++++++++++++++----
.../invoker/test/NamespaceBlacklistTests.scala | 9 ++-------
.../test/InvokerSupervisionTests.scala | 4 +---
.../test/ShardingContainerPoolBalancerTests.scala | 6 +-----
tools/admin/wskadmin | 9 ++++++---
31 files changed, 86 insertions(+), 73 deletions(-)
diff --git a/ansible/roles/controller/tasks/deploy.yml
b/ansible/roles/controller/tasks/deploy.yml
index 9b68273..4a7482e 100644
--- a/ansible/roles/controller/tasks/deploy.yml
+++ b/ansible/roles/controller/tasks/deploy.yml
@@ -197,6 +197,7 @@
"CONFIG_whisk_couchdb_databases_WhiskEntity": "{{ db.whisk.actions }}"
"CONFIG_whisk_couchdb_databases_WhiskActivation":
"{{ db.whisk.activations }}"
+ "CONFIG_whisk_db_subjectsDdoc": "{{ db_whisk_subjects_ddoc | default()
}}"
"CONFIG_whisk_db_actionsDdoc": "{{ db_whisk_actions_ddoc | default() }}"
"CONFIG_whisk_db_activationsDdoc": "{{ db_whisk_activations_ddoc |
default() }}"
"CONFIG_whisk_db_activationsFilterDdoc": "{{
db_whisk_activations_filter_ddoc | default() }}"
diff --git a/ansible/roles/invoker/tasks/deploy.yml
b/ansible/roles/invoker/tasks/deploy.yml
index 1f86ece..ab64cc8 100644
--- a/ansible/roles/invoker/tasks/deploy.yml
+++ b/ansible/roles/invoker/tasks/deploy.yml
@@ -235,6 +235,7 @@
"DB_WHISK_ACTIONS": "{{ db.whisk.actions }}"
"DB_WHISK_ACTIVATIONS": "{{ db.whisk.activations }}"
"DB_WHISK_AUTHS": "{{ db.whisk.auth }}"
+ "CONFIG_whisk_db_subjectsDdoc": "{{ db_whisk_subjects_ddoc | default()
}}"
"CONFIG_whisk_db_actionsDdoc": "{{ db_whisk_actions_ddoc | default() }}"
"CONFIG_whisk_db_activationsDdoc": "{{ db_whisk_activations_ddoc |
default() }}"
"CONFIG_whisk_db_activationsFilterDdoc": "{{
db_whisk_activations_filter_ddoc | default() }}"
diff --git a/common/scala/src/main/resources/application.conf
b/common/scala/src/main/resources/application.conf
index 83dc369..53a50b6 100644
--- a/common/scala/src/main/resources/application.conf
+++ b/common/scala/src/main/resources/application.conf
@@ -186,6 +186,7 @@ whisk {
}
# db related configuration
db {
+ subjects-ddoc = "subjects"
actions-ddoc = "whisks.v2.1.0"
activations-ddoc = "whisks.v2.1.0"
activations-filter-ddoc = "whisks-filters.v2.1.0"
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBViewMapper.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBViewMapper.scala
index ac26965..6707e34 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBViewMapper.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBViewMapper.scala
@@ -33,7 +33,7 @@ import org.apache.openwhisk.core.database.{
UnsupportedView,
WhisksHandler
}
-import org.apache.openwhisk.core.entity.WhiskEntityQueries.TOP
+import org.apache.openwhisk.core.entity.WhiskQueries.TOP
private[cosmosdb] trait CosmosDBViewMapper {
protected val NOTHING = ""
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/memory/MemoryViewMapper.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/memory/MemoryViewMapper.scala
index bf2b951..4a2ca40 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/memory/MemoryViewMapper.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/memory/MemoryViewMapper.scala
@@ -19,7 +19,7 @@ package org.apache.openwhisk.core.database.memory
import spray.json.{JsArray, JsBoolean, JsNumber, JsObject, JsString, JsTrue}
import org.apache.openwhisk.core.database.{ActivationHandler,
UnsupportedQueryKeys, UnsupportedView, WhisksHandler}
-import org.apache.openwhisk.core.entity.{UserLimits, WhiskEntityQueries}
+import org.apache.openwhisk.core.entity.{UserLimits, WhiskQueries}
import org.apache.openwhisk.utils.JsHelpers
/**
@@ -28,7 +28,7 @@ import org.apache.openwhisk.utils.JsHelpers
* are to be supported by any {{{ArtifactStore}}} implementation
*/
trait MemoryViewMapper {
- protected val TOP: String = WhiskEntityQueries.TOP
+ protected val TOP: String = WhiskQueries.TOP
def filter(ddoc: String, view: String, startKey: List[Any], endKey:
List[Any], d: JsObject, c: JsObject): Boolean
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/GenericAuthKey.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/GenericAuthKey.scala
index cf6849a..6c85004 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/GenericAuthKey.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/GenericAuthKey.scala
@@ -24,9 +24,9 @@ import spray.json._
* Base class for Authentication
*
* This is used to transport data generated by the authentication directive to
the invoker.
- * The invoker can passed this data to the user container.
+ * The invoker can pass this data to the action container.
*
- * Be aware that this class can by itself not be used to provide meaningful
authentication.
+ * Be aware that this class itself cannot be used to provide meaningful
authentication.
*/
protected[core] class GenericAuthKey(val toEnvironment: JsObject) {
def getCredentials: Option[HttpCredentials] = None
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/Identity.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/Identity.scala
index fcbb717..57b9f31 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/Identity.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/Identity.scala
@@ -38,6 +38,8 @@ case class UserLimits(invocationsPerMinute: Option[Int] =
None,
storeActivations: Option[Boolean] = None)
object UserLimits extends DefaultJsonProtocol {
+ val standardUserLimits = UserLimits()
+
implicit val serdes = jsonFormat5(UserLimits.apply)
}
@@ -50,12 +52,12 @@ protected[core] object Namespace extends
DefaultJsonProtocol {
protected[core] case class Identity(subject: Subject,
namespace: Namespace,
authkey: GenericAuthKey,
- rights: Set[Privilege],
- limits: UserLimits = UserLimits())
+ rights: Set[Privilege] = Set.empty,
+ limits: UserLimits =
UserLimits.standardUserLimits)
object Identity extends MultipleReadersSingleWriterCache[Option[Identity],
DocInfo] with DefaultJsonProtocol {
- private val viewName = "subjects/identities"
+ private val viewName = WhiskQueries.view(WhiskQueries.dbConfig.subjectsDdoc,
"identities").name
override val cacheEnabled = true
override val evictionPolicy = WriteTime
@@ -129,10 +131,12 @@ object Identity extends
MultipleReadersSingleWriterCache[Option[Identity], DocIn
stale = StaleParameter.No)
}
- private def rowToIdentity(row: JsObject, key: String)(implicit transid:
TransactionId, logger: Logging) = {
+ protected[entity] def rowToIdentity(row: JsObject, key: String)(implicit
transid: TransactionId, logger: Logging) = {
row.getFields("id", "value", "doc") match {
case Seq(JsString(id), JsObject(value), doc) =>
- val limits = Try(doc.convertTo[UserLimits]).getOrElse(UserLimits())
+ val limits =
+ if (doc != JsNull)
Try(doc.convertTo[UserLimits]).getOrElse(UserLimits.standardUserLimits)
+ else UserLimits.standardUserLimits
val subject = Subject(id)
val JsString(uuid) = value("uuid")
val JsString(secret) = value("key")
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskActivation.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskActivation.scala
index 17ff6d0..b275e8b 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskActivation.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskActivation.scala
@@ -24,9 +24,7 @@ import scala.util.Try
import spray.json._
import spray.json.DefaultJsonProtocol._
import org.apache.openwhisk.common.TransactionId
-import org.apache.openwhisk.core.ConfigKeys
import org.apache.openwhisk.core.database.{ArtifactStore,
CacheChangeNotification, DocumentFactory, StaleParameter}
-import pureconfig._
/**
* A WhiskActivation provides an abstraction of the meta-data
@@ -168,18 +166,14 @@ object WhiskActivation
override val collectionName = "activations"
- private val dbConfig = loadConfigOrThrow[DBConfig](ConfigKeys.db)
- private val mainDdoc = dbConfig.activationsDdoc
- private val filtersDdoc = dbConfig.activationsFilterDdoc
-
/** The main view for activations, keyed by namespace, sorted by date. */
- override lazy val view = WhiskEntityQueries.view(mainDdoc, collectionName)
+ override lazy val view =
WhiskQueries.view(WhiskQueries.dbConfig.activationsDdoc, collectionName)
/**
* A view for activations in a namespace additionally keyed by action name
* (and package name if present) sorted by date.
*/
- lazy val filtersView = WhiskEntityQueries.view(filtersDdoc, collectionName)
+ lazy val filtersView =
WhiskQueries.view(WhiskQueries.dbConfig.activationsFilterDdoc, collectionName)
override implicit val serdes = jsonFormat13(WhiskActivation.apply)
@@ -204,7 +198,7 @@ object WhiskActivation
upto: Option[Instant] = None,
stale: StaleParameter = StaleParameter.No)(
implicit transid: TransactionId): Future[Either[List[JsObject],
List[WhiskActivation]]] = {
- import WhiskEntityQueries.TOP
+ import WhiskQueries.TOP
val convert = if (includeDocs) Some((o: JsObject) => Try { serdes.read(o)
}) else None
val startKey = List(namespace.addPath(path).asString, since map {
_.toEpochMilli } getOrElse 0)
val endKey = List(namespace.addPath(path).asString, upto map {
_.toEpochMilli } getOrElse TOP, TOP)
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskPackage.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskPackage.scala
index d865dd8..c3c5050 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskPackage.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskPackage.scala
@@ -202,7 +202,7 @@ object WhiskPackage
override val cacheEnabled = true
- lazy val publicPackagesView: View = WhiskEntityQueries.view(collection =
s"$collectionName-public")
+ lazy val publicPackagesView: View = WhiskQueries.entitiesView(collection =
s"$collectionName-public")
}
/**
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskStore.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskStore.scala
index 0323122..46c7452 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskStore.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskStore.scala
@@ -45,7 +45,7 @@ package object types {
type EntityStore = ArtifactStore[WhiskEntity]
}
-case class DBConfig(actionsDdoc: String, activationsDdoc: String,
activationsFilterDdoc: String)
+case class DBConfig(subjectsDdoc: String, actionsDdoc: String,
activationsDdoc: String, activationsFilterDdoc: String)
protected[core] trait WhiskDocument extends DocumentSerializer with
DocumentRevisionProvider {
@@ -139,23 +139,29 @@ protected[core] case class View(ddoc: String, view:
String) {
* refined by name.
*
*/
-object WhiskEntityQueries {
+object WhiskQueries {
val TOP = "\ufff0"
- /** The design document to use for queries. */
- val designDoc = loadConfigOrThrow[DBConfig](ConfigKeys.db).actionsDdoc
+ /** The view name for the collection, within the design document. */
+ def view(ddoc: String, collection: String) = new View(ddoc, collection)
/** The view name for the collection, within the design document. */
- def view(ddoc: String = designDoc, collection: String) = new View(ddoc,
collection)
+ def entitiesView(collection: String) = new View(entitiesDesignDoc,
collection)
+
+ /** The db configuration. */
+ protected[entity] val dbConfig = loadConfigOrThrow[DBConfig](ConfigKeys.db)
+
+ /** The design document to use for queries. */
+ private val entitiesDesignDoc = dbConfig.actionsDdoc
}
trait WhiskEntityQueries[T] {
val collectionName: String
val serdes: RootJsonFormat[T]
- import WhiskEntityQueries._
+ import WhiskQueries._
/** The view name for the collection, within the design document. */
- lazy val view: View = WhiskEntityQueries.view(collection = collectionName)
+ lazy val view: View = WhiskQueries.entitiesView(collection = collectionName)
/**
* Queries the datastore for records from a specific collection (i.e., type)
matching
diff --git
a/core/controller/src/main/scala/org/apache/openwhisk/core/loadBalancer/InvokerSupervision.scala
b/core/controller/src/main/scala/org/apache/openwhisk/core/loadBalancer/InvokerSupervision.scala
index 147e825..e1b7c64 100644
---
a/core/controller/src/main/scala/org/apache/openwhisk/core/loadBalancer/InvokerSupervision.scala
+++
b/core/controller/src/main/scala/org/apache/openwhisk/core/loadBalancer/InvokerSupervision.scala
@@ -34,7 +34,6 @@ import akka.util.Timeout
import org.apache.openwhisk.common._
import org.apache.openwhisk.core.connector._
import org.apache.openwhisk.core.database.NoDocumentException
-import org.apache.openwhisk.core.entitlement.Privilege
import org.apache.openwhisk.core.entity.ActivationId.ActivationIdGenerator
import org.apache.openwhisk.core.entity._
import org.apache.openwhisk.core.entity.types.EntityStore
@@ -263,11 +262,7 @@ object InvokerPool {
val healthActionIdentity: Identity = {
val whiskSystem = "whisk.system"
val uuid = UUID()
- Identity(
- Subject(whiskSystem),
- Namespace(EntityName(whiskSystem), uuid),
- BasicAuthenticationAuthKey(uuid, Secret()),
- Set[Privilege]())
+ Identity(Subject(whiskSystem), Namespace(EntityName(whiskSystem), uuid),
BasicAuthenticationAuthKey(uuid, Secret()))
}
/** An action to use for monitoring invoker health. */
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchLogStoreTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchLogStoreTests.scala
index a3af8fd..742755a 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchLogStoreTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchLogStoreTests.scala
@@ -56,7 +56,7 @@ class ElasticSearchLogStoreTests
private val uuid = UUID()
private val user =
- Identity(Subject(), Namespace(EntityName("testSpace"), uuid),
BasicAuthenticationAuthKey(uuid, Secret()), Set.empty)
+ Identity(Subject(), Namespace(EntityName("testSpace"), uuid),
BasicAuthenticationAuthKey(uuid, Secret()))
private val activationId = ActivationId.generate()
private val defaultLogSchema =
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/SplunkLogStoreTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/SplunkLogStoreTests.scala
index f2e7ecb..1b185dd 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/SplunkLogStoreTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/SplunkLogStoreTests.scala
@@ -82,7 +82,7 @@ class SplunkLogStoreTests
val endTimePlusOffset = "2007-12-03T10:16:07Z" //queried end time range is
endTime+22
val uuid = UUID()
val user =
- Identity(Subject(), Namespace(EntityName("testSpace"), uuid),
BasicAuthenticationAuthKey(uuid, Secret()), Set.empty)
+ Identity(Subject(), Namespace(EntityName("testSpace"), uuid),
BasicAuthenticationAuthKey(uuid, Secret()))
val request = HttpRequest(
method = POST,
uri = "https://some.url",
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/test/DockerToActivationLogStoreTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/test/DockerToActivationLogStoreTests.scala
index b6118eb..a5660f7 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/test/DockerToActivationLogStoreTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/test/DockerToActivationLogStoreTests.scala
@@ -47,7 +47,7 @@ class DockerToActivationLogStoreTests extends FlatSpec with
Matchers with WskAct
val uuid = UUID()
val user =
- Identity(Subject(), Namespace(EntityName("testSpace"), uuid),
BasicAuthenticationAuthKey(uuid, Secret()), Set.empty)
+ Identity(Subject(), Namespace(EntityName("testSpace"), uuid),
BasicAuthenticationAuthKey(uuid, Secret()))
val exec = CodeExecAsString(RuntimeManifest("actionKind",
ImageName("testImage")), "testCode", None)
val action = ExecutableWhiskAction(user.namespace.name.toPath,
EntityName("actionName"), exec)
val successfulActivation =
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerPoolTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerPoolTests.scala
index e79fec1..2424879 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerPoolTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerPoolTests.scala
@@ -75,7 +75,7 @@ class ContainerPoolTests
TransactionId.testing,
action.fullyQualifiedName(true),
action.rev,
- Identity(Subject(), Namespace(invocationNamespace, uuid),
BasicAuthenticationAuthKey(uuid, Secret()), Set.empty),
+ Identity(Subject(), Namespace(invocationNamespace, uuid),
BasicAuthenticationAuthKey(uuid, Secret())),
ActivationId.generate(),
ControllerInstanceId("0"),
blocking = false,
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerProxyTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerProxyTests.scala
index 21833cb..e4d041d 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerProxyTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerProxyTests.scala
@@ -105,7 +105,7 @@ class ContainerProxyTests
messageTransId,
action.fullyQualifiedName(true),
action.rev,
- Identity(Subject(), Namespace(invocationNamespace, uuid),
BasicAuthenticationAuthKey(uuid, Secret()), Set.empty),
+ Identity(Subject(), Namespace(invocationNamespace, uuid),
BasicAuthenticationAuthKey(uuid, Secret())),
ActivationId.generate(),
ControllerInstanceId("0"),
blocking = false,
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/controller/test/BasicAuthenticateTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/controller/test/BasicAuthenticateTests.scala
index 81fb326..fd4fcbc 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/controller/test/BasicAuthenticateTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/controller/test/BasicAuthenticateTests.scala
@@ -70,7 +70,7 @@ class BasicAuthenticateTests extends ControllerTestCommon {
BasicAuthenticationDirective
.validateCredentials(Some(pass))(transid, executionContext,
logging, authStore),
dbOpTimeout)
- user.get shouldBe Identity(subject, ns.namespace, ns.authkey,
Privilege.ALL)
+ user.get shouldBe Identity(subject, ns.namespace, ns.authkey, rights =
Privilege.ALL)
// first lookup should have been from datastore
stream.toString should include(s"serving from datastore:
${CacheKey(ns.authkey)}")
@@ -81,7 +81,7 @@ class BasicAuthenticateTests extends ControllerTestCommon {
BasicAuthenticationDirective
.validateCredentials(Some(pass))(transid, executionContext,
logging, authStore),
dbOpTimeout)
- cachedUser.get shouldBe Identity(subject, ns.namespace, ns.authkey,
Privilege.ALL)
+ cachedUser.get shouldBe Identity(subject, ns.namespace, ns.authkey,
rights = Privilege.ALL)
stream.toString should include(s"serving from cache:
${CacheKey(ns.authkey)}")
stream.reset()
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/controller/test/EntitlementProviderTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/controller/test/EntitlementProviderTests.scala
index ab93d52..179c651 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/controller/test/EntitlementProviderTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/controller/test/EntitlementProviderTests.scala
@@ -166,7 +166,7 @@ class EntitlementProviderTests extends ControllerTestCommon
with ScalaFutures {
subject,
Namespace(EntityName(subject.asString), uuid),
BasicAuthenticationAuthKey(uuid, Secret()),
- Set(Privilege.ACTIVATE))
+ rights = Set(Privilege.ACTIVATE))
val collections = Seq(ACTIONS, RULES, TRIGGERS)
val resources = collections map { Resource(someUser.namespace.name.toPath,
_, Some("xyz")) }
resources foreach { r =>
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/controller/test/WebActionsApiTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/controller/test/WebActionsApiTests.scala
index bd4708a..47975a2 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/controller/test/WebActionsApiTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/controller/test/WebActionsApiTests.scala
@@ -121,7 +121,8 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
val systemId = Subject()
val systemKey = BasicAuthenticationAuthKey(uuid, Secret())
val systemIdentity =
- Future.successful(Identity(systemId,
Namespace(EntityName(systemId.asString), uuid), systemKey, Privilege.ALL))
+ Future.successful(
+ Identity(systemId, Namespace(EntityName(systemId.asString), uuid),
systemKey, rights = Privilege.ALL))
val namespace = EntityPath(systemId.asString)
val proxyNamespace = namespace.addPath(EntityName("proxy"))
override lazy val entitlementProvider = new
TestingEntitlementProvider(whiskConfig, loadBalancer)
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/controller/test/WhiskAuthHelpers.scala
b/tests/src/test/scala/org/apache/openwhisk/core/controller/test/WhiskAuthHelpers.scala
index 0e21c9e..6feb68f 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/controller/test/WhiskAuthHelpers.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/controller/test/WhiskAuthHelpers.scala
@@ -25,7 +25,11 @@ object WhiskAuthHelpers {
WhiskAuth(s, Set(WhiskNamespace(Namespace(EntityName(s.asString), k.uuid),
k)))
}
- def newIdentity(s: Subject = Subject(), uuid: UUID = UUID(), k:
GenericAuthKey = BasicAuthenticationAuthKey()) = {
- Identity(s, Namespace(EntityName(s.asString), uuid), k, Privilege.ALL)
+ def newIdentity(s: Subject = Subject(), k: BasicAuthenticationAuthKey =
BasicAuthenticationAuthKey()) = {
+ Identity(s, Namespace(EntityName(s.asString), k.uuid), k, rights =
Privilege.ALL)
+ }
+
+ def newIdentityGenricAuth(s: Subject = Subject(), uuid: UUID = UUID(), k:
GenericAuthKey) = {
+ Identity(s, Namespace(EntityName(s.asString), uuid), k, rights =
Privilege.ALL)
}
}
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/database/ArtifactWithFileStorageActivationStoreTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/database/ArtifactWithFileStorageActivationStoreTests.scala
index 8a38b6a..f2c64e9 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/database/ArtifactWithFileStorageActivationStoreTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/database/ArtifactWithFileStorageActivationStoreTests.scala
@@ -56,7 +56,7 @@ class ArtifactWithFileStorageActivationStoreTests()
private val uuid = UUID()
private val subject = Subject()
private val user =
- Identity(subject, Namespace(EntityName("testSpace"), uuid),
BasicAuthenticationAuthKey(uuid, Secret()), Set())
+ Identity(subject, Namespace(EntityName("testSpace"), uuid),
BasicAuthenticationAuthKey(uuid, Secret()))
private val context = UserContext(user, HttpRequest())
override def afterAll(): Unit = {
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBArtifactStoreTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBArtifactStoreTests.scala
index 9600f60..d05c607 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBArtifactStoreTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBArtifactStoreTests.scala
@@ -24,7 +24,7 @@ import org.apache.openwhisk.common.TransactionId
import org.apache.openwhisk.core.database.DocumentSerializer
import org.apache.openwhisk.core.database.memory.MemoryAttachmentStoreProvider
import org.apache.openwhisk.core.database.test.behavior.ArtifactStoreBehavior
-import org.apache.openwhisk.core.entity.WhiskEntityQueries.TOP
+import org.apache.openwhisk.core.entity.WhiskQueries.TOP
import org.apache.openwhisk.core.entity.size._
import org.apache.openwhisk.core.entity.{
DocumentReader,
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/database/test/DbUtils.scala
b/tests/src/test/scala/org/apache/openwhisk/core/database/test/DbUtils.scala
index b5989da..853836a 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/database/test/DbUtils.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/database/test/DbUtils.scala
@@ -98,7 +98,7 @@ trait DbUtils extends Assertions {
implicit context: ExecutionContext,
transid: TransactionId,
timeout: Duration): Unit =
- waitOnViewImpl(db, List(namespace.asString), List(namespace.asString,
WhiskEntityQueries.TOP), count, view)
+ waitOnViewImpl(db, List(namespace.asString), List(namespace.asString,
WhiskQueries.TOP), count, view)
/**
* Wait on a view to update with documents added to namespace. This uses
retry above,
@@ -109,7 +109,7 @@ trait DbUtils extends Assertions {
implicit context: ExecutionContext,
transid: TransactionId,
timeout: Duration): Unit =
- waitOnViewImpl(db, List(path.asString), List(path.asString,
WhiskEntityQueries.TOP), count, view)
+ waitOnViewImpl(db, List(path.asString), List(path.asString,
WhiskQueries.TOP), count, view)
/**
* Wait on a view to update with documents added(don't specify the
namespace). This uses retry above,
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreActivationsQueryBehaviors.scala
b/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreActivationsQueryBehaviors.scala
index 30129fb..91c276c 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreActivationsQueryBehaviors.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreActivationsQueryBehaviors.scala
@@ -18,7 +18,7 @@
package org.apache.openwhisk.core.database.test.behavior
import org.apache.openwhisk.common.TransactionId
-import org.apache.openwhisk.core.entity.WhiskEntityQueries.TOP
+import org.apache.openwhisk.core.entity.WhiskQueries.TOP
import org.apache.openwhisk.core.entity.{EntityPath, WhiskActivation}
trait ArtifactStoreActivationsQueryBehaviors extends ArtifactStoreBehaviorBase
{
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreQueryBehaviors.scala
b/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreQueryBehaviors.scala
index 772403e..89df04b 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreQueryBehaviors.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreQueryBehaviors.scala
@@ -19,7 +19,7 @@ package org.apache.openwhisk.core.database.test.behavior
import spray.json.{JsArray, JsNumber, JsObject, JsString}
import org.apache.openwhisk.common.TransactionId
-import org.apache.openwhisk.core.entity.WhiskEntityQueries.TOP
+import org.apache.openwhisk.core.entity.WhiskQueries.TOP
import org.apache.openwhisk.core.entity.{EntityPath, WhiskAction,
WhiskActivation, WhiskEntity}
trait ArtifactStoreQueryBehaviors extends ArtifactStoreBehaviorBase {
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreWhisksQueryBehaviors.scala
b/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreWhisksQueryBehaviors.scala
index 3d3de55..d287d65 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreWhisksQueryBehaviors.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/database/test/behavior/ArtifactStoreWhisksQueryBehaviors.scala
@@ -20,7 +20,7 @@ package org.apache.openwhisk.core.database.test.behavior
import java.time.Instant
import org.apache.openwhisk.common.TransactionId
-import org.apache.openwhisk.core.entity.WhiskEntityQueries.TOP
+import org.apache.openwhisk.core.entity.WhiskQueries.TOP
import org.apache.openwhisk.core.entity._
trait ArtifactStoreWhisksQueryBehaviors extends ArtifactStoreBehaviorBase {
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/entity/test/SchemaTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/entity/test/SchemaTests.scala
index d353276..6f9a322 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/entity/test/SchemaTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/entity/test/SchemaTests.scala
@@ -42,8 +42,6 @@ import org.apache.openwhisk.utils.JsHelpers
@RunWith(classOf[JUnitRunner])
class SchemaTests extends FlatSpec with BeforeAndAfter with ExecHelpers with
Matchers {
- behavior of "AuthKey"
-
behavior of "Privilege"
private implicit class ExecJson(e: Exec) {
@@ -106,12 +104,12 @@ class SchemaTests extends FlatSpec with BeforeAndAfter
with ExecHelpers with Mat
Identity.serdes.write(i) shouldBe expected
}
- it should "serdes read an generic identity" in {
+ it should "serdes read a generic identity" in {
val uuid = UUID()
val subject = Subject("test_subject")
val entity = EntityName("test_subject")
val genericAuthKey = new GenericAuthKey(JsObject("test_key" ->
"test_value".toJson))
- val i = WhiskAuthHelpers.newIdentity(subject, uuid, genericAuthKey)
+ val i = WhiskAuthHelpers.newIdentityGenricAuth(subject, uuid,
genericAuthKey)
val json = JsObject(
"subject" -> Subject("test_subject").toJson,
@@ -122,6 +120,22 @@ class SchemaTests extends FlatSpec with BeforeAndAfter
with ExecHelpers with Mat
Identity.serdes.read(json) shouldBe i
}
+ it should "deserialize view result" in {
+ implicit val tid = TransactionId("test")
+ val subject = Subject("test_subject")
+ val id = WhiskAuthHelpers.newIdentity(subject)
+
+ val json = JsObject(
+ "id" -> subject.asString.toJson,
+ "value" -> JsObject(
+ "uuid" ->
id.authkey.asInstanceOf[BasicAuthenticationAuthKey].uuid.toJson,
+ "key" ->
id.authkey.asInstanceOf[BasicAuthenticationAuthKey].key.toJson,
+ "namespace" -> "test_subject".toJson),
+ "doc" -> JsNull)
+
+ Identity.rowToIdentity(json, "test") shouldBe id
+ }
+
behavior of "DocInfo"
it should "accept well formed doc info" in {
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/invoker/test/NamespaceBlacklistTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/invoker/test/NamespaceBlacklistTests.scala
index 3c83149..51df0e9 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/invoker/test/NamespaceBlacklistTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/invoker/test/NamespaceBlacklistTests.scala
@@ -69,18 +69,13 @@ class NamespaceBlacklistTests
private def authToIdentities(auth: WhiskAuth): Set[Identity] = {
auth.namespaces.map { ns =>
- Identity(auth.subject, ns.namespace, ns.authkey, Set.empty, UserLimits())
+ Identity(auth.subject, ns.namespace, ns.authkey)
}
}
private def limitToIdentity(limit: LimitEntity): Identity = {
val namespace = limit.docid.id.dropRight("/limits".length)
- Identity(
- limit.subject,
- Namespace(EntityName(namespace), UUID()),
- BasicAuthenticationAuthKey(UUID(), Secret()),
- Set(),
- UserLimits())
+ Identity(limit.subject, Namespace(EntityName(namespace), UUID()),
BasicAuthenticationAuthKey(UUID(), Secret()))
}
override def beforeAll() = {
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/loadBalancer/test/InvokerSupervisionTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/loadBalancer/test/InvokerSupervisionTests.scala
index b675dfa..1bf6d7d 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/loadBalancer/test/InvokerSupervisionTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/loadBalancer/test/InvokerSupervisionTests.scala
@@ -61,7 +61,6 @@ import org.apache.openwhisk.core.loadBalancer.InvokerState
import org.apache.openwhisk.core.loadBalancer.InvokerHealth
import org.apache.openwhisk.utils.retry
import org.apache.openwhisk.core.connector.test.TestConnector
-import org.apache.openwhisk.core.entitlement.Privilege
import org.apache.openwhisk.core.entity.ControllerInstanceId
@RunWith(classOf[JUnitRunner])
@@ -191,8 +190,7 @@ class InvokerSupervisionTests
user = Identity(
Subject("unhealthyInvokerCheck"),
Namespace(EntityName("unhealthyInvokerCheck"), uuid),
- BasicAuthenticationAuthKey(uuid, Secret()),
- Set[Privilege]()),
+ BasicAuthenticationAuthKey(uuid, Secret())),
activationId = new ActivationIdGenerator {}.make(),
rootControllerIndex = ControllerInstanceId("0"),
blocking = false,
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/loadBalancer/test/ShardingContainerPoolBalancerTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/loadBalancer/test/ShardingContainerPoolBalancerTests.scala
index b7666ce..7646b49 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/loadBalancer/test/ShardingContainerPoolBalancerTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/loadBalancer/test/ShardingContainerPoolBalancerTests.scala
@@ -498,11 +498,7 @@ class ShardingContainerPoolBalancerTests
TransactionId.testing,
actionMetaData.fullyQualifiedName(true),
actionMetaData.rev,
- Identity(
- Subject(),
- Namespace(invocationNamespace, uuid),
- BasicAuthenticationAuthKey(uuid, Secret()),
- Set.empty),
+ Identity(Subject(), Namespace(invocationNamespace, uuid),
BasicAuthenticationAuthKey(uuid, Secret())),
aid,
ControllerInstanceId("0"),
blocking = false,
diff --git a/tools/admin/wskadmin b/tools/admin/wskadmin
index 03eb5a0..37e7aeb 100755
--- a/tools/admin/wskadmin
+++ b/tools/admin/wskadmin
@@ -101,6 +101,7 @@ def parseArgs():
subparsers.required = True
propmenu = subparsers.add_parser('user', help='manage users')
+ propmenu.add_argument('-w', '--view', help='the subject view to query',
default='subjects')
subparser = propmenu.add_subparsers(title='available commands',
dest='subcmd')
subparser.required = True
@@ -160,7 +161,7 @@ def parseArgs():
subcmd = subparser.add_parser('get', help='get contents of database')
subcmd.add_argument('database', help='the database name')
- subcmd.add_argument('-v', '--view', help='the view in the database to get')
+ subcmd.add_argument('-w', '--view', help='the view in the database to
query')
subcmd.add_argument('--docs', help='include document contents',
action='store_true')
propmenu = subparsers.add_parser('syslog', help='work with system logs')
@@ -380,12 +381,13 @@ def getIdentitiesFromNamespace(args, props):
password = props[DB_PASSWORD]
database = props[DB_WHISK_AUTHS]
- url =
'%(protocol)s://%(host)s:%(port)s/%(database)s/_design/subjects/_view/identities?key=["%(ns)s"]'
% {
+ url =
'%(protocol)s://%(host)s:%(port)s/%(database)s/_design/%(view)s/_view/identities?key=["%(ns)s"]'
% {
'protocol': protocol,
'host' : host,
'port' : port,
'username': username,
'database': database,
+ 'view' : args.view,
'ns' : args.namespace
}
@@ -472,12 +474,13 @@ def whoisUserCmd(args, props):
uuid = authParts[0]
key = authParts[1]
- url =
'%(protocol)s://%(host)s:%(port)s/%(database)s/_design/subjects/_view/identities?key=["%(uuid)s","%(key)s"]'
% {
+ url =
'%(protocol)s://%(host)s:%(port)s/%(database)s/_design/%(view)s/_view/identities?key=["%(uuid)s","%(key)s"]'
% {
'protocol': protocol,
'host' : host,
'port' : port,
'username': username,
'database': database,
+ 'view' : args.view,
'uuid' : uuid,
'key' : key
}