Sha256: 6a176f9b54780e904fc0a1835391089e478eb8b249efaa190b9930f17910993c

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

# These tests use real network connections to test the SSL
# support. Since a real API key is not used, the success condition is
# that the connection was made and the approriate error message is
# returned from the API
describe 'SSL support' do
  let(:client) { Elastic::SiteSearch::Client.new }

  context 'when the endpoint is configured to use SSL' do
    it 'connects successfully' do
      Elastic::SiteSearch.endpoint = 'https://api.swiftype.com/api/v1/'

      VCR.turned_off do
        WebMock.allow_net_connect!
        expect do
          client.search('site-search-api-example', 'test')
        end.to raise_error(Elastic::SiteSearch::InvalidCredentials)
      end
    end
  end

  context 'when the endpoint is configured not to use SSL' do
    it 'connects successfully' do
      Elastic::SiteSearch.endpoint = 'http://api.swiftype.com/api/v1/'
      VCR.turned_off do
        WebMock.allow_net_connect!
        expect do
          client.search('site-search-api-example', 'test')
        end.to raise_error(Elastic::SiteSearch::InvalidCredentials)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
elastic-site-search-3.0.1 spec/ssl_spec.rb
elastic-site-search-2.2.0 spec/ssl_spec.rb
elastic-site-search-2.1.0 spec/ssl_spec.rb
elastic-site-search-2.0.0 spec/ssl_spec.rb