Lines Matching defs:pyhbac

56             dest_module_path = MODPATH + "/pyhbac.so"
66 import pyhbac
68 print("Could not load the pyhbac module. Please check if it is compiled", file=sys.stderr)
70 self.assertEqual(pyhbac.__file__, MODPATH + "/pyhbac.so")
75 el = pyhbac.HbacRuleElement()
78 self.assertCountEqual(el.category, set([pyhbac.HBAC_CATEGORY_NULL]))
82 el = pyhbac.HbacRuleElement(names=names)
86 el = pyhbac.HbacRuleElement(groups=groups)
91 el = pyhbac.HbacRuleElement()
97 el = pyhbac.HbacRuleElement()
104 el = pyhbac.HbacRuleElement()
110 el = pyhbac.HbacRuleElement()
111 assert pyhbac.HBAC_CATEGORY_NULL in el.category
112 assert pyhbac.HBAC_CATEGORY_ALL not in el.category
114 el.category.add(pyhbac.HBAC_CATEGORY_ALL)
115 assert pyhbac.HBAC_CATEGORY_ALL in el.category
117 el.category = set([pyhbac.HBAC_CATEGORY_ALL])
118 assert pyhbac.HBAC_CATEGORY_ALL in el.category
121 self.assertRaises(TypeError, el.__setattr__, "category", [pyhbac.HBAC_CATEGORY_ALL])
126 self.assertRaises(TypeError, pyhbac.HbacRuleElement, names=123)
127 self.assertRaises(TypeError, pyhbac.HbacRuleElement, names=None)
133 return pyhbac.HbacRuleElement(names=users, groups=user_groups)
140 el = pyhbac.HbacRuleElement()
143 el.category.add(pyhbac.HBAC_CATEGORY_ALL)
153 rule = pyhbac.HbacRule(name)
160 rule = pyhbac.HbacRule("testRuleGetSetEnabled")
198 rule = pyhbac.HbacRule("testRuleElement")
199 self.assertIsInstance(rule.users, pyhbac.HbacRuleElement)
200 self.assertIsInstance(rule.services, pyhbac.HbacRuleElement)
201 self.assertIsInstance(rule.targethosts, pyhbac.HbacRuleElement)
202 self.assertIsInstance(rule.srchosts, pyhbac.HbacRuleElement)
210 user_el = pyhbac.HbacRuleElement(names=users, groups=user_groups)
211 rule = pyhbac.HbacRule("testRuleElement")
217 rule = pyhbac.HbacRule("testRuleElement")
228 el = pyhbac.HbacRuleElement(names=users, groups=user_groups)
229 rule = pyhbac.HbacRule("testRuleElement")
238 r = pyhbac.HbacRule('foo')
263 r = pyhbac.HbacRule('valid_rule')
267 self.assertCountEqual(missing, (pyhbac.HBAC_RULE_ELEMENT_USERS,
268 pyhbac.HBAC_RULE_ELEMENT_SERVICES,
269 pyhbac.HBAC_RULE_ELEMENT_TARGETHOSTS,
270 pyhbac.HBAC_RULE_ELEMENT_SOURCEHOSTS))
277 self.assertCountEqual(missing, (pyhbac.HBAC_RULE_ELEMENT_TARGETHOSTS,
278 pyhbac.HBAC_RULE_ELEMENT_SOURCEHOSTS))
289 el = pyhbac.HbacRequestElement()
295 el = pyhbac.HbacRequestElement(name=name)
299 el = pyhbac.HbacRequestElement(groups=groups)
304 el = pyhbac.HbacRequestElement()
310 el = pyhbac.HbacRequestElement()
317 el = pyhbac.HbacRequestElement()
323 self.assertRaises(TypeError, pyhbac.HbacRequestElement, groups=None)
324 self.assertRaises(TypeError, pyhbac.HbacRequestElement, groups=123)
327 r = pyhbac.HbacRequestElement()
340 req = pyhbac.HbacRequest()
341 self.assertIsInstance(req.user, pyhbac.HbacRequestElement)
342 self.assertIsInstance(req.service, pyhbac.HbacRequestElement)
343 self.assertIsInstance(req.targethost, pyhbac.HbacRequestElement)
344 self.assertIsInstance(req.srchost, pyhbac.HbacRequestElement)
351 user_el = pyhbac.HbacRequestElement(name=name, groups=groups)
352 req = pyhbac.HbacRequest()
358 req = pyhbac.HbacRequest()
365 req = pyhbac.HbacRequest()
376 allow_rule = pyhbac.HbacRule("allowRule", enabled=True)
382 req = pyhbac.HbacRequest()
390 self.assertEqual(res, pyhbac.HBAC_EVAL_ALLOW)
397 self.assertEqual(res, pyhbac.HBAC_EVAL_DENY)
401 allow_rule.users.category.add(pyhbac.HBAC_CATEGORY_ALL)
403 self.assertEqual(res, pyhbac.HBAC_EVAL_ALLOW)
411 req = pyhbac.HbacRequest()
435 allow_rule = pyhbac.HbacRule("allowRule", enabled=True)
441 req = pyhbac.HbacRequest()
452 allow_rule.users.category.add(pyhbac.HBAC_EVAL_ERROR)
469 os.unlink(MODPATH + "/pyhbac.so")
473 assert hasattr(pyhbac, "HBAC_EVAL_ALLOW")
474 assert hasattr(pyhbac, "HBAC_EVAL_DENY")
475 assert hasattr(pyhbac, "HBAC_EVAL_ERROR")
478 assert hasattr(pyhbac, "HBAC_ERROR_UNKNOWN")
479 assert hasattr(pyhbac, "HBAC_SUCCESS")
480 assert hasattr(pyhbac, "HBAC_ERROR_NOT_IMPLEMENTED")
481 assert hasattr(pyhbac, "HBAC_ERROR_OUT_OF_MEMORY")
482 assert hasattr(pyhbac, "HBAC_ERROR_UNPARSEABLE_RULE")
485 assert hasattr(pyhbac, "HBAC_CATEGORY_NULL")
486 assert hasattr(pyhbac, "HBAC_CATEGORY_ALL")
489 assert hasattr(pyhbac, "HBAC_RULE_ELEMENT_USERS")
490 assert hasattr(pyhbac, "HBAC_RULE_ELEMENT_SERVICES")
491 assert hasattr(pyhbac, "HBAC_RULE_ELEMENT_TARGETHOSTS")
492 assert hasattr(pyhbac, "HBAC_RULE_ELEMENT_SOURCEHOSTS")
495 results = [ pyhbac.HBAC_EVAL_ALLOW, pyhbac.HBAC_EVAL_DENY,
496 pyhbac.HBAC_EVAL_ERROR ]
498 s = pyhbac.hbac_result_string(r)
503 errors = [ pyhbac.HBAC_ERROR_UNKNOWN,
504 pyhbac.HBAC_SUCCESS,
505 pyhbac.HBAC_ERROR_NOT_IMPLEMENTED,
506 pyhbac.HBAC_ERROR_OUT_OF_MEMORY,
507 pyhbac.HBAC_ERROR_UNPARSEABLE_RULE ]
509 s = pyhbac.hbac_error_string(e)
521 # need to bail out here because pyhbac could not be imported
524 # import the pyhbac module into the global namespace, but make sure it's
527 import pyhbac