summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-07-12 17:27:33 +0200
committerStephen Gallagher <sgallagh@redhat.com>2011-07-13 11:00:47 -0400
commit22d268c88f6d324b3a66846af007b06488eddae7 (patch)
treef1a30480e9b57aa9ad6b2cbce8b5eeaa265e559c /src/tests
parent55a89b86267239fc4a8bd62a2496ddbc36d9a024 (diff)
downloadsssd-22d268c88f6d324b3a66846af007b06488eddae7.tar.gz
sssd-22d268c88f6d324b3a66846af007b06488eddae7.tar.bz2
sssd-22d268c88f6d324b3a66846af007b06488eddae7.zip
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
Diffstat (limited to 'src/tests')
-rwxr-xr-xsrc/tests/pyhbac-test.py23
1 files changed, 23 insertions, 0 deletions
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" ]