spec/acceptance/realtime/client_spec.rb in ably-0.7.6 vs spec/acceptance/realtime/client_spec.rb in ably-0.8.0
- old
+ new
@@ -15,13 +15,13 @@
context 'initialization' do
context 'basic auth' do
it 'is enabled by default with a provided :key option' do
connection.on(:connected) do
- expect(auth_params[:key_id]).to_not be_nil
+ expect(auth_params[:key]).to_not be_nil
expect(auth_params[:access_token]).to be_nil
- expect(subject.auth.current_token).to be_nil
+ expect(subject.auth.current_token_details).to be_nil
stop_reactor
end
end
context ':tls option' do
@@ -42,30 +42,30 @@
context 'token auth' do
[true, false].each do |tls_enabled|
context "with TLS #{tls_enabled ? 'enabled' : 'disabled'}" do
let(:capability) { { :foo => ["publish"] } }
- let(:token) { Ably::Realtime::Client.new(default_options).auth.request_token(capability: capability) }
- let(:client_options) { default_options.merge(token_id: token.id) }
+ let(:token_details) { Ably::Realtime::Client.new(default_options).auth.request_token(capability: capability) }
+ let(:client_options) { default_options.merge(token: token_details.token) }
- context 'and a pre-generated Token provided with the :token_id option' do
+ context 'and a pre-generated Token provided with the :token option' do
it 'connects using token auth' do
connection.on(:connected) do
expect(auth_params[:access_token]).to_not be_nil
- expect(auth_params[:key_id]).to be_nil
- expect(subject.auth.current_token).to be_nil
+ expect(auth_params[:key]).to be_nil
+ expect(subject.auth.current_token_details).to be_nil
stop_reactor
end
end
end
context 'with valid :key and :use_token_auth option set to true' do
let(:client_options) { default_options.merge(use_token_auth: true) }
it 'automatically authorises on connect and generates a token' do
connection.on(:connected) do
- expect(subject.auth.current_token).to_not be_nil
+ expect(subject.auth.current_token_details).to_not be_nil
expect(auth_params[:access_token]).to_not be_nil
stop_reactor
end
end
end
@@ -77,39 +77,39 @@
it 'connects using token auth' do
run_reactor do
connection.on(:connected) do
expect(connection.state).to eq(:connected)
expect(auth_params[:access_token]).to_not be_nil
- expect(auth_params[:key_id]).to be_nil
+ expect(auth_params[:key]).to be_nil
stop_reactor
end
end
end
end
end
end
- context 'with token_request_block' do
+ context 'with a Proc for the :auth_callback option' do
let(:client_id) { random_str }
let(:auth) { subject.auth }
subject do
- Ably::Realtime::Client.new(client_options) do
+ Ably::Realtime::Client.new(client_options.merge(auth_callback: Proc.new do
@block_called = true
auth.create_token_request(client_id: client_id)
- end
+ end))
end
- it 'calls the block' do
+ it 'calls the Proc' do
connection.on(:connected) do
expect(@block_called).to eql(true)
stop_reactor
end
end
- it 'uses the token request when requesting a new token' do
+ it 'uses the token request returned from the callback when requesting a new token' do
connection.on(:connected) do
- expect(auth.current_token.client_id).to eql(client_id)
+ expect(auth.current_token_details.client_id).to eql(client_id)
stop_reactor
end
end
end
end