def test_04a_user_does_not_exist_without_resolver(self): user = User("MisterX", realm=self.realm1) passw = "somePW" # Now we set a policy, that a non existing user will authenticate set_policy(name="pol1", scope=SCOPE.AUTH, action="{0}, {1}, {2}, {3}=none".format( ACTION.RESETALLTOKENS, ACTION.PASSNOUSER, ACTION.PASSNOTOKEN, ACTION.OTPPIN ), realm=self.realm1) g = FakeFlaskG() g.policy_object = PolicyClass() g.audit_object = FakeAudit() options = {"g": g} rv = auth_user_does_not_exist(check_user_pass, user, passw, options=options) self.assertTrue(rv[0]) self.assertEqual(rv[1].get("message"), u"user does not exist, accepted due " u"to 'pol1'") delete_policy("pol1")
def test_04_user_does_not_exist(self): user = User("MisterX", realm="NoRealm") passw = "wrongPW" options = {} # A non-existing user will fail to authenticate without a policy self.assertRaises(UserError, auth_user_does_not_exist, check_user_pass, user, passw, options) # Now we set a policy, that a non existing user will authenticate set_policy(name="pol1", scope=SCOPE.AUTH, action=ACTION.PASSNOUSER) g = FakeFlaskG() g.policy_object = PolicyClass() options = {"g": g} rv = auth_user_does_not_exist(check_user_pass, user, passw, options=options) self.assertTrue(rv[0]) self.assertEqual(rv[1].get("message"), u"The user does not exist, but is accepted due " u"to policy 'pol1'.") delete_policy("pol1")
def test_04_user_does_not_exist(self): user = User("MisterX", realm="NoRealm") passw = "wrongPW" options = {} # A non-existing user will fail to authenticate without a policy self.assertRaises(UserError, auth_user_does_not_exist, check_user_pass, user, passw, options) # Now we set a policy, that a non existing user will authenticate set_policy(name="pol1", scope=SCOPE.AUTH, action=ACTION.PASSNOUSER) g = FakeFlaskG() g.policy_object = PolicyClass() options = {"g": g} rv = auth_user_does_not_exist(check_user_pass, user, passw, options=options) self.assertTrue(rv[0]) self.assertEqual(rv[1].get("message"), u"user does not exist, accepted due " u"to 'pol1'") delete_policy("pol1")
def test_04a_user_does_not_exist_without_resolver(self): user = User("MisterX", realm=self.realm1) passw = "somePW" # Now we set a policy, that a non existing user will authenticate set_policy(name="pol1", scope=SCOPE.AUTH, action="{0}, {1}, {2}, {3}=none".format( ACTION.RESETALLTOKENS, ACTION.PASSNOUSER, ACTION.PASSNOTOKEN, ACTION.OTPPIN), realm=self.realm1) g = FakeFlaskG() g.policy_object = PolicyClass() options = {"g": g} rv = auth_user_does_not_exist(check_user_pass, user, passw, options=options) self.assertTrue(rv[0]) self.assertEqual(rv[1].get("message"), u"user does not exist, accepted due " u"to 'pol1'") delete_policy("pol1")