From 8764fb7693405159a48c25ef9dffe40515acbfb7 Mon Sep 17 00:00:00 2001
From: Sankar Ramalingam <sramling@redhat.com>
Date: Thu, 27 Jul 2017 17:22:56 +0530
Subject: [PATCH] Ticket #48056 - Extend basic test suite with bugzilla tests

Description: When troubleshoooting basic test failures, its found that deleting attributes from
cn=config throws error as modifiersname and modifytimestamp is not allowed
https://projects.engineering.redhat.com/browse/DSQE-141
https://bugzilla.redhat.com/show_bug.cgi?id=1462399

https://pagure.io/389-ds-base/issue/48056

Reviewed by: ?
---
 dirsrvtests/tests/suites/basic/basic_test.py | 307 ++++++++++++++-------------
 1 file changed, 165 insertions(+), 142 deletions(-)

diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py
index 7b77686..769de02 100644
--- a/dirsrvtests/tests/suites/basic/basic_test.py
+++ b/dirsrvtests/tests/suites/basic/basic_test.py
@@ -13,7 +13,7 @@ import ldap.sasl
 import pytest
 from lib389.tasks import *
 from lib389.utils import *
-from lib389.topologies import topology_st
+from lib389.topologies import topology_st as topo
 
 from lib389._constants import DN_DM, PASSWORD, PW_DM
 
@@ -34,30 +34,30 @@ ROOTDSE_DEF_ATTR_LIST = ('namingContexts',
 
 
 @pytest.fixture(scope="module")
-def import_example_ldif(topology_st):
+def import_example_ldif(topo):
     """Import the Example LDIF for the tests in this suite"""
 
     log.info('Initializing the "basic" test suite')
 
-    ldif = '%s/Example.ldif' % get_data_dir(topology_st.standalone.prefix)
-    import_ldif = topology_st.standalone.get_ldif_dir() + "/Example.ldif"
+    ldif = '%s/Example.ldif' % get_data_dir(topo.standalone.prefix)
+    import_ldif = topo.standalone.get_ldif_dir() + "/Example.ldif"
     shutil.copyfile(ldif, import_ldif)
     try:
-        topology_st.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
-                                                input_file=import_ldif,
-                                                args={TASK_WAIT: True})
+        topo.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+                                         input_file=import_ldif,
+                                         args={TASK_WAIT: True})
     except ValueError:
         log.error('Online import failed')
         assert False
 
 
 @pytest.fixture(params=ROOTDSE_DEF_ATTR_LIST)
-def rootdse_attr(topology_st, request):
+def rootdse_attr(topo, request):
     """Adds an attr from the list
     as the default attr to the rootDSE
     """
     # Ensure the server is started and connected
-    topology_st.standalone.start()
+    topo.standalone.start()
 
     RETURN_DEFAULT_OPATTR = "nsslapd-return-default-opattr"
     rootdse_attr_name = request.param
@@ -66,7 +66,7 @@ def rootdse_attr(topology_st, request):
                                                     rootdse_attr_name))
     mod = [(ldap.MOD_ADD, RETURN_DEFAULT_OPATTR, rootdse_attr_name)]
     try:
-        topology_st.standalone.modify_s("", mod)
+        topo.standalone.modify_s("", mod)
     except ldap.LDAPError as e:
         log.fatal('Failed to add attr: error (%s)' % (e.message['desc']))
         assert False
@@ -76,7 +76,7 @@ def rootdse_attr(topology_st, request):
                                                              rootdse_attr_name))
         mod = [(ldap.MOD_DELETE, RETURN_DEFAULT_OPATTR, rootdse_attr_name)]
         try:
-            topology_st.standalone.modify_s("", mod)
+            topo.standalone.modify_s("", mod)
         except ldap.LDAPError as e:
             log.fatal('Failed to delete attr: error (%s)' % (e.message['desc']))
             assert False
@@ -86,7 +86,7 @@ def rootdse_attr(topology_st, request):
     return rootdse_attr_name
 
 
-def test_basic_ops(topology_st, import_example_ldif):
+def test_basic_ops(topo, import_example_ldif):
     """Test doing adds, mods, modrdns, and deletes"""
 
     log.info('Running test_basic_ops...')
@@ -103,34 +103,34 @@ def test_basic_ops(topology_st, import_example_ldif):
     # Adds
     #
     try:
-        topology_st.standalone.add_s(Entry((USER1_DN,
-                                            {'objectclass': "top extensibleObject".split(),
-                                             'sn': '1',
-                                             'cn': 'user1',
-                                             'uid': 'user1',
-                                             'userpassword': 'password'})))
+        topo.standalone.add_s(Entry((USER1_DN,
+                                     {'objectclass': "top extensibleObject".split(),
+                                      'sn': '1',
+                                      'cn': 'user1',
+                                      'uid': 'user1',
+                                      'userpassword': 'password'})))
     except ldap.LDAPError as e:
         log.error('Failed to add test user' + USER1_DN + ': error ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.add_s(Entry((USER2_DN,
-                                            {'objectclass': "top extensibleObject".split(),
-                                             'sn': '2',
-                                             'cn': 'user2',
-                                             'uid': 'user2',
-                                             'userpassword': 'password'})))
+        topo.standalone.add_s(Entry((USER2_DN,
+                                     {'objectclass': "top extensibleObject".split(),
+                                      'sn': '2',
+                                      'cn': 'user2',
+                                      'uid': 'user2',
+                                      'userpassword': 'password'})))
     except ldap.LDAPError as e:
         log.error('Failed to add test user' + USER2_DN + ': error ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.add_s(Entry((USER3_DN,
-                                            {'objectclass': "top extensibleObject".split(),
-                                             'sn': '3',
-                                             'cn': 'user3',
-                                             'uid': 'user3',
-                                             'userpassword': 'password'})))
+        topo.standalone.add_s(Entry((USER3_DN,
+                                     {'objectclass': "top extensibleObject".split(),
+                                      'sn': '3',
+                                      'cn': 'user3',
+                                      'uid': 'user3',
+                                      'userpassword': 'password'})))
     except ldap.LDAPError as e:
         log.error('Failed to add test user' + USER3_DN + ': error ' + e.message['desc'])
         assert False
@@ -139,22 +139,22 @@ def test_basic_ops(topology_st, import_example_ldif):
     # Mods
     #
     try:
-        topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_ADD, 'description',
-                                                    'New description')])
+        topo.standalone.modify_s(USER1_DN, [(ldap.MOD_ADD, 'description',
+                                             'New description')])
     except ldap.LDAPError as e:
         log.error('Failed to add description: error ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'description',
-                                                    'Modified description')])
+        topo.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'description',
+                                             'Modified description')])
     except ldap.LDAPError as e:
         log.error('Failed to modify description: error ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_DELETE, 'description',
-                                                    None)])
+        topo.standalone.modify_s(USER1_DN, [(ldap.MOD_DELETE, 'description',
+                                             None)])
     except ldap.LDAPError as e:
         log.error('Failed to delete description: error ' + e.message['desc'])
         assert False
@@ -163,21 +163,21 @@ def test_basic_ops(topology_st, import_example_ldif):
     # Modrdns
     #
     try:
