projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
21585: Updates installer's Terraform code to require IMDSv2 on service nodes.
[arvados.git]
/
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 c5876bbfad6280ad407aadece8cef5be606b187a..2c3fa4d0f72f34da5495657d8b75a18ce53d8e44 100644
(file)
--- a/
lib/controller/localdb/login_pam_test.go
+++ b/
lib/controller/localdb/login_pam_test.go
@@
-5,44
+5,33
@@
package localdb
import (
package localdb
import (
- "context"
"io/ioutil"
"net/http"
"os"
"strings"
"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/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 {
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.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,
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) {
}
}
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",
})
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.
// 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 == "" {
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]
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,
})
Username: u,
Password: p,
})