6f51e1
From d336e3558655d44f8ba797392af882e33d492958 Mon Sep 17 00:00:00 2001
6f51e1
From: Mark Reynolds <mreynolds@redhat.com>
6f51e1
Date: Thu, 14 Sep 2017 14:15:25 -0400
6f51e1
Subject: [PATCH] Ticket 49380 - Add CI test
6f51e1
6f51e1
Description:  Add test to verify invalid agreement is rejected, and it
6f51e1
              does not cause a crash
6f51e1
6f51e1
https://pagure.io/389-ds-base/issue/49380
6f51e1
6f51e1
Reviewed by: spichugi(Thanks!)
6f51e1
6f51e1
(cherry picked from commit 02d76b61489f105f81d72d4f3848e2444463289b)
6f51e1
---
6f51e1
 .../tests/suites/replication/acceptance_test.py    | 43 ++++++++++++++++++++++
6f51e1
 1 file changed, 43 insertions(+)
6f51e1
6f51e1
diff --git a/dirsrvtests/tests/suites/replication/acceptance_test.py b/dirsrvtests/tests/suites/replication/acceptance_test.py
6f51e1
index e6f2ef7..2f8b180 100644
6f51e1
--- a/dirsrvtests/tests/suites/replication/acceptance_test.py
6f51e1
+++ b/dirsrvtests/tests/suites/replication/acceptance_test.py
6f51e1
@@ -3,6 +3,12 @@ from lib389.tasks import *
6f51e1
 from lib389.utils import *
6f51e1
 from lib389.topologies import topology_m4 as topo
6f51e1
 
6f51e1
+from lib389._constants import (BACKEND_NAME, DEFAULT_SUFFIX, LOG_REPLICA, REPLICA_RUV_FILTER,
6f51e1
+                               ReplicaRole, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
6f51e1
+                               REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, defaultProperties,
6f51e1
+                               RA_NAME, RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT,
6f51e1
+                               DN_DM, PASSWORD, LOG_DEFAULT, RA_ENABLED, RA_SCHEDULE)
6f51e1
+
6f51e1
 TEST_ENTRY_NAME = 'mmrepl_test'
6f51e1
 TEST_ENTRY_DN = 'uid={},{}'.format(TEST_ENTRY_NAME, DEFAULT_SUFFIX)
6f51e1
 
6f51e1
@@ -193,6 +199,43 @@ def test_modrdn_entry(topo, test_entry, delold):
6f51e1
         topo.ms["master1"].delete_s(newrdn_dn)
6f51e1
 
6f51e1
 
6f51e1
+def test_invalid_agmt(topo_m4):
6f51e1
+    """Test adding that an invalid agreement is properly rejected and does not crash the server
6f51e1
+
6f51e1
+    :id: 6c3b2a7e-edcd-4327-a003-6bd878ff722b
6f51e1
+    :setup: MMR with four masters
6f51e1
+    :steps:
6f51e1
+        1. Add invalid agreement (nsds5ReplicaEnabled set to invalid value)
6f51e1
+        2. Verify the server is still running
6f51e1
+    :expectedresults:
6f51e1
+        1. Invalid repl agreement should be rejected
6f51e1
+        2. Server should be still running
6f51e1
+    """
6f51e1
+    m1 = topo_m4.ms["master1"]
6f51e1
+
6f51e1
+    # Add invalid agreement (nsds5ReplicaEnabled set to invalid value)
6f51e1
+    AGMT_DN = 'cn=whatever,cn=replica,cn="dc=example,dc=com",cn=mapping tree,cn=config'
6f51e1
+    try:
6f51e1
+        invalid_props = {RA_ENABLED: 'True',  # Invalid value
6f51e1
+                         RA_SCHEDULE: '0001-2359 0123456'}
6f51e1
+        m1.agreement.create(suffix=DEFAULT_SUFFIX, host='localhost', port=389, properties=invalid_props)
6f51e1
+    except ldap.UNWILLING_TO_PERFORM:
6f51e1
+        m1.log.info('Invalid repl agreement correctly rejected')
6f51e1
+    except ldap.LDAPError as e:
6f51e1
+        m1.log.fatal('Got unexpected error adding invalid agreement: ' + str(e))
6f51e1
+        assert False
6f51e1
+    else:
6f51e1
+        m1.log.fatal('Invalid agreement was incorrectly accepted by the server')
6f51e1
+        assert False
6f51e1
+
6f51e1
+    # Verify the server is still running
6f51e1
+    try:
6f51e1
+        m1.simple_bind_s(DN_DM, PASSWORD)
6f51e1
+    except ldap.LDAPError as e:
6f51e1
+        m1.log.fatal('Failed to bind: ' + str(e))
6f51e1
+        assert False
6f51e1
+
6f51e1
+
6f51e1
 if __name__ == '__main__':
6f51e1
     # Run isolated
6f51e1
     # -s for DEBUG mode
6f51e1
-- 
6f51e1
2.9.5
6f51e1