From ba3c9db8a76f1428892e867c68c1e2f4c04c1fa1 Mon Sep 17 00:00:00 2001 From: Akito Nozaki Date: Tue, 17 Apr 2018 11:32:39 -0700 Subject: [PATCH] Fixing create_key_and_certificate boolean parameter (#1572) --- moto/iot/responses.py | 2 +- tests/test_iot/test_iot.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/moto/iot/responses.py b/moto/iot/responses.py index f59c105d..4bd35bce 100644 --- a/moto/iot/responses.py +++ b/moto/iot/responses.py @@ -103,7 +103,7 @@ class IoTResponse(BaseResponse): return json.dumps(dict()) def create_keys_and_certificate(self): - set_as_active = self._get_param("setAsActive") + set_as_active = self._get_bool_param("setAsActive") cert, key_pair = self.iot_backend.create_keys_and_certificate( set_as_active=set_as_active, ) diff --git a/tests/test_iot/test_iot.py b/tests/test_iot/test_iot.py index 7c01934d..e69e55fc 100644 --- a/tests/test_iot/test_iot.py +++ b/tests/test_iot/test_iot.py @@ -96,6 +96,23 @@ def test_certs(): res = client.list_certificates() res.should.have.key('certificates').which.should.have.length_of(0) +@mock_iot +def test_certs_create_inactive(): + client = boto3.client('iot', region_name='ap-northeast-1') + cert = client.create_keys_and_certificate(setAsActive=False) + cert_id = cert['certificateId'] + + cert = client.describe_certificate(certificateId=cert_id) + cert.should.have.key('certificateDescription') + cert_desc = cert['certificateDescription'] + cert_desc.should.have.key('status').which.should.equal('INACTIVE') + + client.update_certificate(certificateId=cert_id, newStatus='ACTIVE') + cert = client.describe_certificate(certificateId=cert_id) + cert.should.have.key('certificateDescription') + cert_desc = cert['certificateDescription'] + cert_desc.should.have.key('status').which.should.equal('ACTIVE') + @mock_iot def test_policy(): client = boto3.client('iot', region_name='ap-northeast-1')