Sha256: 29d2dced99605800382ce2903bdfd43b82b669f86fd10babe460a1050001feba
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
require 'spec_helper' require 'faye/authentication' describe Faye::Authentication::HTTPClient do describe '.publish' do it 'should publish a HTTP request with correct params' do message = {'channel' => '/foo/bar', 'clientId' => 'http'} message['signature'] = Faye::Authentication.sign(message, 'my private key') message['data'] = 'hello' request = stub_request(:post, "http://www.example.com").with(body: {message: JSON.dump(message)}).to_return(status: 200, body: "", headers: {}) Faye::Authentication::HTTPClient.publish('http://www.example.com', '/foo/bar', "hello", 'my private key') expect(request).to have_been_made end it 'should not add a signature if the channel is whitelisted' do message = {'channel' => '/foo/bar', 'clientId' => 'http'} message['data'] = 'hello' request = stub_request(:post, "http://www.example.com").with(body: {message: JSON.dump(message)}).to_return(status: 200, body: "", headers: {}) whitelist = lambda do |channel| channel.start_with?('/foo/') end Faye::Authentication::HTTPClient.publish('http://www.example.com', '/foo/bar', "hello", 'my private key', { whitelist: whitelist }) expect(request).to have_been_made end end end
Version data entries
3 entries across 3 versions & 1 rubygems