Sha256: 5cb13fbf3868be6defe11090d835eee1a63ada6aab9b01d08e8d6d5898072087

Contents?: true

Size: 1.77 KB

Versions: 24

Compression:

Stored size: 1.77 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) { { 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::InsecureRequest)
        end
      end
    end

    context ':use_token_auth' do
      context 'set to false' do
        context 'with a key and :tls => false' do
          let(:client_options) { { use_token_auth: false, 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::InsecureRequest)
          end
        end

        context 'without a key' do
          let(:client_options) { { use_token_auth: false } }

          it 'fails as a 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 a key or token' do
          let(:client_options) { { use_token_auth: true, key: true } }

          it 'fails as a 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

24 entries across 24 versions & 2 rubygems

Version Path
ably-rest-0.8.15 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-0.8.15 spec/unit/rest/client_spec.rb
ably-rest-0.9.3 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-rest-0.9.2 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-rest-0.9.1 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-rest-0.9.0 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-rest-0.8.14 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-0.8.14 spec/unit/rest/client_spec.rb
ably-rest-0.8.13 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-0.8.13 spec/unit/rest/client_spec.rb
ably-0.8.12 spec/unit/rest/client_spec.rb
ably-0.8.11 spec/unit/rest/client_spec.rb
ably-0.8.10 spec/unit/rest/client_spec.rb
ably-rest-0.8.9 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-0.8.9 spec/unit/rest/client_spec.rb
ably-0.8.8 spec/unit/rest/client_spec.rb
ably-0.8.7 spec/unit/rest/client_spec.rb
ably-0.8.6 spec/unit/rest/client_spec.rb
ably-rest-0.8.6 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb
ably-rest-0.8.5 lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb