From 4bb89f164c885af381c5298a86dadf3cd8a0b169 Mon Sep 17 00:00:00 2001 From: Anuj Borah Date: Jan 03 2019 03:42:42 +0000 Subject: Issue: 49761 Bug Description:Fix CI test suite issues Fix Description: Ported test scrips https://pagure.io/389-ds-base/issue/49761 Reviewed by: Mark Reynolds and spichugi --- diff --git a/dirsrvtests/tests/suites/replication/regression_nsslapd_plugin_binddn_tracking_test.py b/dirsrvtests/tests/suites/replication/regression_nsslapd_plugin_binddn_tracking_test.py new file mode 100644 index 0000000..9cc624f --- /dev/null +++ b/dirsrvtests/tests/suites/replication/regression_nsslapd_plugin_binddn_tracking_test.py @@ -0,0 +1,114 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2018 Red Hat, Inc. +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- +# +import logging +import pytest +from lib389.tasks import * +from lib389.topologies import topology_m2 as topo_m2 +from lib389.utils import * +from lib389.replica import * +from lib389._constants import * +from lib389.idm.user import UserAccounts +from lib389.idm.domain import Domain + +log = logging.getLogger(__name__) + + +@pytest.mark.DS47950 +def test_nsslapd_plugin_binddn_tracking(topo_m2): + """ + Testing nsslapd-plugin-binddn-tracking does not cause issues around + access control and reconfiguring replication/repl agmt. + :id: f5ba7b64-fe04-11e8-a298-8c16451d917b + :setup: Replication with two masters. + :steps: + 1. Turn on bind dn tracking + 2. Add two users + 3. Add an aci + 4. Make modification as user + 5. Setup replica and create a repl agmt + 6. Modify replica + 7. Modify repl agmt + :expectedresults: + 1. Should Success. + 2. Should Success. + 3. Should Success. + 4. Should Success. + 5. Should Success. + 6. Should Success. + 7. Should Success. + """ + + log.info("Testing Ticket 47950 - Testing nsslapd-plugin-binddn-tracking") + + # + # Turn on bind dn tracking + # + topo_m2.ms["master1"].config.replace("nsslapd-plugin-binddn-tracking", "on") + # + # Add two users + # + users = UserAccounts(topo_m2.ms["master1"], DEFAULT_SUFFIX) + test_user_1 = users.create_test_user(uid=1) + test_user_2 = users.create_test_user(uid=2) + test_user_1.set('userPassword', 'password') + test_user_2.set('userPassword', 'password') + # + # Add an aci + # + USER1_DN = users.list()[0].dn + USER2_DN = users.list()[1].dn + acival = ( + '(targetattr ="cn")(version 3.0;acl "Test bind dn tracking"' + + ';allow (all) (userdn = "ldap:///%s");)' % USER1_DN + ) + Domain(topo_m2.ms["master1"], DEFAULT_SUFFIX).add("aci", acival) + + # + # Make modification as user + # + assert topo_m2.ms["master1"].simple_bind_s(USER1_DN, "password") + test_user_2.replace("cn", "new value") + # + # Setup replica and create a repl agmt + # + repl = ReplicationManager(DEFAULT_SUFFIX) + assert topo_m2.ms["master1"].simple_bind_s(DN_DM, PASSWORD) + repl.test_replication(topo_m2.ms["master1"], topo_m2.ms["master2"], 30) + repl.test_replication(topo_m2.ms["master2"], topo_m2.ms["master1"], 30) + properties = { + "cn": "test_agreement", + "nsDS5ReplicaRoot": "dc=example,dc=com", + "nsDS5ReplicaHost": "localhost.localdomain", + "nsDS5ReplicaPort": "5555", + "nsDS5ReplicaBindDN": "uid=tester", + "nsds5ReplicaCredentials": "password", + "nsDS5ReplicaTransportInfo": "LDAP", + "nsDS5ReplicaBindMethod": "SIMPLE", + } + replicas = Replicas(topo_m2.ms["master1"]) + replica = replicas.get(DEFAULT_SUFFIX) + agmts = Agreements(topo_m2.ms["master1"], basedn=replica.dn) + repl_agreement = agmts.create(properties=properties) + # + # modify replica + # + replica.replace("nsDS5ReplicaId", "7") + assert replica.present("nsDS5ReplicaId", "7") + # + # modify repl agmt + # + repl_agreement.replace('nsDS5ReplicaPort', "8888") + assert repl_agreement.present('nsDS5ReplicaPort', "8888") + + +if __name__ == "__main__": + # Run isolated + # -s for DEBUG mode + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s %s" % CURRENT_FILE) diff --git a/dirsrvtests/tests/suites/vlv/regression_test.py b/dirsrvtests/tests/suites/vlv/regression_test.py new file mode 100644 index 0000000..4ed4477 --- /dev/null +++ b/dirsrvtests/tests/suites/vlv/regression_test.py @@ -0,0 +1,107 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2018 Red Hat, Inc. +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- +# +import pytest, time +from lib389.tasks import * +from lib389.utils import * +from lib389.topologies import topology_m2 +from lib389.replica import * +from lib389._constants import * +from lib389.index import * +from lib389.mappingTree import * +from lib389.backend import * + +logging.getLogger(__name__).setLevel(logging.DEBUG) +log = logging.getLogger(__name__) + + +@pytest.mark.DS47966 +def test_bulk_import_when_the_backend_with_vlv_was_recreated(topology_m2): + """ + Testing bulk import when the backend with VLV was recreated. + If the test passes without the server crash, 47966 is verified. + :id: 512963fa-fe02-11e8-b1d3-8c16451d917b + :setup: Replication with two masters. + :steps: + 1. Generate vlvSearch entry + 2. Generate vlvIndex entry + 3. Delete the backend instance on Master 2 + 4. Delete the agreement, replica, and mapping tree, too. + 5. Recreate the backend and the VLV index on Master 2. + 6. Recreating vlvSrchDn and vlvIndexDn on Master 2. + :expectedresults: + 1. Should Success. + 2. Should Success. + 3. Should Success. + 4. Should Success. + 5. Should Success. + 6. Should Success. + """ + M1 = topology_m2.ms["master1"] + M2 = topology_m2.ms["master2"] + # generate vlvSearch entry + properties_for_search = { + "objectclass": ["top", "vlvSearch"], + "cn": "vlvSrch", + "vlvbase": DEFAULT_SUFFIX, + "vlvfilter": "(|(objectclass=*)(objectclass=ldapsubentry))", + "vlvscope": "2", + } + vlv_searches = VLVSearch(M2) + userroot_vlvsearch = vlv_searches.create( + basedn="cn=userRoot,cn=ldbm database,cn=plugins,cn=config", + properties=properties_for_search, + ) + assert "cn=vlvSrch,cn=userRoot,cn=ldbm database,cn=plugins,cn=config" in M2.getEntry( + "cn=vlvSrch,cn=userRoot,cn=ldbm database,cn=plugins,cn=config").dn + # generate vlvIndex entry + properties_for_index = { + "objectclass": ["top", "vlvIndex"], + "cn": "vlvIdx", + "vlvsort": "cn ou sn", + } + vlv_index = VLVIndex(M2) + userroot_index = vlv_index.create( + basedn="cn=vlvSrch,cn=userRoot,cn=ldbm database,cn=plugins,cn=config", + properties=properties_for_index, + ) + assert "cn=vlvIdx,cn=vlvSrch,cn=userRoot,cn=ldbm database,cn=plugins,cn=config" in M2.getEntry( + "cn=vlvIdx,cn=vlvSrch,cn=userRoot,cn=ldbm database,cn=plugins,cn=config").dn + # Delete the backend instance on Master 2." + userroot_index.delete() + userroot_vlvsearch.delete_all() + # delete the agreement, replica, and mapping tree, too. + repl = ReplicationManager(DEFAULT_SUFFIX) + repl.remove_master(M2) + MappingTrees(M2).list()[0].delete() + Backends(M2).list()[0].delete() + # Recreate the backend and the VLV index on Master 2. + M2.mappingtree.create(DEFAULT_SUFFIX, "userRoot") + M2.backend.create(DEFAULT_SUFFIX, {BACKEND_NAME: "userRoot"}) + # Recreating vlvSrchDn and vlvIndexDn on Master 2. + vlv_searches.create( + basedn="cn=userRoot,cn=ldbm database,cn=plugins,cn=config", + properties=properties_for_search, + ) + vlv_index.create( + basedn="cn=vlvSrch,cn=userRoot,cn=ldbm database,cn=plugins,cn=config", + properties=properties_for_index, + ) + M2.restart() + repl.join_master(M1, M2) + repl.test_replication(M1, M2, 30) + repl.test_replication(M2, M1, 30) + entries = M2.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, "(cn=*)") + assert len(entries) > 0 + + +if __name__ == "__main__": + # Run isolated + # -s for DEBUG mode + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s %s" % CURRENT_FILE)