upfluence-thrift 2.6.1 → 2.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/benchmark/benchmark_constants.rb +11 -0
  3. data/benchmark/benchmark_service.rb +152 -0
  4. data/benchmark/benchmark_types.rb +10 -0
  5. data/ext/struct.c +5 -1
  6. data/lib/thrift/base_stream.rb +85 -0
  7. data/lib/thrift/bidi_stream.rb +183 -0
  8. data/lib/thrift/client.rb +84 -17
  9. data/lib/thrift/definition.rb +4 -0
  10. data/lib/thrift/inbound_stream.rb +72 -0
  11. data/lib/thrift/middleware.rb +42 -0
  12. data/lib/thrift/outbound_stream.rb +52 -0
  13. data/lib/thrift/processor.rb +287 -47
  14. data/lib/thrift/protocol/base_protocol.rb +35 -33
  15. data/lib/thrift/protocol/binary_protocol.rb +8 -1
  16. data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
  17. data/lib/thrift/protocol/compact_protocol.rb +8 -0
  18. data/lib/thrift/protocol/json_protocol.rb +21 -4
  19. data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
  20. data/lib/thrift/server/base_server.rb +8 -2
  21. data/lib/thrift/server/nonblocking_server.rb +5 -4
  22. data/lib/thrift/server/simple_server.rb +5 -1
  23. data/lib/thrift/server/thread_pool_server.rb +5 -1
  24. data/lib/thrift/server/threaded_server.rb +5 -1
  25. data/lib/thrift/transport/base_server_transport.rb +1 -1
  26. data/lib/thrift/transport/base_transport.rb +8 -0
  27. data/lib/thrift/transport/buffered_transport.rb +9 -1
  28. data/lib/thrift/transport/framed_transport.rb +9 -1
  29. data/lib/thrift/transport/http_client_transport.rb +4 -0
  30. data/lib/thrift/transport/io_stream_transport.rb +4 -1
  31. data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
  32. data/lib/thrift/transport/server_socket.rb +5 -0
  33. data/lib/thrift/transport/socket.rb +21 -17
  34. data/lib/thrift/transport/ssl_server_socket.rb +41 -0
  35. data/lib/thrift/transport/ssl_socket.rb +51 -0
  36. data/lib/thrift/transport/unix_server_socket.rb +5 -1
  37. data/lib/thrift/transport/unix_socket.rb +5 -1
  38. data/lib/thrift/types/annotation/deprecation/deprecation_constants.rb +1 -1
  39. data/lib/thrift/types/annotation/deprecation/deprecation_types.rb +2 -2
  40. data/lib/thrift/types/annotation/exception/exception_constants.rb +17 -0
  41. data/lib/thrift/types/annotation/exception/exception_types.rb +44 -0
  42. data/lib/thrift/types/annotation/naming/naming_constants.rb +1 -1
  43. data/lib/thrift/types/annotation/naming/naming_types.rb +2 -2
  44. data/lib/thrift/types/annotation/rpc/rpc_constants.rb +17 -0
  45. data/lib/thrift/types/annotation/rpc/rpc_types.rb +74 -0
  46. data/lib/thrift/types/annotation_definition/annotation_definition_constants.rb +15 -0
  47. data/lib/thrift/types/annotation_definition/annotation_definition_types.rb +116 -0
  48. data/lib/thrift/types/constant_definition/constant_definition_constants.rb +15 -0
  49. data/lib/thrift/types/constant_definition/constant_definition_types.rb +292 -0
  50. data/lib/thrift/types/core/core_constants.rb +15 -0
  51. data/lib/thrift/types/core/core_types.rb +58 -0
  52. data/lib/thrift/types/enum_definition/enum_definition_constants.rb +15 -0
  53. data/lib/thrift/types/enum_definition/enum_definition_types.rb +106 -0
  54. data/lib/thrift/types/known/any/any_constants.rb +1 -1
  55. data/lib/thrift/types/known/any/any_types.rb +2 -2
  56. data/lib/thrift/types/known/duration/duration_constants.rb +1 -1
  57. data/lib/thrift/types/known/duration/duration_types.rb +2 -2
  58. data/lib/thrift/types/known/timestamp/timestamp_constants.rb +1 -1
  59. data/lib/thrift/types/known/timestamp/timestamp_types.rb +2 -2
  60. data/lib/thrift/types/plugin/plugin.rb +139 -0
  61. data/lib/thrift/types/plugin/plugin_constants.rb +15 -0
  62. data/lib/thrift/types/plugin/plugin_types.rb +106 -0
  63. data/lib/thrift/types/program_definition/program_definition_constants.rb +15 -0
  64. data/lib/thrift/types/program_definition/program_definition_types.rb +137 -0
  65. data/lib/thrift/types/service_definition/service_definition_constants.rb +15 -0
  66. data/lib/thrift/types/service_definition/service_definition_types.rb +160 -0
  67. data/lib/thrift/types/struct_definition/struct_definition_constants.rb +15 -0
  68. data/lib/thrift/types/struct_definition/struct_definition_types.rb +157 -0
  69. data/lib/thrift/types/type_definition/type_definition_constants.rb +15 -0
  70. data/lib/thrift/types/type_definition/type_definition_types.rb +242 -0
  71. data/lib/thrift/types/value/value_constants.rb +1 -1
  72. data/lib/thrift/types/value/value_types.rb +50 -51
  73. data/lib/thrift/types.rb +11 -3
  74. data/lib/thrift/union.rb +3 -6
  75. data/lib/thrift.rb +6 -0
  76. data/lib/types/annotation/deprecation/deprecation_constants.rb +16 -0
  77. data/lib/types/annotation/deprecation/deprecation_types.rb +42 -0
  78. data/lib/types/annotation/naming/naming_constants.rb +16 -0
  79. data/lib/types/annotation/naming/naming_types.rb +57 -0
  80. data/lib/types/annotation_definition/annotation_definition_constants.rb +14 -0
  81. data/lib/types/annotation_definition/annotation_definition_types.rb +114 -0
  82. data/lib/types/constant_definition/constant_definition_constants.rb +14 -0
  83. data/lib/types/constant_definition/constant_definition_types.rb +290 -0
  84. data/lib/types/core/core_constants.rb +14 -0
  85. data/lib/types/core/core_types.rb +56 -0
  86. data/lib/types/enum_definition/enum_definition_constants.rb +14 -0
  87. data/lib/types/enum_definition/enum_definition_types.rb +104 -0
  88. data/lib/types/known/any/any_constants.rb +16 -0
  89. data/lib/types/known/any/any_types.rb +59 -0
  90. data/lib/types/known/duration/duration_constants.rb +16 -0
  91. data/lib/types/known/duration/duration_types.rb +59 -0
  92. data/lib/types/known/timestamp/timestamp_constants.rb +16 -0
  93. data/lib/types/known/timestamp/timestamp_types.rb +59 -0
  94. data/lib/types/plugin/plugin.rb +137 -0
  95. data/lib/types/plugin/plugin_constants.rb +14 -0
  96. data/lib/types/plugin/plugin_types.rb +104 -0
  97. data/lib/types/program_definition/program_definition_constants.rb +14 -0
  98. data/lib/types/program_definition/program_definition_types.rb +135 -0
  99. data/lib/types/service_definition/service_definition_constants.rb +14 -0
  100. data/lib/types/service_definition/service_definition_types.rb +158 -0
  101. data/lib/types/struct_definition/struct_definition_constants.rb +14 -0
  102. data/lib/types/struct_definition/struct_definition_types.rb +155 -0
  103. data/lib/types/type_definition/type_definition_constants.rb +14 -0
  104. data/lib/types/type_definition/type_definition_types.rb +240 -0
  105. data/lib/types/value/value_constants.rb +14 -0
  106. data/lib/types/value/value_types.rb +330 -0
  107. data/spec/base/base_service.rb +152 -0
  108. data/spec/base/base_service_constants.rb +11 -0
  109. data/spec/base/base_service_types.rb +45 -0
  110. data/spec/base_protocol_spec.rb +79 -71
  111. data/spec/base_transport_spec.rb +155 -117
  112. data/spec/binary_protocol_accelerated_spec.rb +6 -2
  113. data/spec/binary_protocol_spec.rb +16 -8
  114. data/spec/binary_protocol_spec_shared.rb +77 -77
  115. data/spec/bytes_spec.rb +38 -38
  116. data/spec/client_spec.rb +48 -50
  117. data/spec/compact_protocol_spec.rb +59 -46
  118. data/spec/exception_spec.rb +54 -54
  119. data/spec/extended/extended_service.rb +137 -0
  120. data/spec/extended/extended_service_constants.rb +11 -0
  121. data/spec/extended/extended_service_types.rb +12 -0
  122. data/spec/flat_spec.rb +5 -5
  123. data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +507 -0
  124. data/spec/gen-rb/flat/referenced_constants.rb +11 -0
  125. data/spec/gen-rb/flat/referenced_types.rb +17 -0
  126. data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +11 -0
  127. data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +47 -0
  128. data/spec/http_client_spec.rb +96 -43
  129. data/spec/json_protocol_spec.rb +170 -131
  130. data/spec/namespaced_spec.rb +24 -27
  131. data/spec/namespaced_spec_namespace/namespaced_nonblocking_service.rb +507 -0
  132. data/spec/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +11 -0
  133. data/spec/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +47 -0
  134. data/spec/nonblocking_server_spec.rb +16 -16
  135. data/spec/nonblocking_service.rb +507 -0
  136. data/spec/other_namespace/referenced_constants.rb +11 -0
  137. data/spec/other_namespace/referenced_types.rb +17 -0
  138. data/spec/processor_spec.rb +42 -31
  139. data/spec/rack_application_spec.rb +22 -26
  140. data/spec/serializer_spec.rb +20 -20
  141. data/spec/server_socket_spec.rb +27 -22
  142. data/spec/server_spec.rb +91 -51
  143. data/spec/socket_spec.rb +23 -16
  144. data/spec/socket_spec_shared.rb +31 -31
  145. data/spec/spec_helper.rb +17 -17
  146. data/spec/ssl_server_socket_spec.rb +34 -0
  147. data/spec/ssl_socket_spec.rb +78 -0
  148. data/spec/streaming_spec.rb +442 -0
  149. data/spec/struct_nested_containers_spec.rb +24 -24
  150. data/spec/struct_spec.rb +120 -120
  151. data/spec/thin_http_server_spec.rb +71 -28
  152. data/spec/thrift_spec_constants.rb +11 -0
  153. data/spec/thrift_spec_types.rb +1173 -0
  154. data/spec/types/known/any_spec.rb +2 -2
  155. data/spec/types/known/duration_spec.rb +1 -1
  156. data/spec/types/known/timestamp_spec.rb +1 -1
  157. data/spec/types/value_spec.rb +2 -1
  158. data/spec/types_spec.rb +56 -53
  159. data/spec/union_spec.rb +51 -40
  160. data/spec/unix_socket_spec.rb +43 -34
  161. data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +281 -0
  162. data/test/debug_proto/gen-rb/debug_proto_test_types.rb +2033 -0
  163. data/test/debug_proto/gen-rb/empty_service.rb +52 -0
  164. data/test/debug_proto/gen-rb/inherited.rb +155 -0
  165. data/test/debug_proto/gen-rb/reverse_order_service.rb +169 -0
  166. data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +150 -0
  167. data/test/debug_proto/gen-rb/srv.rb +718 -0
  168. metadata +202 -7
