Sha256: a51bbb91ce3e1660154652fc2a223d334fa4eb45348e811efff68e0a8de38428
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
require 'test_helper' module Razorpay # Tests for Razorpay::Utility class RazorpayUtilityTest < Minitest::Test def setup Razorpay.setup('key_id', 'key_secret') end def test_payment_signature_verification payment_response = { razorpay_order_id: 'fake_other_id', razorpay_payment_id: 'fake_payment_id', razorpay_signature: '965ee2de4c5c4e6f006fb0a5a1736d992e5d4d52f9fe10b98c9b97ee169ebe18' } Razorpay::Utility.verify_payment_signature(payment_response) payment_response[:razorpay_signature] = '_dummy_signature' * 4 assert_raises(SecurityError) do Razorpay::Utility.verify_payment_signature(payment_response) end end def test_subscription_signature_verification payment_response = { razorpay_payment_id: 'fake_payment_id', razorpay_subscription_id: 'fake_other_id', razorpay_signature: '3dabcab8ca113e7994cf78c80f8d50974ddfb2d380029743f30a6d67934cd845' } # A different signature is expected here compared to the previous test, # since the sorted order of the keys is different in this case Razorpay::Utility.verify_payment_signature(payment_response) payment_response[:razorpay_signature] = '_dummy_signature' * 4 assert_raises(SecurityError) do Razorpay::Utility.verify_payment_signature(payment_response) end end def test_webhook_signature_verification webhook_body = fixture_file('fake_payment_authorized_webhook') secret = 'chosen_webhook_secret' signature = 'dda9ca344c56ccbd90167b1be0fd99dfa92fe2b827020f27e2a46024e31c7c99' Razorpay::Utility.verify_webhook_signature(webhook_body, signature, secret) signature = '_dummy_signature' * 4 assert_raises(SecurityError) do Razorpay::Utility.verify_webhook_signature(webhook_body, signature, secret) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
razorpay-2.4.1 | test/razorpay/test_utility.rb |