1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
11 "git.arvados.org/arvados.git/sdk/go/arvados"
12 "git.arvados.org/arvados.git/sdk/go/arvadostest"
13 check "gopkg.in/check.v1"
16 var _ = check.Suite(&LoginSuite{})
18 type LoginSuite struct {
22 func (s *LoginSuite) TestDeferToLoginCluster(c *check.C) {
23 s.addHTTPRemote(c, "zhome", &arvadostest.APIStub{})
24 s.cluster.Login.LoginCluster = "zhome"
26 returnTo := "https://app.example.com/foo?bar"
27 for _, remote := range []string{"", "ccccc"} {
28 resp, err := s.fed.Login(context.Background(), arvados.LoginOptions{Remote: remote, ReturnTo: returnTo})
29 c.Check(err, check.IsNil)
30 c.Logf("remote %q -- RedirectLocation %q", remote, resp.RedirectLocation)
31 target, err := url.Parse(resp.RedirectLocation)
32 c.Check(err, check.IsNil)
33 c.Check(target.Host, check.Equals, s.cluster.RemoteClusters["zhome"].Host)
34 c.Check(target.Scheme, check.Equals, "http")
35 c.Check(target.Query().Get("return_to"), check.Equals, returnTo)
36 c.Check(target.Query().Get("remote"), check.Equals, remote)
37 _, remotePresent := target.Query()["remote"]
38 c.Check(remotePresent, check.Equals, remote != "")