summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tests/intg/.config/screenrc23
-rw-r--r--src/tests/intg/util.py20
2 files changed, 37 insertions, 6 deletions
diff --git a/src/tests/intg/.config/screenrc b/src/tests/intg/.config/screenrc
new file mode 100644
index 000000000..fe1e4248a
--- /dev/null
+++ b/src/tests/intg/.config/screenrc
@@ -0,0 +1,23 @@
+autodetach on
+defscrollback 1024
+startup_message off
+nethack on
+vbell off
+vbell_msg " -- Bell,Bell!! -- "
+multiuser off
+msgminwait 0
+msgwait 10
+
+defutf8 on
+defencoding utf8
+
+hardstatus string '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}]%{=b C}[ %d/%m %c ]%{W}'
+hardstatus alwayslastline
+
+setenv LD_LIBRARY_PATH "$_LD_LIBRARY_PATH"
+setenv LD_PRELOAD "$_LD_PRELOAD"
+
+screen -t / 0 sh -c 'cd $ROOT_DIR; exec "${SHELL:-sh}"'
+screen -t /etc 1 sh -c 'cd $ROOT_DIR/etc; exec "${SHELL:-sh}"'
+screen -t sssd_cache 3 sh -c 'cd $ROOT_DIR/var/lib/sss/db; exec "${SHELL:-sh}"'
+screen -t sssd_log 2 sh -c 'cd $ROOT_DIR/var/log/sssd; exec "${SHELL:-sh}"'
diff --git a/src/tests/intg/util.py b/src/tests/intg/util.py
index 6e8f15d02..a5e01b3db 100644
--- a/src/tests/intg/util.py
+++ b/src/tests/intg/util.py
@@ -20,6 +20,7 @@
import re
import os
import subprocess
+import config
UNINDENT_RE = re.compile("^ +", re.MULTILINE)
@@ -42,13 +43,20 @@ def run_shell():
Execute an interactive shell under "screen", preserving environment.
For use as a breakpoint for debugging.
"""
+ my_env = os.environ.copy()
+ my_env["ROOT_DIR"] = config.PREFIX
+
+ # screen filter out LD_* evniroment varibles.
+ # Back-up them and set them later in screenrc
+ my_env["_LD_LIBRARY_PATH"] = os.getenv("LD_LIBRARY_PATH", "")
+ my_env["_LD_PRELOAD"] = os.getenv("LD_PRELOAD", "")
+
subprocess.call([
- "screen", "-D", "-m", "bash", "-c",
- "PATH='" + os.getenv("PATH", "") + "' " +
- "LD_LIBRARY_PATH='" + os.getenv("LD_LIBRARY_PATH", "") + "' " +
- "LD_PRELOAD='" + os.getenv("LD_PRELOAD", "") + "' " +
- "bash -i"
- ])
+ "screen", "-DAm", "-S", "sssd_cwrap_session", "-c",
+ ".config/screenrc"],
+ env=my_env
+ )
+
def first_dir(*args):
'>191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
# Authors:
#   Rob Crittenden <rcritten@redhat.com>
#
# Copyright (C) 2010 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.
"""

from ipalib import api, errors
from tests.test_xmlrpc import objectclasses
from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid


aci1=u'test1'
taskgroup = u'testtaskgroup'

aci2=u'selftest1'


