openwhisk-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [openwhisk] rabbah commented on a change in pull request #4646: Serialize `updated` value in action doc
Date Thu, 26 Sep 2019 10:04:49 GMT
rabbah commented on a change in pull request #4646: Serialize `updated` value in action doc
URL: https://github.com/apache/openwhisk/pull/4646#discussion_r328538666
 
 

 ##########
 File path: tests/src/test/scala/org/apache/openwhisk/core/controller/test/ActionsApiTests.scala
 ##########
 @@ -194,27 +194,49 @@ class ActionsApiTests extends ControllerTestCommon with WhiskActionsApi
{
     implicit val tid = transid()
     val action = WhiskAction(namespace, aname(), jsDefault("??"), Parameters("x", "b"))
     put(entityStore, action)
+
     Get(s"$collectionPath/${action.name}") ~> Route.seal(routes(creds)) ~> check {
       status should be(OK)
       val response = responseAs[WhiskAction]
       response should be(action)
     }
   }
 
-  it should "get action by name in explicit namespace" in {
+  it should "get action with `updated` field" in {
     implicit val tid = transid()
+
     val action = WhiskAction(namespace, aname(), jsDefault("??"), Parameters("x", "b"))
     put(entityStore, action)
+
+    // `updated` field should be compared with a document in DB
+    val a = get(entityStore, action.docid, WhiskAction)
+
+    Get(s"/$namespace/${collection.path}/${action.name}?code=false") ~> Route.seal(routes(creds))
~> check {
+      status should be(OK)
+      val responseJson = responseAs[JsObject]
+      responseJson.fields("updated").convertTo[Long] should be(a.updated.toEpochMilli)
+    }
+
     Get(s"/$namespace/${collection.path}/${action.name}") ~> Route.seal(routes(creds))
~> check {
       status should be(OK)
-      val response = responseAs[WhiskAction]
-      response should be(action)
+      val responseJson = responseAs[JsObject]
+      responseJson.fields("updated").convertTo[Long] should be(a.updated.toEpochMilli)
     }
+  }
 
-    // it should "reject get action by name in explicit namespace not owned by subject" in
-    val auser = WhiskAuthHelpers.newIdentity()
-    Get(s"/$namespace/${collection.path}/${action.name}") ~> Route.seal(routes(auser))
~> check {
-      status should be(Forbidden)
+  it should "not update action `updated` field with a put" in {
+    implicit val tid = transid()
+
+    val action = WhiskAction(namespace, aname(), jsDefault(""))
+    val dummyUpdated = 1569400000000L;
+    val content = JsObject(
+      "exec" -> JsObject("code" -> "".toJson, "kind" -> action.exec.kind.toJson),
+      "updated" -> dummyUpdated.toJson)
+
+    Put(s"$collectionPath/${action.name}", content) ~> Route.seal(routes(creds)) ~>
check {
+      status should be(OK)
+      val response = responseAs[WhiskAction]
+      response.updated.toEpochMilli should not be (dummyUpdated)
 
 Review comment:
   The time stamp should also be greater than a time stamp you can create just before doing
the api request. This way you can at least lower bound the value and make sure it’s assigned
reasonably. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message