Sha256: 7299d8ba2b3d104552002cc2aaa33e6ea6bca44a66179e03427d58bb45593325

Contents?: true

Size: 896 Bytes

Versions: 24

Compression:

Stored size: 896 Bytes

Contents

require 'test_helper'

class WxPay::SignTest < MiniTest::Test
  def setup
    @params = {
      appid: 'wxd930ea5d5a258f4f',
      auth_code: 123456,
      body: 'test',
      device_info: 123,
      mch_id: 1900000109,
      nonce_str: '960f228109051b9969f76c82bde183ac',
      out_trade_no: '1400755861',
      spbill_create_ip: '127.0.0.1',
      total_fee: 1
    }

    @sign = '729A68AC3DE268DBD9ADE442382E7B24'
  end

  def test_generate_sign
    assert_equal @sign, WxPay::Sign.generate(@params)
  end

  def test_verify_sign
    assert WxPay::Sign.verify?(@params.merge(:sign => @sign))
  end

  def test_verify_sign_when_fails
    assert !WxPay::Sign.verify?(@params.merge(:danger => 'danger', :sign => @sign))
  end

  def test_accept_pars_key_to_generate_sign
    @params.merge!(key: "key")

    assert_equal "1454C32E885B8D9E4A05E976D1C45B88", WxPay::Sign.generate(@params)
  end
end

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
wx_pay-0.4.1 test/wx_pay/sign_test.rb
wx_pay-0.4.0 test/wx_pay/sign_test.rb
weixin_pay-0.2.0 test/wx_pay/sign_test.rb
wx_pay-0.2.0 test/wx_pay/sign_test.rb