spec/acceptance/realtime/auth_spec.rb in ably-1.0.7 vs spec/acceptance/realtime/auth_spec.rb in ably-1.1.0

- old
+ new

@@ -605,30 +605,31 @@ end end context 'when auth fails' do let(:client_options) { default_options.merge(auth_callback: basic_token_cb, log_level: :none) } + let!(:token_string) { client.rest_client.auth.request_token.token } it 'transitions the connection state to the FAILED state (#RSA15c, #RTC8a2, #RTC8a3)' do connection_failed = false client.connection.once(:connected) do - client.auth.authorize(nil, auth_callback: lambda { |token_params| 'invalid.token:will.cause.failure' }).tap do |deferrable| + client.auth.authorize(nil, auth_callback: lambda { |token_params| "#{app_id}.invalid.token.will.cause.failure" }).tap do |deferrable| deferrable.errback do |error| EventMachine.add_timer(0.2) do expect(connection_failed).to eql(true) - expect(error.message).to match(/Invalid accessToken/i) + expect(error.message).to match(/invalid.*accessToken/i) expect(error.code).to eql(40005) stop_reactor end end deferrable.callback { raise "Authorize should not succed" } end end client.connection.once(:failed) do - expect(client.connection.error_reason.message).to match(/Invalid accessToken/i) + expect(client.connection.error_reason.message).to match(/invalid.*accessToken/i) expect(client.connection.error_reason.code).to eql(40005) connection_failed = true end end end @@ -747,14 +748,11 @@ stub_const 'Ably::Models::TokenDetails::TOKEN_EXPIRY_BUFFER', 0 # allow token to be used even if about to expire stub_const 'Ably::Auth::TOKEN_DEFAULTS', Ably::Auth::TOKEN_DEFAULTS.merge(renew_token_buffer: 0) # Ensure tokens issued expire immediately after issue end context 'when received' do - # Ably in all environments other than locla will send AUTH 30 seconds before expiry - # We set the TTL to 33s and wait (3s window) - # In local env, that window is 5 seconds instead of 30 seconds - let(:local_offset) { ENV['ABLY_ENV'] == 'local' ? 25 : 0 } - let(:client_options) { default_options.merge(use_token_auth: :true, default_token_params: { ttl: 33 - local_offset }) } + # Ably will send AUTH 30 seconds before expiry + let(:client_options) { default_options.merge(use_token_auth: :true, default_token_params: { ttl: 33 }) } it 'should immediately start a new authentication process (#RTN22)' do client.connection.once(:connected) do original_token = auth.current_token_details received_auth = false