thrift 0.9.3.0 → 0.10.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4b1c844c7fec342a9de5ce50c17844517c794faf
4
+ data.tar.gz: df2069a8d5a3cdfd32e2ab12baecb02754fa28da
5
+ SHA512:
6
+ metadata.gz: 271e862c9efa8146e3586a47ed561be442c4ebdda6b528f365c307bd951a5e767adfd65da1636555d6ab7274a9d1e72f752be3277362431225b2d15b4234d633
7
+ data.tar.gz: fa52270c79fa32b327bd56efd9075cd3e4dfa9476478c419bb71bdcc1129e94ffdebc5ae9069ddf43afa92e3afc044072737e72b987dda57c0652bd800da92fb
@@ -290,7 +290,7 @@ static void write_container(int ttype, VALUE field_info, VALUE value, VALUE prot
290
290
 
291
291
  if (TYPE(value) == T_ARRAY) {
292
292
  items = value;
293
- } else {
293
+ } else {
294
294
  if (rb_cSet == CLASS_OF(value)) {
295
295
  items = rb_funcall(value, entries_method_id, 0);
296
296
  } else {
@@ -670,6 +670,10 @@ static VALUE rb_thrift_union_write(VALUE self, VALUE protocol) {
670
670
 
671
671
  VALUE field_info = rb_hash_aref(struct_fields, field_id);
672
672
 
673
+ if(NIL_P(field_info)) {
674
+ rb_raise(rb_eRuntimeError, "set_field is not valid for this union!");
675
+ }
676
+
673
677
  VALUE ttype_value = rb_hash_aref(field_info, type_sym);
674
678
  int ttype = FIX2INT(ttype_value);
675
679
 
@@ -1,4 +1,4 @@
1
- #
1
+ #
2
2
  # Licensed to the Apache Software Foundation (ASF) under one
3
3
  # or more contributor license agreements. See the NOTICE file
4
4
  # distributed with this work for additional information
@@ -6,16 +6,16 @@
6
6
  # to you under the Apache License, Version 2.0 (the
7
7
  # "License"); you may not use this file except in compliance
8
8
  # with the License. You may obtain a copy of the License at
9
- #
9
+ #
10
10
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
  # Unless required by applicable law or agreed to in writing,
13
13
  # software distributed under the License is distributed on an
14
14
  # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
15
  # KIND, either express or implied. See the License for the
16
16
  # specific language governing permissions and limitations
17
17
  # under the License.
18
- #
18
+ #
19
19
  # Contains some contributions under the Thrift Software License.
20
20
  # Please see doc/old-thrift-license.txt in the Thrift distribution for
21
21
  # details.
@@ -49,7 +49,9 @@ require 'thrift/protocol/multiplexed_protocol'
49
49
  require 'thrift/transport/base_transport'
50
50
  require 'thrift/transport/base_server_transport'
51
51
  require 'thrift/transport/socket'
52
+ require 'thrift/transport/ssl_socket'
52
53
  require 'thrift/transport/server_socket'
54
+ require 'thrift/transport/ssl_server_socket'
53
55
  require 'thrift/transport/unix_socket'
54
56
  require 'thrift/transport/unix_server_socket'
55
57
  require 'thrift/transport/buffered_transport'
@@ -57,12 +57,10 @@ module Thrift
57
57
  end
58
58
 
59
59
  def write_error(err, oprot, name, seqid)
60
- p 'write_error'
61
60
  oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid)
62
61
  err.write(oprot)
63
62
  oprot.write_message_end
64
63
  oprot.trans.flush
65
- p 'write_error end'
66
64
  end
67
65
  end
68
66
  end
@@ -18,6 +18,7 @@
18
18
  # under the License.
19
19
  #
20
20
 
21
+ require 'base64'
21
22
 
22
23
  module Thrift
23
24
  class LookaheadReader
@@ -310,7 +311,7 @@ module Thrift
310
311
  def write_json_base64(str)
311
312
  @context.write(trans)
312
313
  trans.write(@@kJSONStringDelimiter)
313
- write_json_string([str].pack("m"))
314
+ trans.write(Base64.strict_encode64(str))
314
315
  trans.write(@@kJSONStringDelimiter)
315
316
  end
316
317
 
@@ -513,7 +514,7 @@ module Thrift
513
514
  # The elements of this array must match up with the sequence of characters in
514
515
  # escape_chars
515
516
  escape_char_vals = [
516
- '"', '\\', '/', '\b', '\f', '\n', '\r', '\t',
517
+ "\"", "\\", "\/", "\b", "\f", "\n", "\r", "\t",
517
518
  ]
518
519
 
519
520
  if !skipContext
@@ -546,7 +547,15 @@ module Thrift
546
547
 
547
548
  # Reads a block of base64 characters, decoding it, and returns via str
548
549
  def read_json_base64
549
- read_json_string.unpack("m")[0]
550
+ str = read_json_string
551
+ m = str.length % 4
552
+ if m != 0
553
+ # Add missing padding
554
+ (4 - m).times do
555
+ str += '='
556
+ end
557
+ end
558
+ Base64.strict_decode64(str)
550
559
  end
551
560
 
552
561
  # Reads a sequence of characters, stopping at the first one that is not
@@ -50,6 +50,7 @@ module Thrift
50
50
  data = resp.body
51
51
  data = Bytes.force_binary_encoding(data)
52
52
  @inbuf = StringIO.new data
53
+ ensure
53
54
  @outbuf = Bytes.empty_byte_buffer
54
55
  end
55
56
  end
@@ -33,26 +33,28 @@ module Thrift
33
33
  attr_accessor :handle, :timeout
34
34
 
35
35
  def open
36
- begin
37
- addrinfo = ::Socket::getaddrinfo(@host, @port, nil, ::Socket::SOCK_STREAM).first
38
- @handle = ::Socket.new(addrinfo[4], ::Socket::SOCK_STREAM, 0)
39
- @handle.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
40
- sockaddr = ::Socket.sockaddr_in(addrinfo[1], addrinfo[3])
36
+ for addrinfo in ::Socket::getaddrinfo(@host, @port, nil, ::Socket::SOCK_STREAM) do
41
37
  begin
42
- @handle.connect_nonblock(sockaddr)
43
- rescue Errno::EINPROGRESS
44
- unless IO.select(nil, [ @handle ], nil, @timeout)
45
- raise TransportException.new(TransportException::NOT_OPEN, "Connection timeout to #{@desc}")
46
- end
38
+ socket = ::Socket.new(addrinfo[4], ::Socket::SOCK_STREAM, 0)
39
+ socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
40
+ sockaddr = ::Socket.sockaddr_in(addrinfo[1], addrinfo[3])
47
41
  begin
48
- @handle.connect_nonblock(sockaddr)
49
- rescue Errno::EISCONN
42
+ socket.connect_nonblock(sockaddr)
43
+ rescue Errno::EINPROGRESS
44
+ unless IO.select(nil, [ socket ], nil, @timeout)
45
+ next
46
+ end
47
+ begin
48
+ socket.connect_nonblock(sockaddr)
49
+ rescue Errno::EISCONN
50
+ end
50
51
  end
52
+ return @handle = socket
53
+ rescue StandardError => e
54
+ next
51
55
  end
52
- @handle
53
- rescue StandardError => e
54
- raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
55
56
  end
57
+ raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
56
58
  end
57
59
 
58
60
  def open?
@@ -0,0 +1,37 @@
1
+ # encoding: ascii-8bit
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ require 'socket'
22
+
23
+ module Thrift
24
+ class SSLServerSocket < ServerSocket
25
+ def initialize(host_or_port, port = nil, ssl_context = nil)
26
+ super(host_or_port, port)
27
+ @ssl_context = ssl_context
28
+ end
29
+
30
+ attr_accessor :ssl_context
31
+
32
+ def listen
33
+ socket = TCPServer.new(@host, @port)
34
+ @handle = OpenSSL::SSL::SSLServer.new(socket, @ssl_context)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: ascii-8bit
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Thrift
21
+ class SSLSocket < Socket
22
+ def initialize(host='localhost', port=9090, timeout=nil, ssl_context=nil)
23
+ super(host, port, timeout)
24
+ @ssl_context = ssl_context
25
+ end
26
+
27
+ attr_accessor :ssl_context
28
+
29
+ def open
30
+ socket = super
31
+ @handle = OpenSSL::SSL::SSLSocket.new(socket, @ssl_context)
32
+ begin
33
+ @handle.connect_nonblock
34
+ @handle.post_connection_check(@host)
35
+ @handle
36
+ rescue IO::WaitReadable
37
+ IO.select([ @handle ], nil, nil, @timeout)
38
+ retry
39
+ rescue IO::WaitWritable
40
+ IO.select(nil, [ @handle ], nil, @timeout)
41
+ retry
42
+ rescue StandardError => e
43
+ raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
44
+ end
45
+ end
46
+ end
47
+ end
@@ -423,9 +423,9 @@ shared_examples_for 'a binary protocol' do
423
423
  clientproto = protocol_class.new(clientside)
424
424
  serverproto = protocol_class.new(serverside)
425
425
 
426
- processor = Srv::Processor.new(SrvHandler.new)
426
+ processor = Thrift::Test::Srv::Processor.new(SrvHandler.new)
427
427
 
428
- client = Srv::Client.new(clientproto, clientproto)
428
+ client = Thrift::Test::Srv::Client.new(clientproto, clientproto)
429
429
 
430
430
  # first block
431
431
  firstblock.call(client)
@@ -75,11 +75,11 @@ describe Thrift::CompactProtocol do
75
75
  trans = Thrift::MemoryBufferTransport.new
76
76
  proto = Thrift::CompactProtocol.new(trans)
77
77
 
78
- struct = CompactProtoTestStruct.new
78
+ struct = Thrift::Test::CompactProtoTestStruct.new
79
79
  # sets and maps don't hash well... not sure what to do here.
80
80
  struct.write(proto)
81
81
 
82
- struct2 = CompactProtoTestStruct.new
82
+ struct2 = Thrift::Test::CompactProtoTestStruct.new
83
83
  struct2.read(proto)
84
84
  struct2.should == struct
85
85
  end
@@ -91,9 +91,9 @@ describe Thrift::CompactProtocol do
91
91
  client_in_trans = Thrift::MemoryBufferTransport.new
92
92
  client_in_proto = Thrift::CompactProtocol.new(client_in_trans)
93
93
 
94
- processor = Srv::Processor.new(JankyHandler.new)
94
+ processor = Thrift::Test::Srv::Processor.new(JankyHandler.new)
95
95
 
96
- client = Srv::Client.new(client_in_proto, client_out_proto)
96
+ client = Thrift::Test::Srv::Client.new(client_in_proto, client_out_proto)
97
97
  client.send_Janky(1)
98
98
  # puts client_out_trans.inspect_buffer
99
99
  processor.process(client_out_proto, client_in_proto)
@@ -101,9 +101,9 @@ describe Thrift::CompactProtocol do
101
101
  end
102
102
 
103
103
  it "should deal with fields following fields that have non-delta ids" do
104
- brcp = BreaksRubyCompactProtocol.new(
104
+ brcp = Thrift::Test::BreaksRubyCompactProtocol.new(
105
105
  :field1 => "blah",
106
- :field2 => BigFieldIdStruct.new(
106
+ :field2 => Thrift::Test::BigFieldIdStruct.new(
107
107
  :field1 => "string1",
108
108
  :field2 => "string2"),
109
109
  :field3 => 3)
@@ -111,18 +111,18 @@ describe Thrift::CompactProtocol do
111
111
  bytes = ser.serialize(brcp)
112
112
 
113
113
  deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
114
- brcp2 = BreaksRubyCompactProtocol.new
114
+ brcp2 = Thrift::Test::BreaksRubyCompactProtocol.new
115
115
  deser.deserialize(brcp2, bytes)
116
116
  brcp2.should == brcp
117
117
  end
118
118
 
119
119
  it "should deserialize an empty map to an empty hash" do
120
- struct = SingleMapTestStruct.new(:i32_map => {})
120
+ struct = Thrift::Test::SingleMapTestStruct.new(:i32_map => {})
121
121
  ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
122
122
  bytes = ser.serialize(struct)
123
123
 
124
124
  deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
125
- struct2 = SingleMapTestStruct.new
125
+ struct2 = Thrift::Test::SingleMapTestStruct.new
126
126
  deser.deserialize(struct2, bytes)
127
127
  struct.should == struct2
128
128
  end
@@ -67,6 +67,21 @@ describe 'Thrift::HTTPClientTransport' do
67
67
  end
68
68
  @client.flush
69
69
  end
70
+
71
+ it 'should reset the outbuf on HTTP failures' do
72
+ @client.write "test"
73
+
74
+ Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
75
+ mock("Net::HTTP").tap do |http|
76
+ http.should_receive(:use_ssl=).with(false)
77
+ http.should_receive(:post).with("/path/to/service?param=value", "test", {"Content-Type"=>"application/x-thrift"}) { raise Net::ReadTimeout }
78
+ end
79
+ end
80
+
81
+ @client.flush rescue
82
+ @client.instance_variable_get(:@outbuf).should eq(Thrift::Bytes.empty_byte_buffer)
83
+ end
84
+
70
85
  end
71
86
 
72
87
  describe 'ssl enabled' do
@@ -57,7 +57,7 @@ describe 'JsonProtocol' do
57
57
 
58
58
  it "should write json base64" do
59
59
  @prot.write_json_base64("this is a base64 string")
60
- @trans.read(@trans.available).should == "\"\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\\n\"\""
60
+ @trans.read(@trans.available).should == "\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\""
61
61
  end
62
62
 
63
63
  it "should write json integer" do
@@ -244,7 +244,12 @@ describe 'JsonProtocol' do
244
244
 
245
245
  it "should write binary" do
246
246
  @prot.write_binary("this is a base64 string")
247
- @trans.read(@trans.available).should == "\"\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\\n\"\""
247
+ @trans.read(@trans.available).should == "\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\""
248
+ end
249
+
250
+ it "should write long binary" do
251
+ @prot.write_binary((0...256).to_a.pack('C*'))
252
+ @trans.read(@trans.available).should == "\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==\""
248
253
  end
249
254
 
250
255
  it "should get type name for type id" do
@@ -288,15 +293,36 @@ describe 'JsonProtocol' do
288
293
  it "should read json escape char" do
289
294
  @trans.write('0054')
290
295
  @prot.read_json_escape_char.should == 'T'
296
+
297
+ @trans.write("\"\\\"\"")
298
+ @prot.read_json_string(false).should == "\""
299
+
300
+ @trans.write("\"\\\\\"")
301
+ @prot.read_json_string(false).should == "\\"
302
+
303
+ @trans.write("\"\\/\"")
304
+ @prot.read_json_string(false).should == "\/"
305
+
306
+ @trans.write("\"\\b\"")
307
+ @prot.read_json_string(false).should == "\b"
308
+
309
+ @trans.write("\"\\f\"")
310
+ @prot.read_json_string(false).should == "\f"
311
+
312
+ @trans.write("\"\\n\"")
313
+ @prot.read_json_string(false).should == "\n"
314
+
315
+ @trans.write("\"\\r\"")
316
+ @prot.read_json_string(false).should == "\r"
317
+
318
+ @trans.write("\"\\t\"")
319
+ @prot.read_json_string(false).should == "\t"
291
320
  end
292
321
 
293
322
  it "should read json string" do
294
323
  @trans.write("\"\\P")
295
324
  expect {@prot.read_json_string(false)}.to raise_error(Thrift::ProtocolException)
296
325
 
297
- @trans.write("\"\\n\"")
298
- @prot.read_json_string(false).should == "\\n"
299
-
300
326
  @trans.write("\"this is a test string\"")
301
327
  @prot.read_json_string.should == "this is a test string"
302
328
  end
@@ -503,6 +529,11 @@ describe 'JsonProtocol' do
503
529
  @trans.write("\"dGhpcyBpcyBhIHRlc3Qgc3RyaW5n\"")
504
530
  @prot.read_binary.should == "this is a test string"
505
531
  end
532
+
533
+ it "should read long binary" do
534
+ @trans.write("\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==\"")
535
+ @prot.read_binary.bytes.to_a.should == (0...256).to_a
536
+ end
506
537
  end
507
538
 
508
539
  describe Thrift::JsonProtocolFactory do
@@ -35,7 +35,7 @@ describe 'Socket' do
35
35
  it_should_behave_like "a socket"
36
36
 
37
37
  it "should raise a TransportException when it cannot open a socket" do
38
- ::Socket.should_receive(:new).and_raise(StandardError)
38
+ ::Socket.should_receive(:getaddrinfo).with("localhost", 9090, nil, ::Socket::SOCK_STREAM).and_return([[]])
39
39
  lambda { @socket.open }.should raise_error(Thrift::TransportException) { |e| e.type.should == Thrift::TransportException::NOT_OPEN }
40
40
  end
41
41
 
@@ -54,7 +54,7 @@ require 'thrift_spec_types'
54
54
  require 'nonblocking_service'
55
55
 
56
56
  module Fixtures
57
- COMPACT_PROTOCOL_TEST_STRUCT = COMPACT_TEST.dup
57
+ COMPACT_PROTOCOL_TEST_STRUCT = Thrift::Test::COMPACT_TEST.dup
58
58
  COMPACT_PROTOCOL_TEST_STRUCT.a_binary = [0,1,2,3,4,5,6,7,8].pack('c*')
59
59
  COMPACT_PROTOCOL_TEST_STRUCT.set_byte_map = nil
60
60
  COMPACT_PROTOCOL_TEST_STRUCT.map_byte_map = nil
@@ -0,0 +1,74 @@
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 = mock("Handle", :closed? => false)
30
+ @simple_socket_handle.stub!(:close)
31
+ @simple_socket_handle.stub!(:connect_nonblock)
32
+ @simple_socket_handle.stub!(:setsockopt)
33
+
34
+ @handle = mock(mock("SSLHandle", :connect_nonblock => true, :post_connection_check => true), :closed? => false)
35
+ @handle.stub!(:connect_nonblock)
36
+ @handle.stub!(:close)
37
+ @handle.stub!(:post_connection_check)
38
+
39
+ ::Socket.stub!(:new).and_return(@simple_socket_handle)
40
+ OpenSSL::SSL::SSLSocket.stub!(: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
+ ::Socket.should_receive(:getaddrinfo).with("localhost", 9090, nil, ::Socket::SOCK_STREAM).and_return([[]])
47
+ lambda { @socket.open }.should raise_error(Thrift::TransportException) { |e| e.type.should == Thrift::TransportException::NOT_OPEN }
48
+ end
49
+
50
+ it "should open a ::Socket with default args" do
51
+ OpenSSL::SSL::SSLSocket.should_receive(:new).with(@simple_socket_handle, nil).and_return(@handle)
52
+ @handle.should_receive(:post_connection_check).with('localhost')
53
+ @socket.open
54
+ end
55
+
56
+ it "should accept host/port options" do
57
+ handle = mock("Handle", :connect_nonblock => true, :setsockopt => nil)
58
+ ::Socket.stub!(:new).and_return(handle)
59
+ ::Socket.should_receive(:getaddrinfo).with("my.domain", 1234, nil, ::Socket::SOCK_STREAM).and_return([[]])
60
+ ::Socket.should_receive(:sockaddr_in)
61
+ OpenSSL::SSL::SSLSocket.should_receive(:new).with(handle, nil).and_return(@handle)
62
+ @handle.should_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
+ Thrift::SSLSocket.new('localhost', 8080, 5).timeout.should == 5
68
+ end
69
+
70
+ it "should accept an optional context" do
71
+ Thrift::SSLSocket.new('localhost', 8080, 5, @context).ssl_context.should == @context
72
+ end
73
+ end
74
+ end
@@ -48,6 +48,13 @@ describe 'Union' do
48
48
  lambda { union.some_characters }.should raise_error(RuntimeError, "some_characters is not union's set field.")
49
49
  end
50
50
 
51
+ it "should raise for wrong set field when hash initialized and type checking is off" do
52
+ Thrift.type_checking = false
53
+ union = SpecNamespace::My_union.new({incorrect_field: :incorrect})
54
+ example = lambda { Thrift::Serializer.new.serialize(union) }
55
+ example.should raise_error(RuntimeError, "set_field is not valid for this union!")
56
+ end
57
+
51
58
  it "should not be equal to nil" do
52
59
  union = SpecNamespace::My_union.new
53
60
  union.should_not == nil
metadata CHANGED
@@ -1,112 +1,105 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thrift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3.0
5
- prerelease:
4
+ version: 0.10.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Thrift Developers
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-09-30 00:00:00.000000000 Z
11
+ date: 2017-01-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 2.10.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 2.14.0
22
23
  type: :development
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 2.10.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 2.14.0
30
33
  - !ruby/object:Gem::Dependency
31
34
  name: rack
32
35
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
36
  requirements:
35
- - - ~>
37
+ - - "~>"
36
38
  - !ruby/object:Gem::Version
37
- version: 1.5.2
39
+ version: '1.5'
38
40
  type: :development
39
41
  prerelease: false
40
42
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
43
  requirements:
43
- - - ~>
44
+ - - "~>"
44
45
  - !ruby/object:Gem::Version
45
- version: 1.5.2
46
+ version: '1.5'
46
47
  - !ruby/object:Gem::Dependency
47
48
  name: rack-test
48
49
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
50
  requirements:
51
- - - ~>
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 0.6.2
53
+ version: '0.6'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
57
  requirements:
59
- - - ~>
58
+ - - "~>"
60
59
  - !ruby/object:Gem::Version
61
- version: 0.6.2
60
+ version: '0.6'
62
61
  - !ruby/object:Gem::Dependency
63
62
  name: thin
64
63
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
64
  requirements:
67
- - - ~>
65
+ - - "~>"
68
66
  - !ruby/object:Gem::Version
69
- version: 1.5.0
67
+ version: '1.5'
70
68
  type: :development
71
69
  prerelease: false
72
70
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
71
  requirements:
75
- - - ~>
72
+ - - "~>"
76
73
  - !ruby/object:Gem::Version
77
- version: 1.5.0
74
+ version: '1.5'
78
75
  - !ruby/object:Gem::Dependency
79
76
  name: bundler
80
77
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
78
  requirements:
83
- - - ! '>='
79
+ - - "~>"
84
80
  - !ruby/object:Gem::Version
85
- version: '0'
81
+ version: '1'
86
82
  type: :development
87
83
  prerelease: false
88
84
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
85
  requirements:
91
- - - ! '>='
86
+ - - "~>"
92
87
  - !ruby/object:Gem::Version
93
- version: '0'
88
+ version: '1'
94
89
  - !ruby/object:Gem::Dependency
95
90
  name: rake
96
91
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
92
  requirements:
99
- - - ! '>='
93
+ - - "~>"
100
94
  - !ruby/object:Gem::Version
101
- version: '0'
95
+ version: '10.5'
102
96
  type: :development
103
97
  prerelease: false
104
98
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
99
  requirements:
107
- - - ! '>='
100
+ - - "~>"
108
101
  - !ruby/object:Gem::Version
109
- version: '0'
102
+ version: '10.5'
110
103
  description: Ruby bindings for the Apache Thrift RPC system
111
104
  email:
112
105
  - dev@thrift.apache.org
@@ -168,16 +161,43 @@ extra_rdoc_files:
168
161
  - lib/thrift/transport/memory_buffer_transport.rb
169
162
  - lib/thrift/transport/server_socket.rb
170
163
  - lib/thrift/transport/socket.rb
164
+ - lib/thrift/transport/ssl_server_socket.rb
165
+ - lib/thrift/transport/ssl_socket.rb
171
166
  - lib/thrift/transport/unix_server_socket.rb
172
167
  - lib/thrift/transport/unix_socket.rb
173
168
  - lib/thrift/types.rb
174
169
  - lib/thrift/union.rb
175
170
  - lib/thrift.rb
176
171
  files:
172
+ - README.md
173
+ - benchmark/Benchmark.thrift
174
+ - benchmark/benchmark.rb
175
+ - benchmark/client.rb
176
+ - benchmark/server.rb
177
+ - benchmark/thin_server.rb
178
+ - ext/binary_protocol_accelerated.c
179
+ - ext/binary_protocol_accelerated.h
180
+ - ext/bytes.c
181
+ - ext/bytes.h
182
+ - ext/compact_protocol.c
183
+ - ext/compact_protocol.h
184
+ - ext/constants.h
185
+ - ext/extconf.rb
186
+ - ext/macros.h
187
+ - ext/memory_buffer.c
188
+ - ext/memory_buffer.h
189
+ - ext/protocol.c
190
+ - ext/protocol.h
191
+ - ext/strlcpy.c
192
+ - ext/strlcpy.h
193
+ - ext/struct.c
194
+ - ext/struct.h
195
+ - ext/thrift_native.c
196
+ - lib/thrift.rb
177
197
  - lib/thrift/bytes.rb
178
198
  - lib/thrift/client.rb
179
- - lib/thrift/core_ext/fixnum.rb
180
199
  - lib/thrift/core_ext.rb
200
+ - lib/thrift/core_ext/fixnum.rb
181
201
  - lib/thrift/exceptions.rb
182
202
  - lib/thrift/multiplexed_processor.rb
183
203
  - lib/thrift/processor.rb
@@ -209,14 +229,19 @@ files:
209
229
  - lib/thrift/transport/memory_buffer_transport.rb
210
230
  - lib/thrift/transport/server_socket.rb
211
231
  - lib/thrift/transport/socket.rb
232
+ - lib/thrift/transport/ssl_server_socket.rb
233
+ - lib/thrift/transport/ssl_socket.rb
212
234
  - lib/thrift/transport/unix_server_socket.rb
213
235
  - lib/thrift/transport/unix_socket.rb
214
236
  - lib/thrift/types.rb
215
237
  - lib/thrift/union.rb
216
- - lib/thrift.rb
238
+ - spec/BaseService.thrift
239
+ - spec/ExtendedService.thrift
240
+ - spec/Referenced.thrift
241
+ - spec/ThriftNamespacedSpec.thrift
242
+ - spec/ThriftSpec.thrift
217
243
  - spec/base_protocol_spec.rb
218
244
  - spec/base_transport_spec.rb
219
- - spec/BaseService.thrift
220
245
  - spec/binary_protocol_accelerated_spec.rb
221
246
  - spec/binary_protocol_spec.rb
222
247
  - spec/binary_protocol_spec_shared.rb
@@ -224,83 +249,55 @@ files:
224
249
  - spec/client_spec.rb
225
250
  - spec/compact_protocol_spec.rb
226
251
  - spec/exception_spec.rb
227
- - spec/ExtendedService.thrift
228
252
  - spec/flat_spec.rb
229
253
  - spec/http_client_spec.rb
230
254
  - spec/json_protocol_spec.rb
231
255
  - spec/namespaced_spec.rb
232
256
  - spec/nonblocking_server_spec.rb
233
257
  - spec/processor_spec.rb
234
- - spec/Referenced.thrift
235
258
  - spec/serializer_spec.rb
236
259
  - spec/server_socket_spec.rb
237
260
  - spec/server_spec.rb
238
261
  - spec/socket_spec.rb
239
262
  - spec/socket_spec_shared.rb
240
263
  - spec/spec_helper.rb
264
+ - spec/ssl_socket_spec.rb
241
265
  - spec/struct_nested_containers_spec.rb
242
266
  - spec/struct_spec.rb
243
267
  - spec/thin_http_server_spec.rb
244
- - spec/ThriftNamespacedSpec.thrift
245
- - spec/ThriftSpec.thrift
246
268
  - spec/types_spec.rb
247
269
  - spec/union_spec.rb
248
270
  - spec/unix_socket_spec.rb
249
- - README.md
250
- - ext/binary_protocol_accelerated.c
251
- - ext/bytes.c
252
- - ext/compact_protocol.c
253
- - ext/memory_buffer.c
254
- - ext/protocol.c
255
- - ext/strlcpy.c
256
- - ext/struct.c
257
- - ext/thrift_native.c
258
- - ext/binary_protocol_accelerated.h
259
- - ext/bytes.h
260
- - ext/compact_protocol.h
261
- - ext/constants.h
262
- - ext/macros.h
263
- - ext/memory_buffer.h
264
- - ext/protocol.h
265
- - ext/strlcpy.h
266
- - ext/struct.h
267
- - ext/extconf.rb
268
- - benchmark/benchmark.rb
269
- - benchmark/Benchmark.thrift
270
- - benchmark/client.rb
271
- - benchmark/server.rb
272
- - benchmark/thin_server.rb
273
271
  homepage: http://thrift.apache.org
274
272
  licenses:
275
273
  - Apache 2.0
274
+ metadata: {}
276
275
  post_install_message:
277
276
  rdoc_options:
278
- - --line-numbers
279
- - --inline-source
280
- - --title
277
+ - "--line-numbers"
278
+ - "--inline-source"
279
+ - "--title"
281
280
  - Thrift
282
- - --main
281
+ - "--main"
283
282
  - README
284
283
  require_paths:
285
284
  - lib
286
285
  - ext
287
286
  required_ruby_version: !ruby/object:Gem::Requirement
288
- none: false
289
287
  requirements:
290
- - - ! '>='
288
+ - - ">="
291
289
  - !ruby/object:Gem::Version
292
290
  version: '0'
293
291
  required_rubygems_version: !ruby/object:Gem::Requirement
294
- none: false
295
292
  requirements:
296
- - - ! '>='
293
+ - - ">="
297
294
  - !ruby/object:Gem::Version
298
295
  version: '0'
299
296
  requirements: []
300
297
  rubyforge_project: thrift
301
- rubygems_version: 1.8.23
298
+ rubygems_version: 2.6.8
302
299
  signing_key:
303
- specification_version: 3
300
+ specification_version: 4
304
301
  summary: Ruby bindings for Apache Thrift
305
302
  test_files:
306
303
  - spec/base_protocol_spec.rb
@@ -327,6 +324,7 @@ test_files:
327
324
  - spec/socket_spec.rb
328
325
  - spec/socket_spec_shared.rb
329
326
  - spec/spec_helper.rb
327
+ - spec/ssl_socket_spec.rb
330
328
  - spec/struct_nested_containers_spec.rb
331
329
  - spec/struct_spec.rb
332
330
  - spec/thin_http_server_spec.rb
@@ -340,3 +338,4 @@ test_files:
340
338
  - benchmark/client.rb
341
339
  - benchmark/server.rb
342
340
  - benchmark/thin_server.rb
341
+ has_rdoc: true