Sha256: 2bdad227bbf00601bc186fffe4fb7d0d1f948c362445035f588a20b75e529f10

Contents?: true

Size: 730 Bytes

Versions: 4

Compression:

Stored size: 730 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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wx_pay-0.1.0 test/wx_pay/sign_test.rb
wx_pay-0.0.4 test/wx_pay/sign_test.rb
wx_pay-0.0.3 test/wx_pay/sign_test.rb
wx_pay-0.0.2 test/wx_pay/sign_test.rb