| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706 |
- # --- BEGIN COPYRIGHT BLOCK ---
- # Copyright (C) 2015 Red Hat, Inc.
- # All rights reserved.
- #
- # License: GPL (version 3 or any later version).
- # See LICENSE for details.
- # --- END COPYRIGHT BLOCK ---
- #
- import os
- import sys
- import time
- import ldap
- import logging
- import socket
- import pytest
- import shutil
- from lib389 import DirSrv, Entry, tools
- from lib389.tools import DirSrvTools
- from lib389._constants import *
- from lib389.properties import *
- log = logging.getLogger(__name__)
- installation_prefix = None
- ACCT_POLICY_CONFIG_DN = 'cn=config,cn=%s,cn=plugins,cn=config' % PLUGIN_ACCT_POLICY
- ACCT_POLICY_DN = 'cn=Account Inactivation Policy,%s' % SUFFIX
- INACTIVITY_LIMIT = '9'
- SEARCHFILTER = '(objectclass=*)'
- DUMMY_CONTAINER = 'cn=dummy container,%s' % SUFFIX
- PROVISIONING = 'cn=provisioning,%s' % SUFFIX
- ACTIVE_USER1_CN = 'active user1'
- ACTIVE_USER1_DN = 'cn=%s,%s' % (ACTIVE_USER1_CN, SUFFIX)
- STAGED_USER1_CN = 'staged user1'
- STAGED_USER1_DN = 'cn=%s,%s' % (STAGED_USER1_CN, PROVISIONING)
- DUMMY_USER1_CN = 'dummy user1'
- DUMMY_USER1_DN = 'cn=%s,%s' % (DUMMY_USER1_CN, DUMMY_CONTAINER)
- ALLOCATED_ATTR = 'employeeNumber'
- class TopologyStandalone(object):
- def __init__(self, standalone):
- standalone.open()
- self.standalone = standalone
- @pytest.fixture(scope="module")
- def topology(request):
- '''
- This fixture is used to standalone topology for the 'module'.
- At the beginning, It may exists a standalone instance.
- It may also exists a backup for the standalone instance.
- '''
- global installation_prefix
- if installation_prefix:
- args_instance[SER_DEPLOYED_DIR] = installation_prefix
- standalone = DirSrv(verbose=False)
- # Args for the standalone instance
- args_instance[SER_HOST] = HOST_STANDALONE
- args_instance[SER_PORT] = PORT_STANDALONE
- args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
- args_standalone = args_instance.copy()
- standalone.allocate(args_standalone)
- # Get the status of the instance and restart it if it exists
- instance_standalone = standalone.exists()
- if instance_standalone:
- standalone.delete()
- # Create the instance
- standalone.create()
- # Used to retrieve configuration information (dbdir, confdir...)
- standalone.open()
- def fin():
- standalone.delete()
- request.addfinalizer(fin)
- return TopologyStandalone(standalone)
- def _header(topology, label):
- topology.standalone.log.info("\n\n###############################################")
- topology.standalone.log.info("#######")
- topology.standalone.log.info("####### %s" % label)
- topology.standalone.log.info("#######")
- topology.standalone.log.info("###############################################")
- def test_ticket47828_init(topology):
- """
- Enable DNA
- """
- topology.standalone.plugins.enable(name=PLUGIN_DNA)
- topology.standalone.add_s(Entry((PROVISIONING,{'objectclass': "top nscontainer".split(),
- 'cn': 'provisioning'})))
- topology.standalone.add_s(Entry((DUMMY_CONTAINER,{'objectclass': "top nscontainer".split(),
- 'cn': 'dummy container'})))
- dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN)
- topology.standalone.add_s(Entry((dn_config, {'objectclass': "top extensibleObject".split(),
- 'cn': 'excluded scope',
- 'dnaType': ALLOCATED_ATTR,
- 'dnaNextValue': str(1000),
- 'dnaMaxValue': str(2000),
- 'dnaMagicRegen': str(-1),
- 'dnaFilter': '(&(objectClass=person)(objectClass=organizationalPerson)(objectClass=inetOrgPerson))',
- 'dnaScope': SUFFIX})))
- topology.standalone.restart(timeout=10)
- def test_ticket47828_run_0(topology):
- """
- NO exclude scope: Add an active entry and check its ALLOCATED_ATTR is set
- """
- _header(topology, 'NO exclude scope: Add an active entry and check its ALLOCATED_ATTR is set')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) != str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_1(topology):
- """
- NO exclude scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'NO exclude scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_2(topology):
- """
- NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is set
- """
- _header(topology, 'NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is set')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) != str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_3(topology):
- """
- NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_4(topology):
- '''
- Exclude the provisioning container
- '''
- _header(topology, 'Exclude the provisioning container')
- dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN)
- mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', PROVISIONING)]
- topology.standalone.modify_s(dn_config, mod)
- def test_ticket47828_run_5(topology):
- """
- Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is set
- """
- _header(topology, 'Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is set')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) != str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_6(topology):
- """
- Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_7(topology):
- """
- Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set
- """
- _header(topology, 'Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_8(topology):
- """
- Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_9(topology):
- """
- Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set
- """
- _header(topology, 'Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set')
- topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': DUMMY_USER1_CN,
- 'sn': DUMMY_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) != str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(DUMMY_USER1_DN)
- def test_ticket47828_run_10(topology):
- """
- Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': DUMMY_USER1_CN,
- 'sn': DUMMY_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(DUMMY_USER1_DN)
- def test_ticket47828_run_11(topology):
- '''
- Exclude (in addition) the dummy container
- '''
- _header(topology, 'Exclude (in addition) the dummy container')
- dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN)
- mod = [(ldap.MOD_ADD, 'dnaExcludeScope', DUMMY_CONTAINER)]
- topology.standalone.modify_s(dn_config, mod)
- def test_ticket47828_run_12(topology):
- """
- Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is set
- """
- _header(topology, 'Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is set')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) != str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_13(topology):
- """
- Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_14(topology):
- """
- Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set
- """
- _header(topology, 'Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_15(topology):
- """
- Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_16(topology):
- """
- Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is not set
- """
- _header(topology, 'Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR not is set')
- topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': DUMMY_USER1_CN,
- 'sn': DUMMY_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(DUMMY_USER1_DN)
- def test_ticket47828_run_17(topology):
- """
- Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': DUMMY_USER1_CN,
- 'sn': DUMMY_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(DUMMY_USER1_DN)
- def test_ticket47828_run_18(topology):
- '''
- Exclude PROVISIONING and a wrong container
- '''
- _header(topology, 'Exclude PROVISIONING and a wrong container')
- dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN)
- mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', PROVISIONING)]
- topology.standalone.modify_s(dn_config, mod)
- try:
- mod = [(ldap.MOD_ADD, 'dnaExcludeScope', "invalidDN,%s" % SUFFIX)]
- topology.standalone.modify_s(dn_config, mod)
- raise ValueError("invalid dnaExcludeScope value (not a DN)")
- except ldap.INVALID_SYNTAX:
- pass
- def test_ticket47828_run_19(topology):
- """
- Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set
- """
- _header(topology, 'Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) != str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_20(topology):
- """
- Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_21(topology):
- """
- Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set
- """
- _header(topology, 'Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_22(topology):
- """
- Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_23(topology):
- """
- Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set
- """
- _header(topology, 'Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set')
- topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': DUMMY_USER1_CN,
- 'sn': DUMMY_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) != str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(DUMMY_USER1_DN)
- def test_ticket47828_run_24(topology):
- """
- Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': DUMMY_USER1_CN,
- 'sn': DUMMY_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(DUMMY_USER1_DN)
- def test_ticket47828_run_25(topology):
- '''
- Exclude a wrong container
- '''
- _header(topology, 'Exclude a wrong container')
- dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN)
- try:
- mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', "invalidDN,%s" % SUFFIX)]
- topology.standalone.modify_s(dn_config, mod)
- raise ValueError("invalid dnaExcludeScope value (not a DN)")
- except ldap.INVALID_SYNTAX:
- pass
- def test_ticket47828_run_26(topology):
- """
- Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set
- """
- _header(topology, 'Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) != str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_27(topology):
- """
- Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': ACTIVE_USER1_CN,
- 'sn': ACTIVE_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(ACTIVE_USER1_DN)
- def test_ticket47828_run_28(topology):
- """
- Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set
- """
- _header(topology, 'Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_29(topology):
- """
- Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': STAGED_USER1_CN,
- 'sn': STAGED_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(STAGED_USER1_DN)
- def test_ticket47828_run_30(topology):
- """
- Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set
- """
- _header(topology, 'Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set')
- topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': DUMMY_USER1_CN,
- 'sn': DUMMY_USER1_CN,
- ALLOCATED_ATTR: str(-1)})))
- ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) != str(-1)
- topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(DUMMY_USER1_DN)
- def test_ticket47828_run_31(topology):
- """
- Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)
- """
- _header(topology, 'Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)')
- topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(),
- 'cn': DUMMY_USER1_CN,
- 'sn': DUMMY_USER1_CN,
- ALLOCATED_ATTR: str(20)})))
- ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
- assert ent.hasAttr(ALLOCATED_ATTR)
- assert ent.getValue(ALLOCATED_ATTR) == str(20)
- topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
- topology.standalone.delete_s(DUMMY_USER1_DN)
- def test_ticket47828_final(topology):
- topology.standalone.plugins.disable(name=PLUGIN_DNA)
- topology.standalone.stop(timeout=10)
- def run_isolated():
- '''
- run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
- To run isolated without py.test, you need to
- - edit this file and comment '@pytest.fixture' line before 'topology' function.
- - set the installation prefix
- - run this program
- '''
- global installation_prefix
- installation_prefix = None
- topo = topology(True)
- test_ticket47828_init(topo)
- test_ticket47828_run_0(topo)
- test_ticket47828_run_1(topo)
- test_ticket47828_run_2(topo)
- test_ticket47828_run_3(topo)
- test_ticket47828_run_4(topo)
- test_ticket47828_run_5(topo)
- test_ticket47828_run_6(topo)
- test_ticket47828_run_7(topo)
- test_ticket47828_run_8(topo)
- test_ticket47828_run_9(topo)
- test_ticket47828_run_10(topo)
- test_ticket47828_run_11(topo)
- test_ticket47828_run_12(topo)
- test_ticket47828_run_13(topo)
- test_ticket47828_run_14(topo)
- test_ticket47828_run_15(topo)
- test_ticket47828_run_16(topo)
- test_ticket47828_run_17(topo)
- test_ticket47828_run_18(topo)
- test_ticket47828_run_19(topo)
- test_ticket47828_run_20(topo)
- test_ticket47828_run_21(topo)
- test_ticket47828_run_22(topo)
- test_ticket47828_run_23(topo)
- test_ticket47828_run_24(topo)
- test_ticket47828_run_25(topo)
- test_ticket47828_run_26(topo)
- test_ticket47828_run_27(topo)
- test_ticket47828_run_28(topo)
- test_ticket47828_run_29(topo)
- test_ticket47828_run_30(topo)
- test_ticket47828_run_31(topo)
- test_ticket47828_final(topo)
- if __name__ == '__main__':
- run_isolated()
|