sandro / ephemeral_response

Automatic recording, replaying, and expiry of web responses.
MIT License
96 stars 4 forks source link

Added support for our SOAP requests #1

Closed bernerdschaefer closed 13 years ago

bernerdschaefer commented 14 years ago

They weren't being sent out with a body on the request object, choosing instead to be passed in as the second parameter to Net::HTTP#request.

sandro commented 14 years ago

Thanks for the patch. I'll get it in as soon as I get some free time.

sandro commented 14 years ago

Would you mind testing your code against master? I think I fixed the bug in this commit: http://github.com/sandro/ephemeral_response/commit/bd30a7f2cb76d4703ffb2fcccdd8bbef7c40929b

morganchristiansson commented 13 years ago

I have the same problem with ActiveMerchant. http.post is called like this: https://github.com/Shopify/active_merchant/blob/master/lib/active_merchant/common/connection.rb#L67

After installing the gem from https://github.com/hashrocket/ephemeral_response it works as expected and the fixtures have a toplevel body attribute.

morganchristiansson commented 13 years ago

It's been 4 months since this problem+patch was submitted. Are there any plans to release an updated gem with this issue resolved?

Thanks, Morgan

sandro commented 13 years ago

Mmm, yeah...sounds like a good idea. I've been on vacation out of the country for the last month but that doesn't make up for those additional three months. I've mostly been waiting on confirmation that the fix works, that and have been lazy.

morganchristiansson commented 13 years ago

Yes master seems to work. On the released gem request.body is empty

request: !ruby/object:Net::HTTP::Post 
  body: 
  body_stream: 
  *snip*
  method: POST
  *snip*
  request_has_body: true
  response_has_body: true

Whereas in your and hashrockets master it contains the request body as expected.

request: !ruby/object:Net::HTTP::Post 
  body: |
    <request timestamp="20110105120113" ........*snip*

  body_stream: 
  *snip*
  method: POST
  *snip*
  request_has_body: true
  response_has_body: true

So i guess that means: yes the issue is fixed in your master.

morganchristiansson commented 13 years ago

I just completed my tests using ephemeral_response from master and they all pass correctly as they would if ephemeral response wasn't running. I really like the simplicity of this gem. Even though it was a bit quirky to configure and find the parameters which were changing between the same requests (timestamp, generated order id and sha1hash which included the generated order id).

So any chance of getting a new release? :-)

PS/FYI this is the config i used with cucumber:

Before do
  EphemeralResponse.configure do |config|
    config.register('epage.payandshop.com') do |request|
      xml = REXML::Document.new request.body
      xml.root.attributes["timestamp"]="20110101000000"
      orderid = REXML::XPath.first(xml, '/request/orderid') and orderid.text = 'ORDERID'
      sha1hash = REXML::XPath.first(xml, '/request/sha1hash') and sha1hash.text = 'SHA1HASH'
      "#{request.uri.host}#{xml.to_s}"
    end

    config.register('www.secpay.com') do |request|
      xml = REXML::Document.new request.body
      if method = REXML::XPath.first(xml, '/methodCall/methodName') and ['SECVPN.validateCardFull','SECVPN.threeDSecureEnrolmentRequest'].include? method.text
        REXML::XPath.first(xml, '/methodCall/params/param[3]/value/string').text = 'ORDERID'
      end
      "#{request.uri.host}#{xml.to_s}"
    end
  end
  EphemeralResponse.activate
end
After do
  EphemeralResponse.deactivate
end

Thanks!

sandro commented 13 years ago

It's at the top of my list when I get back to the States in the next few days.

morganchristiansson commented 13 years ago

Thanks, enjoy the rest of your vacation. Thanks for a great gem. :-)