test/alipay/sign_test.rb in alipay-0.5.0 vs test/alipay/sign_test.rb in alipay-0.6.0.beta1

- old
+ new

@@ -1,23 +1,27 @@ require 'test_helper' -class Alipay::SignTest < Test::Unit::TestCase +class Alipay::SignTest < Minitest::Test def setup @params = { :service => 'test', :partner => '123' } - @sign = Digest::MD5.hexdigest("partner=123&service=test#{Alipay.key}") + @md5_sign = 'bbd13b52823b576291595f472ebcfbc2' end def test_generate_sign - assert_equal @sign, Alipay::Sign.generate(@params) + assert_equal @md5_sign, Alipay::Sign.generate(@params) end + def test_generate_md5_sign + assert_equal @md5_sign, Alipay::Sign.generate_md5(Alipay.key, @params) + end + def test_verify_sign - assert Alipay::Sign.verify?(@params.merge(:sign => @sign)) + assert Alipay::Sign.verify?(@params.merge(:sign_type => 'MD5', :sign => @md5_sign)) end def test_verify_sign_when_fails - assert !Alipay::Sign.verify?(@params.merge(:danger => 'danger', :sign => @sign)) + assert !Alipay::Sign.verify?(@params.merge(:danger => 'danger', :sign_type => 'MD5', :sign => @md5_sign)) end end