-        topology_st.standalone.rename_s(USER1_DN, USER1_NEWDN, delold=1)
+        topo.standalone.rename_s(USER1_DN, USER1_NEWDN, delold=1)
     except ldap.LDAPError as e:
         log.error('Failed to modrdn user1: error ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.rename_s(USER2_DN, USER2_NEWDN, delold=0)
+        topo.standalone.rename_s(USER2_DN, USER2_NEWDN, delold=0)
     except ldap.LDAPError as e:
         log.error('Failed to modrdn user2: error ' + e.message['desc'])
         assert False
 
     # Modrdn - New superior
     try:
-        topology_st.standalone.rename_s(USER3_DN, USER3_NEWDN,
-                                        newsuperior=NEW_SUPERIOR, delold=1)
+        topo.standalone.rename_s(USER3_DN, USER3_NEWDN,
+                                 newsuperior=NEW_SUPERIOR, delold=1)
     except ldap.LDAPError as e:
         log.error('Failed to modrdn(new superior) user3: error ' + e.message['desc'])
         assert False
@@ -186,19 +186,19 @@ def test_basic_ops(topology_st, import_example_ldif):
     # Deletes
     #
     try:
-        topology_st.standalone.delete_s(USER1_RDN_DN)
+        topo.standalone.delete_s(USER1_RDN_DN)
     except ldap.LDAPError as e:
         log.error('Failed to delete test entry1: ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.delete_s(USER2_RDN_DN)
+        topo.standalone.delete_s(USER2_RDN_DN)
     except ldap.LDAPError as e:
         log.error('Failed to delete test entry2: ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.delete_s(USER3_RDN_DN)
+        topo.standalone.delete_s(USER3_RDN_DN)
     except ldap.LDAPError as e:
         log.error('Failed to delete test entry3: ' + e.message['desc'])
         assert False
@@ -206,7 +206,7 @@ def test_basic_ops(topology_st, import_example_ldif):
     log.info('test_basic_ops: PASSED')
 
 
-def test_basic_import_export(topology_st, import_example_ldif):
+def test_basic_import_export(topo, import_example_ldif):
     """Test online and offline LDIF imports & exports"""
 
     log.info('Running test_basic_import_export...')
@@ -218,10 +218,10 @@ def test_basic_import_export(topology_st, import_example_ldif):
     #
 
     # Generate a test ldif (50k entries)
-    ldif_dir = topology_st.standalone.get_ldif_dir()
+    ldif_dir = topo.standalone.get_ldif_dir()
     import_ldif = ldif_dir + '/basic_import.ldif'
     try:
-        topology_st.standalone.buildLDIF(50000, import_ldif)
+        topo.standalone.buildLDIF(50000, import_ldif)
     except OSError as e:
         log.fatal('test_basic_import_export: failed to create test ldif,\
                   error: %s - %s' % (e.errno, e.strerror))
@@ -229,19 +229,19 @@ def test_basic_import_export(topology_st, import_example_ldif):
 
     # Online
     try:
-        topology_st.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
-                                                input_file=import_ldif,
-                                                args={TASK_WAIT: True})
+        topo.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+                                         input_file=import_ldif,
+                                         args={TASK_WAIT: True})
     except ValueError:
         log.fatal('test_basic_import_export: Online import failed')
         assert False
 
     # Offline
-    topology_st.standalone.stop()
-    if not topology_st.standalone.ldif2db(DEFAULT_BENAME, None, None, None, import_ldif):
+    topo.standalone.stop()
+    if not topo.standalone.ldif2db(DEFAULT_BENAME, None, None, None, import_ldif):
         log.fatal('test_basic_import_export: Offline import failed')
         assert False
-    topology_st.standalone.start()
+    topo.standalone.start()
 
     #
     # Test online and offline LDIF export
@@ -249,7 +249,7 @@ def test_basic_import_export(topology_st, import_example_ldif):
 
     # Online export
     export_ldif = ldif_dir + '/export.ldif'
-    exportTask = Tasks(topology_st.standalone)
+    exportTask = Tasks(topo.standalone)
     try:
         args = {TASK_WAIT: True}
         exportTask.exportLDIF(DEFAULT_SUFFIX, None, export_ldif, args)
@@ -258,24 +258,24 @@ def test_basic_import_export(topology_st, import_example_ldif):
         assert False
 
     # Offline export
-    topology_st.standalone.stop()
-    if not topology_st.standalone.db2ldif(DEFAULT_BENAME, (DEFAULT_SUFFIX,),
-                                          None, None, None, export_ldif):
+    topo.standalone.stop()
+    if not topo.standalone.db2ldif(DEFAULT_BENAME, (DEFAULT_SUFFIX,),
+                                   None, None, None, export_ldif):
         log.fatal('test_basic_import_export: Failed to run offline db2ldif')
         assert False
 
-    topology_st.standalone.start()
+    topo.standalone.start()
 
     #
     # Cleanup - Import the Example LDIF for the other tests in this suite
     #
-    ldif = '%s/Example.ldif' % get_data_dir(topology_st.standalone.prefix)
-    import_ldif = topology_st.standalone.get_ldif_dir() + "/Example.ldif"
+    ldif = '%s/Example.ldif' % get_data_dir(topo.standalone.prefix)
+    import_ldif = topo.standalone.get_ldif_dir() + "/Example.ldif"
     shutil.copyfile(ldif, import_ldif)
     try:
-        topology_st.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
-                                                input_file=import_ldif,
-                                                args={TASK_WAIT: True})
+        topo.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+                                         input_file=import_ldif,
+                                         args={TASK_WAIT: True})
     except ValueError:
         log.fatal('test_basic_import_export: Online import failed')
         assert False
