Sha256: 58ed5c26b8a43768ba3187f84b1b6302da78b699e609120054a189b5947d4e6c

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'rest_client'
require 'json'

RSpec.describe SageoneApiSigner do
  subject do
    SageoneApiSigner.new({
      request_method: 'post',
      url: 'https://api.sageone.com/test/accounts/v1/contacts?config_setting=foo',
      body_params: {
        'contact[contact_type_id]' => 1,
        'contact[name]' => 'My Customer'
      },
      signing_secret: 'TestSigningSecret',
      access_token: 'TestToken',
    })
  end

  describe 'doing a real call to the test endpoint' do
    it 'should check with the test server data' do
      headers = subject.request_headers('foo')

      begin
        RestClient.post subject.url, subject.body_params, headers
      rescue => e
        response =  JSON.parse(e.response.to_s)
        raise "#{response['error']}: #{response['error_description']}"
      end

    end
  end

  describe 'bug when the url has no params' do
    it 'should not raise an error!' do
      subject.url = 'https://api.sageone.com/test/accounts/v1/contacts'
      expect(subject.url_params).to eql({})
      expect(subject.signature).to_not be nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sageone_api_signer-1.3.0 spec/integration/check_signature_data_spec.rb