Sha256: 54d54777a8012dcdaddcb12d56ea921098560ca568456860d7fcdc4f6afbbe93

Contents?: true

Size: 1.31 KB

Versions: 163

Compression:

Stored size: 1.31 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) if operation.output
          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

163 entries across 163 versions & 1 rubygems

Version Path
aws-sdk-core-3.46.1 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.46.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.45.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.44.2 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.44.1 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.44.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.43.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.42.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.41.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.40.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.39.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.38.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.37.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.36.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.35.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.34.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.33.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.32.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.31.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb
aws-sdk-core-3.30.0 lib/aws-sdk-core/stubbing/protocols/ec2.rb