def test_item_substring_any(self): text = r'*foo*' filt = pureldap.LDAPFilter_substrings( type='cn', substrings=[pureldap.LDAPFilter_substrings_any('foo'), ]) self.assertEqual(ldapfilter.parseMaybeSubstring('cn', text), filt)
def test_escape_simple(self): text = r"f\2aoo(bar" filt = pureldap.LDAPFilter_equalityMatch( attributeDesc=pureldap.LDAPAttributeDescription(value="cn"), assertionValue=pureldap.LDAPAssertionValue(value="f*oo(bar"), ) self.assertEqual(ldapfilter.parseMaybeSubstring("cn", text), filt)
def test_item_substring_if(self): text = r'foo*bar' filt = pureldap.LDAPFilter_substrings( type='cn', substrings=[pureldap.LDAPFilter_substrings_initial('foo'), pureldap.LDAPFilter_substrings_final('bar'), ]) self.assertEqual(ldapfilter.parseMaybeSubstring('cn', text), filt)
def test_item_substring_any(self): text = r"*foo*" filt = pureldap.LDAPFilter_substrings( type="cn", substrings=[ pureldap.LDAPFilter_substrings_any("foo"), ], ) self.assertEqual(ldapfilter.parseMaybeSubstring("cn", text), filt)
def test_item_substring_if(self): text = r"foo*bar" filt = pureldap.LDAPFilter_substrings( type="cn", substrings=[ pureldap.LDAPFilter_substrings_initial("foo"), pureldap.LDAPFilter_substrings_final("bar"), ], ) self.assertEqual(ldapfilter.parseMaybeSubstring("cn", text), filt)
def _getSearchFilter(self): filters = [] for attr,value in self.data.items(): if value is not None: f = ldapfilter.parseMaybeSubstring(attr, value) filters.append(f) if not filters: return None searchFilter = pureldap.LDAPFilter_and( [pureldap.LDAPFilter_equalityMatch( attributeDesc=pureldap.LDAPAttributeDescription('objectClass'), assertionValue=pureldap.LDAPAssertionValue('addressbookPerson'))] + filters) return searchFilter
def _getSearchFilter(self): filters = [] for attr, value in self.data.items(): if value is not None: f = ldapfilter.parseMaybeSubstring(attr, value) filters.append(f) if not filters: return None searchFilter = pureldap.LDAPFilter_and([ pureldap.LDAPFilter_equalityMatch( attributeDesc=pureldap.LDAPAttributeDescription('objectClass'), assertionValue=pureldap.LDAPAssertionValue( 'addressbookPerson')) ] + filters) return searchFilter
def test_item_present(self): text = r"*" filt = pureldap.LDAPFilter_present(value="cn") self.assertEqual(ldapfilter.parseMaybeSubstring("cn", text), filt)
def test_escape_simple(self): text = r'f\2aoo(bar' filt = pureldap.LDAPFilter_equalityMatch( attributeDesc=pureldap.LDAPAttributeDescription(value='cn'), assertionValue=pureldap.LDAPAssertionValue(value='f*oo(bar')) self.assertEqual(ldapfilter.parseMaybeSubstring('cn', text), filt)
def test_item_present(self): text = r'*' filt = pureldap.LDAPFilter_present(value='cn') self.assertEqual(ldapfilter.parseMaybeSubstring('cn', text), filt)
def test_item_simple(self): text = r'foo' filt = pureldap.LDAPFilter_equalityMatch( attributeDesc=pureldap.LDAPAttributeDescription(value='cn'), assertionValue=pureldap.LDAPAssertionValue(value='foo')) self.assertEqual(ldapfilter.parseMaybeSubstring('cn', text), filt)