amoralej / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 years ago
Clone

Blame SOURCES/0068-Ticket-49380-Add-CI-test.patch

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