spec/acceptance/rest/auth_spec.rb in ably-0.7.5 vs spec/acceptance/rest/auth_spec.rb in ably-0.7.6
- old
+ new
@@ -21,11 +21,11 @@
)
end
vary_by_protocol do
let(:client) do
- Ably::Rest::Client.new(api_key: api_key, environment: environment, protocol: protocol)
+ Ably::Rest::Client.new(key: api_key, environment: environment, protocol: protocol)
end
let(:auth) { client.auth }
let(:content_type) do
if protocol == :msgpack
'application/x-msgpack'
@@ -347,10 +347,19 @@
it 'returns a literal token' do
expect(token.id.length).to be > 64
end
end
end
+
+ context 'with client_id' do
+ let(:client_id) { random_str }
+ let(:token) { auth.request_token(client_id: client_id) }
+
+ it 'returns a token with the client_id' do
+ expect(token.client_id).to eql(client_id)
+ end
+ end
end
context 'before #authorise has been called' do
it 'has no current_token' do
expect(auth.current_token).to be_nil
@@ -585,11 +594,11 @@
end
context 'when implicit as a result of using :client id' do
let(:client_id) { '999' }
let(:client) do
- Ably::Rest::Client.new(api_key: api_key, client_id: client_id, environment: environment, protocol: protocol)
+ Ably::Rest::Client.new(key: api_key, client_id: client_id, environment: environment, protocol: protocol)
end
let(:token_id) { 'unique-token-id' }
let(:token_response) do
{
access_token: {
@@ -630,24 +639,42 @@
client.channel('foo').publish('event', 'data')
expect(token).to be_a(Ably::Models::Token)
capability_with_str_key = Ably::Models::Token::DEFAULTS[:capability]
capability = Hash[capability_with_str_key.keys.map(&:to_sym).zip(capability_with_str_key.values)]
- expect(token.capability).to eq(capability)
+ expect(token.capability).to eq(JSON.dump(capability))
expect(token.expires_at.to_i).to be_within(2).of(Time.now.to_i + Ably::Models::Token::DEFAULTS[:ttl])
expect(token.client_id).to eq(client_id)
end
end
end
end
- context 'when using an :api_key and basic auth' do
+ context 'when using an :key and basic auth' do
specify '#using_token_auth? is false' do
expect(auth).to_not be_using_token_auth
end
+ specify '#key attribute contains the key string' do
+ expect(auth.key).to eql(api_key)
+ end
+
specify '#using_basic_auth? is true' do
expect(auth).to be_using_basic_auth
+ end
+ end
+
+ context 'when using legacy :api_key option and basic auth' do
+ let(:client) do
+ Ably::Rest::Client.new(api_key: api_key, environment: environment, protocol: protocol)
+ end
+
+ specify '#using_token_auth? is false' do
+ expect(auth).to_not be_using_token_auth
+ end
+
+ specify '#key attribute contains the key string' do
+ expect(auth.key).to eql(api_key)
end
end
end
end