@@ -21,84 +21,84 @@ require 'spec_helper'
21
21
 
22
22
  shared_examples_for "a socket" do
23
23
  it "should open a socket" do
24
- @socket.open.should == @handle
24
+ expect(@socket.open).to eq(@handle)
25
25
  end
26
26
 
27
27
  it "should be open whenever it has a handle" do
28
- @socket.should_not be_open
28
+ expect(@socket).not_to be_open
29
29
  @socket.open
30
- @socket.should be_open
30
+ expect(@socket).to be_open
31
31
  @socket.handle = nil
32
- @socket.should_not be_open
32
+ expect(@socket).not_to be_open
33
33
  @socket.handle = @handle
34
34
  @socket.close
35
- @socket.should_not be_open
35
+ expect(@socket).not_to be_open
36
36
  end
37
37
 
38
38
  it "should write data to the handle" do
39
39
  @socket.open
40
- @handle.should_receive(:write).with("foobar")
40
+ expect(@handle).to receive(:write).with("foobar")
41
41
  @socket.write("foobar")
42
- @handle.should_receive(:write).with("fail").and_raise(StandardError)
43
- lambda { @socket.write("fail") }.should raise_error(Thrift::TransportException) { |e| e.type.should == Thrift::TransportException::NOT_OPEN }
42
+ expect(@handle).to receive(:write).with("fail").and_raise(StandardError)
43
+ expect { @socket.write("fail") }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::NOT_OPEN) }
44
44
  end
