Sha256: cafcfb15a1e6aff4ec051334748e8051d254e27255d59f643450e9158c99d296
Contents?: true
Size: 1.29 KB
Versions: 8
Compression:
Stored size: 1.29 KB
Contents
require 'test_helper' class Alipay::Notify::WapTest < Test::Unit::TestCase def setup @notify_id = 'notify_id_test' @notify_params = { :service => 'alipay.wap.trade.create.direct', :v => '1.0', :sec_id => 'MD5', :notify_data => "<notify><notify_id>#{@notify_id}</notify_id><other_key>other_value</other_key></notify>" } query = [ :service, :v, :sec_id, :notify_data ].map {|key| "#{key}=#{@notify_params[key]}"}.join('&') @sign_params = @notify_params.merge(:sign => Digest::MD5.hexdigest("#{query}#{Alipay.key}")) end def test_unsign_notify FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}¬ify_id=#{@notify_id}", :body => "true") assert !Alipay::Notify::Wap.verify?(@notify_params) end def test_verify_notify_when_true FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}¬ify_id=#{@notify_id}", :body => "true") assert Alipay::Notify::Wap.verify?(@sign_params) end def test_verify_notify_when_false FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}¬ify_id=#{@notify_id}", :body => "false") assert !Alipay::Notify::Wap.verify?(@sign_params) end end
Version data entries
8 entries across 8 versions & 1 rubygems