@@ -283,45 +283,45 @@ def test_basic_import_export(topology_st, import_example_ldif):
     log.info('test_basic_import_export: PASSED')
 
 
-def test_basic_backup(topology_st, import_example_ldif):
+def test_basic_backup(topo, import_example_ldif):
     """Test online and offline back and restore"""
 
     log.info('Running test_basic_backup...')
 
-    backup_dir = topology_st.standalone.get_bak_dir() + '/backup_test'
+    backup_dir = topo.standalone.get_bak_dir() + '/backup_test'
 
     # Test online backup
     try:
-        topology_st.standalone.tasks.db2bak(backup_dir=backup_dir,
-                                            args={TASK_WAIT: True})
+        topo.standalone.tasks.db2bak(backup_dir=backup_dir,
+                                     args={TASK_WAIT: True})
     except ValueError:
         log.fatal('test_basic_backup: Online backup failed')
         assert False
 
     # Test online restore
     try:
-        topology_st.standalone.tasks.bak2db(backup_dir=backup_dir,
-                                            args={TASK_WAIT: True})
+        topo.standalone.tasks.bak2db(backup_dir=backup_dir,
+                                     args={TASK_WAIT: True})
     except ValueError:
         log.fatal('test_basic_backup: Online restore failed')
         assert False
 
     # Test offline backup
-    topology_st.standalone.stop()
-    if not topology_st.standalone.db2bak(backup_dir):
+    topo.standalone.stop()
+    if not topo.standalone.db2bak(backup_dir):
         log.fatal('test_basic_backup: Offline backup failed')
         assert False
 
     # Test offline restore
-    if not topology_st.standalone.bak2db(backup_dir):
+    if not topo.standalone.bak2db(backup_dir):
         log.fatal('test_basic_backup: Offline backup failed')
         assert False
-    topology_st.standalone.start()
+    topo.standalone.start()
 
     log.info('test_basic_backup: PASSED')
 
 
-def test_basic_acl(topology_st, import_example_ldif):
+def test_basic_acl(topo, import_example_ldif):
     """Run some basic access control(ACL) tests"""
 
     log.info('Running test_basic_acl...')
@@ -333,24 +333,24 @@ def test_basic_acl(topology_st, import_example_ldif):
     # Add two users
     #
     try:
-        topology_st.standalone.add_s(Entry((USER1_DN,
-                                            {'objectclass': "top extensibleObject".split(),
-                                             'sn': '1',
-                                             'cn': 'user 1',
-                                             'uid': 'user1',
-                                             'userpassword': PASSWORD})))
+        topo.standalone.add_s(Entry((USER1_DN,
+                                     {'objectclass': "top extensibleObject".split(),
+                                      'sn': '1',
+                                      'cn': 'user 1',
+                                      'uid': 'user1',
+                                      'userpassword': PASSWORD})))
     except ldap.LDAPError as e:
         log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN
                   + ': error ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.add_s(Entry((USER2_DN,
-                                            {'objectclass': "top extensibleObject".split(),
-                                             'sn': '2',
-                                             'cn': 'user 2',
-                                             'uid': 'user2',
-                                             'userpassword': PASSWORD})))
+        topo.standalone.add_s(Entry((USER2_DN,
+                                     {'objectclass': "top extensibleObject".split(),
+                                      'sn': '2',
+                                      'cn': 'user 2',
+                                      'uid': 'user2',
+                                      'userpassword': PASSWORD})))
     except ldap.LDAPError as e:
         log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN
                   + ': error ' + e.message['desc'])
