17785: Fixes ACA type so that it doesn't have pointers to string fields.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Wed, 24 Nov 2021 19:53:02 +0000 (16:53 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Wed, 24 Nov 2021 20:36:33 +0000 (17:36 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

lib/controller/handler_test.go
sdk/go/arvados/api_client_authorization.go

index a456627c0d49edb8e65cb3dd717d399589e8c9d2..723e1011f9de62ac871566ec21c4488d1f55b360 100644 (file)
@@ -392,10 +392,30 @@ func (s *HandlerSuite) TestGetObjects(c *check.C) {
        json.Unmarshal(resp.Body.Bytes(), &ksList)
        c.Assert(len(ksList.Items), check.Not(check.Equals), 0)
        ksUUID := ksList.Items[0].UUID
+       // Create a new token for the test user so that we're not comparing
+       // the ones from the fixtures.
+       req = httptest.NewRequest("POST", "/arvados/v1/api_client_authorizations",
+               strings.NewReader(`{
+                       "api_client_authorization": {
+                               "owner_uuid": "`+arvadostest.AdminUserUUID+`",
+                               "created_by_ip_address": "::1",
+                               "last_used_by_ip_address": "::1",
+                               "default_owner_uuid": "`+arvadostest.AdminUserUUID+`"
+                       }
+               }`))
+       req.Header.Set("Authorization", "Bearer "+arvadostest.SystemRootToken)
+       req.Header.Set("Content-type", "application/json")
+       resp = httptest.NewRecorder()
+       s.handler.ServeHTTP(resp, req)
+       c.Assert(resp.Code, check.Equals, http.StatusOK,
+               check.Commentf("%s", resp.Body.String()))
+       var auth arvados.APIClientAuthorization
+       json.Unmarshal(resp.Body.Bytes(), &auth)
+       c.Assert(auth.UUID, check.Not(check.Equals), "")
 
        testCases := map[string]map[string]bool{
                "api_clients/" + arvadostest.TrustedWorkbenchAPIClientUUID:     nil,
-               "api_client_authorizations/" + arvadostest.AdminTokenUUID:      nil,
+               "api_client_authorizations/" + auth.UUID:                       {"href": true, "modified_by_client_uuid": true, "modified_by_user_uuid": true},
                "authorized_keys/" + arvadostest.AdminAuthorizedKeysUUID:       nil,
                "collections/" + arvadostest.CollectionWithUniqueWordsUUID:     {"href": true},
                "containers/" + arvadostest.RunningContainerUUID:               nil,
@@ -411,7 +431,8 @@ func (s *HandlerSuite) TestGetObjects(c *check.C) {
                "workflows/" + arvadostest.WorkflowWithDefinitionYAMLUUID:      nil,
        }
        for url, skippedFields := range testCases {
-               s.CheckObjectType(c, "/arvados/v1/"+url, arvadostest.AdminToken, skippedFields)
+               c.Logf("Testing %q", url)
+               s.CheckObjectType(c, "/arvados/v1/"+url, auth.TokenV2(), skippedFields)
        }
 }
 
index 0fb1dd894062e3942e6b33c3c2c661ee75890629..686caf49d5426a9e32462e20c037cccd5b975652 100644 (file)
@@ -12,16 +12,15 @@ type APIClientAuthorization struct {
        APIClientID          int       `json:"api_client_id"`
        APIToken             string    `json:"api_token"`
        CreatedAt            time.Time `json:"created_at"`
-       CreatedByIPAddress   *string   `json:"created_by_ip_address"`
-       DefaultOwnerUUID     *string   `json:"default_owner_uuid"`
+       CreatedByIPAddress   string    `json:"created_by_ip_address"`
+       DefaultOwnerUUID     string    `json:"default_owner_uuid"`
        Etag                 string    `json:"etag"`
        ExpiresAt            string    `json:"expires_at"`
-       Href                 string    `json:"href"`
        LastUsedAt           time.Time `json:"last_used_at"`
-       LastUsedByIPAddress  *string   `json:"last_used_by_ip_address"`
+       LastUsedByIPAddress  string    `json:"last_used_by_ip_address"`
        ModifiedAt           time.Time `json:"modified_at"`
-       ModifiedByClientUUID *string   `json:"modified_by_client_uuid"`
-       ModifiedByUserUUID   *string   `json:"modified_by_user_uuid"`
+       ModifiedByClientUUID string    `json:"modified_by_client_uuid"`
+       ModifiedByUserUUID   string    `json:"modified_by_user_uuid"`
        OwnerUUID            string    `json:"owner_uuid"`
        Scopes               []string  `json:"scopes"`
        UserID               int       `json:"user_id"`