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