20640: Test computed permission API through controller.
authorTom Clegg <tom@curii.com>
Thu, 13 Jun 2024 20:45:23 +0000 (16:45 -0400)
committerTom Clegg <tom@curii.com>
Thu, 13 Jun 2024 20:57:11 +0000 (16:57 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/controller/router/router_test.go

index a8359a440026e5eb617c35c4623b998571a277d5..a418855f3b34dd9ac4fcd44b7895296de25d8e52 100644 (file)
@@ -623,6 +623,22 @@ func (s *RouterIntegrationSuite) TestCORS(c *check.C) {
        }
 }
 
+func (s *RouterIntegrationSuite) TestComputedPermissionList(c *check.C) {
+       token := arvadostest.AdminToken
+
+       jresp := map[string]interface{}{}
+       _, rr := doRequest(c, s.rtr, token, "GET", `/arvados/v1/computed_permissions?filters=[["user_uuid","=","`+arvadostest.ActiveUserUUID+`"],["target_uuid","=","`+arvadostest.AProjectUUID+`"]]&select=["perm_level"]`, true, nil, nil, jresp)
+       c.Check(rr.Code, check.Equals, http.StatusOK)
+       c.Check(jresp["items_available"], check.IsNil)
+       if c.Check(jresp["items"], check.HasLen, 1) {
+               item := jresp["items"].([]interface{})[0].(map[string]interface{})
+               c.Check(item, check.DeepEquals, map[string]interface{}{
+                       "kind":       "arvados#computedPermission",
+                       "perm_level": "can_manage",
+               })
+       }
+}
+
 func doRequest(c *check.C, rtr http.Handler, token, method, path string, auth bool, hdrs http.Header, body io.Reader, jresp map[string]interface{}) (*http.Request, *httptest.ResponseRecorder) {
        req := httptest.NewRequest(method, path, body)
        for k, v := range hdrs {