def test_build_search_filter(monkeypatch, criteria, type_filter, mapping, exact, expected): def _convert_app_data(*args, **kwargs): return OrderedDict(sorted(convert_app_data(*args, **kwargs).items())) monkeypatch.setattr('flask_multipass.providers.ldap.util.convert_app_data', _convert_app_data) assert build_search_filter(criteria, type_filter, mapping, exact) == expected
def build_group_search_filter(criteria, mapping=None, exact=False): # pragma: no cover """Builds the LDAP search filter for retrieving groups. :param criteria: dict -- Criteria to be `AND`ed together to build the filter. :param mapping: dict -- Mapping from criteria to LDAP attributes :param exact: bool -- Match attributes values exactly if ``True``, othewise perform substring matching. :return: str -- Valid LDAP search filter. """ type_filter = current_ldap.settings['group_filter'] return build_search_filter(criteria, type_filter, mapping, exact)
def build_group_search_filter(criteria, mapping=None, exact=False): # pragma: no cover """Builds the LDAP search filter for retrieving groups. :param criteria: dict -- Criteria to be `AND`ed together to build the filter. :param mapping: dict -- Mapping from criteria to LDAP attributes :param exact: bool -- Match attributes values exactly if ``True``, othewise perform substring matching. :return: str -- Valid LDAP search filter. """ type_filter = current_ldap.settings['group_filter'] return build_search_filter(criteria, type_filter, mapping, exact)
def test_build_search_filter(monkeypatch, criteria, type_filter, mapping, exact, expected): def _convert_app_data(*args, **kwargs): return OrderedDict(sorted(convert_app_data(*args, **kwargs).items())) monkeypatch.setattr('flask_multipass.providers.ldap.util.convert_app_data', _convert_app_data) assert build_search_filter(criteria, type_filter, mapping, exact) == expected