45
45
 
46
46
  it "should raise an error when it cannot read from the handle" do
47
47
  @socket.open
48
- @handle.should_receive(:readpartial).with(17).and_raise(StandardError)
49
- lambda { @socket.read(17) }.should raise_error(Thrift::TransportException) { |e| e.type.should == Thrift::TransportException::NOT_OPEN }
48
+ expect(@handle).to receive(:readpartial).with(17).and_raise(StandardError)
49
+ expect { @socket.read(17) }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::NOT_OPEN) }
50
50
  end
51
51
 
52
52
  it "should return the data read when reading from the handle works" do
53
53
  @socket.open
54
- @handle.should_receive(:readpartial).with(17).and_return("test data")
55
- @socket.read(17).should == "test data"
54
+ expect(@handle).to receive(:readpartial).with(17).and_return("test data")
55
+ expect(@socket.read(17)).to eq("test data")
56
56
  end
57
57
 
58
58
  it "should declare itself as closed when it has an error" do
59
59
  @socket.open
60
- @handle.should_receive(:write).with("fail").and_raise(StandardError)
61
- @socket.should be_open
62
- lambda { @socket.write("fail") }.should raise_error
63
- @socket.should_not be_open
60
+ expect(@handle).to receive(:write).with("fail").and_raise(StandardError)
61
+ expect(@socket).to be_open
62
+ expect { @socket.write("fail") }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::NOT_OPEN) }
63
+ expect(@socket).not_to be_open
64
64
  end
