lib/fog/aws/requests/iam/delete_access_key.rb in fog-1.1.2 vs lib/fog/aws/requests/iam/delete_access_key.rb in fog-1.2.0

- old
+ new

@@ -27,8 +27,25 @@ :parser => Fog::Parsers::AWS::IAM::Basic.new }.merge!(options)) end end + + class Mock + + def delete_access_key(access_key_id, options = {}) + user_name = options['UserName'] + if user_name && data[:users].has_key?(user_name) && data[:users][user_name][:access_keys].any? { |akey| akey['AccessKeyId'] == access_key_id } + data[:users][user_name][:access_keys].delete_if { |akey| akey['AccessKeyId'] == access_key_id } + Excon::Response.new.tap do |response| + response.body = { 'RequestId' => Fog::AWS::Mock.request_id } + response.status = 200 + end + else + raise Fog::AWS::IAM::NotFound.new("The Access Key with id #{access_key_id} cannot be found.") + end + end + + end end end end