Sha256: 8409ce49316e1f683048a9c2af931c577db3d1a119476ab726155e2e5e9d8948

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe 'ca-bundle.crt' do
  it 'should be able to connect to the 4me REST API' do
    WebMock.allow_net_connect!
    client = Sdk4me::Client.new(api_token: 'invalid', max_retry_time: -1)
    result = {}

    # no exception concerning the certificate
    expect { result[:response] = client.get('me') }.not_to raise_error
    response = result[:response]
    expect(response.valid?).to be_falsey

    # expecting 401 error
    expect(response.message).to start_with('401:')
  end

  it 'should be able to connect to the 4me REST API (access token)' do
    WebMock.allow_net_connect!
    client = Sdk4me::Client.new(access_token: 'invalid', max_retry_time: -1)
    result = {}

    # no exception concerning the certificate
    expect { result[:response] = client.get('me') }.not_to raise_error
    response = result[:response]
    expect(response.valid?).to be_falsey

    # expecting 401 error
    expect(response.message).to start_with('401:')
  end

  it 'should be able to connect to S3' do
    WebMock.allow_net_connect!
    http = Net::HTTP.new('sdk4me-eu.s3-eu-west-1.amazonaws.com', 443)
    http.read_timeout = 1
    http.use_ssl = true

    # no SSL error please
    expect { http.start { |transport| transport.request(Net::HTTP::Get.new('/exports/20141107/')) } }.to never_raise(OpenSSL::SSL::SSLError)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
4me-sdk-2.0.4 spec/lib/sdk4me/certificate_spec.rb
4me-sdk-2.0.3 spec/lib/sdk4me/certificate_spec.rb
4me-sdk-2.0.2 spec/lib/sdk4me/certificate_spec.rb