Sha256: fc10a8cd5f8f38ab95b8e93f5389b949a5b3592de8f78a2270cf0bfbb3d6fa68
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
require 'spec_helper' require 'faye/authentication/extension' describe Faye::Authentication::Extension do let(:secret) { 'macaroni' } let(:extension) { Faye::Authentication::Extension.new(secret) } it 'does not add an eror if the message is correctly signed' do message = {'channel' => '/foo/bar', 'clientId' => '42', 'text' => 'whatever'} signature = Faye::Authentication.sign(message, secret) message['signature'] = signature result = nil extension.incoming(message, ->(m) { result = m }); expect(result).to_not have_key('error') end it 'adds an eror if the message is not signed' do message = {'channel' => '/foo/bar', 'clientId' => '42', 'text' => 'whatever'} result = nil extension.incoming(message, ->(m) { result = m }); expect(result).to have_key('error') end it 'adds an error if the signature is incorrect' do message = {'channel' => '/foo/bar', 'clientId' => '42', 'text' => 'whatever', 'signature' => 'hello'} result = nil extension.incoming(message, ->(m) { result = m }); expect(result).to have_key('error') end ['/meta/handshake', '/meta/connect', '/meta/unsubscribe', '/meta/disconnect'].each do |channel| it "does not check the signature for #{channel}" do message = {'channel' => channel, 'clientId' => '42', 'text' => 'whatever', 'signature' => 'hello'} expect(Faye::Authentication).to_not receive(:valid?) extension.incoming(message, ->(_) {}); end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
faye-authentication-0.2.0 | spec/lib/faye/authentication/extension_spec.rb |
faye-authentication-0.1.0 | spec/lib/faye/authentication/extension_spec.rb |