From 426e4e087e630c87fa87e850c78c0f4bb832e18d Mon Sep 17 00:00:00 2001 From: Viktor Ashirov Date: Apr 06 2020 12:21:20 +0000 Subject: Issue 51005 - AttributeUniqueness plugin's DN parameter should not have a default value Bug Description: Currently we have an optional dn parameter with a default value: def __init__(self, instance, dn="cn=plugins,cn=config"): This breaks some tests that assume the default base DN for this plugin. But it can have multiple instances, so we should always specify the DN. Making this parameter mandatory will ensure this. Fix Description: Remove the default DN value and update tests. Fixes: https://pagure.io/389-ds-base/issue/51005 Reviewed by: mreynolds (Thanks!) --- diff --git a/dirsrvtests/tests/suites/betxns/betxn_test.py b/dirsrvtests/tests/suites/betxns/betxn_test.py index ee160df..aab2392 100644 --- a/dirsrvtests/tests/suites/betxns/betxn_test.py +++ b/dirsrvtests/tests/suites/betxns/betxn_test.py @@ -98,7 +98,11 @@ def test_betxn_attr_uniqueness(topology_st): 5. Test user entry should be removed """ - attruniq = AttributeUniquenessPlugin(topology_st.standalone) + attruniq = AttributeUniquenessPlugin(topology_st.standalone, dn="cn=attruniq,cn=plugins,cn=config") + attruniq.create(properties={'cn': 'attruniq'}) + attruniq.add_unique_attribute('uid') + attruniq.add_unique_subtree(DEFAULT_SUFFIX) + attruniq.enable_all_subtrees() attruniq.enable() topology_st.standalone.restart() diff --git a/dirsrvtests/tests/suites/plugins/acceptance_test.py b/dirsrvtests/tests/suites/plugins/acceptance_test.py index c4b68e2..e9e830d 100644 --- a/dirsrvtests/tests/suites/plugins/acceptance_test.py +++ b/dirsrvtests/tests/suites/plugins/acceptance_test.py @@ -223,7 +223,7 @@ def test_attruniq(topo, args=None): inst = topo[0] # stop the plugin, and start it - plugin = AttributeUniquenessPlugin(inst) + plugin = AttributeUniquenessPlugin(inst, dn="cn=attribute uniqueness,cn=plugins,cn=config") plugin.disable() plugin.enable() diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py index 8ea40bc..5069bd7 100644 --- a/src/lib389/lib389/plugins.py +++ b/src/lib389/lib389/plugins.py @@ -134,7 +134,7 @@ class AttributeUniquenessPlugin(Plugin): 'nsslapd-pluginDescription': 'Enforce unique attribute values', } - def __init__(self, instance, dn="cn=plugins,cn=config"): + def __init__(self, instance, dn): super(AttributeUniquenessPlugin, self).__init__(instance, dn) self._protected = False self._create_objectclasses = ['top', 'nsslapdplugin', 'extensibleObject']