65
65
 
66
66
  it "should raise an error when the stream is closed" do
67
67
  @socket.open
68
- @handle.stub!(:closed?).and_return(true)
69
- @socket.should_not be_open
70
- lambda { @socket.write("fail") }.should raise_error(IOError, "closed stream")
71
- lambda { @socket.read(10) }.should raise_error(IOError, "closed stream")
68
+ allow(@handle).to receive(:closed?).and_return(true)
69
+ expect(@socket).not_to be_open
70
+ expect { @socket.write("fail") }.to raise_error(IOError, "closed stream")
71
+ expect { @socket.read(10) }.to raise_error(IOError, "closed stream")
72
72
  end
73
73
 
74
74
  it "should support the timeout accessor for read" do
75
75
  @socket.timeout = 3
76
76
  @socket.open
77
- IO.should_receive(:select).with([@handle], nil, nil, 3).and_return([[@handle], [], []])
78
- @handle.should_receive(:readpartial).with(17).and_return("test data")
79
- @socket.read(17).should == "test data"
77
+ expect(IO).to receive(:select).with([@handle], nil, nil, 3).and_return([[@handle], [], []])
78
+ expect(@handle).to receive(:readpartial).with(17).and_return("test data")
79
+ expect(@socket.read(17)).to eq("test data")
80
80
  end