class test_aci(Declarative):

    cleanup_commands = [
        ('aci_del', [aci1], {}),
        ('aci_del', [aci2], {}),
    ]

    tests = [

        dict(
            desc='Try to retrieve non-existent %r' % aci1,
            command=('aci_show', [aci1], {}),
            expected=errors.NotFound(reason='no such entry'),
        ),


        dict(
            desc='Try to update non-existent %r' % aci1,
            command=('aci_mod', [aci1], dict(permissions=u'write')),
            expected=errors.NotFound(reason='no such entry'),
        ),


        dict(
            desc='Try to delete non-existent %r' % aci1,
            command=('aci_del', [aci1], {}),
            expected=errors.NotFound(reason='no such entry'),
        ),


        dict(
            desc='Create %r' % aci1,
            command=(
                'aci_add', [aci1], dict(permissions=u'add', type=u'user', taskgroup=taskgroup)
            ),
            expected=dict(
                value=aci1,
                summary=u'Created ACI "test1"',
                result=u'(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "test1";allow (add) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn),
                ),
        ),


        dict(
            desc='Try to create duplicate %r' % aci1,
            command=(
                'aci_add', [aci1], dict(permissions=u'add', type=u'user', taskgroup=taskgroup)
            ),
            expected=errors.DuplicateEntry(),
        ),


        dict(
            desc='Retrieve %r' % aci1,
            command=(
                'aci_show', [aci1], {}
            ),
            expected=dict(
                value=aci1,
                summary=None,
                result=u'(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "test1";allow (add) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn),
                ),
        ),


        dict(
            desc='Search for %r with all=True' % aci1,
            command=(
                'aci_find', [aci1], {'all': True}
            ),
            expected=dict(
                result=[
                    u'(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "test1";allow (add) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn)
                ],
                summary=u'1 ACI matched',
                count=1,
            ),
        ),


        dict(
            desc='Search for %r with minimal attributes' % aci1,
            command=(
                'aci_find', [aci1], {}
            ),
            expected=dict(
                result=[
                    u'(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "test1";allow (add) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn)
                ],
                summary=u'1 ACI matched',
                count=1,
            ),
        ),


        dict(
            desc='Update permissions in %r' % aci1,
            command=(
                'aci_mod', [aci1], dict(permissions=u'add,write')
            ),
            expected=dict(
                value=aci1,
                summary=u'Modified ACI "test1"',
                result=u'(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "test1";allow (add,write) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn),
            ),
        ),


        dict(
            desc='Retrieve %r to verify update' % aci1,
            command=('aci_show', [aci1], {}),
            expected=dict(
                value=aci1,
                summary=None,
                result=u'(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "test1";allow (add,write) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn),
            ),

        ),

        dict(
            desc='Update attributes in %r' % aci1,
            command=(
                'aci_mod', [aci1], dict(attrs=u'cn, sn,givenName')
            ),
            expected=dict(
                value=aci1,
                summary=u'Modified ACI "test1"',
                result=u'(targetattr = "cn || sn || givenName")(target = "ldap:///uid=*,cn=users,cn=accounts,%s")(version 3.0;acl "test1";allow (add,write) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn),
            ),
        ),


        dict(
            desc='Update type in %r' % aci1,
            command=(
                'aci_mod', [aci1], dict(type=u'group')
            ),
            expected=dict(
                value=aci1,
                summary=u'Modified ACI "test1"',
                result=u'(targetattr = "cn || sn || givenName")(target = "ldap:///cn=*,cn=groups,cn=accounts,%s")(version 3.0;acl "test1";allow (add,write) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn),
            ),
        ),


        dict(
            desc='Update memberOf in %r' % aci1,
            command=(
                'aci_mod', [aci1], dict(memberof=u'ipausers')
            ),
            expected=dict(
                value=aci1,
                summary=u'Modified ACI "test1"',
                result=u'(targetattr = "cn || sn || givenName")(targetfilter = "(memberOf=cn=testtaskgroup,cn=taskgroups,cn=accounts,%s)")(target = "ldap:///cn=*,cn=groups,cn=accounts,%s")(version 3.0;acl "test1";allow (add,write) groupdn = "ldap:///cn=testtaskgroup,cn=taskgroups,cn=accounts,%s";)' % (api.env.basedn, api.env.basedn, api.env.basedn),
            ),
        ),


        dict(
            desc='Delete %r' % aci1,
            command=('aci_del', [aci1], {}),
            expected=dict(
                result=True,
                summary=u'Deleted ACI "test1"',
                value=aci1,
            ),
        ),


        dict(
            desc='Try to delete non-existent %r' % aci1,
            command=('aci_del', [aci1], {}),
            expected=errors.NotFound(reason='no such entry'),
        ),


        dict(
            desc='Try to retrieve non-existent %r' % aci1,
            command=('aci_show', [aci1], {}),
            expected=errors.NotFound(reason='no such entry'),
        ),


        dict(
            desc='Try to update non-existent %r' % aci1,
            command=('aci_mod', [aci1], dict(givenname=u'Foo')),
            expected=errors.NotFound(reason='no such entry'),
        ),


        dict(
            desc='Create %r' % aci2,
            command=(
                'aci_add', [aci2], dict(permissions=u'write', attrs=(u'givenName',u'sn',u'cn'), selfaci=True)
            ),
            expected=dict(
                value=aci2,
                summary=u'Created ACI "%s"' % aci2,
                result=u'(targetattr = "givenName || sn || cn")(version 3.0;acl "selftest1";allow (write) userdn = "ldap:///self";)'),
        ),


        dict(
            desc='Update attributes in %r' % aci2,
            command=(
                'aci_mod', [aci2], dict(attrs=(u'givenName',u'sn',u'cn',u'uidNumber'))
            ),
            expected=dict(
                value=aci2,