httparty 0.17.0 → 0.17.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of httparty might be problematic. Click here for more details.

Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +7 -0
  3. data/Gemfile +1 -0
  4. data/httparty.gemspec +0 -1
  5. data/lib/httparty.rb +2 -18
  6. data/lib/httparty/connection_adapter.rb +10 -0
  7. data/lib/httparty/headers_processor.rb +30 -0
  8. data/lib/httparty/request.rb +4 -4
  9. data/lib/httparty/version.rb +1 -1
  10. metadata +4 -103
  11. data/features/basic_authentication.feature +0 -20
  12. data/features/command_line.feature +0 -95
  13. data/features/deals_with_http_error_codes.feature +0 -26
  14. data/features/digest_authentication.feature +0 -30
  15. data/features/handles_compressed_responses.feature +0 -27
  16. data/features/handles_multiple_formats.feature +0 -57
  17. data/features/steps/env.rb +0 -27
  18. data/features/steps/httparty_response_steps.rb +0 -56
  19. data/features/steps/httparty_steps.rb +0 -43
  20. data/features/steps/mongrel_helper.rb +0 -127
  21. data/features/steps/remote_service_steps.rb +0 -92
  22. data/features/supports_read_timeout_option.feature +0 -13
  23. data/features/supports_redirection.feature +0 -22
  24. data/features/supports_timeout_option.feature +0 -13
  25. data/spec/fixtures/delicious.xml +0 -23
  26. data/spec/fixtures/empty.xml +0 -0
  27. data/spec/fixtures/example.html +0 -10
  28. data/spec/fixtures/ssl/generate.sh +0 -29
  29. data/spec/fixtures/ssl/generated/bogushost.crt +0 -29
  30. data/spec/fixtures/ssl/generated/ca.crt +0 -31
  31. data/spec/fixtures/ssl/generated/ca.key +0 -52
  32. data/spec/fixtures/ssl/generated/selfsigned.crt +0 -29
  33. data/spec/fixtures/ssl/generated/server.crt +0 -30
  34. data/spec/fixtures/ssl/generated/server.key +0 -52
  35. data/spec/fixtures/ssl/openssl-exts.cnf +0 -9
  36. data/spec/fixtures/tiny.gif +0 -0
  37. data/spec/fixtures/twitter.csv +0 -2
  38. data/spec/fixtures/twitter.json +0 -1
  39. data/spec/fixtures/twitter.xml +0 -403
  40. data/spec/fixtures/undefined_method_add_node_for_nil.xml +0 -2
  41. data/spec/httparty/connection_adapter_spec.rb +0 -628
  42. data/spec/httparty/cookie_hash_spec.rb +0 -100
  43. data/spec/httparty/exception_spec.rb +0 -45
  44. data/spec/httparty/hash_conversions_spec.rb +0 -58
  45. data/spec/httparty/logger/apache_formatter_spec.rb +0 -40
  46. data/spec/httparty/logger/curl_formatter_spec.rb +0 -119
  47. data/spec/httparty/logger/logger_spec.rb +0 -43
  48. data/spec/httparty/logger/logstash_formatter_spec.rb +0 -44
  49. data/spec/httparty/net_digest_auth_spec.rb +0 -270
  50. data/spec/httparty/parser_spec.rb +0 -190
  51. data/spec/httparty/request/body_spec.rb +0 -165
  52. data/spec/httparty/request_spec.rb +0 -1389
  53. data/spec/httparty/response_fragment_spec.rb +0 -17
  54. data/spec/httparty/response_spec.rb +0 -374
  55. data/spec/httparty/ssl_spec.rb +0 -82
  56. data/spec/httparty_spec.rb +0 -943
  57. data/spec/spec_helper.rb +0 -57
  58. data/spec/support/ssl_test_helper.rb +0 -47
  59. data/spec/support/ssl_test_server.rb +0 -80
  60. data/spec/support/stub_response.rb +0 -50
