var _ = check.Suite(&FederationSuite{})
type FederationSuite struct {
+ ctx context.Context
+ cancel context.CancelFunc
+
log logrus.FieldLogger
// testServer and testHandler are the controller being tested,
// "zhome".
}
func (s *FederationSuite) SetUpTest(c *check.C) {
+ s.ctx, s.cancel = context.WithCancel(context.Background())
s.log = ctxlog.TestLogger(c)
s.remoteServer = newServerFromIntegrationTestEnv(c)
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(s.ctx, s.log)}
s.testServer = newServerFromIntegrationTestEnv(c)
s.testServer.Server.BaseContext = func(net.Listener) context.Context {
return ctxlog.Context(context.Background(), s.log)
if s.testServer != nil {
s.testServer.Close()
}
+ s.cancel()
}
func (s *FederationSuite) testRequest(req *http.Request) *httptest.ResponseRecorder {
s.testHandler.Cluster.API.MaxTokenLifetime = arvados.Duration(time.Hour)
resp := s.testRequest(req).Result()
- c.Check(resp.StatusCode, check.Equals, http.StatusOK)
+ c.Assert(resp.StatusCode, check.Equals, http.StatusOK)
cr := s.getCRfromMockRequest(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)
}