def test_log_out_removes_token(self): stub_request = mock.Mock() cookie = auth.log_in_as_user(stub_request, 'user') num_tokens = len(auth.login_tokens) auth.forget_login_cookie(cookie) assert len(auth.login_tokens) == num_tokens - 1
def token_login(self, cookie): username, ok = auth.check_login_cookie(cookie) if ok: auth.forget_login_cookie(cookie) self.logger.info("User %s logging in (via token).", username) self.do_login(username) else: self.logger.warning("Wrong login token for user %s.", username) self.send_message("login_fail")
def test_repeated_log_out_is_idempotent(self): stub_request = mock.Mock() cookie = auth.log_in_as_user(stub_request, 'user') auth.forget_login_cookie(cookie) login_tokens = auth.login_tokens auth.forget_login_cookie(cookie) # Repeat call should do nothing assert login_tokens == auth.login_tokens
def forget_login_cookie(self, cookie): auth.forget_login_cookie(cookie)