Sha256: 98677b14ee9e6c2d4976e11d85572ec0631573ca36fca309b58f46d27588ad7d

Contents?: true

Size: 1.26 KB

Versions: 9

Compression:

Stored size: 1.26 KB

Contents

require 'test_helper'

class Alipay::Wap::NotifyTest < Minitest::Test
  def setup
    @notify_id = 'notify_id_test'

    @notify_params = {
      service: 'alipay.wap.trade.create.direct',
      v: '1.0',
      sec_id: 'MD5',
      notify_data: "<notify><notify_id>#{@notify_id}</notify_id><other_key>other_value</other_key></notify>"
    }

    query = [ :service, :v, :sec_id, :notify_data ].map {|key| "#{key}=#{@notify_params[key]}"}.join('&')
    @sign_params = @notify_params.merge(sign: Digest::MD5.hexdigest("#{query}#{Alipay.key}"))
  end

  def test_unsign_notify
    FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{@notify_id}", body: "true")
    assert !Alipay::Wap::Notify.verify?(@notify_params)
  end

  def test_verify_notify_when_true
    FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{@notify_id}", body: "true")
    assert Alipay::Wap::Notify.verify?(@sign_params)
  end

  def test_verify_notify_when_false
    FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{@notify_id}", body: "false")
    assert !Alipay::Wap::Notify.verify?(@sign_params)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alipay-0.13.0 test/alipay/wap/notify_test.rb
alipay-0.12.0 test/alipay/wap/notify_test.rb
alipay-0.11.0 test/alipay/wap/notify_test.rb
alipay-0.10.0 test/alipay/wap/notify_test.rb
alipay-0.9.0 test/alipay/wap/notify_test.rb
alipay-0.8.0 test/alipay/wap/notify_test.rb
alipay-0.7.1 test/alipay/wap/notify_test.rb
alipay-0.7.0 test/alipay/wap/notify_test.rb
alipay-0.6.0 test/alipay/wap/notify_test.rb