Exemplo n.º 1
0
func (s *UserSuite) logoutTests(u t.TestUser, key util.Key, login bool, c *gc.C) error {
	if login {
		key, err := user.LoginUser(s.d, u.Email, u.Pwhash)
		c.Assert(err, jc.ErrorIsNil)
		u = t.TestUser{
			Email:    u.Email,
			Pwhash:   u.Pwhash,
			LoginKey: string(key),
		}
	}

	if key != util.Key("") {
		u.LoginKey = string(key)
	}

	err := user.LogoutUser(s.d, u.Email, util.Key(u.LoginKey))
	if err != nil {
		return err
	}

	err = user.LogoutUser(s.d, u.Email, util.Key(u.LoginKey))
	c.Assert(err, gc.ErrorMatches, fmt.Sprintf("could not get login for email %q not valid", u.Email))
	return nil
}
Exemplo n.º 2
0
func (s *AuthSuite) logoutTests(user t.TestUser, key util.Key, login bool, c *gc.C) error {
	if login {
		key, err := auth.LoginUser(s.d, user.Email, user.Pwhash)
		c.Assert(err, gc.IsNil)
		user = t.TestUser{
			Email:    user.Email,
			Pwhash:   user.Pwhash,
			LoginKey: string(key),
		}
	}

	if key != util.Key("") {
		user.LoginKey = string(key)
	}

	err := auth.LogoutUser(s.d, user.Email, util.Key(user.LoginKey))
	if err != nil {
		return err
	}

	err = auth.LogoutUser(s.d, user.Email, util.Key(user.LoginKey))
	c.Assert(err, gc.ErrorMatches, fmt.Sprintf("user %q not logged in user not found", user.Email))
	return nil
}