Sha256: f1c4e953fbc8c6dfb45ae6ede068aaeaabdcd35cf07bb003c0cfaa2fac30c653

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

require_relative '../../test_helper'

module PagarMe
  class TransactionTest < Test::Unit::TestCase
    should 'be valid when has valid signature' do
      fixed_api_key do
        postback = PagarMe::Postback.new postback_response_params
        assert postback.valid?
      end
    end

    should 'be valid when has invalid signature' do
      postback = PagarMe::Postback.new postback_response_params(signature: 'invalid signature')
      assert !postback.valid?
    end

    should 'validate signature' do
      params = postback_response_params
      assert  PagarMe::Postback.valid_request_signature?(params[:payload], "sha1=#{params[:signature]}")
      assert !PagarMe::Postback.valid_request_signature?(params[:payload], params[:signature])
      assert !PagarMe::Postback.valid_request_signature?(params[:payload], 'invalid signature')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pagarme-2.1.1 test/pagarme/resources/postback_test.rb