2015-07-23 03:28:47 -05:00
|
|
|
#
|
|
|
|
# Copyright (C) 2015 FreeIPA Contributors see COPYING for license
|
|
|
|
#
|
|
|
|
|
2015-08-27 12:19:28 -05:00
|
|
|
import io
|
2015-07-23 03:28:47 -05:00
|
|
|
import os
|
|
|
|
from ipaserver.plugins.ldap2 import ldap2
|
|
|
|
from ipalib import api
|
|
|
|
from ipapython.dn import DN
|
2015-08-27 12:19:28 -05:00
|
|
|
import pytest
|
2015-07-23 03:28:47 -05:00
|
|
|
|
|
|
|
|
2015-04-24 07:39:48 -05:00
|
|
|
@pytest.mark.tier1
|
2018-09-26 04:59:50 -05:00
|
|
|
class TestTopologyPlugin:
|
2015-07-23 03:28:47 -05:00
|
|
|
"""
|
|
|
|
Test Topology plugin from the DS point of view
|
2015-08-27 12:19:28 -05:00
|
|
|
Testcase: http://www.freeipa.org/page/V4/Manage_replication_topology/
|
|
|
|
Test_plan#Test_case:
|
|
|
|
_Replication_Topology_is_listed_among_directory_server_plugins
|
2015-07-23 03:28:47 -05:00
|
|
|
"""
|
2015-08-27 12:19:28 -05:00
|
|
|
pwfile = os.path.join(api.env.dot_ipa, ".dmpw")
|
2015-07-23 03:28:47 -05:00
|
|
|
|
2019-06-20 09:14:02 -05:00
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def topologyplugin_setup(self, request):
|
2015-07-23 03:28:47 -05:00
|
|
|
"""
|
|
|
|
setup for test
|
|
|
|
"""
|
|
|
|
self.conn = None
|
|
|
|
|
2019-06-20 09:14:02 -05:00
|
|
|
def fin():
|
|
|
|
if self.conn and self.conn.isconnected():
|
|
|
|
self.conn.disconnect()
|
|
|
|
request.addfinalizer(fin)
|
2015-07-23 03:28:47 -05:00
|
|
|
|
2017-10-20 04:10:20 -05:00
|
|
|
@pytest.mark.skipif(os.path.isfile(pwfile) is False,
|
2015-08-27 12:19:28 -05:00
|
|
|
reason="You did not provide a .dmpw file with the DM password")
|
2015-07-23 03:28:47 -05:00
|
|
|
def test_topologyplugin(self):
|
|
|
|
pluginattrs = {
|
|
|
|
u'nsslapd-pluginPath': [u'libtopology'],
|
|
|
|
u'nsslapd-pluginVendor': [u'freeipa'],
|
|
|
|
u'cn': [u'IPA Topology Configuration'],
|
|
|
|
u'nsslapd-plugin-depends-on-named':
|
|
|
|
[u'Multimaster Replication Plugin', u'ldbm database'],
|
|
|
|
u'nsslapd-topo-plugin-shared-replica-root': [u'dc=example,dc=com'],
|
|
|
|
u'nsslapd-pluginVersion': [u'1.0'],
|
|
|
|
u'nsslapd-topo-plugin-shared-config-base':
|
|
|
|
[u'cn=ipa,cn=etc,dc=example,dc=com'],
|
|
|
|
u'nsslapd-pluginDescription': [u'ipa-topology-plugin'],
|
|
|
|
u'nsslapd-pluginEnabled': [u'on'],
|
|
|
|
u'nsslapd-pluginId': [u'ipa-topology-plugin'],
|
|
|
|
u'objectClass': [u'top', u'nsSlapdPlugin', u'extensibleObject'],
|
|
|
|
u'nsslapd-topo-plugin-startup-delay': [u'20'],
|
|
|
|
u'nsslapd-topo-plugin-shared-binddngroup':
|
|
|
|
[u'cn=replication managers,cn=sysaccounts,cn=etc,dc=example,dc=com'],
|
|
|
|
u'nsslapd-pluginType': [u'object'],
|
|
|
|
u'nsslapd-pluginInitfunc': [u'ipa_topo_init']
|
|
|
|
}
|
|
|
|
variable_attrs = {u'nsslapd-topo-plugin-shared-replica-root',
|
|
|
|
u'nsslapd-topo-plugin-shared-config-base',
|
|
|
|
u'nsslapd-topo-plugin-shared-binddngroup'}
|
|
|
|
|
|
|
|
# Now eliminate keys that have domain-dependent values.
|
|
|
|
checkvalues = set(pluginattrs.keys()) - variable_attrs
|
|
|
|
topoplugindn = DN(('cn', 'IPA Topology Configuration'),
|
|
|
|
('cn', 'plugins'),
|
|
|
|
('cn', 'config'))
|
|
|
|
pwfile = os.path.join(api.env.dot_ipa, ".dmpw")
|
2015-08-27 12:19:28 -05:00
|
|
|
with io.open(pwfile, "r") as f:
|
|
|
|
dm_password = f.read().rstrip()
|
2015-07-23 03:28:47 -05:00
|
|
|
self.conn = ldap2(api)
|
|
|
|
self.conn.connect(bind_dn=DN(('cn', 'directory manager')),
|
|
|
|
bind_pw=dm_password)
|
|
|
|
entry = self.conn.get_entry(topoplugindn)
|
|
|
|
assert(set(entry.keys()) == set(pluginattrs.keys()))
|
|
|
|
for i in checkvalues:
|
2016-05-06 10:35:26 -05:00
|
|
|
assert(set(pluginattrs[i]) == set(entry[i]))
|