thrift 0.24.0 → 0.25.0
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.
- checksums.yaml +4 -4
- data/README.md +107 -4
- data/ext/binary_protocol_accelerated.c +52 -17
- data/ext/compact_protocol.c +135 -70
- data/ext/constants.h +3 -0
- data/ext/extconf.rb +4 -4
- data/ext/macros.h +11 -0
- data/ext/memory_buffer.c +35 -17
- data/ext/struct.c +185 -64
- data/ext/thrift_native.c +6 -0
- data/lib/thrift/bytes.rb +2 -2
- data/lib/thrift/client.rb +31 -22
- data/lib/thrift/exceptions.rb +10 -8
- data/lib/thrift/multiplexed_processor.rb +5 -6
- data/lib/thrift/processor.rb +24 -3
- data/lib/thrift/protocol/base_protocol.rb +53 -27
- data/lib/thrift/protocol/binary_protocol.rb +54 -40
- data/lib/thrift/protocol/binary_protocol_accelerated.rb +6 -2
- data/lib/thrift/protocol/compact_protocol.rb +193 -88
- data/lib/thrift/protocol/header_protocol.rb +14 -3
- data/lib/thrift/protocol/json_protocol.rb +146 -104
- data/lib/thrift/protocol/multiplexed_protocol.rb +2 -3
- data/lib/thrift/protocol/protocol_decorator.rb +5 -2
- data/lib/thrift/serializer/serializer.rb +6 -0
- data/lib/thrift/server/base_server.rb +10 -2
- data/lib/thrift/server/nonblocking_server.rb +49 -26
- data/lib/thrift/server/rack_application.rb +69 -0
- data/lib/thrift/server/simple_server.rb +27 -23
- data/lib/thrift/server/thin_http_server.rb +20 -44
- data/lib/thrift/server/thread_pool_server.rb +20 -17
- data/lib/thrift/server/threaded_server.rb +22 -26
- data/lib/thrift/struct.rb +33 -18
- data/lib/thrift/struct_union.rb +36 -30
- data/lib/thrift/transport/base_transport.rb +23 -5
- data/lib/thrift/transport/buffered_transport.rb +4 -4
- data/lib/thrift/transport/framed_transport.rb +32 -7
- data/lib/thrift/transport/header_transport.rb +130 -50
- data/lib/thrift/transport/http_client_transport.rb +27 -14
- data/lib/thrift/transport/io_stream_transport.rb +2 -1
- data/lib/thrift/transport/memory_buffer_transport.rb +8 -10
- data/lib/thrift/transport/server_socket.rb +4 -5
- data/lib/thrift/transport/socket.rb +20 -22
- data/lib/thrift/transport/ssl_server_socket.rb +64 -4
- data/lib/thrift/transport/ssl_socket.rb +32 -5
- data/lib/thrift/transport/unix_server_socket.rb +1 -1
- data/lib/thrift/transport/unix_socket.rb +4 -6
- data/lib/thrift/types.rb +22 -22
- data/lib/thrift/union.rb +20 -11
- data/lib/thrift/uuid.rb +8 -8
- data/lib/thrift.rb +39 -39
- metadata +5 -230
- data/benchmark/Benchmark.thrift +0 -24
- data/benchmark/benchmark.rb +0 -286
- data/benchmark/client.rb +0 -118
- data/benchmark/server.rb +0 -121
- data/benchmark/thin_server.rb +0 -46
- data/lib/thrift/server/mongrel_http_server.rb +0 -61
- data/spec/BaseService.thrift +0 -27
- data/spec/ExtendedService.thrift +0 -25
- data/spec/Referenced.thrift +0 -44
- data/spec/ThriftNamespacedSpec.thrift +0 -53
- data/spec/ThriftSpec.thrift +0 -203
- data/spec/base_protocol_spec.rb +0 -244
- data/spec/base_transport_spec.rb +0 -428
- data/spec/binary_protocol_accelerated_spec.rb +0 -47
- data/spec/binary_protocol_spec.rb +0 -73
- data/spec/binary_protocol_spec_shared.rb +0 -509
- data/spec/bytes_spec.rb +0 -117
- data/spec/client_spec.rb +0 -167
- data/spec/compact_protocol_spec.rb +0 -295
- data/spec/constants_demo_spec.rb +0 -102
- data/spec/exception_spec.rb +0 -141
- data/spec/flat_spec.rb +0 -63
- data/spec/header_protocol_spec.rb +0 -476
- data/spec/header_transport_spec.rb +0 -431
- data/spec/http_client_spec.rb +0 -160
- data/spec/json_protocol_spec.rb +0 -574
- data/spec/multiplexed_processor_spec.rb +0 -75
- data/spec/namespaced_spec.rb +0 -67
- data/spec/nonblocking_server_spec.rb +0 -429
- data/spec/processor_spec.rb +0 -80
- data/spec/recursion_depth_spec.rb +0 -223
- data/spec/serializer_spec.rb +0 -67
- data/spec/server_socket_spec.rb +0 -121
- data/spec/server_spec.rb +0 -238
- data/spec/socket_spec.rb +0 -174
- data/spec/socket_spec_shared.rb +0 -168
- data/spec/spec_helper.rb +0 -70
- data/spec/ssl_server_socket_spec.rb +0 -85
- data/spec/ssl_socket_spec.rb +0 -248
- data/spec/struct_nested_containers_spec.rb +0 -191
- data/spec/struct_spec.rb +0 -398
- data/spec/support/header_protocol_helper.rb +0 -55
- data/spec/thin_http_server_spec.rb +0 -127
- data/spec/types_spec.rb +0 -118
- data/spec/union_spec.rb +0 -273
- data/spec/unix_socket_spec.rb +0 -131
- data/spec/uuid_validation_spec.rb +0 -239
- data/test/fuzz/Makefile +0 -779
- data/test/fuzz/Makefile.am +0 -173
- data/test/fuzz/Makefile.in +0 -775
- data/test/fuzz/README.md +0 -149
- data/test/fuzz/fuzz_common.rb +0 -96
- data/test/fuzz/fuzz_parse_binary_protocol.rb +0 -23
- data/test/fuzz/fuzz_parse_binary_protocol_accelerated.rb +0 -23
- data/test/fuzz/fuzz_parse_binary_protocol_accelerated_harness.rb +0 -23
- data/test/fuzz/fuzz_parse_binary_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_parse_compact_protocol.rb +0 -23
- data/test/fuzz/fuzz_parse_compact_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_parse_json_protocol.rb +0 -23
- data/test/fuzz/fuzz_parse_json_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_binary_protocol.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated_harness.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_binary_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_compact_protocol.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_compact_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_json_protocol.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_json_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_tracer.rb +0 -29
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
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 'spec_helper'
|
|
22
|
-
|
|
23
|
-
describe 'UUID Validation' do
|
|
24
|
-
protocols = [
|
|
25
|
-
['BinaryProtocol', Thrift::BinaryProtocol],
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
if defined?(Thrift::BinaryProtocolAccelerated)
|
|
29
|
-
protocols << ['BinaryProtocolAccelerated', Thrift::BinaryProtocolAccelerated]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
protocols << ['CompactProtocol', Thrift::CompactProtocol]
|
|
33
|
-
protocols << ['JsonProtocol', Thrift::JsonProtocol]
|
|
34
|
-
|
|
35
|
-
protocols.each do |protocol_name, protocol_class|
|
|
36
|
-
describe protocol_name do
|
|
37
|
-
before(:each) do
|
|
38
|
-
@trans = Thrift::MemoryBufferTransport.new
|
|
39
|
-
@prot = protocol_class.new(@trans)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'valid UUIDs' do
|
|
43
|
-
it 'should accept lowercase UUIDs' do
|
|
44
|
-
uuid = '550e8400-e29b-41d4-a716-446655440000'
|
|
45
|
-
expect { @prot.write_uuid(uuid) }.not_to raise_error
|
|
46
|
-
result = @prot.read_uuid
|
|
47
|
-
expect(result).to eq(uuid)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'should accept uppercase UUIDs' do
|
|
51
|
-
uuid = '550E8400-E29B-41D4-A716-446655440000'
|
|
52
|
-
expect { @prot.write_uuid(uuid) }.not_to raise_error
|
|
53
|
-
result = @prot.read_uuid
|
|
54
|
-
# Result should be lowercase
|
|
55
|
-
expect(result).to eq('550e8400-e29b-41d4-a716-446655440000')
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it 'should accept mixed case UUIDs' do
|
|
59
|
-
uuid = '550e8400-E29B-41d4-A716-446655440000'
|
|
60
|
-
expect { @prot.write_uuid(uuid) }.not_to raise_error
|
|
61
|
-
result = @prot.read_uuid
|
|
62
|
-
expect(result).to eq('550e8400-e29b-41d4-a716-446655440000')
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it 'should accept all zeros' do
|
|
66
|
-
uuid = '00000000-0000-0000-0000-000000000000'
|
|
67
|
-
expect { @prot.write_uuid(uuid) }.not_to raise_error
|
|
68
|
-
result = @prot.read_uuid
|
|
69
|
-
expect(result).to eq(uuid)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it 'should accept all fs' do
|
|
73
|
-
uuid = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
|
|
74
|
-
expect { @prot.write_uuid(uuid) }.not_to raise_error
|
|
75
|
-
result = @prot.read_uuid
|
|
76
|
-
expect(result).to eq(uuid)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context 'invalid UUIDs' do
|
|
81
|
-
def expect_invalid_uuid(value, message)
|
|
82
|
-
expect { @prot.write_uuid(value) }.to raise_error(Thrift::ProtocolException) do |error|
|
|
83
|
-
expect(error.type).to eq(Thrift::ProtocolException::INVALID_DATA)
|
|
84
|
-
expect(error.message).to eq(message)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
it 'should reject nil' do
|
|
89
|
-
expect_invalid_uuid(nil, 'UUID must be a string')
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it 'should reject non-string' do
|
|
93
|
-
expect_invalid_uuid(12345, 'UUID must be a string')
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it 'should reject wrong length' do
|
|
97
|
-
expect_invalid_uuid('550e8400-e29b-41d4-a716', 'Invalid UUID format')
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it 'should reject missing hyphens' do
|
|
101
|
-
expect_invalid_uuid('550e8400e29b41d4a716446655440000', 'Invalid UUID format')
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it 'should reject hyphens in wrong positions' do
|
|
105
|
-
expect_invalid_uuid('550e840-0e29b-41d4-a716-446655440000', 'Invalid UUID format')
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it 'should reject invalid hex characters (g)' do
|
|
109
|
-
expect_invalid_uuid('550e8400-e29b-41d4-a716-44665544000g', 'Invalid UUID format')
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
it 'should reject invalid hex characters (z)' do
|
|
113
|
-
expect_invalid_uuid('z50e8400-e29b-41d4-a716-446655440000', 'Invalid UUID format')
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it 'should reject invalid hex characters (space)' do
|
|
117
|
-
expect_invalid_uuid('550e8400-e29b-41d4-a716-44665544000 ', 'Invalid UUID format')
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it 'should reject empty string' do
|
|
121
|
-
expect_invalid_uuid('', 'Invalid UUID format')
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it 'should reject UUID with extra characters' do
|
|
125
|
-
expect_invalid_uuid('550e8400-e29b-41d4-a716-446655440000x', 'Invalid UUID format')
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it 'should reject trailing hyphen' do
|
|
129
|
-
expect_invalid_uuid('550e8400-e29b-41d4-a716-44665544000-', 'Invalid UUID format')
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
it 'should reject hyphen inside hex pair' do
|
|
133
|
-
expect_invalid_uuid('550e8400-e29b-41d4-a716-4466-5544000', 'Invalid UUID format')
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
context 'malformed binary data on read' do
|
|
138
|
-
it 'should raise error on truncated data' do
|
|
139
|
-
@trans = Thrift::MemoryBufferTransport.new
|
|
140
|
-
@prot = protocol_class.new(@trans)
|
|
141
|
-
|
|
142
|
-
# Write only 10 bytes instead of 16
|
|
143
|
-
if protocol_class == Thrift::JsonProtocol
|
|
144
|
-
@trans.write('"00000000-0000-0000-0000"')
|
|
145
|
-
else
|
|
146
|
-
@trans.write("\x00" * 10)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
expect { @prot.read_uuid }.to raise_error(EOFError)
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
it 'should raise error on 15 bytes (one byte short)' do
|
|
153
|
-
@trans = Thrift::MemoryBufferTransport.new
|
|
154
|
-
@prot = protocol_class.new(@trans)
|
|
155
|
-
|
|
156
|
-
if protocol_class == Thrift::JsonProtocol
|
|
157
|
-
@trans.write('"00000000-0000-0000-0000-000000000"')
|
|
158
|
-
else
|
|
159
|
-
@trans.write("\x00" * 15)
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
expect { @prot.read_uuid }.to raise_error(EOFError)
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
it 'should raise error on empty buffer' do
|
|
166
|
-
@trans = Thrift::MemoryBufferTransport.new
|
|
167
|
-
@prot = protocol_class.new(@trans)
|
|
168
|
-
|
|
169
|
-
expect { @prot.read_uuid }.to raise_error(EOFError)
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
context 'multiple UUIDs in sequence' do
|
|
174
|
-
it 'should handle 10 UUIDs in sequence' do
|
|
175
|
-
uuids = 10.times.map { |i| sprintf('%08x-0000-0000-0000-000000000000', i) }
|
|
176
|
-
|
|
177
|
-
@trans = Thrift::MemoryBufferTransport.new
|
|
178
|
-
@prot = protocol_class.new(@trans)
|
|
179
|
-
|
|
180
|
-
uuids.each { |uuid| @prot.write_uuid(uuid) }
|
|
181
|
-
|
|
182
|
-
results = 10.times.map { @prot.read_uuid }
|
|
183
|
-
expect(results).to eq(uuids)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
it 'should handle UUIDs interleaved with other types' do
|
|
187
|
-
@trans = Thrift::MemoryBufferTransport.new
|
|
188
|
-
@prot = protocol_class.new(@trans)
|
|
189
|
-
|
|
190
|
-
@prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 0)
|
|
191
|
-
@prot.write_i32(42)
|
|
192
|
-
@prot.write_uuid('550e8400-e29b-41d4-a716-446655440000')
|
|
193
|
-
@prot.write_string('test')
|
|
194
|
-
@prot.write_uuid('6ba7b810-9dad-11d1-80b4-00c04fd430c8')
|
|
195
|
-
@prot.write_i64(123456789)
|
|
196
|
-
@prot.write_message_end
|
|
197
|
-
|
|
198
|
-
@prot.read_message_begin
|
|
199
|
-
expect(@prot.read_i32).to eq(42)
|
|
200
|
-
expect(@prot.read_uuid).to eq('550e8400-e29b-41d4-a716-446655440000')
|
|
201
|
-
expect(@prot.read_string).to eq('test')
|
|
202
|
-
expect(@prot.read_uuid).to eq('6ba7b810-9dad-11d1-80b4-00c04fd430c8')
|
|
203
|
-
expect(@prot.read_i64).to eq(123456789)
|
|
204
|
-
@prot.read_message_end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
it 'should handle UUIDs in struct fields context' do
|
|
208
|
-
@trans = Thrift::MemoryBufferTransport.new
|
|
209
|
-
@prot = protocol_class.new(@trans)
|
|
210
|
-
|
|
211
|
-
# Simulate struct field headers
|
|
212
|
-
@prot.write_struct_begin('test')
|
|
213
|
-
@prot.write_field_begin('uuid1', Thrift::Types::UUID, 1)
|
|
214
|
-
@prot.write_uuid('550e8400-e29b-41d4-a716-446655440000')
|
|
215
|
-
@prot.write_field_end
|
|
216
|
-
@prot.write_field_begin('uuid2', Thrift::Types::UUID, 2)
|
|
217
|
-
@prot.write_uuid('6ba7b810-9dad-11d1-80b4-00c04fd430c8')
|
|
218
|
-
@prot.write_field_end
|
|
219
|
-
@prot.write_field_stop
|
|
220
|
-
@prot.write_struct_end
|
|
221
|
-
|
|
222
|
-
@prot.read_struct_begin
|
|
223
|
-
name, type, id = @prot.read_field_begin
|
|
224
|
-
expect(type).to eq(Thrift::Types::UUID)
|
|
225
|
-
expect(@prot.read_uuid).to eq('550e8400-e29b-41d4-a716-446655440000')
|
|
226
|
-
@prot.read_field_end
|
|
227
|
-
|
|
228
|
-
name, type, id = @prot.read_field_begin
|
|
229
|
-
expect(type).to eq(Thrift::Types::UUID)
|
|
230
|
-
expect(@prot.read_uuid).to eq('6ba7b810-9dad-11d1-80b4-00c04fd430c8')
|
|
231
|
-
@prot.read_field_end
|
|
232
|
-
|
|
233
|
-
name, type, id = @prot.read_field_begin
|
|
234
|
-
expect(type).to eq(Thrift::Types::STOP)
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
end
|
|
238
|
-
end
|
|
239
|
-
end
|