Sha256: c8baa87e7da45b7addaa8f3c1c8dc6e018192ea78ea9d9b8fc7f174b701b6c2a

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'test_helper'

class Alipay::NotifyTest < Minitest::Test
  def setup
    @params = {
      notify_id: '1234',
    }
    @unsign_params = @params.merge(sign_type: 'MD5', sign: 'xxxx')
    @sign_params = @params.merge(
      sign_type: 'MD5',
      sign: '22fc7e38e5acdfede396aa463870d111'
    )
  end

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

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

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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
yl_alipay-0.15.3 test/alipay/notify_test.rb
yl_alipay-0.15.2 test/alipay/notify_test.rb
alipay-0.14.0 test/alipay/notify_test.rb