Sha256: 41778d1172f7adff455636fdd0434874e84e78b575daa991b606e48d393248e8

Contents?: true

Size: 1.82 KB

Versions: 7

Compression:

Stored size: 1.82 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'shared/client_initializer_behaviour'

describe Ably::Rest::Client do
  subject do
    Ably::Rest::Client.new(client_options)
  end

  it_behaves_like 'a client initializer'

  context 'initializer options' do
    context 'TLS' do
      context 'disabled' do
        let(:client_options) { { api_key: 'appid.keyuid:keysecret', tls: false } }

        it 'fails for any operation with basic auth and attempting to send an API key over a non-secure connection' do
          expect { subject.channel('a').publish('event', 'message') }.to raise_error(Ably::Exceptions::InsecureRequestError)
        end
      end
    end

    context ':use_token_auth' do
      context 'set to false' do
        context 'with an api_key with :tls => false' do
          let(:client_options) { { use_token_auth: false, api_key: 'appid.keyuid:keysecret', tls: false } }

          it 'fails for any operation with basic auth and attempting to send an API key over a non-secure connection' do
            expect { subject.channel('a').publish('event', 'message') }.to raise_error(Ably::Exceptions::InsecureRequestError)
          end
        end

        context 'without an api_key' do
          let(:client_options) { { use_token_auth: false } }

          it 'fails as an api_key is required if not using token auth' do
            expect { subject.channel('a').publish('event', 'message') }.to raise_error(ArgumentError)
          end
        end
      end

      context 'set to true' do
        context 'without an api_key or token_id' do
          let(:client_options) { { use_token_auth: true, api_key: true } }

          it 'fails as an api_key is required to issue tokens' do
            expect { subject.channel('a').publish('event', 'message') }.to raise_error(ArgumentError)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
ably-rest-0.7.5 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-0.7.5 spec/unit/rest/client_spec.rb
ably-0.7.4 spec/unit/rest/client_spec.rb
ably-rest-0.7.3 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-0.7.2 spec/unit/rest/client_spec.rb
ably-0.7.1 spec/unit/rest/client_spec.rb
ably-0.7.0 spec/unit/rest/client_spec.rb