81
81
 
82
82
  it "should support the timeout accessor for write" do
83
83
  @socket.timeout = 3
84
84
  @socket.open
85
- IO.should_receive(:select).with(nil, [@handle], nil, 3).twice.and_return([[], [@handle], []])
86
- @handle.should_receive(:write_nonblock).with("test data").and_return(4)
87
- @handle.should_receive(:write_nonblock).with(" data").and_return(5)
88
- @socket.write("test data").should == 9
85
+ expect(IO).to receive(:select).with(nil, [@handle], nil, 3).twice.and_return([[], [@handle], []])
86
+ expect(@handle).to receive(:write_nonblock).with("test data").and_return(4)
87
+ expect(@handle).to receive(:write_nonblock).with(" data").and_return(5)
88
+ expect(@socket.write("test data")).to eq(9)
89
89
  end
90
90
 
91
91
  it "should raise an error when read times out" do
92
92
  @socket.timeout = 0.5
93
93
  @socket.open
94
- IO.should_receive(:select).once {sleep(0.5); nil}
95
- lambda { @socket.read(17) }.should raise_error(Thrift::TransportException) { |e| e.type.should == Thrift::TransportException::TIMED_OUT }
94
+ expect(IO).to receive(:select).once {sleep(0.5); nil}
95
+ expect { @socket.read(17) }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::TIMED_OUT) }
96
96
  end
97
97
 
98
98
  it "should raise an error when write times out" do
99
99
  @socket.timeout = 0.5
100
100
  @socket.open
101
- IO.should_receive(:select).with(nil, [@handle], nil, 0.5).any_number_of_times.and_return(nil)
102
- lambda { @socket.write("test data") }.should raise_error(Thrift::TransportException) { |e| e.type.should == Thrift::TransportException::TIMED_OUT }
101
+ allow(IO).to receive(:select).with(nil, [@handle], nil, 0.5).and_return(nil)
102
+ expect { @socket.write("test data") }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::TIMED_OUT) }
103
103
  end
104
104
  end
data/spec/spec_helper.rb CHANGED
@@ -44,21 +44,21 @@ RSpec.configure do |configuration|
44
44
  Thrift.type_checking = true
45
45
  end
46
46
  end
47
- #
48
- # $:.unshift File.join(File.dirname(__FILE__), *%w[.. test debug_proto gen-rb])
49
- # require 'srv'
50
- # require 'debug_proto_test_constants'
51
- #
52
- # $:.unshift File.join(File.dirname(__FILE__), *%w[gen-rb])
53
- # require 'thrift_spec_types'
54
- # require 'nonblocking_service'
55
- #
56
- # module Fixtures
57
- # COMPACT_PROTOCOL_TEST_STRUCT = COMPACT_TEST.dup
58
- # COMPACT_PROTOCOL_TEST_STRUCT.a_binary = [0,1,2,3,4,5,6,7,8].pack('c*')
59
- # COMPACT_PROTOCOL_TEST_STRUCT.set_byte_map = nil
60
- # COMPACT_PROTOCOL_TEST_STRUCT.map_byte_map = nil
61
- # end
62
- #
63
- # $:.unshift File.join(File.dirname(__FILE__), *%w[gen-rb/flat])
47
+
48
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. test debug_proto gen-rb])
49
+ require 'srv'
50
+ require 'debug_proto_test_constants'
51
+
52
+ $:.unshift File.join(File.dirname(__FILE__), *%w[gen-rb])
53
+ require 'thrift_spec_types'
54
+ require 'nonblocking_service'
55
+
56
+ module Fixtures
57
+ COMPACT_PROTOCOL_TEST_STRUCT = Thrift::Test::COMPACT_TEST.dup
58
+ COMPACT_PROTOCOL_TEST_STRUCT.a_binary = [0,1,2,3,4,5,6,7,8].pack('c*')
59
+ COMPACT_PROTOCOL_TEST_STRUCT.set_byte_map = nil
60
+ COMPACT_PROTOCOL_TEST_STRUCT.map_byte_map = nil
61
+ end
62
+
63
+ $:.unshift File.join(File.dirname(__FILE__), *%w[gen-rb/flat])
64
64
 