@@ -361,7 +361,7 @@ def test_basic_acl(topology_st, import_example_ldif):
     # and also set the default anonymous access
     #
     try:
-        topology_st.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_ADD, 'aci', DENY_ACI)])
+        topo.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_ADD, 'aci', DENY_ACI)])
     except ldap.LDAPError as e:
         log.fatal('test_basic_acl: Failed to add DENY ACI: error ' + e.message['desc'])
         assert False
@@ -370,15 +370,15 @@ def test_basic_acl(topology_st, import_example_ldif):
     # Make sure USER1_DN can not search anything, but USER2_dn can...
     #
     try:
-        topology_st.standalone.simple_bind_s(USER1_DN, PASSWORD)
+        topo.standalone.simple_bind_s(USER1_DN, PASSWORD)
     except ldap.LDAPError as e:
         log.fatal('test_basic_acl: Failed to bind as user1, error: ' + e.message['desc'])
         assert False
 
     try:
-        entries = topology_st.standalone.search_s(DEFAULT_SUFFIX,
-                                                  ldap.SCOPE_SUBTREE,
-                                                  '(uid=*)')
+        entries = topo.standalone.search_s(DEFAULT_SUFFIX,
+                                           ldap.SCOPE_SUBTREE,
+                                           '(uid=*)')
         if entries:
             log.fatal('test_basic_acl: User1 was incorrectly able to search the suffix!')
             assert False
@@ -388,15 +388,15 @@ def test_basic_acl(topology_st, import_example_ldif):
 
     # Now try user2...  Also check that userpassword is stripped out
     try:
-        topology_st.standalone.simple_bind_s(USER2_DN, PASSWORD)
+        topo.standalone.simple_bind_s(USER2_DN, PASSWORD)
     except ldap.LDAPError as e:
         log.fatal('test_basic_acl: Failed to bind as user2, error: ' + e.message['desc'])
         assert False
 
     try:
-        entries = topology_st.standalone.search_s(DEFAULT_SUFFIX,
-                                                  ldap.SCOPE_SUBTREE,
-                                                  '(uid=user1)')
+        entries = topo.standalone.search_s(DEFAULT_SUFFIX,
+                                           ldap.SCOPE_SUBTREE,
+                                           '(uid=user1)')
         if not entries:
             log.fatal('test_basic_acl: User1 incorrectly not able to search the suffix')
             assert False
@@ -411,15 +411,15 @@ def test_basic_acl(topology_st, import_example_ldif):
     # Make sure Root DN can also search (this also resets the bind dn to the
     # Root DN for future operations)
     try:
-        topology_st.standalone.simple_bind_s(DN_DM, PW_DM)
+        topo.standalone.simple_bind_s(DN_DM, PW_DM)
     except ldap.LDAPError as e:
         log.fatal('test_basic_acl: Failed to bind as ROotDN, error: ' + e.message['desc'])
         assert False
 
     try:
-        entries = topology_st.standalone.search_s(DEFAULT_SUFFIX,
-                                                  ldap.SCOPE_SUBTREE,
-                                                  '(uid=*)')
+        entries = topo.standalone.search_s(DEFAULT_SUFFIX,
+                                           ldap.SCOPE_SUBTREE,
+                                           '(uid=*)')
         if not entries:
             log.fatal('test_basic_acl: Root DN incorrectly not able to search the suffix')
             assert False
@@ -431,19 +431,19 @@ def test_basic_acl(topology_st, import_example_ldif):
     # Cleanup
     #
     try:
-        topology_st.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_DELETE, 'aci', DENY_ACI)])
+        topo.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_DELETE, 'aci', DENY_ACI)])
     except ldap.LDAPError as e:
         log.fatal('test_basic_acl: Failed to delete DENY ACI: error ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.delete_s(USER1_DN)
+        topo.standalone.delete_s(USER1_DN)
     except ldap.LDAPError as e:
         log.fatal('test_basic_acl: Failed to delete test entry1: ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.delete_s(USER2_DN)
+        topo.standalone.delete_s(USER2_DN)
     except ldap.LDAPError as e:
         log.fatal('test_basic_acl: Failed to delete test entry2: ' + e.message['desc'])
         assert False
@@ -451,7 +451,7 @@ def test_basic_acl(topology_st, import_example_ldif):
     log.info('test_basic_acl: PASSED')
 
 
-def test_basic_searches(topology_st, import_example_ldif):
+def test_basic_searches(topo, import_example_ldif):
     """The search results are gathered from testing with Example.ldif"""
 
     log.info('Running test_basic_searches...')
@@ -475,9 +475,9 @@ def test_basic_searches(topology_st, import_example_ldif):
 
     for (search_filter, search_result) in filters:
         try:
-            entries = topology_st.standalone.search_s(DEFAULT_SUFFIX,
-                                                      ldap.SCOPE_SUBTREE,
-                                                      search_filter)
+            entries = topo.standalone.search_s(DEFAULT_SUFFIX,
+                                               ldap.SCOPE_SUBTREE,
+                                               search_filter)
             if len(entries) != search_result:
                 log.fatal('test_basic_searches: An incorrect number of entries\
                           was returned from filter (%s): (%d) expected (%d)' %
@@ -490,7 +490,7 @@ def test_basic_searches(topology_st, import_example_ldif):
     log.info('test_basic_searches: PASSED')
 
 
-def test_basic_referrals(topology_st, import_example_ldif):
+def test_basic_referrals(topo, import_example_ldif):
     """Set the server to referral mode,
     and make sure we recive the referal error(10)
     """
@@ -503,17 +503,17 @@ def test_basic_referrals(topology_st, import_example_ldif):
     # Set the referral, adn the backend state
     #
     try:
-        topology_st.standalone.modify_s(SUFFIX_CONFIG,
-                                        [(ldap.MOD_REPLACE,
-                                          'nsslapd-referral',
-                                          'ldap://localhost.localdomain:389/o%3dnetscaperoot')])
+        topo.standalone.modify_s(SUFFIX_CONFIG,
+                                 [(ldap.MOD_REPLACE,
+                                   'nsslapd-referral',
+                                   'ldap://localhost.localdomain:389/o%3dnetscaperoot')])
     except ldap.LDAPError as e:
         log.fatal('test_basic_referrals: Failed to set referral: error ' + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
-                                                         'nsslapd-state', 'Referral')])
+        topo.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
+                                                  'nsslapd-state', 'Referral')])
     except ldap.LDAPError as e:
         log.fatal('test_basic_referrals: Failed to set backend state: error '
                   + e.message['desc'])
@@ -522,9 +522,9 @@ def test_basic_referrals(topology_st, import_example_ldif):
     #
     # Test that a referral error is returned
     #
-    topology_st.standalone.set_option(ldap.OPT_REFERRALS, 0)  # Do not follow referral
+    topo.standalone.set_option(ldap.OPT_REFERRALS, 0)  # Do not follow referral
     try:
-        topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, 'objectclass=top')
+        topo.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, 'objectclass=top')
     except ldap.REFERRAL:
         pass
     except ldap.LDAPError as e:
@@ -534,52 +534,52 @@ def test_basic_referrals(topology_st, import_example_ldif):
     #
     # Make sure server can restart in referral mode
     #
-    topology_st.standalone.restart(timeout=10)
+    topo.standalone.restart(timeout=10)
 
     #
     # Cleanup
     #
     try:
-        topology_st.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
-                                                         'nsslapd-state', 'Backend')])
+        topo.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
+                                                  'nsslapd-state', 'Backend')])
     except ldap.LDAPError as e:
         log.fatal('test_basic_referrals: Failed to set backend state: error '
                   + e.message['desc'])
         assert False
 
     try:
-        topology_st.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_DELETE,
-                                                         'nsslapd-referral', None)])
+        topo.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_DELETE,
+                                                  'nsslapd-referral', None)])
     except ldap.LDAPError as e:
         log.fatal('test_basic_referrals: Failed to delete referral: error '
                   + e.message['desc'])
         assert False
