Sha256: 241933a434b97517f254f859c33db19312298274bc8d07e91795b5abffc270b2

Contents?: true

Size: 887 Bytes

Versions: 3

Compression:

Stored size: 887 Bytes

Contents

require 'spec_helper'

RSpec.describe Webhook do
  describe 'validating a webhook signature' do
    let(:action) { Webhook.valid_signature? signature, url, params, files }
    let(:signature) { '64a735ef0c47a0ae671e381c046648f0966deb29' }
    let(:url) { 'example.com' }
    let(:params) { {test: true} }
    let(:files) { [] }

    it 'raises an error if Phaxio::Config.webhook_token is unset' do
      Phaxio.webhook_token = nil
      expect {
        action
      }.to raise_error(Phaxio::Error::PhaxioError, 'No webhook token has been set')
    end

    context 'signature matches' do
      it 'returns true' do
        result = action
        expect(result).to eq(true)
      end
    end

    context 'signature does not match' do
      let(:signature) { 'wrong' }

      it 'returns false' do
        result = action
        expect(result).to eq(false)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phaxio-2.1.2 spec/resources/webhook_spec.rb
phaxio-2.1.1 spec/resources/webhook_spec.rb
phaxio-2.1.0 spec/resources/webhook_spec.rb