16669: Fix access token cache panic.
authorTom Clegg <tom@tomclegg.ca>
Tue, 22 Sep 2020 15:03:45 +0000 (11:03 -0400)
committerTom Clegg <tom@tomclegg.ca>
Wed, 21 Oct 2020 13:04:25 +0000 (09:04 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/controller/auth_test.go
lib/controller/localdb/login_oidc.go

index a188c30828205c47fe86f4d78d52340d19629f47..ad214b160591928892e75c0f6e1e805d4c9e3506 100644 (file)
@@ -115,4 +115,12 @@ func (s *AuthSuite) TestLocalOIDCAccessToken(c *check.C) {
        c.Check(json.NewDecoder(resp.Body).Decode(&u), check.IsNil)
        c.Check(u.UUID, check.Equals, arvadostest.ActiveUserUUID)
        c.Check(u.OwnerUUID, check.Equals, "zzzzz-tpzed-000000000000000")
+
+       // Request again to exercise cache.
+       req = httptest.NewRequest("GET", "/arvados/v1/users/current", nil)
+       req.Header.Set("Authorization", "Bearer "+s.fakeProvider.ValidAccessToken())
+       rr = httptest.NewRecorder()
+       s.testServer.Server.Handler.ServeHTTP(rr, req)
+       resp = rr.Result()
+       c.Check(resp.StatusCode, check.Equals, http.StatusOK)
 }
index b74d22f8ead979e09686856b6b053c7f3c9250f2..8909e0a72ea157028a80915eb51cdfe9ae4dc82b 100644 (file)
@@ -395,7 +395,7 @@ func (ta *oidcTokenAuthorizer) registerToken(ctx context.Context, tok string) er
                }
        } else {
                // cached positive result
-               aca := cached.(*arvados.APIClientAuthorization)
+               aca := cached.(arvados.APIClientAuthorization)
                var expiring bool
                if aca.ExpiresAt != "" {
                        t, err := time.Parse(time.RFC3339Nano, aca.ExpiresAt)