dirsrvtests/tests/tickets/ticket47973_test.py | 109 ++++++++++++++++++++++++++
ldap/servers/slapd/schema.c | 11 ++
2 files changed, 118 insertions(+), 2 deletions(-)
New commits:
commit 75a19585f47bdabdd2c3e0ac0c343fb4ffd42337
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jan 19 16:26:51 2017 -0800
Ticket 47973 - CI Test case (test_ticket47973_case)
Description: custom schema is registered in small caps after schema reload
diff --git a/dirsrvtests/tests/tickets/ticket47973_test.py
b/dirsrvtests/tests/tickets/ticket47973_test.py
index c333ddb..c7548a5 100644
--- a/dirsrvtests/tests/tickets/ticket47973_test.py
+++ b/dirsrvtests/tests/tickets/ticket47973_test.py
@@ -7,6 +7,7 @@
# --- END COPYRIGHT BLOCK ---
#
import logging
+import re
import ldap.sasl
import pytest
@@ -107,6 +108,114 @@ def test_ticket47973(topology_st):
task_count += 1
+def test_ticket47973_case(topology_st):
+ log.info('Testing Ticket 47973 (case) - Test the cases in the original schema are
preserved.')
+
+ log.info('case 1 - Test the cases in the original schema are preserved.')
+
+ tsfile = topology_st.standalone.schemadir + '/98test.ldif'
+ tsfd = open(tsfile, "w")
+ Mozattr0 = "MoZiLLaaTTRiBuTe"
+ testschema = "dn: cn=schema\nattributetypes: ( 8.9.10.11.12.13.14 NAME
'MozillaAttribute' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Mozilla
Dummy Schema' )\nobjectclasses: ( 1.2.3.4.5.6.7 NAME 'MozillaObject' SUP top
MUST ( objectclass $ cn ) MAY ( " + Mozattr0 + " ) X-ORIGIN 'user
defined' )"
+ tsfd.write(testschema)
+ tsfd.close()
+
+ try:
+ # run the schema reload task with the default schemadir
+
topology_st.standalone.tasks.schemaReload(schemadir=topology_st.standalone.schemadir,
+ args={TASK_WAIT: False})
+ except ValueError:
+ log.error('Schema Reload task failed.')
+ assert False
+
+ time.sleep(5)
+
+ try:
+ schemaentry = topology_st.standalone.search_s("cn=schema",
ldap.SCOPE_BASE,
+ 'objectclass=top',
+ ["objectclasses"])
+ oclist = schemaentry[0].data.get("objectclasses")
+ except ldap.LDAPError as e:
+ log.error('Failed to get schema entry: error (%s)' %
e.message['desc'])
+ raise e
+
+ found = 0
+ for oc in oclist:
+ log.info('OC: %s' % oc)
+ moz = re.findall(Mozattr0, oc)
+ if moz:
+ found = 1
+ log.info('case 1: %s is in the objectclasses list -- PASS' %
Mozattr0)
+
+ if found == 0:
+ log.error('case 1: %s is not in the objectclasses list -- FAILURE' %
Mozattr0)
+ assert False
+
+ log.info('case 2 - Duplicated schema except cases are not loaded.')
+
+ tsfile = topology_st.standalone.schemadir + '/97test.ldif'
+ tsfd = open(tsfile, "w")
+ Mozattr1 = "MOZILLAATTRIBUTE"
+ testschema = "dn: cn=schema\nattributetypes: ( 8.9.10.11.12.13.14 NAME
'MozillaAttribute' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Mozilla
Dummy Schema' )\nobjectclasses: ( 1.2.3.4.5.6.7 NAME 'MozillaObject' SUP top
MUST ( objectclass $ cn ) MAY ( " + Mozattr1 + " ) X-ORIGIN 'user
defined' )"
+ tsfd.write(testschema)
+ tsfd.close()
+
+ try:
+ # run the schema reload task with the default schemadir
+
topology_st.standalone.tasks.schemaReload(schemadir=topology_st.standalone.schemadir,
+ args={TASK_WAIT: False})
+ except ValueError:
+ log.error('Schema Reload task failed.')
+ assert False
+
+ time.sleep(5)
+
+ try:
+ schemaentry = topology_st.standalone.search_s("cn=schema",
ldap.SCOPE_BASE,
+ 'objectclass=top',
+ ["objectclasses"])
+ oclist = schemaentry[0].data.get("objectclasses")
+ except ldap.LDAPError as e:
+ log.error('Failed to get schema entry: error (%s)' %
e.message['desc'])
+ raise e
+
+ for oc in oclist:
+ log.info('OC: %s' % oc)
+ moz = re.findall(Mozattr1, oc)
+ if moz:
+ log.error('case 2: %s is in the objectclasses list -- FAILURE' %
Mozattr1)
+ assert False
+
+ log.info('case 2: %s is not in the objectclasses list -- PASS' % Mozattr1)
+
+ Mozattr2 = "mozillaattribute"
+ log.info('case 2-1: Use the custom schema with %s' % Mozattr2)
+ name = "test user"
+ try:
+ topology_st.standalone.add_s(Entry(("cn=%s,%s" % (name, SUFFIX), {
+ 'objectclass': "top person
MozillaObject".split(),
+ 'sn': name,
+ 'cn': name,
+ Mozattr2: name})))
+ except ldap.LDAPError as e:
+ log.error('Failed to add a test entry: error (%s)' %
e.message['desc'])
+ raise e
+
+ try:
+ testentry = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE,
+ 'objectclass=mozillaobject',
+ [Mozattr2])
+ except ldap.LDAPError as e:
+ log.error('Failed to get schema entry: error (%s)' %
e.message['desc'])
+ raise e
+
+ mozattrval = testentry[0].data.get(Mozattr2)
+ if mozattrval[0] == name:
+ log.info('case 2-1: %s: %s found-- PASS' % (Mozattr2, name))
+ else:
+ log.info('case 2-1: %s: %s not found-- FAILURE' % (Mozattr2,
mozattrval[0]))
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
commit a0545ed39904f969e083c4b385664e3c4ebfab45
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jan 18 14:42:49 2017 -0800
Ticket 47973 - custom schema is registered in small caps after schema reload
Description: The fix for ticket 47973 [1] brougt an side effect which
lowers the case of the reloaded new schema. This patch fixes the issue
by eliminating normalize_oc_nolock().
Note that the normalization is not needed since all the checks are done
by strcasecmp. There is an exception. When trying to replace a schema
with the same one having the different cases, exact string compare is
called.
[1] commit e0c78e1c1db351ea5cf835cdb55437b1ea26a3a6
https://fedorahosted.org/389/ticket/47973
Reviewed by bordaz(a)redhat.com (Thanks, Thierry!!)
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index c65cdba..392c01f 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -5377,10 +5377,17 @@ init_schema_dse_ext(char *schemadir, Slapi_Backend *be,
if (rc && !(schema_flags & DSE_SCHEMA_NO_BACKEND))
{
- /* make sure the schema is normalized */
if (schema_flags & DSE_SCHEMA_LOCKED) {
- normalize_oc_nolock();
+ /*
+ * Code path for schema reload.
+ * To fix the side effect which lowers the case of the
+ * reloaded new schema, eliminating normalize_oc_nolock().
+ * Note that the normalization is not needed since all
+ * the checks are done by strcasecmp.
+ */
+ ;
} else {
+ /* make sure the schema is normalized */
normalize_oc();
}