X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0634b763dd27914cff5ca49c6cfe11233746ee31..da204dccd3df12b5c885068768f95c84e4703047:/lib/controller/federation/login_test.go diff --git a/lib/controller/federation/login_test.go b/lib/controller/federation/login_test.go index ad91bcf802..a6743b320b 100644 --- a/lib/controller/federation/login_test.go +++ b/lib/controller/federation/login_test.go @@ -8,6 +8,7 @@ import ( "context" "net/url" + "git.arvados.org/arvados.git/lib/ctrlctx" "git.arvados.org/arvados.git/sdk/go/arvados" "git.arvados.org/arvados.git/sdk/go/arvadostest" "git.arvados.org/arvados.git/sdk/go/auth" @@ -41,30 +42,30 @@ func (s *LoginSuite) TestDeferToLoginCluster(c *check.C) { } func (s *LoginSuite) TestLogout(c *check.C) { + otherOrigin := arvados.URL{Scheme: "https", Host: "app.example.com", Path: "/"} + otherURL := "https://app.example.com/foo" s.cluster.Services.Workbench1.ExternalURL = arvados.URL{Scheme: "https", Host: "workbench1.example.com"} s.cluster.Services.Workbench2.ExternalURL = arvados.URL{Scheme: "https", Host: "workbench2.example.com"} - s.cluster.Login.Google.Enable = true - s.cluster.Login.Google.ClientID = "zzzzzzzzzzzzzz" + s.cluster.Login.TrustedClients = map[arvados.URL]struct{}{otherOrigin: {}} s.addHTTPRemote(c, "zhome", &arvadostest.APIStub{}) s.cluster.Login.LoginCluster = "zhome" // s.fed is already set by SetUpTest, but we need to // reinitialize with the above config changes. - s.fed = New(s.cluster) + s.fed = New(s.ctx, s.cluster, nil, (&ctrlctx.DBConnector{PostgreSQL: s.cluster.PostgreSQL}).GetDB) - returnTo := "https://app.example.com/foo?bar" for _, trial := range []struct { token string returnTo string target string }{ {token: "", returnTo: "", target: s.cluster.Services.Workbench2.ExternalURL.String()}, - {token: "", returnTo: returnTo, target: returnTo}, - {token: "zzzzzzzzzzzzzzzzzzzzz", returnTo: returnTo, target: returnTo}, - {token: "v2/zzzzz-aaaaa-aaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", returnTo: returnTo, target: returnTo}, - {token: "v2/zhome-aaaaa-aaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", returnTo: returnTo, target: "http://" + s.cluster.RemoteClusters["zhome"].Host + "/logout?" + url.Values{"return_to": {returnTo}}.Encode()}, + {token: "", returnTo: otherURL, target: otherURL}, + {token: "zzzzzzzzzzzzzzzzzzzzz", returnTo: otherURL, target: otherURL}, + {token: "v2/zzzzz-aaaaa-aaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", returnTo: otherURL, target: otherURL}, + {token: "v2/zhome-aaaaa-aaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", returnTo: otherURL, target: "http://" + s.cluster.RemoteClusters["zhome"].Host + "/logout?" + url.Values{"return_to": {otherURL}}.Encode()}, } { c.Logf("trial %#v", trial) - ctx := context.Background() + ctx := s.ctx if trial.token != "" { ctx = auth.NewContext(ctx, &auth.Credentials{Tokens: []string{trial.token}}) }