File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,12 @@ def initialize(options = {})
27
27
:scheme => 'http' ,
28
28
:port => 80 ,
29
29
}
30
+
31
+ if options [ :useTLS ] || options [ :encrypted ]
32
+ default_options [ :scheme ] = "https"
33
+ default_options [ :port ] = 443
34
+ end
35
+
30
36
merged_options = default_options . merge ( options )
31
37
32
38
if options . has_key? ( :host )
Original file line number Diff line number Diff line change 100
100
end
101
101
end
102
102
103
+ describe 'configuring TLS' do
104
+ it 'should set port and scheme if "useTLS" enabled' do
105
+ client = Pusher ::Client . new ( {
106
+ :useTLS => true ,
107
+ } )
108
+ expect ( client . scheme ) . to eq ( 'https' )
109
+ expect ( client . port ) . to eq ( 443 )
110
+ end
111
+
112
+ it 'should set port and scheme if "encrypted" enabled' do
113
+ client = Pusher ::Client . new ( {
114
+ :encrypted => true ,
115
+ } )
116
+ expect ( client . scheme ) . to eq ( 'https' )
117
+ expect ( client . port ) . to eq ( 443 )
118
+ end
119
+
120
+ it 'should use non-TLS port and scheme if "encrypted" or "useTLS" are not set' do
121
+ client = Pusher ::Client . new
122
+ expect ( client . scheme ) . to eq ( 'http' )
123
+ expect ( client . port ) . to eq ( 80 )
124
+ end
125
+
126
+ it 'should override port if "useTLS" option set but a different port is specified' do
127
+ client = Pusher ::Client . new ( {
128
+ :useTLS => true ,
129
+ :port => 8443
130
+ } )
131
+ expect ( client . scheme ) . to eq ( 'https' )
132
+ expect ( client . port ) . to eq ( 8443 )
133
+ end
134
+
135
+ end
136
+
103
137
describe 'configuring a http proxy' do
104
138
it "should be possible to configure everything by setting the http_proxy" do
105
139
@client . http_proxy = 'http://someuser:somepassword@proxy.host.com:8080'
You can’t perform that action at this time.
0 commit comments