@@ -42,24 +42,45 @@ class Zencoder::HTTP::NetHTTPTest < Test::Unit::TestCase
42
42
43
43
context "SSL verification" do
44
44
setup do
45
- @http_stub = stub ( :use_ssl= => true , :request => true , :verify_mode= => true )
45
+ @cert_store = stub ( :add_file => true , :add_path => true , :flags= => true , :set_default_paths => true )
46
+ @http_stub = stub ( :use_ssl= => true , :request => true , :verify_mode= => true , :cert_store= => true , :cert_store => @cert_store )
46
47
::Net ::HTTP . expects ( :new ) . returns ( @http_stub )
47
48
end
48
49
49
- should "not verify when set to skip ssl verification" do
50
- @http_stub . expects ( :verify_mode= ) . with ( OpenSSL ::SSL ::VERIFY_NONE )
51
- Zencoder ::HTTP ::NetHTTP . post ( 'https://example.com/path' , :skip_ssl_verify => true )
52
- end
50
+ context "when set to skip ssl verification" do
51
+ should "not verify" do
52
+ @http_stub . expects ( :verify_mode= ) . with ( OpenSSL ::SSL ::VERIFY_NONE )
53
+ Zencoder ::HTTP ::NetHTTP . post ( 'https://example.com/path' , :skip_ssl_verify => true )
54
+ end
53
55
54
- should "set the ca_file" do
55
- @http_stub . expects ( :ca_file= ) . with ( "/foo/bar/baz.crt" )
56
- Zencoder ::HTTP ::NetHTTP . post ( 'https://example.com/path' , :ca_file => "/foo/bar/baz.crt" )
56
+ should "not setup a custom cert store" do
57
+ @http_stub . expects ( :cert_store= ) . never
58
+ Zencoder ::HTTP ::NetHTTP . post ( 'https://example.com/path' , :skip_ssl_verify => true )
59
+ end
57
60
end
58
61
59
- should "set the ca_path" do
60
- @http_stub . expects ( :ca_path= ) . with ( "/foo/bar/" )
61
- Zencoder ::HTTP ::NetHTTP . post ( 'https://example.com/path' , :ca_path => "/foo/bar/" )
62
+ context "when set to do ssl verification" do
63
+ should "setup a custom cert store" do
64
+ @http_stub . expects ( :cert_store= )
65
+ Zencoder ::HTTP ::NetHTTP . post ( 'https://example.com/path' )
66
+ end
67
+
68
+ should "set the default paths on the custom cert store" do
69
+ @cert_store . expects ( :set_default_paths )
70
+ Zencoder ::HTTP ::NetHTTP . post ( 'https://example.com/path' )
71
+ end
72
+
73
+ should "set the ca_file when it is passed in" do
74
+ @cert_store . expects ( :add_file ) . with ( "/foo/bar/baz.crt" )
75
+ Zencoder ::HTTP ::NetHTTP . post ( 'https://example.com/path' , :ca_file => "/foo/bar/baz.crt" )
76
+ end
77
+
78
+ should "set the ca_path when it is passed in" do
79
+ @cert_store . expects ( :add_path ) . with ( "/foo/bar/" )
80
+ Zencoder ::HTTP ::NetHTTP . post ( 'https://example.com/path' , :ca_path => "/foo/bar/" )
81
+ end
62
82
end
83
+
63
84
end
64
85
65
86
context ".post" do
0 commit comments