IOT: group names can now contain special characters (#6701)

This commit is contained in:
Bert Blommers 2023-08-20 10:17:57 +00:00 committed by GitHub
parent 5e1b166f25
commit e11ba21b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View File

@ -581,14 +581,14 @@ class IoTResponse(BaseResponse):
return json.dumps(dict(principals=principals))
def describe_thing_group(self) -> str:
thing_group_name = self._get_param("thingGroupName")
thing_group_name = unquote(self.path.split("/thing-groups/")[-1])
thing_group = self.iot_backend.describe_thing_group(
thing_group_name=thing_group_name
)
return json.dumps(thing_group.to_dict())
def create_thing_group(self) -> str:
thing_group_name = self._get_param("thingGroupName")
thing_group_name = unquote(self.path.split("/thing-groups/")[-1])
parent_group_name = self._get_param("parentGroupName")
thing_group_properties = self._get_param("thingGroupProperties")
(
@ -609,7 +609,7 @@ class IoTResponse(BaseResponse):
)
def delete_thing_group(self) -> str:
thing_group_name = self._get_param("thingGroupName")
thing_group_name = unquote(self.path.split("/thing-groups/")[-1])
self.iot_backend.delete_thing_group(thing_group_name=thing_group_name)
return json.dumps(dict())
@ -632,7 +632,7 @@ class IoTResponse(BaseResponse):
return json.dumps(dict(thingGroups=rets, nextToken=next_token))
def update_thing_group(self) -> str:
thing_group_name = self._get_param("thingGroupName")
thing_group_name = unquote(self.path.split("/thing-groups/")[-1])
thing_group_properties = self._get_param("thingGroupProperties")
expected_version = self._get_param("expectedVersion")
version = self.iot_backend.update_thing_group(

View File

@ -38,8 +38,8 @@ def generate_thing_group_tree(iot_client, tree_dict, _parent=None):
class TestListThingGroup:
group_name_1a = "my-group-name-1a"
group_name_1b = "my-group-name-1b"
group_name_1a = "my-group:name-1a"
group_name_1b = "my-group:name-1b"
group_name_2a = "my-group-name-2a"
group_name_2b = "my-group-name-2b"
group_name_3a = "my-group-name-3a"
@ -112,7 +112,7 @@ class TestListThingGroup:
client = boto3.client("iot", region_name="ap-northeast-1")
generate_thing_group_tree(client, self.tree_dict)
# test
resp = client.list_thing_groups(namePrefixFilter="my-group-name-1")
resp = client.list_thing_groups(namePrefixFilter="my-group:name-1")
assert "thingGroups" in resp
assert len(resp["thingGroups"]) == 2
resp = client.list_thing_groups(namePrefixFilter="my-group-name-3")
@ -129,7 +129,7 @@ class TestListThingGroup:
generate_thing_group_tree(client, self.tree_dict)
# test
resp = client.list_thing_groups(
namePrefixFilter="my-group-name-1", recursive=False
namePrefixFilter="my-group:name-1", recursive=False
)
assert "thingGroups" in resp
assert len(resp["thingGroups"]) == 2
@ -166,7 +166,7 @@ class TestListThingGroup:
@mock_iot
def test_delete_thing_group():
client = boto3.client("iot", region_name="ap-northeast-1")
group_name_1a = "my-group-name-1a"
group_name_1a = "my-group:name-1a"
group_name_2a = "my-group-name-2a"
tree_dict = {group_name_1a: {group_name_2a: {}}}
generate_thing_group_tree(client, tree_dict)
@ -199,8 +199,8 @@ def test_delete_thing_group():
@mock_iot
def test_describe_thing_group_metadata_hierarchy():
client = boto3.client("iot", region_name="ap-northeast-1")
group_name_1a = "my-group-name-1a"
group_name_1b = "my-group-name-1b"
group_name_1a = "my-group:name-1a"
group_name_1b = "my-group:name-1b"
group_name_2a = "my-group-name-2a"
group_name_2b = "my-group-name-2b"
group_name_3a = "my-group-name-3a"
@ -313,7 +313,7 @@ def test_describe_thing_group_metadata_hierarchy():
@mock_iot
def test_thing_groups():
client = boto3.client("iot", region_name="ap-northeast-1")
group_name = "my-group-name"
group_name = "my-group:name"
# thing group
thing_group = client.create_thing_group(thingGroupName=group_name)