Sha256: cb454f4ec7462ba996b5292c9603e6acffa3b91a94504ca6a5a51e61ca4d4ff2

Contents?: true

Size: 956 Bytes

Versions: 12

Compression:

Stored size: 956 Bytes

Contents

require 'test_helper'

class Alipay::SignTest < Minitest::Test
  def setup
    @params = {
      service: 'test',
      partner: '123'
    }
    @md5_sign = 'bbd13b52823b576291595f472ebcfbc2'

    @key_2 = '20000000000000000000000000000000'
    @md5_sign_2 = '6d581af270c023fdaaca6880491e9bf7'
  end

  def test_generate_sign
    assert_equal @md5_sign, Alipay::Sign.generate(@params)
    assert_equal @md5_sign_2, Alipay::Sign.generate(@params, {key: @key_2})
  end

  def test_verify_sign
    assert Alipay::Sign.verify?(@params.merge(sign_type: 'MD5', sign: @md5_sign))
    assert Alipay::Sign.verify?(@params.merge(sign_type: 'MD5', sign: @md5_sign_2), {key: @key_2})
  end

  def test_verify_fail_when_sign_not_true
    assert !Alipay::Sign.verify?(@params)
    assert !Alipay::Sign.verify?(@params.merge(danger: 'danger', sign_type: 'MD5', sign: @md5_sign))
    assert !Alipay::Sign.verify?(@params.merge(sign_type: 'MD5', sign: 'danger'))
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
yl_alipay-0.15.3 test/alipay/sign_test.rb
yl_alipay-0.15.2 test/alipay/sign_test.rb
alipay-0.14.0 test/alipay/sign_test.rb
alipay-0.13.0 test/alipay/sign_test.rb
alipay-0.12.0 test/alipay/sign_test.rb
alipay-0.11.0 test/alipay/sign_test.rb
alipay-0.10.0 test/alipay/sign_test.rb
alipay-0.9.0 test/alipay/sign_test.rb
alipay-0.8.0 test/alipay/sign_test.rb
alipay-0.7.1 test/alipay/sign_test.rb
alipay-0.7.0 test/alipay/sign_test.rb
alipay-0.6.0 test/alipay/sign_test.rb