spec/acceptance/rest/auth_spec.rb in ably-0.8.8 vs spec/acceptance/rest/auth_spec.rb in ably-0.8.9

- old
+ new

@@ -16,11 +16,11 @@ :ttl, :capability, :client_id, :timestamp, :nonce - ].map { |key| "#{token_request.hash[key]}\n" }.join("") + ].map { |key| "#{token_request.attributes[key]}\n" }.join("") encode64( OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, secret, text) ) end @@ -700,11 +700,11 @@ end) } it 'calls the Proc once the token has expired and the new token is used' do client.stats - expect(@block_called).to be_nil + expect(@block_called).to eql(0) sleep 3.5 expect { client.stats }.to change { client.auth.current_token_details } expect(@block_called).to eql(1) end end @@ -822,13 +822,13 @@ end context 'with additional invalid attributes' do let(:token_params) { { nonce: 'valid', is_not_used_by_token_request: 'invalid' } } specify 'are ignored' do - expect(subject.hash.keys).to_not include(:is_not_used_by_token_request) - expect(subject.hash.keys).to_not include(convert_to_mixed_case(:is_not_used_by_token_request)) - expect(subject.hash.keys).to include(:nonce) + expect(subject.attributes.keys).to_not include(:is_not_used_by_token_request) + expect(subject.attributes.keys).to_not include(convert_to_mixed_case(:is_not_used_by_token_request)) + expect(subject.attributes.keys).to include(:nonce) expect(subject.nonce).to eql('valid') end end context 'when required fields are missing' do @@ -888,11 +888,11 @@ let(:token_request_attributes) do token_attributes.merge(timestamp: token_attributes[:timestamp] * 1000, ttl: token_attributes[:ttl] * 1000) end it 'generates a valid HMAC' do - hmac = hmac_for(Ably::Models::TokenRequest(token_request_attributes).hash, key_secret) + hmac = hmac_for(Ably::Models::TokenRequest(token_request_attributes).attributes, key_secret) expect(subject['mac']).to eql(hmac) end end end @@ -916,18 +916,18 @@ expect(token_auth_client.channel('foo').publish('event', 'data')).to be_truthy end it 'disallows publishing on unspecified capability channels' do expect { token_auth_client.channel('bar').publish('event', 'data') }.to raise_error do |error| - expect(error).to be_a(Ably::Exceptions::InvalidRequest) + expect(error).to be_a(Ably::Exceptions::UnauthorizedRequest) expect(error.status).to eql(401) expect(error.code).to eql(40160) end end it 'fails if timestamp is invalid' do expect { auth.request_token(timestamp: Time.now - 180) }.to raise_error do |error| - expect(error).to be_a(Ably::Exceptions::InvalidRequest) + expect(error).to be_a(Ably::Exceptions::UnauthorizedRequest) expect(error.status).to eql(401) expect(error.code).to eql(40101) end end