X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3ec51dcf456b2afe02857089895a261653abddd4..f10e92fe095a7b292dde71da0f1d8465312236d7:/lib/controller/localdb/login_pam_test.go diff --git a/lib/controller/localdb/login_pam_test.go b/lib/controller/localdb/login_pam_test.go index c5876bbfad..2c3fa4d0f7 100644 --- a/lib/controller/localdb/login_pam_test.go +++ b/lib/controller/localdb/login_pam_test.go @@ -5,44 +5,33 @@ package localdb import ( - "context" "io/ioutil" "net/http" "os" "strings" - "git.arvados.org/arvados.git/lib/config" - "git.arvados.org/arvados.git/lib/controller/rpc" "git.arvados.org/arvados.git/sdk/go/arvados" - "git.arvados.org/arvados.git/sdk/go/arvadostest" - "git.arvados.org/arvados.git/sdk/go/ctxlog" check "gopkg.in/check.v1" ) var _ = check.Suite(&PamSuite{}) type PamSuite struct { - cluster *arvados.Cluster - ctrl *pamLoginController - railsSpy *arvadostest.Proxy + localdbSuite } -func (s *PamSuite) SetUpSuite(c *check.C) { - cfg, err := config.NewLoader(nil, ctxlog.TestLogger(c)).Load() - c.Assert(err, check.IsNil) - s.cluster, err = cfg.GetCluster("") - c.Assert(err, check.IsNil) +func (s *PamSuite) SetUpTest(c *check.C) { + s.localdbSuite.SetUpTest(c) s.cluster.Login.PAM.Enable = true s.cluster.Login.PAM.DefaultEmailDomain = "example.com" - s.railsSpy = arvadostest.NewProxy(c, s.cluster.Services.RailsAPI) - s.ctrl = &pamLoginController{ + s.localdb.loginController = &pamLoginController{ Cluster: s.cluster, - Parent: &Conn{railsProxy: rpc.NewConn(s.cluster.ClusterID, s.railsSpy.URL, true, rpc.PassthroughTokenProvider)}, + Parent: s.localdb, } } func (s *PamSuite) TestLoginFailure(c *check.C) { - resp, err := s.ctrl.UserAuthenticate(context.Background(), arvados.UserAuthenticateOptions{ + resp, err := s.localdb.UserAuthenticate(s.ctx, arvados.UserAuthenticateOptions{ Username: "bogususername", Password: "boguspassword", }) @@ -57,6 +46,9 @@ func (s *PamSuite) TestLoginFailure(c *check.C) { // This test only runs if the ARVADOS_TEST_PAM_CREDENTIALS_FILE env // var is set. The credentials file should contain a valid username // and password, separated by \n. +// +// Depending on the host config, this test succeeds only if the test +// credentials are for the same account being used to run tests. func (s *PamSuite) TestLoginSuccess(c *check.C) { testCredsFile := os.Getenv("ARVADOS_TEST_PAM_CREDENTIALS_FILE") if testCredsFile == "" { @@ -69,7 +61,7 @@ func (s *PamSuite) TestLoginSuccess(c *check.C) { c.Assert(len(lines), check.Equals, 2, check.Commentf("credentials file %s should contain \"username\\npassword\"", testCredsFile)) u, p := lines[0], lines[1] - resp, err := s.ctrl.UserAuthenticate(context.Background(), arvados.UserAuthenticateOptions{ + resp, err := s.localdb.UserAuthenticate(s.ctx, arvados.UserAuthenticateOptions{ Username: u, Password: p, })