-    topology_st.standalone.set_option(ldap.OPT_REFERRALS, 1)
+    topo.standalone.set_option(ldap.OPT_REFERRALS, 1)
 
     log.info('test_basic_referrals: PASSED')
 
 
-def test_basic_systemctl(topology_st, import_example_ldif):
+def test_basic_systemctl(topo, import_example_ldif):
     """Test systemctl/lib389 can stop and start the server.  Also test that start reports an
     error when the instance does not start.  Only for RPM builds
     """
 
     log.info('Running test_basic_systemctl...')
 
-    config_dir = topology_st.standalone.get_config_dir()
+    config_dir = topo.standalone.get_config_dir()
 
     #
     # Stop the server
     #
     log.info('Stopping the server...')
-    topology_st.standalone.stop()
+    topo.standalone.stop()
     log.info('Stopped the server.')
 
     #
     # Start the server
     #
     log.info('Starting the server...')
-    topology_st.standalone.start()
+    topo.standalone.start()
     log.info('Started the server.')
 
     #
@@ -587,7 +587,7 @@ def test_basic_systemctl(topology_st, import_example_ldif):
     # and verify that systemctl detects the failed start
     #
     log.info('Stopping the server...')
-    topology_st.standalone.stop()
+    topo.standalone.stop()
     log.info('Stopped the server before breaking the dse.ldif.')
 
     shutil.copy(config_dir + '/dse.ldif', config_dir + '/dse.ldif.correct')
@@ -597,11 +597,11 @@ def test_basic_systemctl(topology_st, import_example_ldif):
 
     log.info('Attempting to start the server with broken dse.ldif...')
     try:
-        topology_st.standalone.start()
+        topo.standalone.start()
     except:
         log.info('Server failed to start as expected')
     log.info('Check the status...')
-    assert (not topology_st.standalone.status())
+    assert (not topo.standalone.status())
     log.info('Server failed to start as expected')
     time.sleep(5)
 
@@ -611,27 +611,27 @@ def test_basic_systemctl(topology_st, import_example_ldif):
     #
     shutil.copy(config_dir + '/dse.ldif.correct', config_dir + '/dse.ldif')
     log.info('Starting the server with good dse.ldif...')
-    topology_st.standalone.start()
+    topo.standalone.start()
     log.info('Check the status...')
-    assert (topology_st.standalone.status())
+    assert (topo.standalone.status())
     log.info('Server started after fixing dse.ldif.')
 
     log.info('test_basic_systemctl: PASSED')
 
 
-def test_basic_ldapagent(topology_st, import_example_ldif):
+def test_basic_ldapagent(topo, import_example_ldif):
     """Test that the ldap agent starts"""
 
     log.info('Running test_basic_ldapagent...')
 
-    var_dir = topology_st.standalone.get_local_state_dir()
-    config_file = os.path.join(topology_st.standalone.get_sysconf_dir(), 'dirsrv/config/agent.conf')
-    cmd = 'sudo %s %s' % (os.path.join(topology_st.standalone.get_sbin_dir(), 'ldap-agent'), config_file)
+    var_dir = topo.standalone.get_local_state_dir()
+    config_file = os.path.join(topo.standalone.get_sysconf_dir(), 'dirsrv/config/agent.conf')
+    cmd = 'sudo %s %s' % (os.path.join(topo.standalone.get_sbin_dir(), 'ldap-agent'), config_file)
 
     agent_config_file = open(config_file, 'w')
     agent_config_file.write('agentx-master ' + var_dir + '/agentx/master\n')
     agent_config_file.write('agent-logdir ' + var_dir + '/log/dirsrv\n')
-    agent_config_file.write('server slapd-' + topology_st.standalone.serverid + '\n')
+    agent_config_file.write('server slapd-' + topo.standalone.serverid + '\n')
     agent_config_file.close()
 
     rc = os.system(cmd)
@@ -651,21 +651,21 @@ def test_basic_ldapagent(topology_st, import_example_ldif):
     log.info('test_basic_ldapagent: PASSED')
 
 