@@ -0,0 +1,34 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require 'spec_helper'
21
+ require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
22
+
23
+ describe 'SSLServerSocket' do
24
+
25
+ describe Thrift::SSLServerSocket do
26
+ before(:each) do
27
+ @socket = Thrift::SSLServerSocket.new(1234)
28
+ end
29
+
30
+ it "should provide a reasonable to_s" do
31
+ expect(@socket.to_s).to eq("ssl(socket(:1234))")
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,78 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require 'spec_helper'
21
+ require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
22
+
23
+ describe 'SSLSocket' do
24
+
25
+ describe Thrift::SSLSocket do
26
+ before(:each) do
27
+ @context = OpenSSL::SSL::SSLContext.new
28
+ @socket = Thrift::SSLSocket.new
29
+ @simple_socket_handle = double("Handle", :closed? => false)
30
+ allow(@simple_socket_handle).to receive(:close)
31
+ allow(@simple_socket_handle).to receive(:connect_nonblock)
32
+ allow(@simple_socket_handle).to receive(:setsockopt)
33
+
34
+ @handle = double(double("SSLHandle", :connect_nonblock => true, :post_connection_check => true), :closed? => false)
35
+ allow(@handle).to receive(:connect_nonblock)
36
+ allow(@handle).to receive(:close)
37
+ allow(@handle).to receive(:post_connection_check)
38
+
39
+ allow(::Socket).to receive(:new).and_return(@simple_socket_handle)
40
+ allow(OpenSSL::SSL::SSLSocket).to receive(:new).and_return(@handle)
41
+ end
42
+
43
+ it_should_behave_like "a socket"
44
+
45
+ it "should raise a TransportException when it cannot open a ssl socket" do
46
+ expect(::Socket).to receive(:getaddrinfo).with("localhost", 9090, nil, ::Socket::SOCK_STREAM).and_return([[]])
47
+ expect { @socket.open }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::NOT_OPEN) }
48
+ end
49
+
50
+ it "should open a ::Socket with default args" do
51
+ expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(@simple_socket_handle, nil).and_return(@handle)
52
+ expect(@handle).to receive(:post_connection_check).with('localhost')
53
+ @socket.open
54
+ end
55
+
56
+ it "should accept host/port options" do
57
+ handle = double("Handle", :connect_nonblock => true, :setsockopt => nil)
58
+ allow(::Socket).to receive(:new).and_return(handle)
59
+ expect(::Socket).to receive(:getaddrinfo).with("my.domain", 1234, nil, ::Socket::SOCK_STREAM).and_return([[]])
60
+ expect(::Socket).to receive(:sockaddr_in)
61
+ expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(handle, nil).and_return(@handle)
62
+ expect(@handle).to receive(:post_connection_check).with('my.domain')
63
+ Thrift::SSLSocket.new('my.domain', 1234, 6000, nil).open
64
+ end
65
+
66
+ it "should accept an optional timeout" do
67
+ expect(Thrift::SSLSocket.new('localhost', 8080, 5).timeout).to eq(5)
68
+ end
69
+
70
+ it "should accept an optional context" do
71
+ expect(Thrift::SSLSocket.new('localhost', 8080, 5, @context).ssl_context).to eq(@context)
72
+ end
73
+
74
+ it "should provide a reasonable to_s" do
75
+ expect(Thrift::SSLSocket.new('myhost', 8090).to_s).to eq("ssl(socket(myhost:8090))")
76
+ end
77
+ end
78
+ end