17014: Add mock response to users/current. 17014-controller-container-requests-TC
authorTom Clegg <tom@tomclegg.ca>
Tue, 1 Dec 2020 17:14:16 +0000 (12:14 -0500)
committerTom Clegg <tom@tomclegg.ca>
Tue, 1 Dec 2020 17:14:16 +0000 (12:14 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/controller/federation/conn.go
lib/controller/federation_test.go

index 7cbf4f8eb140e3c55ecba4a88bede436f9d90359..e99afc251f21d48dc07341148189e022811d0314 100644 (file)
@@ -360,7 +360,7 @@ func (conn *Conn) ContainerRequestCreate(ctx context.Context, options arvados.Cr
                if err != nil {
                        return arvados.ContainerRequest{}, err
                }
-               if len(aca.Scopes) != 0 || aca.Scopes[0] != "all" {
+               if len(aca.Scopes) == 0 || aca.Scopes[0] != "all" {
                        return arvados.ContainerRequest{}, httpErrorf(http.StatusForbidden, "token scope is not [all]")
                }
                if strings.HasPrefix(aca.UUID, conn.cluster.ClusterID) {
index aa37e332815eb0644acb6a6f88763ac79d3f09c9..9cc9859b6fed23694e600a68ac9027bc3e9d56d1 100644 (file)
@@ -352,7 +352,13 @@ func (s *FederationSuite) localServiceReturns404(c *check.C) *httpserver.Server
        return s.localServiceHandler(c, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
                if req.URL.Path == "/arvados/v1/api_client_authorizations/current" {
                        if req.Header.Get("Authorization") == "Bearer "+arvadostest.ActiveToken {
-                               json.NewEncoder(w).Encode(arvados.APIClientAuthorization{UUID: arvadostest.ActiveTokenUUID, APIToken: arvadostest.ActiveToken})
+                               json.NewEncoder(w).Encode(arvados.APIClientAuthorization{UUID: arvadostest.ActiveTokenUUID, APIToken: arvadostest.ActiveToken, Scopes: []string{"all"}})
+                       } else {
+                               w.WriteHeader(http.StatusUnauthorized)
+                       }
+               } else if req.URL.Path == "/arvados/v1/users/current" {
+                       if req.Header.Get("Authorization") == "Bearer "+arvadostest.ActiveToken {
+                               json.NewEncoder(w).Encode(arvados.User{UUID: arvadostest.ActiveUserUUID})
                        } else {
                                w.WriteHeader(http.StatusUnauthorized)
                        }