Skip to content

Commit 8a6cb78

Browse files
committed
Add Pusher.use_tls support
1 parent 18109ec commit 8a6cb78

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

lib/pusher.rb

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class << self
3434

3535
def_delegators :default_client, :authentication_token, :url, :cluster
3636
def_delegators :default_client, :encrypted=, :url=, :cluster=
37+
def_delegators :default_client, :use_tls=, :url=, :cluster=
3738
def_delegators :default_client, :timeout=, :connect_timeout=, :send_timeout=, :receive_timeout=, :keep_alive_timeout=
3839

3940
def_delegators :default_client, :get, :get_async, :post, :post_async

lib/pusher/client.rb

+8
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ def encrypted?
122122
@scheme == 'https'
123123
end
124124

125+
def use_tls=(boolean)
126+
self.encrypted = boolean
127+
end
128+
129+
def use_tls?
130+
self.encrypted?
131+
end
132+
125133
def cluster=(cluster)
126134
cluster = DEFAULT_CLUSTER if cluster.nil? || cluster.empty?
127135

spec/client_spec.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
@client.url
7171
}.to raise_error(Pusher::ConfigurationError)
7272
end
73-
7473
end
7574

7675
describe 'configuring the cluster' do
@@ -156,6 +155,17 @@
156155
expect(client.port).to eq(8000)
157156
end
158157

158+
describe '#use_tls=' do
159+
it "should set the use_tls configuration option as alias of encrypted" do
160+
@client.use_tls = true
161+
expect(@client.use_tls?).to eq(true)
162+
expect(@client.encrypted?).to eq(true)
163+
164+
@client.use_tls = false
165+
expect(@client.use_tls?).to eq(false)
166+
expect(@client.encrypted?).to eq(false)
167+
end
168+
end
159169
end
160170

161171
describe 'configuring a http proxy' do

0 commit comments

Comments
 (0)