From df34b7864b8b647bf87c5caf9cb61b8d9d052954 Mon Sep 17 00:00:00 2001 From: cm-iwata <38879253+cm-iwata@users.noreply.github.com> Date: Mon, 19 Apr 2021 21:35:09 +0900 Subject: [PATCH] fix #3867 IoT list_principal_things (#3868) * fix #3867 iot list_principal_things should return list of thingnames. * lint --- moto/iot/models.py | 2 +- tests/test_iot/test_iot.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/moto/iot/models.py b/moto/iot/models.py index b72a63f40..17ea65dc6 100644 --- a/moto/iot/models.py +++ b/moto/iot/models.py @@ -925,7 +925,7 @@ class IoTBackend(BaseBackend): def list_principal_things(self, principal_arn): thing_names = [ - k[0] for k, v in self.principal_things.items() if k[0] == principal_arn + k[1] for k, v in self.principal_things.items() if k[0] == principal_arn ] return thing_names diff --git a/tests/test_iot/test_iot.py b/tests/test_iot/test_iot.py index f0e0048d5..1f9c940e9 100644 --- a/tests/test_iot/test_iot.py +++ b/tests/test_iot/test_iot.py @@ -847,8 +847,7 @@ def test_principal_thing(): res = client.list_principal_things(principal=cert_arn) res.should.have.key("things").which.should.have.length_of(1) - for thing in res["things"]: - thing.should_not.be.none + res["things"][0].should.equal(thing_name) res = client.list_thing_principals(thingName=thing_name) res.should.have.key("principals").which.should.have.length_of(1) for principal in res["principals"]: