diff --git a/lib/fog/aws/requests/iam/delete_server_certificate.rb b/lib/fog/aws/requests/iam/delete_server_certificate.rb index 5d7e0b411..a49d38053 100644 --- a/lib/fog/aws/requests/iam/delete_server_certificate.rb +++ b/lib/fog/aws/requests/iam/delete_server_certificate.rb @@ -36,7 +36,9 @@ module Fog 'RequestId' => Fog::AWS::Mock.request_id } - self.data[:server_certificates].delete(server_certificate_name) + unless self.data[:server_certificates].delete(server_certificate_name) + raise Fog::AWS::IAM::NotFound.new("The Server Certificate with name #{server_certificate_name} cannot be found.") + end response end diff --git a/tests/aws/requests/iam/server_certificate_tests.rb b/tests/aws/requests/iam/server_certificate_tests.rb index dae47c3c1..ea7c14282 100644 --- a/tests/aws/requests/iam/server_certificate_tests.rb +++ b/tests/aws/requests/iam/server_certificate_tests.rb @@ -120,6 +120,9 @@ Shindo.tests('AWS::IAM | server certificate requests', ['aws']) do end tests('#delete_server_certificate').formats(AWS::IAM::Formats::BASIC) do + tests('raises NotFound').raises(Fog::AWS::IAM::NotFound) do + Fog::AWS::IAM.new.delete_server_certificate("#{@key_name}fake") + end Fog::AWS::IAM.new.delete_server_certificate(@key_name).body end