#49959 Ticket 49958: extended search fail to match entries
Closed 3 years ago by spichugi. Opened 5 years ago by tbordaz.
tbordaz/389-ds-base ticket_49958  into  master

@@ -223,6 +223,88 @@ 

  

      log.info('Testcase PASSED')

  

+ @pytest.mark.bz1615155

+ def test_extended_search(topology_st):

+     """Test we can search with equality extended matching rule

+ 

+     :id: 

+     :setup: Standalone instance

+     :steps:

+          1. Add a test user with 'sn: ext-test-entry'

+          2. Search '(cn:de:=ext-test-entry)'

+          3. Search '(sn:caseIgnoreIA5Match:=EXT-TEST-ENTRY)'

+          4. Search '(sn:caseIgnoreMatch:=EXT-TEST-ENTRY)'

+          5. Search '(sn:caseExactMatch:=EXT-TEST-ENTRY)'

+          6. Search '(sn:caseExactMatch:=ext-test-entry)'

+          7. Search '(sn:caseExactIA5Match:=EXT-TEST-ENTRY)'

+          8. Search '(sn:caseExactIA5Match:=ext-test-entry)'

+     :expectedresults:

+          1. This should pass

+          2. This should return one entry

+          3. This should return one entry

+          4. This should return one entry

+          5. This should return NO entry

+          6. This should return one entry

+          7. This should return NO entry

+          8. This should return one entry

+          3. return one entry

+     """

+     log.info('Running test_filter_escaped...')

+     

+     ATTR_VAL = 'ext-test-entry'

+     USER1_DN = "uid=%s,%s" % (ATTR_VAL, DEFAULT_SUFFIX)

+ 

+     try:

+         topology_st.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(),

+                                                        'sn': ATTR_VAL.encode(),

+                                                        'cn': ATTR_VAL.encode(),

+                                                        'uid': ATTR_VAL.encode()})))

+     except ldap.LDAPError as e:

+         log.fatal('test_extended_search: Failed to add test user ' + USER1_DN + ': error ' +

+                   e.message['desc'])

+         assert False

+ 

+     # filter: '(cn:de:=ext-test-entry)'

+     myfilter = '(cn:de:=%s)' % ATTR_VAL

+     topology_st.standalone.log.info("Try to search with filter %s" % myfilter)

+     ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)

+     assert len(ents) == 1

+ 

+     # filter: '(sn:caseIgnoreIA5Match:=EXT-TEST-ENTRY)'

+     myfilter = '(cn:caseIgnoreIA5Match:=%s)' % ATTR_VAL.upper()

+     topology_st.standalone.log.info("Try to search with filter %s" % myfilter)

+     ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)

+     assert len(ents) == 1

+ 

+     # filter: '(sn:caseIgnoreMatch:=EXT-TEST-ENTRY)'

+     myfilter = '(cn:caseIgnoreMatch:=%s)' % ATTR_VAL.upper()

+     topology_st.standalone.log.info("Try to search with filter %s" % myfilter)

+     ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)

+     assert len(ents) == 1

+ 

+     # filter: '(sn:caseExactMatch:=EXT-TEST-ENTRY)'

+     myfilter = '(cn:caseExactMatch:=%s)' % ATTR_VAL.upper()

+     topology_st.standalone.log.info("Try to search with filter %s" % myfilter)

+     ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)

+     assert len(ents) == 0

+ 

+     # filter: '(sn:caseExactMatch:=ext-test-entry)'

+     myfilter = '(cn:caseExactMatch:=%s)' % ATTR_VAL

+     topology_st.standalone.log.info("Try to search with filter %s" % myfilter)

+     ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)

+     assert len(ents) == 1

+ 

+     # filter: '(sn:caseExactIA5Match:=EXT-TEST-ENTRY)'

+     myfilter = '(cn:caseExactIA5Match:=%s)' % ATTR_VAL.upper()

+     topology_st.standalone.log.info("Try to search with filter %s" % myfilter)

+     ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)

+     assert len(ents) == 0

+ 

+     # filter: '(sn:caseExactIA5Match:=ext-test-entry)'

+     myfilter = '(cn:caseExactIA5Match:=%s)' % ATTR_VAL

+     topology_st.standalone.log.info("Try to search with filter %s" % myfilter)

+     ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)

+     assert len(ents) == 1

  

  if __name__ == '__main__':

      # Run isolated

@@ -531,10 +531,8 @@ 

              default:

                  break;

              }

-             for (; len > 0 && *val != ' '; ++val, --len)

+             for (; len > 0 && *val == ' '; ++val, --len)

                  ;

-             if (len > 0)

-                 ++val, --len; /* skip the space */

              bv.bv_len = len;

              bv.bv_val = (len > 0) ? val : NULL;

          } else { /* mrOID does not identify an ordering rule. */

Bug Description:
During an extended search, a structure is created for each filter component.
The structure contains the keys generated from the assertion and using the given
matching rule indexer.
Later the keys will be compared (with the MR) with keys generated from the
attribute values of the candidate entries.
The bug is that parsing the assertion, instead of removing the heading spaces
the routine clear the assertion that is empty. So the generated keys is NULL.

Fix Description:
The fix consists to only remove heading spaces

https://pagure.io/389-ds-base/issue/49958

Reviewed by: ?

Platforms tested: F27

Flag Day: no

Doc impact: no

rebased onto ff3da97

5 years ago

Pull-Request has been merged by tbordaz

5 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3018

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago