diff --git a/swh/graphql/resolvers/directory_entry.py b/swh/graphql/resolvers/directory_entry.py --- a/swh/graphql/resolvers/directory_entry.py +++ b/swh/graphql/resolvers/directory_entry.py @@ -56,6 +56,8 @@ if name_include is not None: # STORAGE-TODO, move this filter to swh-storage entries = [ - x for x in entries if name_include.lower().encode() in x.name.lower() + x + for x in entries + if name_include.casefold() in x.name.decode().casefold() ] return utils.paginated(entries, self._get_first_arg(), self._get_after_arg()) diff --git a/swh/graphql/tests/data.py b/swh/graphql/tests/data.py --- a/swh/graphql/tests/data.py +++ b/swh/graphql/tests/data.py @@ -127,6 +127,21 @@ ] +def get_directories_with_speical_name_entries(): + return [ + Directory( + entries=( + DirectoryEntry( + name=b"\xc3\x9f\xc3\x9f\xc3\xa9tE\xc3\x89t", + perms=0o644, + type="file", + target=get_contents()[0].sha1_git, + ), + ) + ) + ] + + def get_visit_with_multiple_status(): return [ OriginVisitStatus( @@ -144,7 +159,8 @@ GRAPHQL_EXTRA_TEST_OBJECTS = { "release": get_releases_with_target(), "revision": get_revisions_with_parents(), - "directory": get_directories_with_nested_path(), + "directory": get_directories_with_nested_path() + + get_directories_with_speical_name_entries(), "origin_visit_status": get_visit_with_multiple_status(), } diff --git a/swh/graphql/tests/functional/test_directory_entry.py b/swh/graphql/tests/functional/test_directory_entry.py --- a/swh/graphql/tests/functional/test_directory_entry.py +++ b/swh/graphql/tests/functional/test_directory_entry.py @@ -9,7 +9,11 @@ from swh.model.swhids import CoreSWHID, ObjectType from . import utils -from ..data import get_directories, get_directories_with_nested_path +from ..data import ( + get_directories, + get_directories_with_nested_path, + get_directories_with_speical_name_entries, +) def get_target_type(target_type): @@ -125,7 +129,9 @@ assert each_entry in directory_entries -@pytest.mark.parametrize("directory", get_directories()) +@pytest.mark.parametrize( + "directory", get_directories() + get_directories_with_speical_name_entries() +) def test_directory_entry_connection_filter_by_name(client, directory): storage = server.get_storage() for dir_entry in storage.directory_ls(directory.id):