def test_05_user_has_no_tokens(self): user = User("cornelius", realm="r1") passw = "test" options = {} # A user with no tokens will fail to authenticate rv = auth_user_has_no_token(check_user_pass, user, passw, options) self.assertFalse(rv[0]) self.assertEqual(rv[1].get("message"), "The user has no tokens assigned") # Now we set a policy, that a non existing user will authenticate set_policy(name="pol1", scope=SCOPE.AUTH, action=ACTION.PASSNOTOKEN) g = FakeFlaskG() g.policy_object = PolicyClass() g.audit_object = FakeAudit() options = {"g": g} rv = auth_user_has_no_token(check_user_pass, user, passw, options=options) self.assertTrue(rv[0]) self.assertEqual(rv[1].get("message"), u"user has no token, accepted due to " u"'pol1'") delete_policy("pol1")
def test_05_user_has_no_tokens(self): user = User("cornelius", realm="r1") passw = "test" options = {} # A user with no tokens will fail to authenticate rv = auth_user_has_no_token(check_user_pass, user, passw, options) self.assertFalse(rv[0]) self.assertEqual(rv[1].get("message"), "The user has no tokens assigned") # Now we set a policy, that a non existing user will authenticate set_policy(name="pol1", scope=SCOPE.AUTH, action=ACTION.PASSNOTOKEN) g = FakeFlaskG() g.policy_object = PolicyClass() g.audit_object = FakeAudit() options = {"g": g} rv = auth_user_has_no_token(check_user_pass, user, passw, options=options) self.assertTrue(rv[0]) self.assertEqual(rv[1].get("message"), u"user has no token, accepted due to " u"'pol1'") delete_policy("pol1")