diff --git a/moto/iam/models.py b/moto/iam/models.py index 0f95d6453..6acdf8a8c 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -318,6 +318,10 @@ class IAMBackend(BaseBackend): if name == cert.cert_name: return cert + raise IAMNotFoundException( + "The Server Certificate with name {0} cannot be " + "found.".format(name)) + def create_group(self, group_name, path='/'): if group_name in self.groups: raise IAMConflictException("Group {0} already exists".format(group_name)) diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index 39f16e836..046939a85 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -21,6 +21,14 @@ def test_get_all_server_certs(): cert1.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname") +@mock_iam() +def test_get_server_cert_doesnt_exist(): + conn = boto.connect_iam() + + with assert_raises(BotoServerError): + conn.get_server_certificate("NonExistant") + + @mock_iam() def test_get_server_cert(): conn = boto.connect_iam()