Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Authors: # Pavel Zuna <pzuna@redhat.com> # Alexander Bokovoy <abokovoy@redhat.com> # # Copyright (C) 2009-2011 Red Hat # see file 'COPYING' for use and warranty information # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. Test the `ipalib/plugins/hbactest.py` module. """
# Test strategy: # 1. Create few allow rules: with user categories, with explicit users, with user groups, with groups, with services # 2. Create users for test # 3. Run detailed and non-detailed tests for explicitly specified rules, check expected result # """ Test the `hbactest` plugin. """
# Auxiliary funcion for checking existence of warning for specified rule return False
""" Prepare data by adding test HBAC rules using `xmlrpc.hbacrule_add'. """
self.test_user, givenname=u'first', sn=u'last' ) self.test_group, description=u'description' ) self.test_host, force=True ) self.test_hostgroup, description=u'description' ) self.test_sourcehost, force=True ) self.test_sourcehostgroup, description=u'desc' ) self.test_service, description=u'desc' )
self.rule_names[i], accessruletype=self.rule_type, description=self.rule_descs[i], )
self.rule_names[i], user=self.test_user, group=self.test_group )
self.rule_names[i], host=self.test_host, hostgroup=self.test_hostgroup )
self.rule_names[i], host=self.test_sourcehost, hostgroup=self.test_sourcehostgroup )
self.rule_names[i], hbacsvc=self.test_service )
""" Test 'ipa hbactest --rules' (explicit IPA rules, detailed output) """ user=self.test_user, sourcehost=self.test_sourcehost, targethost=self.test_host, service=self.test_service, rules=self.rule_names )
# same test without sourcehost value user=self.test_user, targethost=self.test_host, service=self.test_service, rules=self.rule_names )
""" Test 'ipa hbactest --rules --nodetail' (explicit IPA rules, no detailed output) """ user=self.test_user, sourcehost=self.test_sourcehost, targethost=self.test_host, service=self.test_service, rules=self.rule_names, nodetail=True )
# same test without sourcehost value user=self.test_user, targethost=self.test_host, service=self.test_service, rules=self.rule_names, nodetail=True )
""" Test 'ipa hbactest --enabled' (all enabled IPA rules, detailed output) """ user=self.test_user, sourcehost=self.test_sourcehost, targethost=self.test_host, service=self.test_service, enabled=True ) # --enabled will try to work with _all_ enabled rules in IPA database # It means we could have matched something else (unlikely but possible) # Thus, check that our two enabled rules are in matched, nothing more
# same test without sourcehost value user=self.test_user, targethost=self.test_host, service=self.test_service, enabled=True )
""" Test 'ipa hbactest --disabled' (all disabled IPA rules, detailed output) """ user=self.test_user, sourcehost=self.test_sourcehost, targethost=self.test_host, service=self.test_service, disabled=True ) # --disabled will try to work with _all_ disabled rules in IPA database # It means we could have matched something else (unlikely but possible) # Thus, check that our two disabled rules are in matched, nothing more
# same test without sourcehost value user=self.test_user, targethost=self.test_host, service=self.test_service, disabled=True )
""" Test running 'ipa hbactest' with non-existing rule in --rules """ user=self.test_user, sourcehost=self.test_sourcehost, targethost=self.test_host, service=self.test_service, rules=[u'%s_1x1' % (rule) for rule in self.rule_names], nodetail=True )
# same test without sourcehost value user=self.test_user, targethost=self.test_host, service=self.test_service, rules=[u'%s_1x1' % (rule) for rule in self.rule_names], nodetail=True )
""" Clear data for HBAC test plugin testing. """
|