Return all things when using "*" query_string parameter (#4960)

This commit is contained in:
Arno Lehtonen 2022-03-23 00:35:37 +02:00 committed by GitHub
parent 4f92ee8a1c
commit 5e55daebb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -45,6 +45,8 @@ class FakeThing(BaseModel):
self.thing_shadow = None
def matches(self, query_string):
if query_string == "*":
return True
if query_string.startswith("thingName:"):
qs = query_string[10:].replace("*", ".*").replace("?", ".")
return re.search(f"^{qs}$", self.thing_name)

View File

@ -12,6 +12,7 @@ from moto import mock_iot
["thingName:abc", {"abc"}],
["thingName:ab*", {"abc", "abd", "abcefg"}],
["thingName:ab?", {"abc", "abd"}],
["*", {"abc", "abd", "bbe", "abcefg", "uuuabc", "bbefg"}],
],
)
def test_search_things(query_string, results):