예제 #1
0
파일: agent_test.go 프로젝트: kapilt/juju
func (s *agentAuthenticatorSuite) TestInvalidLogins(c *gc.C) {
	testCases := []testCase{{
		entity:       s.relation,
		credentials:  "dummy-secret",
		about:        "relation login",
		errorMessage: "invalid request",
	}, {
		entity:       s.user,
		credentials:  "wrongpassword",
		about:        "user login for nonexistant user",
		errorMessage: "invalid entity name or password",
	}, {
		entity:       s.machine,
		credentials:  s.machinePassword,
		nonce:        "123",
		about:        "machine login",
		errorMessage: "machine 0 is not provisioned",
	}, {
		entity:       s.user,
		credentials:  "wrong-secret",
		about:        "user login for nonexistant user",
		errorMessage: "invalid entity name or password",
	}}

	for i, t := range testCases {
		c.Logf("test %d: %s", i, t.about)
		var authenticator authentication.AgentAuthenticator
		err := authenticator.Authenticate(t.entity, t.credentials, t.nonce)
		c.Check(err, gc.ErrorMatches, t.errorMessage)
	}
}
예제 #2
0
func (s *agentAuthenticatorSuite) TestValidLogins(c *gc.C) {
	testCases := []testCase{{
		entity:      s.user,
		credentials: "password",
		about:       "user login",
	}, {
		entity:      s.machine,
		credentials: s.machinePassword,
		nonce:       s.machineNonce,
		about:       "machine login",
	}, {
		entity:      s.unit,
		credentials: s.unitPassword,
		about:       "unit login",
	}}

	for i, t := range testCases {
		c.Logf("test %d: %s", i, t.about)
		var authenticator authentication.AgentAuthenticator
		entity, err := authenticator.Authenticate(s.State, t.entity.Tag(), params.LoginRequest{
			Credentials: t.credentials,
			Nonce:       t.nonce,
		})
		c.Assert(err, jc.ErrorIsNil)
		c.Assert(entity.Tag(), gc.DeepEquals, t.entity.Tag())
	}
}
예제 #3
0
파일: agent_test.go 프로젝트: kapilt/juju
func (s *agentAuthenticatorSuite) TestValidLogins(c *gc.C) {
	testCases := []testCase{{
		entity:      s.user,
		credentials: "password",
		about:       "user login",
	}, {
		entity:      s.machine,
		credentials: s.machinePassword,
		nonce:       s.machineNonce,
		about:       "machine login",
	}, {
		entity:      s.unit,
		credentials: s.unitPassword,
		about:       "unit login",
	}}

	for i, t := range testCases {
		c.Logf("test %d: %s", i, t.about)
		var authenticator authentication.AgentAuthenticator
		err := authenticator.Authenticate(t.entity, t.credentials, t.nonce)
		c.Check(err, gc.IsNil)
	}
}