@@ -1,2 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Entities total="0" results="0" page="1" page-size="25" href="https://s3-sandbox.parature.com/api/v1/5578/5633/Account" />
@@ -1,628 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe HTTParty::ConnectionAdapter do
4
- describe "initialization" do
5
- let(:uri) { URI 'http://www.google.com' }
6
- it "takes a URI as input" do
7
- HTTParty::ConnectionAdapter.new(uri)
8
- end
9
-
10
- it "raises an ArgumentError if the uri is nil" do
11
- expect { HTTParty::ConnectionAdapter.new(nil) }.to raise_error ArgumentError
12
- end
13
-
14
- it "raises an ArgumentError if the uri is a String" do
15
- expect { HTTParty::ConnectionAdapter.new('http://www.google.com') }.to raise_error ArgumentError
16
- end
17
-
18
- it "sets the uri" do
19
- adapter = HTTParty::ConnectionAdapter.new(uri)
20
- expect(adapter.uri).to be uri
21
- end
22
-
23
- it "also accepts an optional options hash" do
24
- HTTParty::ConnectionAdapter.new(uri, {})
25
- end
26
-
27
- it "sets the options" do
28
- options = {foo: :bar}
29
- adapter = HTTParty::ConnectionAdapter.new(uri, options)
30
- expect(adapter.options.keys).to include(:verify, :verify_peer, :foo)
31
- end
32
- end
33
-
34
- describe ".call" do
35
- let(:uri) { URI 'http://www.google.com' }
36
- let(:options) { { foo: :bar } }
37
-
38
- it "generates an HTTParty::ConnectionAdapter instance with the given uri and options" do
39
- expect(HTTParty::ConnectionAdapter).to receive(:new).with(uri, options).and_return(double(connection: nil))
40
- HTTParty::ConnectionAdapter.call(uri, options)
41
- end
42
-
43
- it "calls #connection on the connection adapter" do
44
- adapter = double('Adapter')
45
- connection = double('Connection')
46
- expect(adapter).to receive(:connection).and_return(connection)
47
- allow(HTTParty::ConnectionAdapter).to receive_messages(new: adapter)
48
- expect(HTTParty::ConnectionAdapter.call(uri, options)).to be connection
49
- end
50
- end
51
-
52
- describe '#connection' do
53
- let(:uri) { URI 'http://www.google.com' }
54
- let(:options) { Hash.new }
55
- let(:adapter) { HTTParty::ConnectionAdapter.new(uri, options) }
56
-
57
- describe "the resulting connection" do
58
- subject { adapter.connection }
59
- it { is_expected.to be_an_instance_of Net::HTTP }
60
-
61
- context "using port 80" do
62
- let(:uri) { URI 'http://foobar.com' }
63
- it { is_expected.not_to use_ssl }
64
- end
65
-
66
- context "when dealing with ssl" do
67
- let(:uri) { URI 'https://foobar.com' }
68
-
69
- context "uses the system cert_store, by default" do
70
- let!(:system_cert_store) do
71
- system_cert_store = double('default_cert_store')
72
- expect(system_cert_store).to receive(:set_default_paths)
73
- expect(OpenSSL::X509::Store).to receive(:new).and_return(system_cert_store)
74
- system_cert_store
75
- end
76
- it { is_expected.to use_cert_store(system_cert_store) }
77
- end
78
-
79
- context "should use the specified cert store, when one is given" do
80
- let(:custom_cert_store) { double('custom_cert_store') }
81
- let(:options) { {cert_store: custom_cert_store} }
82
- it { is_expected.to use_cert_store(custom_cert_store) }
83
- end
84
-
85
- context "using port 443 for ssl" do
86
- let(:uri) { URI 'https://api.foo.com/v1:443' }
87
- it { is_expected.to use_ssl }
88
- end
89
-
90
- context "https scheme with default port" do
91
- it { is_expected.to use_ssl }
92
- end
93
-
94
- context "https scheme with non-standard port" do
95
- let(:uri) { URI 'https://foobar.com:123456' }
96
- it { is_expected.to use_ssl }
97
- end
98
-
99
- context "when ssl version is set" do
100
- let(:options) { {ssl_version: :TLSv1} }
101
-
102
- it "sets ssl version" do
103
- expect(subject.ssl_version).to eq(:TLSv1)
104
- end
105
- end if RUBY_VERSION > '1.9'
106
- end
107
-
108
- context "when dealing with IPv6" do
109
- let(:uri) { URI 'http://[fd00::1]' }
110
-
111
- it "strips brackets from the address" do
112
- expect(subject.address).to eq('fd00::1')
113
- end
114
- end
115
-
116
- context "specifying ciphers" do
117
- let(:options) { {ciphers: 'RC4-SHA' } }
118
-
119
- it "should set the ciphers on the connection" do
120
- expect(subject.ciphers).to eq('RC4-SHA')
121
- end
122
- end if RUBY_VERSION > '1.9'
123
-
124
- context "when timeout is not set" do
125
- it "doesn't set the timeout" do
126
- http = double(
127
- "http",
128
- :null_object => true,
129
- :use_ssl= => false,
130
- :use_ssl? => false
131
- )
132
- expect(http).not_to receive(:open_timeout=)
133
- expect(http).not_to receive(:read_timeout=)
134
- expect(http).not_to receive(:write_timeout=)
135
- allow(Net::HTTP).to receive_messages(new: http)
136
-
137
- adapter.connection
138
- end
139
- end
140
-
141
- context "when setting timeout" do
142
- context "to 5 seconds" do
143
- let(:options) { {timeout: 5} }
144
-
145
- describe '#open_timeout' do
146
- subject { super().open_timeout }
147
- it { is_expected.to eq(5) }
148
- end
149
-
150
- describe '#read_timeout' do
151
- subject { super().read_timeout }
152
- it { is_expected.to eq(5) }
153
- end
154
-
155
- if RUBY_VERSION >= '2.6.0'
156
- describe '#write_timeout' do
157
- subject { super().write_timeout }
158
- it { is_expected.to eq(5) }
159
- end
160
- end
161
- end
162
-
163
- context "and timeout is a string" do
164
- let(:options) { {timeout: "five seconds"} }
165
-
166
- it "doesn't set the timeout" do
167
- http = double(
168
- "http",
169
- :null_object => true,
170
- :use_ssl= => false,
171
- :use_ssl? => false
172
- )
173
- expect(http).not_to receive(:open_timeout=)
174
- expect(http).not_to receive(:read_timeout=)
175
- expect(http).not_to receive(:write_timeout=)
176
- allow(Net::HTTP).to receive_messages(new: http)
177
-
178
- adapter.connection
179
- end
180
- end
181
- end
182
-
183
- context "when timeout is not set and read_timeout is set to 6 seconds" do
184
- let(:options) { {read_timeout: 6} }
185
-
186
- describe '#read_timeout' do
187
- subject { super().read_timeout }
188
- it { is_expected.to eq(6) }
189
- end
190
-
191
- it "should not set the open_timeout" do
192
- http = double(
193
- "http",
194
- :null_object => true,
195
- :use_ssl= => false,
196
- :use_ssl? => false,
197
- :read_timeout= => 0
198
- )
199
- expect(http).not_to receive(:open_timeout=)
200
- allow(Net::HTTP).to receive_messages(new: http)
201
- adapter.connection
202
- end
203
-
204
- it "should not set the write_timeout" do
205
- http = double(
206
- "http",
207
- :null_object => true,
208
- :use_ssl= => false,
209
- :use_ssl? => false,
210
- :read_timeout= => 0
211
- )
212
- expect(http).not_to receive(:write_timeout=)
213
- allow(Net::HTTP).to receive_messages(new: http)
214
- adapter.connection
215
- end
216
- end
217
-
218
- context "when timeout is set and read_timeout is set to 6 seconds" do
219
- let(:options) { {timeout: 5, read_timeout: 6} }
220
-
221
- describe '#open_timeout' do
222
- subject { super().open_timeout }
223
- it { is_expected.to eq(5) }
224
- end
225
-
226
- if RUBY_VERSION >= '2.6.0'
227
- describe '#write_timeout' do
228
- subject { super().write_timeout }
229
- it { is_expected.to eq(5) }
230
- end
231
- end
232
-
233
- describe '#read_timeout' do
234
- subject { super().read_timeout }
235
- it { is_expected.to eq(6) }
236
- end
237
-
238
- it "should override the timeout option" do
239
- http = double(
240
- "http",
241
- :null_object => true,
242
- :use_ssl= => false,
243
- :use_ssl? => false,
244
- :read_timeout= => 0,
245
- :open_timeout= => 0,
246
- :write_timeout= => 0,
247
- )
248
- expect(http).to receive(:open_timeout=)
249
- expect(http).to receive(:read_timeout=).twice
250
- if RUBY_VERSION >= '2.6.0'
251
- expect(http).to receive(:write_timeout=)
252
- end
253
- allow(Net::HTTP).to receive_messages(new: http)
254
- adapter.connection
255
- end
256
- end
257
-
258
- context "when timeout is not set and open_timeout is set to 7 seconds" do
259
- let(:options) { {open_timeout: 7} }
260
-
261
- describe '#open_timeout' do
262
- subject { super().open_timeout }
263
- it { is_expected.to eq(7) }
264
- end
265
-
266
- it "should not set the read_timeout" do
267
- http = double(
268
- "http",
269
- :null_object => true,
270
- :use_ssl= => false,
271
- :use_ssl? => false,
272
- :open_timeout= => 0
273
- )
274
- expect(http).not_to receive(:read_timeout=)
275
- allow(Net::HTTP).to receive_messages(new: http)
276
- adapter.connection
277
- end
278
-
279
- it "should not set the write_timeout" do
280
- http = double(
281
- "http",
282
- :null_object => true,
283
- :use_ssl= => false,
284
- :use_ssl? => false,
285
- :open_timeout= => 0
286
- )
287
- expect(http).not_to receive(:write_timeout=)
288
- allow(Net::HTTP).to receive_messages(new: http)
289
- adapter.connection
290
- end
291
- end
292
-
293
- context "when timeout is set and open_timeout is set to 7 seconds" do
294
- let(:options) { {timeout: 5, open_timeout: 7} }
295
-
296
- describe '#open_timeout' do
297
- subject { super().open_timeout }
298
- it { is_expected.to eq(7) }
299
- end
300
-
301
- if RUBY_VERSION >= '2.6.0'
302
- describe '#write_timeout' do
303
- subject { super().write_timeout }
304
- it { is_expected.to eq(5) }
305
- end
306
- end
307
-
308
- describe '#read_timeout' do
309
- subject { super().read_timeout }
310
- it { is_expected.to eq(5) }
311
- end
312
-
313
- it "should override the timeout option" do
314
- http = double(
315
- "http",
316
- :null_object => true,
317
- :use_ssl= => false,
318
- :use_ssl? => false,
319
- :read_timeout= => 0,
320
- :open_timeout= => 0,
321
- :write_timeout= => 0,
322
- )
323
- expect(http).to receive(:open_timeout=).twice
324
- expect(http).to receive(:read_timeout=)
325
- if RUBY_VERSION >= '2.6.0'
326
- expect(http).to receive(:write_timeout=)
327
- end
328
- allow(Net::HTTP).to receive_messages(new: http)
329
- adapter.connection
330
- end
331
- end
332
-
333
- if RUBY_VERSION >= '2.6.0'
334
- context "when timeout is not set and write_timeout is set to 8 seconds" do
335
- let(:options) { {write_timeout: 8} }
336
-
337
- describe '#write_timeout' do
338
- subject { super().write_timeout }
339
- it { is_expected.to eq(8) }
340
- end
341
-
342
- it "should not set the open timeout" do
343
- http = double(
344
- "http",
345
- :null_object => true,
346
- :use_ssl= => false,
347
- :use_ssl? => false,
348
- :read_timeout= => 0,
349
- :open_timeout= => 0,
350
- :write_timeout= => 0,
351
-
352
- )
353
- expect(http).not_to receive(:open_timeout=)
354
- allow(Net::HTTP).to receive_messages(new: http)
355
- adapter.connection
356
- end
357
-
358
- it "should not set the read timeout" do
359
- http = double(
360
- "http",
361
- :null_object => true,
362
- :use_ssl= => false,
363
- :use_ssl? => false,
364
- :read_timeout= => 0,
365
- :open_timeout= => 0,
366
- :write_timeout= => 0,
367
-
368
- )
369
- expect(http).not_to receive(:read_timeout=)
370
- allow(Net::HTTP).to receive_messages(new: http)
371
- adapter.connection
372
- end
373
- end
374
-
375
- context "when timeout is set and write_timeout is set to 8 seconds" do
376
- let(:options) { {timeout: 2, write_timeout: 8} }
377
-
378
- describe '#write_timeout' do
379
- subject { super().write_timeout }
380
- it { is_expected.to eq(8) }
381
- end
382
-
383
- it "should override the timeout option" do
384
- http = double(
385
- "http",
386
- :null_object => true,
387
- :use_ssl= => false,
388
- :use_ssl? => false,
389
- :read_timeout= => 0,
390
- :open_timeout= => 0,
391
- :write_timeout= => 0,
392
- )
393
- expect(http).to receive(:read_timeout=)
394
- expect(http).to receive(:open_timeout=)
395
- expect(http).to receive(:write_timeout=).twice
396
- allow(Net::HTTP).to receive_messages(new: http)
397
- adapter.connection
398
- end
399
- end
400
- end
401
-
402
- context "when debug_output" do
403
- let(:http) { Net::HTTP.new(uri) }
404
- before do
405
- allow(Net::HTTP).to receive_messages(new: http)
406
- end
407
-
408
- context "is set to $stderr" do
409
- let(:options) { {debug_output: $stderr} }
410
- it "has debug output set" do
411
- expect(http).to receive(:set_debug_output).with($stderr)
412
- adapter.connection
413
- end
414
- end
415
-
416
- context "is not provided" do
417
- it "does not set_debug_output" do
418
- expect(http).not_to receive(:set_debug_output)
419
- adapter.connection
420
- end
421
- end
422
- end
423
-
424
- context 'when providing proxy address and port' do
425
- let(:options) { {http_proxyaddr: '1.2.3.4', http_proxyport: 8080} }
426
-
427
- it { is_expected.to be_a_proxy }
428
-
429
- describe '#proxy_address' do
430
- subject { super().proxy_address }
431
- it { is_expected.to eq('1.2.3.4') }
432
- end
433
-
434
- describe '#proxy_port' do
435
- subject { super().proxy_port }
436
- it { is_expected.to eq(8080) }
437
- end
438
-
439
- context 'as well as proxy user and password' do
440
- let(:options) do
441
- {
442
- http_proxyaddr: '1.2.3.4',
443
- http_proxyport: 8080,
444
- http_proxyuser: 'user',
445
- http_proxypass: 'pass'
446
- }
447
- end
448
-
449
- describe '#proxy_user' do
450
- subject { super().proxy_user }
451
- it { is_expected.to eq('user') }
452
- end
453
-
454
- describe '#proxy_pass' do
455
- subject { super().proxy_pass }
456
- it { is_expected.to eq('pass') }
457
- end
458
- end
459
- end
460
-
461
- context 'when providing nil as proxy address' do
462
- let(:uri) { URI 'http://noproxytest.com' }
463
- let(:options) { {http_proxyaddr: nil} }
464
-
465
- it { is_expected.not_to be_a_proxy }
466
-
467
- it "does pass nil proxy parameters to the connection, this forces to not use a proxy" do
468
- http = Net::HTTP.new("noproxytest.com")
469
- expect(Net::HTTP).to receive(:new).once.with("noproxytest.com", 80, nil, nil, nil, nil).and_return(http)
470
- adapter.connection
471
- end
472
- end
473
-
474
- context 'when not providing a proxy address' do
475
- let(:uri) { URI 'http://proxytest.com' }
476
-
477
- it "does not pass any proxy parameters to the connection" do
478
- http = Net::HTTP.new("proxytest.com")
479
- expect(Net::HTTP).to receive(:new).once.with("proxytest.com", 80).and_return(http)
480
- adapter.connection
481
- end
482
- end
483
-
484
- context 'when providing a local bind address and port' do
485
- let(:options) { {local_host: "127.0.0.1", local_port: 12345 } }
486
-
487
- describe '#local_host' do
488
- subject { super().local_host }
489
- it { is_expected.to eq('127.0.0.1') }
490
- end
491
-
492
- describe '#local_port' do
493
- subject { super().local_port }
494
- it { is_expected.to eq(12345) }
495
- end
496
- end if RUBY_VERSION >= '2.0'
497
-
498
- context "when providing PEM certificates" do
499
- let(:pem) { :pem_contents }
500
- let(:options) { {pem: pem, pem_password: "password"} }
501
-
502
- context "when scheme is https" do
503
- let(:uri) { URI 'https://google.com' }
504
- let(:cert) { double("OpenSSL::X509::Certificate") }
505
- let(:key) { double("OpenSSL::PKey::RSA") }
506
-
507
- before do
508
- expect(OpenSSL::X509::Certificate).to receive(:new).with(pem).and_return(cert)
509
- expect(OpenSSL::PKey::RSA).to receive(:new).with(pem, "password").and_return(key)
510
- end
511
-
512
- it "uses the provided PEM certificate" do
513
- expect(subject.cert).to eq(cert)
514
- expect(subject.key).to eq(key)
515
- end
516
-
517
- it "will verify the certificate" do
518
- expect(subject.verify_mode).to eq(OpenSSL::SSL::VERIFY_PEER)
519
- end
520
-
521
- context "when options include verify=false" do
522
- let(:options) { {pem: pem, pem_password: "password", verify: false} }
523
-
524
- it "should not verify the certificate" do
525
- expect(subject.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
526
- end
527
- end
528
- context "when options include verify_peer=false" do
529
- let(:options) { {pem: pem, pem_password: "password", verify_peer: false} }
530
-
531
- it "should not verify the certificate" do
532
- expect(subject.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
533
- end
534
- end
535
- end
536
-
537
- context "when scheme is not https" do
538
- let(:uri) { URI 'http://google.com' }
539
- let(:http) { Net::HTTP.new(uri) }
540
-
541
- before do
542
- allow(Net::HTTP).to receive_messages(new: http)
543
- expect(OpenSSL::X509::Certificate).not_to receive(:new).with(pem)
544
- expect(OpenSSL::PKey::RSA).not_to receive(:new).with(pem, "password")
545
- expect(http).not_to receive(:cert=)
546
- expect(http).not_to receive(:key=)
547
- end
548
-
549
- it "has no PEM certificate " do
550
- expect(subject.cert).to be_nil
551
- expect(subject.key).to be_nil
552
- end
553
- end
554
- end
555
-
556
- context "when providing PKCS12 certificates" do
557
- let(:p12) { :p12_contents }
558
- let(:options) { {p12: p12, p12_password: "password"} }
559
-
560
- context "when scheme is https" do
561
- let(:uri) { URI 'https://google.com' }
562
- let(:pkcs12) { double("OpenSSL::PKCS12", certificate: cert, key: key) }
563
- let(:cert) { double("OpenSSL::X509::Certificate") }
564
- let(:key) { double("OpenSSL::PKey::RSA") }
565
-
566
- before do
567
- expect(OpenSSL::PKCS12).to receive(:new).with(p12, "password").and_return(pkcs12)
568
- end
569
-
570
- it "uses the provided P12 certificate " do
571
- expect(subject.cert).to eq(cert)
572
- expect(subject.key).to eq(key)
573
- end
574
-
575
- it "will verify the certificate" do
576
- expect(subject.verify_mode).to eq(OpenSSL::SSL::VERIFY_PEER)
577
- end
578
-
579
- context "when options include verify=false" do
580
- let(:options) { {p12: p12, p12_password: "password", verify: false} }
581
-
582
- it "should not verify the certificate" do
583
- expect(subject.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
584
- end
585
- end
586
- context "when options include verify_peer=false" do
587
- let(:options) { {p12: p12, p12_password: "password", verify_peer: false} }
588
-
589
- it "should not verify the certificate" do
590
- expect(subject.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
591
- end
592
- end
593
- end
594
-
595
- context "when scheme is not https" do
596
- let(:uri) { URI 'http://google.com' }
597
- let(:http) { Net::HTTP.new(uri) }
598
-
599
- before do
600
- allow(Net::HTTP).to receive_messages(new: http)
601
- expect(OpenSSL::PKCS12).not_to receive(:new).with(p12, "password")
602
- expect(http).not_to receive(:cert=)
603
- expect(http).not_to receive(:key=)
604
- end
605
-
606
- it "has no PKCS12 certificate " do
607
- expect(subject.cert).to be_nil
608
- expect(subject.key).to be_nil
609
- end
610
- end
611
- end
612
-
613
- context "when uri port is not defined" do
614
- context "falls back to 80 port on http" do
615
- let(:uri) { URI 'http://foobar.com' }
616
- before { allow(uri).to receive(:port).and_return(nil) }
617
- it { expect(subject.port).to be 80 }
618
- end
619
-
620
- context "falls back to 443 port on https" do
621
- let(:uri) { URI 'https://foobar.com' }
622
- before { allow(uri).to receive(:port).and_return(nil) }
623
- it { expect(subject.port).to be 443 }
624
- end
625
- end
626
- end
627
- end
628
- end