From 22d268c88f6d324b3a66846af007b06488eddae7 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 12 Jul 2011 17:27:33 +0200 Subject: Fixes for python HBAC bindings These changes were proposed during a review: * Change the signature of str_concat_sequence() to const char * * use a getsetter for HbacRule.enabled to allow string true/false and integer 1/0 in addition to bool * fix a minor memory leak (HbacRequest.rule_name) * remove overzealous discard consts --- src/tests/pyhbac-test.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/tests') diff --git a/src/tests/pyhbac-test.py b/src/tests/pyhbac-test.py index fdf4ac32..b15d1653 100755 --- a/src/tests/pyhbac-test.py +++ b/src/tests/pyhbac-test.py @@ -137,8 +137,31 @@ class PyHbacRuleTest(unittest.TestCase): rule.enabled = False self.assertEqual(rule.enabled, False) + rule.enabled = "TRUE" + self.assertEqual(rule.enabled, True) + rule.enabled = "FALSE" + self.assertEqual(rule.enabled, False) + + rule.enabled = "true" + self.assertEqual(rule.enabled, True) + rule.enabled = "false" + self.assertEqual(rule.enabled, False) + + rule.enabled = "True" + self.assertEqual(rule.enabled, True) + rule.enabled = "False" + self.assertEqual(rule.enabled, False) + + rule.enabled = 1 + self.assertEqual(rule.enabled, True) + rule.enabled = 0 + self.assertEqual(rule.enabled, False) + # negative test self.assertRaises(TypeError, rule.__setattr__, "enabled", None) + self.assertRaises(TypeError, rule.__setattr__, "enabled", []) + self.assertRaises(ValueError, rule.__setattr__, "enabled", "foo") + self.assertRaises(ValueError, rule.__setattr__, "enabled", 5) def testRuleElementInRule(self): users = [ "foo", "bar" ] -- cgit