A simple test to check that Topology Plugin has registered itself in the ldap tree.

--
Oleg Fayans
Quality Engineer
FreeIPA team
RedHat.

From 49280b12b1701c3baf095c8d3c209e14dce0dcde Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Mon, 20 Jul 2015 11:50:32 +0200
Subject: [PATCH] Added test - topology plugin is listed among DS plugins

---
 ipatests/test_ipaserver/test_topology_plugin.py | 62 +++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 ipatests/test_ipaserver/test_topology_plugin.py

diff --git a/ipatests/test_ipaserver/test_topology_plugin.py b/ipatests/test_ipaserver/test_topology_plugin.py
new file mode 100644
index 0000000000000000000000000000000000000000..fc457190f2280197c523520db4a41375ace1fb03
--- /dev/null
+++ b/ipatests/test_ipaserver/test_topology_plugin.py
@@ -0,0 +1,62 @@
+import os
+from ipaserver.plugins.ldap2 import ldap2
+from ipalib import api
+from ipapython import ipautil
+from ipapython.dn import DN
+
+
+class TestTopologyPlugin(object):
+    """
+    Test Topology plugin from the DS point of view
+    """
+
+    def setup(self):
+        """
+        setup for test
+        """
+
+        self.ldapuri = 'ldap://%s' % ipautil.format_netloc(api.env.host)
+        self.conn = None
+
+    def teardown(self):
+        if self.conn and self.conn.isconnected():
+            self.conn.disconnect()
+
+    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']
+        }
+        # Now eliminate keys that have domain-dependent values.
+        checkvalues = set(pluginattrs.keys()) - {u'nsslapd-topo-plugin-shared-replica-root',
+                                               u'nsslapd-topo-plugin-shared-config-base',
+                                               u'nsslapd-topo-plugin-shared-binddngroup'}
+        topoplugindn = DN(('cn', 'IPA Topology Configuration'),
+                          ('cn', 'plugins'),
+                          ('cn', 'config'))
+        pwfile = api.env.dot_ipa + os.sep + ".dmpw"
+        if ipautil.file_exists(pwfile):
+            fp = open(pwfile, "r")
+            dm_password = fp.read().rstrip()
+            fp.close()
+        else:
+            raise nose.SkipTest("No directory manager password in %s" % pwfile)
+        self.conn = ldap2(api, ldap_uri=self.ldapuri)
+        self.conn.connect(bind_dn=DN(('cn', 'directory manager')), bind_pw=dm_password)
+        entry = self.conn.get_entry(topoplugindn)
+        assert(sorted(entry.keys()) == sorted(pluginattrs.keys()))
+        for i in checkvalues:
+            assert(pluginattrs[i] == entry[i])
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to