Sha256: 24e485f6aaf7f0478eecd97182dd312d89c086ac5f927319879f5f8657b01fd7

Contents?: true

Size: 903 Bytes

Versions: 4

Compression:

Stored size: 903 Bytes

Contents

require_relative '../../test_helper'

module PagarMe
  class TransactionTest < PagarMeTestCase
    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: 'sha1=invalid signature')
      assert !postback.valid?
    end

    should 'validate signature' do
      fixed_api_key do
        params = postback_response_params
        assert  PagarMe::Postback.valid_request_signature?(params[:payload], params[:signature])
        assert !PagarMe::Postback.valid_request_signature?(params[:payload], params[:signature][4..-1])
        assert !PagarMe::Postback.valid_request_signature?(params[:payload], 'invalid signature')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pagarme-2.2.1 test/pagarme/resources/postback_test.rb
pagarme-2.2.0 test/pagarme/resources/postback_test.rb
pagarme-2.1.4 test/pagarme/resources/postback_test.rb
pagarme-2.1.3 test/pagarme/resources/postback_test.rb