X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/65219ea552b17e3501f933e0b5a40506a5837709..94e82b3e5e65cc8792baf0b4d5dc80ae3721760e:/lib/controller/federation_test.go?ds=sidebyside diff --git a/lib/controller/federation_test.go b/lib/controller/federation_test.go index e3b2291bce..a3b198ffc9 100644 --- a/lib/controller/federation_test.go +++ b/lib/controller/federation_test.go @@ -11,6 +11,7 @@ import ( "fmt" "io" "io/ioutil" + "net" "net/http" "net/http/httptest" "net/url" @@ -57,21 +58,24 @@ func (s *FederationSuite) SetUpTest(c *check.C) { c.Assert(s.remoteMock.Start(), check.IsNil) cluster := &arvados.Cluster{ - ClusterID: "zhome", - PostgreSQL: integrationTestCluster().PostgreSQL, - ForceLegacyAPI14: forceLegacyAPI14, + ClusterID: "zhome", + PostgreSQL: integrationTestCluster().PostgreSQL, } cluster.TLS.Insecure = true cluster.API.MaxItemsPerResponse = 1000 cluster.API.MaxRequestAmplification = 4 cluster.API.RequestTimeout = arvados.Duration(5 * time.Minute) + cluster.Collections.BlobSigning = true + cluster.Collections.BlobSigningKey = arvadostest.BlobSigningKey + cluster.Collections.BlobSigningTTL = arvados.Duration(time.Hour * 24 * 14) arvadostest.SetServiceURL(&cluster.Services.RailsAPI, "http://localhost:1/") arvadostest.SetServiceURL(&cluster.Services.Controller, "http://localhost:/") - s.testHandler = &Handler{Cluster: cluster} + s.testHandler = &Handler{Cluster: cluster, BackgroundContext: ctxlog.Context(context.Background(), s.log)} s.testServer = newServerFromIntegrationTestEnv(c) - s.testServer.Server.Handler = httpserver.HandlerWithContext( - ctxlog.Context(context.Background(), s.log), - httpserver.AddRequestIDs(httpserver.LogRequests(s.testHandler))) + s.testServer.Server.BaseContext = func(net.Listener) context.Context { + return ctxlog.Context(context.Background(), s.log) + } + s.testServer.Server.Handler = httpserver.AddRequestIDs(httpserver.LogRequests(s.testHandler)) cluster.RemoteClusters = map[string]arvados.RemoteCluster{ "zzzzz": { @@ -696,7 +700,6 @@ func (s *FederationSuite) TestCreateRemoteContainerRequestCheckRuntimeToken(c *c s.testHandler.Cluster.ClusterID = "zzzzz" s.testHandler.Cluster.SystemRootToken = arvadostest.SystemRootToken s.testHandler.Cluster.API.MaxTokenLifetime = arvados.Duration(time.Hour) - s.testHandler.Cluster.Collections.BlobSigningTTL = arvados.Duration(336 * time.Hour) // For some reason, this was set to 0h resp := s.testRequest(req).Result() c.Check(resp.StatusCode, check.Equals, http.StatusOK) @@ -718,7 +721,7 @@ func (s *FederationSuite) TestCreateRemoteContainerRequestCheckRuntimeToken(c *c var aca arvados.APIClientAuthorization c.Check(json.NewDecoder(resp.Body).Decode(&aca), check.IsNil) c.Check(aca.ExpiresAt, check.NotNil) // Time.Now()+BlobSigningTTL - t, _ := time.Parse(time.RFC3339Nano, aca.ExpiresAt) + t := aca.ExpiresAt c.Check(t.After(time.Now().Add(s.testHandler.Cluster.API.MaxTokenLifetime.Duration())), check.Equals, true) c.Check(t.Before(time.Now().Add(s.testHandler.Cluster.Collections.BlobSigningTTL.Duration())), check.Equals, true) }