Sha256: e2d5f90be94821950ef4eddb5cd869701c5fc87ccff9ccc8ac0aa2e0564ecca6

Contents?: true

Size: 1.29 KB

Versions: 996

Compression:

Stored size: 1.29 KB

Contents

module Aws
  module Stubbing
    module Protocols
      class EC2

        def stub_data(api, operation, data)
          resp = Seahorse::Client::Http::Response.new
          resp.status_code = 200
          resp.body = build_body(api, operation, data)
          resp.headers['Content-Length'] = resp.body.size
          resp.headers['Content-Type'] = 'text/xml;charset=UTF-8'
          resp.headers['Server'] = 'AmazonEC2'
          resp
        end

        def stub_error(error_code)
          http_resp = Seahorse::Client::Http::Response.new
          http_resp.status_code = 400
          http_resp.body = <<-XML.strip
<ErrorResponse>
  <Error>
    <Code>#{error_code}</Code>
    <Message>stubbed-response-error-message</Message>
  </Error>
</ErrorResponse>
          XML
          http_resp
        end

        private

        def build_body(api, operation, data)
          xml = []
          Xml::Builder.new(operation.output, target:xml).to_xml(data)
          xml.shift
          xml.pop
          xmlns = "http://ec2.amazonaws.com/doc/#{api.version}/".inspect
          xml.unshift("  <requestId>stubbed-request-id</requestId>")
          xml.unshift("<#{operation.name}Response xmlns=#{xmlns}>\n")
          xml.push("</#{operation.name}Response>\n")
          xml.join
        end

      end
    end
  end
end

Version data entries

996 entries across 996 versions & 2 rubygems

Version Path
aws-sdk-core-2.11.632 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.631 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.630 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.629 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.628 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.627 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.626 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.625 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.624 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.623 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.622 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.621 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.620 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.619 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.618 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.617 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.616 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.615 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.614 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-2.11.613 lib/aws-sdk-core/stubbing/protocols/ec2.rb