-def test_basic_dse(topology_st, import_example_ldif):
+def test_basic_dse(topo, import_example_ldif):
     """Test that the dse.ldif is not wipped out
     after the process is killed (bug 910581)
     """
 
     log.info('Running test_basic_dse...')
 
-    dse_file = topology_st.standalone.confdir + '/dse.ldif'
+    dse_file = topo.standalone.confdir + '/dse.ldif'
     pid = check_output(['pidof', '-s', 'ns-slapd'])
     os.system('sudo kill -9 ' + pid)
     if os.path.getsize(dse_file) == 0:
         log.fatal('test_basic_dse: dse.ldif\'s content was incorrectly removed!')
         assert False
 
-    topology_st.standalone.start(timeout=60)
+    topo.standalone.start(timeout=60)
     log.info('dse.ldif was not corrupted, and the server was restarted')
 
     log.info('test_basic_dse: PASSED')
@@ -674,16 +674,16 @@ def test_basic_dse(topology_st, import_example_ldif):
 
 
 @pytest.mark.parametrize("rootdse_attr_name", ROOTDSE_DEF_ATTR_LIST)
-def test_def_rootdse_attr(topology_st, import_example_ldif, rootdse_attr_name):
+def test_def_rootdse_attr(topo, import_example_ldif, rootdse_attr_name):
     """Tests that operational attributes
     are not returned by default in rootDSE searches
     """
 
-    topology_st.standalone.start()
+    topo.standalone.start()
 
     log.info("        Assert rootdse search hasn't %s attr" % rootdse_attr_name)
     try:
-        entries = topology_st.standalone.search_s("", ldap.SCOPE_BASE)
+        entries = topo.standalone.search_s("", ldap.SCOPE_BASE)
         entry = str(entries[0])
         assert rootdse_attr_name not in entry
 
@@ -692,14 +692,14 @@ def test_def_rootdse_attr(topology_st, import_example_ldif, rootdse_attr_name):
         assert False
 
 
-def test_mod_def_rootdse_attr(topology_st, import_example_ldif, rootdse_attr):
+def test_mod_def_rootdse_attr(topo, import_example_ldif, rootdse_attr):
     """Tests that operational attributes are returned
     by default in rootDSE searches after config modification
     """
 
     log.info("        Assert rootdse search has %s attr" % rootdse_attr)
     try:
-        entries = topology_st.standalone.search_s("", ldap.SCOPE_BASE)
+        entries = topo.standalone.search_s("", ldap.SCOPE_BASE)
         entry = str(entries[0])
         assert rootdse_attr in entry
 
@@ -708,6 +708,29 @@ def test_mod_def_rootdse_attr(topology_st, import_example_ldif, rootdse_attr):
         assert False
 
 
+def test_del_config_attr(topo):
+    """Deleting attributes from cn=config throws Modification of attribute modifiersname is not allowed
+    Bugzilla - https://bugzilla.redhat.com/show_bug.cgi?id=1462399
+    """
+
+    log.info('Check if deleting cn=config attribute throws modifiersname not allowed in DS error logs')
+    try:
+        topo.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-listenhost', 'localhost')])
+        topo.standalone.modify_s(DN_CONFIG, [(ldap.MOD_DELETE, 'nsslapd-listenhost', 'localhost')])
+    except ldap.LDAPError as e:
+        log.error('Delete with value - failed to replace or delete nsslapd-listenhost attr' + e.message['desc'])
+        raise e
+    try:
+        topo.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-listenhost', 'localhost')])
+        topo.standalone.modify_s(DN_CONFIG, [(ldap.MOD_DELETE, 'nsslapd-listenhost', None)])
+    except ldap.LDAPError as e:
+        log.error('Delete without value - failed to replace or delete nsslapd-listenhost attr' + e.message['desc'])
+        raise e
+
+    assert not topo.standalone.ds_error_log.match('.*attribute \"modifiersname\" is not allowed, ignoring.*')
+    assert not topo.standalone.ds_error_log.match('.*attribute \"modifytimestamp\" is not allowed, ignoring.*')
+
+
 if __name__ == '__main__':
     # Run isolated
     # -s for DEBUG mode
-- 
2.7.4

