mongo 2.1.1 → 2.1.2
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
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/lib/mongo/client.rb +52 -5
- data/lib/mongo/database.rb +2 -2
- data/lib/mongo/grid/fs_bucket.rb +1 -1
- data/lib/mongo/loggable.rb +1 -1
- data/lib/mongo/operation/executable.rb +1 -1
- data/lib/mongo/operation/write/gle.rb +2 -2
- data/lib/mongo/operation/write/write_command_enabled.rb +1 -1
- data/lib/mongo/retryable.rb +3 -1
- data/lib/mongo/server/connectable.rb +4 -4
- data/lib/mongo/server/monitor/connection.rb +17 -0
- data/lib/mongo/socket/ssl.rb +4 -1
- data/lib/mongo/version.rb +1 -1
- data/spec/mongo/client_spec.rb +42 -2
- data/spec/mongo/collection/view/readable_spec.rb +3 -3
- data/spec/mongo/collection_spec.rb +2 -2
- data/spec/mongo/database_spec.rb +12 -0
- data/spec/mongo/operation/result_spec.rb +19 -0
- data/spec/mongo/retryable_spec.rb +2 -2
- data/spec/mongo/server/monitor_spec.rb +23 -0
- data/spec/mongo/socket/ssl_spec.rb +74 -54
- metadata +26 -5
- metadata.gz.sig +0 -0
- data/lib/csasl/csasl.bundle +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5848eb885418bc7cba6b6a44761b1b47f4bbcb7d
|
4
|
+
data.tar.gz: fa960cc01b750a11b49a30a64cc602a6b665898e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6809a0802bba0bc3bd58d45dff14a15f6bddf4194deaa4063fadebf27bcb1a3af451c28f1076d5094ab18a65522b5571ca62bd5e2ff3baaf3d583e3962ec1c
|
7
|
+
data.tar.gz: da274d6b705a440c81d7fb9f09a413ef3a200ca1af858c1eb0b82db1a4ffd95edba29d07872e031440c5822bcac4114cabf40b3b3b32d1af349e4d80452fdb28
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
data/lib/mongo/client.rb
CHANGED
@@ -20,6 +20,7 @@ module Mongo
|
|
20
20
|
# @since 2.0.0
|
21
21
|
class Client
|
22
22
|
extend Forwardable
|
23
|
+
include Loggable
|
23
24
|
|
24
25
|
# The options that do not affect the behaviour of a cluster and its
|
25
26
|
# subcomponents.
|
@@ -27,6 +28,40 @@ module Mongo
|
|
27
28
|
# @since 2.1.0
|
28
29
|
CRUD_OPTIONS = [ :database, :read, :write ].freeze
|
29
30
|
|
31
|
+
# Valid client options.
|
32
|
+
#
|
33
|
+
# @since 2.1.2
|
34
|
+
VALID_OPTIONS = [
|
35
|
+
:auth_mech,
|
36
|
+
:auth_source,
|
37
|
+
:connect,
|
38
|
+
:database,
|
39
|
+
:auth_mech_properties,
|
40
|
+
:heartbeat_frequency,
|
41
|
+
:local_threshold,
|
42
|
+
:server_selection_timeout,
|
43
|
+
:password,
|
44
|
+
:max_pool_size,
|
45
|
+
:min_pool_size,
|
46
|
+
:wait_queue_timeout,
|
47
|
+
:connect_timeout,
|
48
|
+
:read,
|
49
|
+
:roles,
|
50
|
+
:replica_set,
|
51
|
+
:ssl,
|
52
|
+
:ssl_cert,
|
53
|
+
:ssl_key,
|
54
|
+
:ssl_key_pass_phrase,
|
55
|
+
:ssl_verify,
|
56
|
+
:ssl_ca_cert,
|
57
|
+
:socket_timeout,
|
58
|
+
:user,
|
59
|
+
:write,
|
60
|
+
:monitoring,
|
61
|
+
:logger,
|
62
|
+
:truncate_logs
|
63
|
+
].freeze
|
64
|
+
|
30
65
|
# @return [ Mongo::Cluster ] cluster The cluster of servers for the client.
|
31
66
|
attr_reader :cluster
|
32
67
|
|
@@ -160,9 +195,9 @@ module Mongo
|
|
160
195
|
def initialize(addresses_or_uri, options = Options::Redacted.new)
|
161
196
|
@monitoring = Monitoring.new(options)
|
162
197
|
if addresses_or_uri.is_a?(::String)
|
163
|
-
create_from_uri(addresses_or_uri, options)
|
198
|
+
create_from_uri(addresses_or_uri, validate_options(options))
|
164
199
|
else
|
165
|
-
create_from_addresses(addresses_or_uri, options)
|
200
|
+
create_from_addresses(addresses_or_uri, validate_options(options))
|
166
201
|
end
|
167
202
|
yield(self) if block_given?
|
168
203
|
end
|
@@ -221,7 +256,7 @@ module Mongo
|
|
221
256
|
# @since 2.0.0
|
222
257
|
def with(new_options = Options::Redacted.new)
|
223
258
|
clone.tap do |client|
|
224
|
-
opts =
|
259
|
+
opts = validate_options(new_options)
|
225
260
|
client.options.update(opts)
|
226
261
|
Database.create(client)
|
227
262
|
# We can't use the same cluster if some options that would affect it
|
@@ -296,14 +331,14 @@ module Mongo
|
|
296
331
|
private
|
297
332
|
|
298
333
|
def create_from_addresses(addresses, opts = Options::Redacted.new)
|
299
|
-
@options =
|
334
|
+
@options = Database::DEFAULT_OPTIONS.merge(opts).freeze
|
300
335
|
@cluster = Cluster.new(addresses, @monitoring, options)
|
301
336
|
@database = Database.new(self, options[:database], options)
|
302
337
|
end
|
303
338
|
|
304
339
|
def create_from_uri(connection_string, opts = Options::Redacted.new)
|
305
340
|
uri = URI.new(connection_string, opts)
|
306
|
-
@options =
|
341
|
+
@options = Database::DEFAULT_OPTIONS.merge(uri.client_options.merge(opts)).freeze
|
307
342
|
@cluster = Cluster.new(uri.servers, @monitoring, options)
|
308
343
|
@database = Database.new(self, options[:database], options)
|
309
344
|
end
|
@@ -324,5 +359,17 @@ module Mongo
|
|
324
359
|
options[name] != value
|
325
360
|
end
|
326
361
|
end
|
362
|
+
|
363
|
+
def validate_options(opts = Options::Redacted.new)
|
364
|
+
return Options::Redacted.new unless opts
|
365
|
+
Options::Redacted.new(opts.select do |o|
|
366
|
+
if VALID_OPTIONS.include?(o)
|
367
|
+
true
|
368
|
+
else
|
369
|
+
log_warn("Unsupported client option '#{o}'. It will be ignored.")
|
370
|
+
false
|
371
|
+
end
|
372
|
+
end)
|
373
|
+
end
|
327
374
|
end
|
328
375
|
end
|
data/lib/mongo/database.rb
CHANGED
@@ -148,8 +148,8 @@ module Mongo
|
|
148
148
|
#
|
149
149
|
# @return [ Hash ] The result of the command execution.
|
150
150
|
def command(operation, opts = {})
|
151
|
-
preference =
|
152
|
-
server = preference.select_server(cluster)
|
151
|
+
preference = ServerSelector.get(client.options.merge(opts[:read])) if opts[:read]
|
152
|
+
server = preference ? preference.select_server(cluster) : cluster.next_primary
|
153
153
|
Operation::Command.new({
|
154
154
|
:selector => operation,
|
155
155
|
:db_name => name,
|
data/lib/mongo/grid/fs_bucket.rb
CHANGED
@@ -438,7 +438,7 @@ module Mongo
|
|
438
438
|
end
|
439
439
|
|
440
440
|
def ensure_indexes!
|
441
|
-
if files_collection.find({}, projection: { _id: 1 }).
|
441
|
+
if files_collection.find({}, limit: 1, projection: { _id: 1 }).first.nil?
|
442
442
|
chunks_collection.indexes.create_one(FSBucket::CHUNKS_INDEX, :unique => true)
|
443
443
|
files_collection.indexes.create_one(FSBucket::FILES_INDEX)
|
444
444
|
end
|
data/lib/mongo/loggable.rb
CHANGED
@@ -32,7 +32,7 @@ module Mongo
|
|
32
32
|
# @since 2.0.0
|
33
33
|
def execute(context)
|
34
34
|
context.with_connection do |connection|
|
35
|
-
result_class =
|
35
|
+
result_class = self.class.const_defined?(:Result, false) ? self.class::Result : Result
|
36
36
|
result_class.new(connection.dispatch([ message(context) ], operation_id)).validate!
|
37
37
|
end
|
38
38
|
end
|
@@ -26,8 +26,8 @@ module Mongo
|
|
26
26
|
|
27
27
|
def execute_message(context)
|
28
28
|
context.with_connection do |connection|
|
29
|
-
result_class =
|
30
|
-
|
29
|
+
result_class = self.class.const_defined?(:LegacyResult, false) ? self.class::LegacyResult :
|
30
|
+
self.class.const_defined?(:Result, false) ? self.class::Result : Result
|
31
31
|
result_class.new(connection.dispatch([ message, gle ].compact)).validate!
|
32
32
|
end
|
33
33
|
end
|
@@ -44,7 +44,7 @@ module Mongo
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def execute_write_command(context)
|
47
|
-
result_class =
|
47
|
+
result_class = self.class.const_defined?(:Result, false) ? self.class::Result : Result
|
48
48
|
result_class.new(write_command_op.execute(context)).validate!
|
49
49
|
end
|
50
50
|
end
|
data/lib/mongo/retryable.rb
CHANGED
@@ -52,7 +52,9 @@ module Mongo
|
|
52
52
|
# We don't scan the cluster in this case as Mongos always returns
|
53
53
|
# ready after a ping no matter what the state behind it is.
|
54
54
|
sleep(cluster.read_retry_interval)
|
55
|
-
read_with_retry(attempt
|
55
|
+
read_with_retry(attempt + 1, &block)
|
56
|
+
else
|
57
|
+
raise e
|
56
58
|
end
|
57
59
|
else
|
58
60
|
raise e
|
@@ -25,7 +25,7 @@ module Mongo
|
|
25
25
|
# @since 2.1.0
|
26
26
|
SSL = 'ssl'.freeze
|
27
27
|
|
28
|
-
# The default time in seconds to timeout a
|
28
|
+
# The default time in seconds to timeout an operation executed on a socket.
|
29
29
|
#
|
30
30
|
# @since 2.0.0
|
31
31
|
TIMEOUT = 5.freeze
|
@@ -64,12 +64,12 @@ module Mongo
|
|
64
64
|
!!@socket && @socket.alive?
|
65
65
|
end
|
66
66
|
|
67
|
-
# Get the
|
67
|
+
# Get the timeout to execute an operation on a socket.
|
68
68
|
#
|
69
|
-
# @example Get the
|
69
|
+
# @example Get the timeout to execute an operation on a socket.
|
70
70
|
# connection.timeout
|
71
71
|
#
|
72
|
-
# @return [ Float ] The
|
72
|
+
# @return [ Float ] The operation timeout in seconds.
|
73
73
|
#
|
74
74
|
# @since 2.0.0
|
75
75
|
def timeout
|
@@ -22,6 +22,23 @@ module Mongo
|
|
22
22
|
class Connection
|
23
23
|
include Connectable
|
24
24
|
|
25
|
+
# The default time in seconds to timeout a connection attempt.
|
26
|
+
#
|
27
|
+
# @since 2.1.2
|
28
|
+
CONNECT_TIMEOUT = 10.freeze
|
29
|
+
|
30
|
+
# Get the connection timeout.
|
31
|
+
#
|
32
|
+
# @example Get the connection timeout.
|
33
|
+
# connection.timeout
|
34
|
+
#
|
35
|
+
# @return [ Float ] The connection timeout in seconds.
|
36
|
+
#
|
37
|
+
# @since 2.0.0
|
38
|
+
def timeout
|
39
|
+
@timeout ||= options[:connect_timeout] || CONNECT_TIMEOUT
|
40
|
+
end
|
41
|
+
|
25
42
|
# Tell the underlying socket to establish a connection to the host.
|
26
43
|
#
|
27
44
|
# @example Connect to the host.
|
data/lib/mongo/socket/ssl.rb
CHANGED
data/lib/mongo/version.rb
CHANGED
data/spec/mongo/client_spec.rb
CHANGED
@@ -166,7 +166,7 @@ describe Mongo::Client do
|
|
166
166
|
described_class.new(
|
167
167
|
['127.0.0.1:27017'],
|
168
168
|
:read => { :mode => :primary },
|
169
|
-
:
|
169
|
+
:local_threshold => 10,
|
170
170
|
:server_selection_timeout => 10000,
|
171
171
|
:database => TEST_DB
|
172
172
|
)
|
@@ -174,7 +174,7 @@ describe Mongo::Client do
|
|
174
174
|
|
175
175
|
let(:options) do
|
176
176
|
Mongo::Options::Redacted.new(:read => { :mode => :primary },
|
177
|
-
:
|
177
|
+
:local_threshold => 10,
|
178
178
|
:server_selection_timeout => 10000,
|
179
179
|
:database => TEST_DB)
|
180
180
|
end
|
@@ -373,6 +373,26 @@ describe Mongo::Client do
|
|
373
373
|
expect(client.cluster.topology).to be_a(Mongo::Cluster::Topology::ReplicaSet)
|
374
374
|
end
|
375
375
|
end
|
376
|
+
|
377
|
+
context 'when an invalid option is provided' do
|
378
|
+
|
379
|
+
let(:client) do
|
380
|
+
described_class.new(['127.0.0.1:27017'], :ssl => false, :invalid => :test)
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'does not set the option' do
|
384
|
+
expect(client.options.keys).not_to include('invalid')
|
385
|
+
end
|
386
|
+
|
387
|
+
it 'sets the valid options' do
|
388
|
+
expect(client.options.keys).to include('ssl')
|
389
|
+
end
|
390
|
+
|
391
|
+
it 'warns that an invalid option has been specified' do
|
392
|
+
expect(Mongo::Logger.logger).to receive(:warn)
|
393
|
+
expect(client.options.keys).not_to include('invalid')
|
394
|
+
end
|
395
|
+
end
|
376
396
|
end
|
377
397
|
end
|
378
398
|
|
@@ -624,6 +644,26 @@ describe Mongo::Client do
|
|
624
644
|
end
|
625
645
|
end
|
626
646
|
end
|
647
|
+
|
648
|
+
context 'when an invalid option is provided' do
|
649
|
+
|
650
|
+
let(:new_client) do
|
651
|
+
client.with(invalid: :option, ssl: false)
|
652
|
+
end
|
653
|
+
|
654
|
+
it 'does not set the invalid option' do
|
655
|
+
expect(new_client.options.keys).not_to include('invalid')
|
656
|
+
end
|
657
|
+
|
658
|
+
it 'sets the valid options' do
|
659
|
+
expect(new_client.options.keys).to include('ssl')
|
660
|
+
end
|
661
|
+
|
662
|
+
it 'warns that an invalid option has been specified' do
|
663
|
+
expect(Mongo::Logger.logger).to receive(:warn)
|
664
|
+
expect(new_client.options.keys).not_to include('invalid')
|
665
|
+
end
|
666
|
+
end
|
627
667
|
end
|
628
668
|
|
629
669
|
describe '#write_concern' do
|
@@ -322,7 +322,7 @@ describe Mongo::Collection::View::Readable do
|
|
322
322
|
end
|
323
323
|
|
324
324
|
it 'returns the distinct values' do
|
325
|
-
expect(distinct).to eq([ 'test1', 'test2', 'test3' ])
|
325
|
+
expect(distinct.sort).to eq([ 'test1', 'test2', 'test3' ])
|
326
326
|
end
|
327
327
|
end
|
328
328
|
|
@@ -333,7 +333,7 @@ describe Mongo::Collection::View::Readable do
|
|
333
333
|
end
|
334
334
|
|
335
335
|
it 'returns the distinct values' do
|
336
|
-
expect(distinct).to eq([ 'test1', 'test2', 'test3' ])
|
336
|
+
expect(distinct.sort).to eq([ 'test1', 'test2', 'test3' ])
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
@@ -364,7 +364,7 @@ describe Mongo::Collection::View::Readable do
|
|
364
364
|
end
|
365
365
|
|
366
366
|
it 'returns the distinct values' do
|
367
|
-
expect(distinct).to eq([ 'test1', 'test2', 'test3' ])
|
367
|
+
expect(distinct.sort).to eq([ 'test1', 'test2', 'test3' ])
|
368
368
|
end
|
369
369
|
end
|
370
370
|
|
@@ -822,7 +822,7 @@ describe Mongo::Collection do
|
|
822
822
|
end
|
823
823
|
|
824
824
|
it 'returns the distinct values' do
|
825
|
-
expect(authorized_collection.distinct(:field)).to eq([ 'test1', 'test2', 'test3' ])
|
825
|
+
expect(authorized_collection.distinct(:field).sort).to eq([ 'test1', 'test2', 'test3' ])
|
826
826
|
end
|
827
827
|
|
828
828
|
context 'when a selector is provided' do
|
@@ -835,7 +835,7 @@ describe Mongo::Collection do
|
|
835
835
|
context 'when options are provided' do
|
836
836
|
|
837
837
|
it 'passes the options to the distinct command' do
|
838
|
-
expect(authorized_collection.distinct(:field, {}, max_time_ms: 100)).to eq([ 'test1', 'test2', 'test3' ])
|
838
|
+
expect(authorized_collection.distinct(:field, {}, max_time_ms: 100).sort).to eq([ 'test1', 'test2', 'test3' ])
|
839
839
|
end
|
840
840
|
end
|
841
841
|
end
|
data/spec/mongo/database_spec.rb
CHANGED
@@ -228,6 +228,18 @@ describe Mongo::Database do
|
|
228
228
|
end.to raise_error(Mongo::Error::NoServerAvailable)
|
229
229
|
end
|
230
230
|
end
|
231
|
+
|
232
|
+
context 'when there is a read preference set on the client' do
|
233
|
+
|
234
|
+
let(:database) do
|
235
|
+
described_class.new(authorized_client.with(read: { mode: :secondary }), TEST_DB)
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'does not use the read preference' do
|
239
|
+
expect(database.client.cluster).to receive(:next_primary).and_call_original
|
240
|
+
database.command(ping: 1)
|
241
|
+
end
|
242
|
+
end
|
231
243
|
end
|
232
244
|
|
233
245
|
describe '#drop' do
|
@@ -272,4 +272,23 @@ describe Mongo::Operation::Result do
|
|
272
272
|
end
|
273
273
|
end
|
274
274
|
end
|
275
|
+
|
276
|
+
context 'when there is a top-level Result class defined' do
|
277
|
+
|
278
|
+
before do
|
279
|
+
class Result
|
280
|
+
def get_result
|
281
|
+
Mongo::Client.new([DEFAULT_ADDRESS], TEST_OPTIONS).database.command(:ping => 1)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
let(:result) do
|
287
|
+
Result.new.get_result
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'uses the Result class of the operation' do
|
291
|
+
expect(result).to be_a(Mongo::Operation::Result)
|
292
|
+
end
|
293
|
+
end
|
275
294
|
end
|
@@ -149,11 +149,11 @@ describe Mongo::Retryable do
|
|
149
149
|
before do
|
150
150
|
expect(operation).to receive(:execute).and_raise(error).ordered
|
151
151
|
expect(cluster).to receive(:sharded?).and_return(true)
|
152
|
-
expect(cluster).to receive(:max_read_retries).and_return(
|
152
|
+
expect(cluster).to receive(:max_read_retries).and_return(2).ordered
|
153
153
|
expect(cluster).to receive(:read_retry_interval).and_return(0.1).ordered
|
154
154
|
expect(operation).to receive(:execute).and_raise(error).ordered
|
155
155
|
expect(cluster).to receive(:sharded?).and_return(true)
|
156
|
-
expect(cluster).to receive(:max_read_retries).and_return(
|
156
|
+
expect(cluster).to receive(:max_read_retries).and_return(2).ordered
|
157
157
|
expect(cluster).to receive(:read_retry_interval).and_return(0.1).ordered
|
158
158
|
expect(operation).to receive(:execute).and_return(true).ordered
|
159
159
|
end
|
@@ -192,4 +192,27 @@ describe Mongo::Server::Monitor do
|
|
192
192
|
expect(thread.stop?).to be(true)
|
193
193
|
end
|
194
194
|
end
|
195
|
+
|
196
|
+
describe '#connection' do
|
197
|
+
|
198
|
+
context 'when there is a connect_timeout option set' do
|
199
|
+
|
200
|
+
let(:connect_timeout) do
|
201
|
+
1
|
202
|
+
end
|
203
|
+
|
204
|
+
let(:monitor) do
|
205
|
+
described_class.new(address, listeners, TEST_OPTIONS.merge(connect_timeout: connect_timeout))
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'sets the value as the timeout on the connection' do
|
209
|
+
expect(monitor.connection.timeout).to eq(connect_timeout)
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'set the value as the timeout on the socket' do
|
213
|
+
monitor.connection.connect!
|
214
|
+
expect(monitor.connection.send(:socket).timeout).to eq(connect_timeout)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
195
218
|
end
|
@@ -1,24 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Socket::SSL do
|
3
|
+
describe Mongo::Socket::SSL, if: running_ssl? do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
described_class.new(*DEFAULT_ADDRESS.split(":"), DEFAULT_ADDRESS.split(":")[0], 5, Socket::PF_INET, options)
|
9
|
-
end
|
5
|
+
let(:socket) do
|
6
|
+
described_class.new(*DEFAULT_ADDRESS.split(":"), DEFAULT_ADDRESS.split(":")[0], 5, Socket::PF_INET, options)
|
7
|
+
end
|
10
8
|
|
11
|
-
|
9
|
+
let(:options) do
|
10
|
+
{
|
11
|
+
:ssl => true,
|
12
|
+
:ssl_cert => CLIENT_PEM,
|
13
|
+
:ssl_key => CLIENT_PEM,
|
14
|
+
:ssl_verify => false
|
15
|
+
}
|
16
|
+
end
|
12
17
|
|
13
|
-
|
14
|
-
{
|
15
|
-
:ssl => true,
|
16
|
-
:ssl_cert => CLIENT_PEM,
|
17
|
-
:ssl_key => CLIENT_PEM,
|
18
|
-
:ssl_verify => false
|
19
|
-
}
|
20
|
-
end
|
18
|
+
describe '#connect!' do
|
21
19
|
|
20
|
+
context 'when a certificate is provided' do
|
22
21
|
|
23
22
|
context 'when connecting the tcp socket is successful' do
|
24
23
|
|
@@ -55,12 +54,9 @@ describe Mongo::Socket::SSL do
|
|
55
54
|
context 'when a bad certificate is provided' do
|
56
55
|
|
57
56
|
let(:options) do
|
58
|
-
{
|
59
|
-
|
60
|
-
|
61
|
-
:ssl_key => CRL_PEM,
|
62
|
-
:ssl_verify => false
|
63
|
-
}
|
57
|
+
super().merge({
|
58
|
+
:ssl_key => CRL_PEM
|
59
|
+
})
|
64
60
|
end
|
65
61
|
|
66
62
|
it 'raises an exception' do
|
@@ -73,13 +69,10 @@ describe Mongo::Socket::SSL do
|
|
73
69
|
context 'when a CA certificate is provided', if: testing_ssl_locally? do
|
74
70
|
|
75
71
|
let(:options) do
|
76
|
-
{
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
:ssl_ca_cert => CA_PEM,
|
81
|
-
:ssl_verify => true
|
82
|
-
}
|
72
|
+
super().merge({
|
73
|
+
:ssl_ca_cert => CA_PEM,
|
74
|
+
:ssl_verify => true
|
75
|
+
})
|
83
76
|
end
|
84
77
|
|
85
78
|
before do
|
@@ -94,12 +87,9 @@ describe Mongo::Socket::SSL do
|
|
94
87
|
context 'when a CA certificate is not provided', if: testing_ssl_locally? do
|
95
88
|
|
96
89
|
let(:options) do
|
97
|
-
{
|
98
|
-
|
99
|
-
|
100
|
-
:ssl_key => CLIENT_PEM,
|
101
|
-
:ssl_verify => true
|
102
|
-
}
|
90
|
+
super().merge({
|
91
|
+
:ssl_verify => true
|
92
|
+
})
|
103
93
|
end
|
104
94
|
|
105
95
|
before do
|
@@ -115,12 +105,9 @@ describe Mongo::Socket::SSL do
|
|
115
105
|
context 'when ssl_verify is not specified', if: testing_ssl_locally? do
|
116
106
|
|
117
107
|
let(:options) do
|
118
|
-
{
|
119
|
-
|
120
|
-
|
121
|
-
:ssl_key => CLIENT_PEM,
|
122
|
-
:ssl_ca_cert => CA_PEM
|
123
|
-
}
|
108
|
+
super().merge({
|
109
|
+
:ssl_ca_cert => CA_PEM
|
110
|
+
}).tap { |options| options.delete(:ssl_verify) }
|
124
111
|
end
|
125
112
|
|
126
113
|
before do
|
@@ -135,13 +122,10 @@ describe Mongo::Socket::SSL do
|
|
135
122
|
context 'when ssl_verify is true', if: testing_ssl_locally? do
|
136
123
|
|
137
124
|
let(:options) do
|
138
|
-
{
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
:ssl_ca_cert => CA_PEM,
|
143
|
-
:ssl_verify => true
|
144
|
-
}
|
125
|
+
super().merge({
|
126
|
+
:ssl_ca_cert => CA_PEM,
|
127
|
+
:ssl_verify => true
|
128
|
+
})
|
145
129
|
end
|
146
130
|
|
147
131
|
before do
|
@@ -156,13 +140,10 @@ describe Mongo::Socket::SSL do
|
|
156
140
|
context 'when ssl_verify is false' do
|
157
141
|
|
158
142
|
let(:options) do
|
159
|
-
{
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
:ssl_ca_cert => 'invalid',
|
164
|
-
:ssl_verify => false
|
165
|
-
}
|
143
|
+
super().merge({
|
144
|
+
:ssl_ca_cert => 'invalid',
|
145
|
+
:ssl_verify => false
|
146
|
+
})
|
166
147
|
end
|
167
148
|
|
168
149
|
before do
|
@@ -174,4 +155,43 @@ describe Mongo::Socket::SSL do
|
|
174
155
|
end
|
175
156
|
end
|
176
157
|
end
|
158
|
+
|
159
|
+
describe '#readbyte' do
|
160
|
+
|
161
|
+
before do
|
162
|
+
allow_message_expectations_on_nil
|
163
|
+
|
164
|
+
allow(socket.socket).to receive(:read) do |length|
|
165
|
+
socket_content[0, length]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context 'with the socket providing "abc"' do
|
170
|
+
|
171
|
+
let(:socket_content) { "abc" }
|
172
|
+
|
173
|
+
it 'should return 97 (the byte for "a")' do
|
174
|
+
expect(socket.readbyte).to eq(97)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context 'with the socket providing "\x00" (NULL_BYTE)' do
|
179
|
+
|
180
|
+
let(:socket_content) { "\x00" }
|
181
|
+
|
182
|
+
it 'should return 0' do
|
183
|
+
expect(socket.readbyte).to eq(0)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
context 'with the socket providing no data' do
|
188
|
+
|
189
|
+
let(:socket_content) { "" }
|
190
|
+
|
191
|
+
it 'should raise EOFError' do
|
192
|
+
expect { socket.readbyte }
|
193
|
+
.to raise_error(Mongo::Error::SocketError).with_message("EOFError")
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
177
197
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -9,8 +9,30 @@ authors:
|
|
9
9
|
- Durran Jordan
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
|
-
cert_chain:
|
13
|
-
|
12
|
+
cert_chain:
|
13
|
+
- |
|
14
|
+
-----BEGIN CERTIFICATE-----
|
15
|
+
MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
|
16
|
+
ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
|
17
|
+
Y29tMB4XDTE0MTEyMDE1NTYxOVoXDTE1MTEyMDE1NTYxOVowQjEUMBIGA1UEAwwL
|
18
|
+
ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZAEZFgUxMGdlbjETMBEGCgmSJomT8ixk
|
19
|
+
ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANFdSAa8fRm1
|
20
|
+
bAM9za6Z0fAH4g02bqM1NGnw8zJQrE/PFrFfY6IFCT2AsLfOwr1maVm7iU1+kdVI
|
21
|
+
IQ+iI/9+E+ArJ+rbGV3dDPQ+SLl3mLT+vXjfjcxMqI2IW6UuVtt2U3Rxd4QU0kdT
|
22
|
+
JxmcPYs5fDN6BgYc6XXgUjy3m+Kwha2pGctdciUOwEfOZ4RmNRlEZKCMLRHdFP8j
|
23
|
+
4WTnJSGfXDiuoXICJb5yOPOZPuaapPSNXp93QkUdsqdKC32I+KMpKKYGBQ6yisfA
|
24
|
+
5MyVPPCzLR1lP5qXVGJPnOqUAkvEUfCahg7EP9tI20qxiXrR6TSEraYhIFXL0EGY
|
25
|
+
u8KAcPHm5KkCAwEAAaN9MHswCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
26
|
+
BBYEFFt3WbF+9JpUjAoj62cQBgNb8HzXMCAGA1UdEQQZMBeBFWRyaXZlci1ydWJ5
|
27
|
+
QDEwZ2VuLmNvbTAgBgNVHRIEGTAXgRVkcml2ZXItcnVieUAxMGdlbi5jb20wDQYJ
|
28
|
+
KoZIhvcNAQEFBQADggEBAKjvumG2Fy9zAoSc1OEcmAqqOfzx1U+isGyEsz1rs5eT
|
29
|
+
HAIHsxaEdZTjSwDuqyelLDWJHWspeWU5pV5lepfI4cop29wwoPJIJ9Az2RMMbtdv
|
30
|
+
gFApVb6QX61OMenFeOdJ/QZ3n9xcrxJZFdvrXQ5GjEU2anq3dJhFeESwIMlfVJC7
|
31
|
+
7XrlMxizzH712DPfy65dMj0Y39qHdoWYKeCkEoj5UWNcHRK9xgaHJR6prlXrIhgb
|
32
|
+
o2UXDbWtz5PqoFd8EgNJAn3+BG1pwC9S9pVFG3WPucfAx/bE8iq/vvchHei5Y/Vo
|
33
|
+
aAz5f/hY4zFeYWvGDBHYEXE1rTN2hhMSyJscPcFbmz0=
|
34
|
+
-----END CERTIFICATE-----
|
35
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
14
36
|
dependencies:
|
15
37
|
- !ruby/object:Gem::Dependency
|
16
38
|
name: bson
|
@@ -37,7 +59,6 @@ files:
|
|
37
59
|
- README.md
|
38
60
|
- Rakefile
|
39
61
|
- bin/mongo_console
|
40
|
-
- lib/csasl/csasl.bundle
|
41
62
|
- lib/mongo.rb
|
42
63
|
- lib/mongo/address.rb
|
43
64
|
- lib/mongo/address/ipv4.rb
|
@@ -521,7 +542,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
521
542
|
version: '0'
|
522
543
|
requirements: []
|
523
544
|
rubyforge_project: mongo
|
524
|
-
rubygems_version: 2.4.
|
545
|
+
rubygems_version: 2.4.8
|
525
546
|
signing_key:
|
526
547
|
specification_version: 4
|
527
548
|
summary: Ruby driver for MongoDB
|
metadata.gz.sig
ADDED
Binary file
|
data/lib/csasl/csasl.bundle
DELETED
Binary file
|