Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Pusher.use_tls support #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/pusher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class << self

def_delegators :default_client, :authentication_token, :url, :cluster
def_delegators :default_client, :encrypted=, :url=, :cluster=
def_delegators :default_client, :use_tls=, :url=, :cluster=
def_delegators :default_client, :timeout=, :connect_timeout=, :send_timeout=, :receive_timeout=, :keep_alive_timeout=

def_delegators :default_client, :get, :get_async, :post, :post_async
Expand Down
8 changes: 8 additions & 0 deletions lib/pusher/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ def encrypted?
@scheme == 'https'
end

def use_tls=(boolean)
self.encrypted = boolean
end

def use_tls?
self.encrypted?
end

def cluster=(cluster)
cluster = DEFAULT_CLUSTER if cluster.nil? || cluster.empty?

Expand Down
12 changes: 11 additions & 1 deletion spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
@client.url
}.to raise_error(Pusher::ConfigurationError)
end

end

describe 'configuring the cluster' do
Expand Down Expand Up @@ -156,6 +155,17 @@
expect(client.port).to eq(8000)
end

describe '#use_tls=' do
it "should set the use_tls configuration option as alias of encrypted" do
@client.use_tls = true
expect(@client.use_tls?).to eq(true)
expect(@client.encrypted?).to eq(true)

@client.use_tls = false
expect(@client.use_tls?).to eq(false)
expect(@client.encrypted?).to eq(false)
end
end
end

describe 'configuring a http proxy' do
Expand Down