From 55197760e1701178b054a4e1bec5333dc1f13cc9 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Thu, 14 Sep 2017 11:00:05 -0400 Subject: [PATCH] Ticket 49380 - Add CI test Description: Add test to verify invalid agreement is rejected, and it does not cause a crash https://pagure.io/389-ds-base/issue/49380 Reviewed by: ? --- .../tests/suites/replication/acceptance_test.py | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/dirsrvtests/tests/suites/replication/acceptance_test.py b/dirsrvtests/tests/suites/replication/acceptance_test.py index 76005ff..fa1b324 100644 --- a/dirsrvtests/tests/suites/replication/acceptance_test.py +++ b/dirsrvtests/tests/suites/replication/acceptance_test.py @@ -487,6 +487,44 @@ def test_password_repl_error(topo_m4, test_entry): m2.setLogLevel(LOG_DEFAULT) +def test_invalid_agmt(topo_m4): + '''Test adding that an invalid agreement is properly rejected and does not crash the server + ''' + m1 = topo_m4.ms["master1"] + + # Add invalid agreement (nsds5ReplicaEnabled set to invalid value) + AGMT_DN = 'cn=whatever,cn=replica,cn="dc=example,dc=com",cn=mapping tree,cn=config' + try: + m1.add_s(Entry((AGMT_DN, { + 'objectclass': ['top', 'nsds5replicationagreement'], + 'nsds5replicahost': 'ldap.example.com', + 'nsds5replicaport': '389', + 'nsds5ReplicaBindDN': 'cn=test,cn=config', + 'nsds5replicabindmethod': 'SIMPLE', + 'nsds5replicaroot': 'dc=example,dc=com', + 'description': 'test', + 'nsds5replicaupdateschedule': '0001-2359 0123456', + 'nsds5replicatedattributelist': '(objectclass=*) $ EXCLUDE authorityRevocationList', + 'nsds5replicacredentials': 'test', + 'nsds5BeginReplicaRefresh': 'start', + 'nsds5ReplicaEnabled': 'True'}))) + except ldap.UNWILLING_TO_PERFORM: + m1.log.info('Invalid repl agreement correctly rejected') + except ldap.LDAPError as e: + m1.log.fatal('Got unexpected error adding invalid agreement: ' + str(e)) + assert False + else: + m1.log.fatal('Invalid agreement was incorrectly accepted by the server') + assert False + + # Verify the server is still running + try: + m1.simple_bind_s(DN_DM, PASSWORD) + except ldap.LDAPError as e: + m1.log.fatal('Failed to bind: ' + str(e)) + assert False + + if __name__ == '__main__': # Run isolated # -s for DEBUG mode -- 2.9.5