summaryrefslogtreecommitdiffstats
path: root/tests/test_xmlrpc/test_aci_plugin.py
blob: c42f1abd8bc1fcd65397f0020507c17ffd6edf68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Authors:
#   Rob Crittenden <rcritten@redhat.com>
#
# Copyright (C) 2009  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; version 2 only
#
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
Test the `ipalib/plugins/aci.py` module.
"""

import sys
from xmlrpc_test import XMLRPC_test, assert_attr_equal
from ipalib import api
from ipalib import errors


class test_aci(XMLRPC_test):
    """
    Test the `aci` plugin.
    """
    aciname = u'acitest'
    taskgroup = u'testtaskgroup'
    kw = {'permissions': u'add', 'type': u'user', 'taskgroup': taskgroup }
    aci = u'(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "acitest";allow (add) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn)

    def test_1_aci_add(self):
        """
        Test adding an aci using the `xmlrpc.aci_add` method.
        """
        result = api.Command['aci_add'](self.aciname, **self.kw)['result']

        assert result == self.aci

    def test_2_aci_show(self):
        """
        Test showing an aci using the `xmlrpc.aci_show` method.
        """
        result = api.Command['aci_show'](self.aciname)['result']

        assert result == self.aci

    def test_3_aci_find(self):
        """
        Test showing an aci using the `xmlrpc.aci_show` method.
        """
        outcome = api.Command['aci_find'](self.aciname)
        result = outcome['result']
        count = outcome['count']

        assert count == 1
        assert result[0] == self.aci

    def test_4_aci_del(self):
        """
        Remove the second test policy with `xmlrpc.aci_del`.
        """
        assert api.Command['aci_del'](self.aciname)['result'] is True

        # Verify that it is gone
        try:
            api.Command['aci_show'](self.aciname)
        except errors.NotFound:
            pass
        else:
            assert False