mongo 2.6.1 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -1
- data.tar.gz.sig +0 -0
- data/lib/mongo/client.rb +27 -16
- data/lib/mongo/cluster/topology/replica_set.rb +15 -3
- data/lib/mongo/error/lint_error.rb +1 -1
- data/lib/mongo/server/description.rb +1 -1
- data/lib/mongo/version.rb +1 -1
- data/spec/{mongo → integration}/change_stream_examples_spec.rb +0 -0
- data/spec/{mongo → integration}/docs_examples_spec.rb +0 -0
- data/spec/integration/reconnect_spec.rb +31 -0
- data/spec/{mongo → integration}/retryable_writes_spec.rb +0 -0
- data/spec/{mongo → integration}/shell_examples_spec.rb +0 -0
- data/spec/{mongo → integration}/transactions_examples_spec.rb +46 -61
- data/spec/lite_spec_helper.rb +7 -2
- data/spec/mongo/address/unix_spec.rb +1 -1
- data/spec/mongo/address_spec.rb +10 -10
- data/spec/mongo/auth/scram/conversation_spec.rb +2 -1
- data/spec/mongo/auth/scram/negotiation_spec.rb +6 -5
- data/spec/mongo/auth/scram_spec.rb +5 -4
- data/spec/mongo/bulk_write_spec.rb +3 -2
- data/spec/mongo/client_spec.rb +15 -7
- data/spec/mongo/cluster/topology/replica_set_spec.rb +46 -10
- data/spec/mongo/cluster_spec.rb +3 -3
- data/spec/mongo/collection/view/aggregation_spec.rb +2 -1
- data/spec/mongo/collection/view/readable_spec.rb +2 -1
- data/spec/mongo/collection_spec.rb +40 -23
- data/spec/mongo/database_spec.rb +3 -3
- data/spec/mongo/index/view_spec.rb +4 -2
- data/spec/mongo/server/connection_pool_spec.rb +1 -1
- data/spec/mongo/socket/ssl_spec.rb +3 -3
- data/spec/mongo/socket/unix_spec.rb +1 -1
- data/spec/mongo/socket_spec.rb +2 -2
- data/spec/mongo/uri/srv_protocol_spec.rb +2 -1
- data/spec/mongo/uri_spec.rb +6 -5
- data/spec/spec_helper.rb +7 -28
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +61 -63
- data/spec/spec_tests/sdam_monitoring_spec.rb +10 -7
- data/spec/{mongo → spec_tests}/transactions_spec.rb +8 -3
- data/spec/support/authorization.rb +10 -55
- data/spec/support/constraints.rb +34 -10
- data/spec/support/lite_constraints.rb +18 -0
- data/spec/support/sdam/rs/secondary_ignore_ok_0.yml +85 -0
- data/spec/support/spec_config.rb +73 -0
- data/spec/support/transactions.rb +1 -1
- metadata +170 -162
- metadata.gz.sig +1 -2
data/spec/mongo/database_spec.rb
CHANGED
@@ -279,7 +279,8 @@ describe Mongo::Database do
|
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
282
|
-
context 'when a read concern is provided'
|
282
|
+
context 'when a read concern is provided' do
|
283
|
+
min_server_version '3.2'
|
283
284
|
|
284
285
|
context 'when the read concern is valid' do
|
285
286
|
|
@@ -291,8 +292,7 @@ describe Mongo::Database do
|
|
291
292
|
end
|
292
293
|
|
293
294
|
context 'when the read concern is not valid' do
|
294
|
-
|
295
|
-
it 'raises an exception', if: (find_command_enabled? && !sharded?) do
|
295
|
+
it 'raises an exception', if: !sharded? do
|
296
296
|
expect {
|
297
297
|
database.command(:ismaster => 1, readConcern: { level: 'yay' })
|
298
298
|
}.to raise_error(Mongo::Error::OperationFailure)
|
@@ -663,7 +663,8 @@ describe Mongo::Index::View do
|
|
663
663
|
end
|
664
664
|
end
|
665
665
|
|
666
|
-
context 'when providing an invalid partial index filter'
|
666
|
+
context 'when providing an invalid partial index filter' do
|
667
|
+
min_server_version '3.2'
|
667
668
|
|
668
669
|
it 'raises an exception' do
|
669
670
|
expect {
|
@@ -672,7 +673,8 @@ describe Mongo::Index::View do
|
|
672
673
|
end
|
673
674
|
end
|
674
675
|
|
675
|
-
context 'when providing a valid partial index filter'
|
676
|
+
context 'when providing a valid partial index filter' do
|
677
|
+
min_server_version '3.2'
|
676
678
|
|
677
679
|
let(:expression) do
|
678
680
|
{'a' => {'$lte' => 1.5}}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Socket::SSL, if:
|
3
|
+
describe Mongo::Socket::SSL, if: SpecConfig.instance.ssl? do
|
4
4
|
|
5
5
|
let(:address) do
|
6
6
|
default_address
|
@@ -278,7 +278,7 @@ describe Mongo::Socket::SSL, if: running_ssl? do
|
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
281
|
-
context 'when ruby version is < 2.4.1', if: (RUBY_VERSION < '2.4.1' &&
|
281
|
+
context 'when ruby version is < 2.4.1', if: (RUBY_VERSION < '2.4.1' && SpecConfig.instance.ssl?) do
|
282
282
|
|
283
283
|
context 'when a key is passed, but it is not of the right type' do
|
284
284
|
|
@@ -302,7 +302,7 @@ describe Mongo::Socket::SSL, if: running_ssl? do
|
|
302
302
|
|
303
303
|
# Note that as of MRI 2.4, Creating a socket with the wrong key type raises
|
304
304
|
# a NoMethodError because #private? is attempted to be called on the key.
|
305
|
-
context 'when ruby version is >= 2.4.1', if: (RUBY_VERSION >= '2.4.1' &&
|
305
|
+
context 'when ruby version is >= 2.4.1', if: (RUBY_VERSION >= '2.4.1' && SpecConfig.instance.ssl?) do
|
306
306
|
|
307
307
|
context 'when a key is passed, but it is not of the right type' do
|
308
308
|
|
data/spec/mongo/socket_spec.rb
CHANGED
@@ -18,9 +18,9 @@ describe Mongo::Socket do
|
|
18
18
|
it 'maps SystemCallError and preserves message' do
|
19
19
|
expect do
|
20
20
|
socket.send(:handle_errors) do
|
21
|
-
raise SystemCallError.new('Test error', Errno::
|
21
|
+
raise SystemCallError.new('Test error', Errno::ENFILE::Errno)
|
22
22
|
end
|
23
|
-
end.to raise_error(Mongo::Error::SocketError, 'Errno::
|
23
|
+
end.to raise_error(Mongo::Error::SocketError, 'Errno::ENFILE: Too many open files in system - Test error')
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'maps IOError and preserves message' do
|
data/spec/mongo/uri_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'lite_spec_helper'
|
2
2
|
|
3
3
|
describe Mongo::URI do
|
4
4
|
|
@@ -17,7 +17,8 @@ describe Mongo::URI do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
context 'when the scheme is mongodb+srv://'
|
20
|
+
context 'when the scheme is mongodb+srv://' do
|
21
|
+
require_external_connectivity
|
21
22
|
|
22
23
|
let(:string) do
|
23
24
|
'mongodb+srv://test5.test.build.10gen.cc'
|
@@ -325,7 +326,7 @@ describe Mongo::URI do
|
|
325
326
|
|
326
327
|
describe '#client_options' do
|
327
328
|
|
328
|
-
let(:db) {
|
329
|
+
let(:db) { 'dummy_db' }
|
329
330
|
let(:servers) { 'localhost' }
|
330
331
|
let(:string) { "#{scheme}#{credentials}@#{servers}/#{db}" }
|
331
332
|
let(:user) { 'tyler' }
|
@@ -337,7 +338,7 @@ describe Mongo::URI do
|
|
337
338
|
end
|
338
339
|
|
339
340
|
it 'includes the database in the options' do
|
340
|
-
expect(options[:database]).to eq(
|
341
|
+
expect(options[:database]).to eq('dummy_db')
|
341
342
|
end
|
342
343
|
|
343
344
|
it 'includes the user in the options' do
|
@@ -624,7 +625,7 @@ describe Mongo::URI do
|
|
624
625
|
end
|
625
626
|
|
626
627
|
context 'replica set option provided' do
|
627
|
-
let(:rs_name) {
|
628
|
+
let(:rs_name) { 'dummy_rs' }
|
628
629
|
let(:options) { "replicaSet=#{rs_name}" }
|
629
630
|
|
630
631
|
it 'sets the replica set option' do
|
data/spec/spec_helper.rb
CHANGED
@@ -70,8 +70,11 @@
|
|
70
70
|
|
71
71
|
require 'lite_spec_helper'
|
72
72
|
|
73
|
-
if
|
73
|
+
if SpecConfig.instance.mri?
|
74
74
|
require 'timeout_interrupt'
|
75
|
+
else
|
76
|
+
require 'timeout'
|
77
|
+
TimeoutInterrupt = Timeout
|
75
78
|
end
|
76
79
|
|
77
80
|
# Replica set name can be overridden via replicaSet parameter in MONGODB_URI
|
@@ -160,7 +163,7 @@ end
|
|
160
163
|
#
|
161
164
|
# @since 2.0.0
|
162
165
|
def single_seed?
|
163
|
-
|
166
|
+
SpecConfig.instance.addresses.size == 1
|
164
167
|
end
|
165
168
|
|
166
169
|
# For instances where behaviour is different on different versions, we need to
|
@@ -191,14 +194,6 @@ def test_change_streams?
|
|
191
194
|
!BSON::Environment.jruby? && change_stream_enabled? & replica_set?
|
192
195
|
end
|
193
196
|
|
194
|
-
# Whether transactions can be tested. Transactions are available on server versions 4.0 and higher
|
195
|
-
# and when connected to a replica set.
|
196
|
-
#
|
197
|
-
# @since 2.6.0
|
198
|
-
def test_transactions?
|
199
|
-
transactions_enabled? && replica_set?
|
200
|
-
end
|
201
|
-
|
202
197
|
# For instances where behaviour is different on different versions, we need to
|
203
198
|
# determine in the specs if we are 3.6 or higher.
|
204
199
|
#
|
@@ -245,27 +240,11 @@ def scram_sha_256_enabled?
|
|
245
240
|
$scram_sha_256_enabled ||= $mongo_client.cluster.servers.first.features.scram_sha_256_enabled?
|
246
241
|
end
|
247
242
|
|
248
|
-
alias :transactions_enabled? :scram_sha_256_enabled?
|
249
|
-
|
250
243
|
# Is the test suite running locally (not on Travis).
|
251
244
|
#
|
252
245
|
# @since 2.1.0
|
253
246
|
def testing_ssl_locally?
|
254
|
-
|
255
|
-
end
|
256
|
-
|
257
|
-
# Should tests relying on external connections be run.
|
258
|
-
#
|
259
|
-
# @since 2.5.1
|
260
|
-
def test_connecting_externally?
|
261
|
-
!ENV['CI'] && !ENV['EXTERNAL_DISABLED']
|
262
|
-
end
|
263
|
-
|
264
|
-
# Is the test suite running on SSL.
|
265
|
-
#
|
266
|
-
# @since 2.0.2
|
267
|
-
def running_ssl?
|
268
|
-
SSL
|
247
|
+
SpecConfig.instance.ssl? && !(ENV['CI'])
|
269
248
|
end
|
270
249
|
|
271
250
|
# Is the test suite using compression.
|
@@ -317,7 +296,7 @@ end
|
|
317
296
|
#
|
318
297
|
# @since 2.0.0
|
319
298
|
def initialize_scanned_client!
|
320
|
-
Mongo::Client.new(
|
299
|
+
Mongo::Client.new(SpecConfig.instance.addresses, TEST_OPTIONS.merge(database: TEST_DB))
|
321
300
|
end
|
322
301
|
|
323
302
|
# Converts a 'camelCase' string or symbol to a :snake_case symbol.
|
@@ -1,96 +1,94 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'DNS Seedlist Discovery' do
|
4
|
+
require_external_connectivity
|
4
5
|
|
5
|
-
|
6
|
+
include Mongo::ConnectionString
|
6
7
|
|
7
|
-
|
8
|
+
before(:all) do
|
8
9
|
|
9
|
-
|
10
|
+
module Mongo
|
11
|
+
class Server
|
12
|
+
# The constructor keeps the same API, but does not instantiate a
|
13
|
+
# monitor and run it.
|
14
|
+
alias :original_initialize :initialize
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@address = address
|
19
|
-
@cluster = cluster
|
20
|
-
@monitoring = monitoring
|
21
|
-
@options = options.freeze
|
22
|
-
@monitor = Monitor.new(address, event_listeners, options)
|
23
|
-
end
|
16
|
+
def initialize(address, cluster, monitoring, event_listeners, options = {})
|
17
|
+
@address = address
|
18
|
+
@cluster = cluster
|
19
|
+
@monitoring = monitoring
|
20
|
+
@options = options.freeze
|
21
|
+
@monitor = Monitor.new(address, event_listeners, options)
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
# Disconnect simply needs to return true since we have no monitor and
|
25
|
+
# no connection.
|
26
|
+
alias :original_disconnect! :disconnect!
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
end
|
28
|
+
def disconnect!;
|
29
|
+
true;
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
33
|
+
end
|
35
34
|
|
36
|
-
|
35
|
+
after(:all) do
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
module Mongo
|
38
|
+
class Server
|
39
|
+
alias :initialize :original_initialize
|
40
|
+
remove_method(:original_initialize)
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
end
|
42
|
+
alias :disconnect! :original_disconnect!
|
43
|
+
remove_method(:original_disconnect!)
|
46
44
|
end
|
47
45
|
end
|
46
|
+
end
|
48
47
|
|
49
|
-
|
48
|
+
DNS_SEEDLIST_DISCOVERY_TESTS.each do |file_name|
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
file = File.new(file_name)
|
51
|
+
spec = YAML.load(ERB.new(file.read).result)
|
52
|
+
file.close
|
54
53
|
|
55
|
-
|
54
|
+
test = Mongo::ConnectionString::Test.new(spec)
|
56
55
|
|
57
|
-
|
56
|
+
context(File.basename(file_name)) do
|
58
57
|
|
59
|
-
|
58
|
+
context 'when the uri is invalid', if: test.raise_error? do
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
60
|
+
let(:valid_errors) do
|
61
|
+
[
|
62
|
+
Mongo::Error::InvalidTXTRecord,
|
63
|
+
Mongo::Error::NoSRVRecords,
|
64
|
+
Mongo::Error::InvalidURI,
|
65
|
+
Mongo::Error::MismatchedDomain,
|
66
|
+
]
|
67
|
+
end
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
let(:error) do
|
70
|
+
e = nil
|
71
|
+
begin; test.uri; rescue => ex; e = ex; end
|
72
|
+
e
|
73
|
+
end
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
75
|
+
it 'raises an error' do
|
76
|
+
expect(valid_errors).to include(error.class)
|
79
77
|
end
|
78
|
+
end
|
80
79
|
|
81
|
-
|
80
|
+
context 'when the uri is valid', unless: test.raise_error? do
|
82
81
|
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
it 'does not raise an exception' do
|
83
|
+
expect(test.uri).to be_a(Mongo::URI::SRVProtocol)
|
84
|
+
end
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
it 'creates a client with the correct hosts' do
|
87
|
+
expect(test.client).to have_hosts(test)
|
88
|
+
end
|
90
89
|
|
91
|
-
|
92
|
-
|
93
|
-
end
|
90
|
+
it 'creates a client with the correct options' do
|
91
|
+
expect(test.client).to match_options(test)
|
94
92
|
end
|
95
93
|
end
|
96
94
|
end
|
@@ -10,14 +10,17 @@ describe 'SDAM Monitoring' do
|
|
10
10
|
context("#{spec.description} (#{file.sub(%r'.*support/sdam_monitoring/', '')})") do
|
11
11
|
|
12
12
|
before(:all) do
|
13
|
-
@client = Mongo::Client.new([], heartbeat_frequency: 100, connect_timeout: 0.1)
|
14
13
|
@subscriber = Mongo::SDAMMonitoring::TestSubscriber.new
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
sdam_proc = lambda do |client|
|
15
|
+
client.subscribe(Mongo::Monitoring::SERVER_OPENING, @subscriber)
|
16
|
+
client.subscribe(Mongo::Monitoring::SERVER_CLOSED, @subscriber)
|
17
|
+
client.subscribe(Mongo::Monitoring::SERVER_DESCRIPTION_CHANGED, @subscriber)
|
18
|
+
client.subscribe(Mongo::Monitoring::TOPOLOGY_OPENING, @subscriber)
|
19
|
+
client.subscribe(Mongo::Monitoring::TOPOLOGY_CHANGED, @subscriber)
|
20
|
+
end
|
21
|
+
@client = Mongo::Client.new(spec.uri_string,
|
22
|
+
sdam_proc: sdam_proc,
|
23
|
+
heartbeat_frequency: 100, connect_timeout: 0.1)
|
21
24
|
end
|
22
25
|
|
23
26
|
after(:all) do
|
@@ -9,24 +9,29 @@ describe 'Transactions' do
|
|
9
9
|
context(spec.description) do
|
10
10
|
spec.tests.each do |test|
|
11
11
|
context(test.description) do
|
12
|
+
require_transaction_support
|
12
13
|
|
13
14
|
before(:each) do
|
14
15
|
test.setup_test
|
15
16
|
end
|
16
17
|
|
18
|
+
after(:each) do
|
19
|
+
test.teardown_test
|
20
|
+
end
|
21
|
+
|
17
22
|
let(:results) do
|
18
23
|
test.run
|
19
24
|
end
|
20
25
|
|
21
|
-
it 'returns the correct result'
|
26
|
+
it 'returns the correct result' do
|
22
27
|
expect(results[:results]).to match_operation_result(test)
|
23
28
|
end
|
24
29
|
|
25
|
-
it 'has the correct data in the collection', if:
|
30
|
+
it 'has the correct data in the collection', if: test.outcome_collection_data do
|
26
31
|
expect(results[:contents]).to match_collection_data(test)
|
27
32
|
end
|
28
33
|
|
29
|
-
it 'has the correct command_started events', if:
|
34
|
+
it 'has the correct command_started events', if: test.expectations do
|
30
35
|
test.expectations.each do |expectation|
|
31
36
|
# We convert the hashes to sorted arrays to ensure that asserting equality between
|
32
37
|
# the expected and actual event descriptions don't fail due to the same entries being
|
@@ -22,46 +22,16 @@ TEST_DB = 'ruby-driver'.freeze
|
|
22
22
|
# @since 2.0.0
|
23
23
|
TEST_COLL = 'test'.freeze
|
24
24
|
|
25
|
-
# For Evergreen
|
26
|
-
if ENV['MONGODB_URI']
|
27
|
-
MONGODB_URI = Mongo::URI.new(ENV['MONGODB_URI'])
|
28
|
-
URI_OPTIONS = Mongo::Options::Mapper.transform_keys_to_symbols(MONGODB_URI.uri_options)
|
29
|
-
if URI_OPTIONS[:replica_set]
|
30
|
-
ADDRESSES = MONGODB_URI.servers
|
31
|
-
CONNECT = { connect: :replica_set, replica_set: URI_OPTIONS[:replica_set] }
|
32
|
-
elsif ENV['TOPOLOGY'] == 'sharded_cluster'
|
33
|
-
ADDRESSES = [ MONGODB_URI.servers.first ] # See SERVER-16836 for why we can only use one host:port
|
34
|
-
CONNECT = { connect: :sharded }
|
35
|
-
else
|
36
|
-
ADDRESSES = MONGODB_URI.servers
|
37
|
-
CONNECT = { connect: :direct }
|
38
|
-
end
|
39
|
-
else
|
40
|
-
ADDRESSES = ENV['MONGODB_ADDRESSES'] ? ENV['MONGODB_ADDRESSES'].split(',').freeze : [ '127.0.0.1:27017' ].freeze
|
41
|
-
if ENV['RS_ENABLED']
|
42
|
-
CONNECT = { connect: :replica_set, replica_set: ENV['RS_NAME'] }
|
43
|
-
elsif ENV['SHARDED_ENABLED']
|
44
|
-
CONNECT = { connect: :sharded }
|
45
|
-
else
|
46
|
-
CONNECT = { connect: :direct }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
25
|
# The write concern to use in the tests.
|
51
26
|
#
|
52
27
|
# @since 2.0.0
|
53
|
-
WRITE_CONCERN =
|
28
|
+
WRITE_CONCERN = SpecConfig.instance.connect_replica_set? ? { w: 2 } : { w: 1 }
|
54
29
|
|
55
30
|
# An invalid write concern.
|
56
31
|
#
|
57
32
|
# @since 2.4.2
|
58
33
|
INVALID_WRITE_CONCERN = { w: 4 }
|
59
34
|
|
60
|
-
# Whether to use SSL.
|
61
|
-
#
|
62
|
-
# @since 2.0.3
|
63
|
-
SSL = (ENV['SSL'] == 'ssl') || (ENV['SSL_ENABLED'] == 'true')
|
64
|
-
|
65
35
|
# What compressor to use, if any.
|
66
36
|
#
|
67
37
|
# @since 2.5.0
|
@@ -71,7 +41,7 @@ COMPRESSORS = ENV['COMPRESSORS'] ? { compressors: ENV['COMPRESSORS'].split(',')
|
|
71
41
|
#
|
72
42
|
# @since 2.1.0
|
73
43
|
SSL_OPTIONS = {
|
74
|
-
ssl:
|
44
|
+
ssl: SpecConfig.instance.ssl?,
|
75
45
|
ssl_verify: false,
|
76
46
|
ssl_cert: CLIENT_CERT_PEM,
|
77
47
|
ssl_key: CLIENT_KEY_PEM
|
@@ -100,29 +70,14 @@ BASE_OPTIONS = {
|
|
100
70
|
# Options for test suite clients.
|
101
71
|
#
|
102
72
|
# @since 2.0.3
|
103
|
-
TEST_OPTIONS = BASE_OPTIONS.merge(
|
104
|
-
|
105
|
-
# The root user name.
|
106
|
-
#
|
107
|
-
# @since 2.0.0
|
108
|
-
ROOT_USER_NAME = (defined?(MONGODB_URI) && MONGODB_URI.credentials[:user]) || 'root-user'
|
109
|
-
|
110
|
-
# The root user password.
|
111
|
-
#
|
112
|
-
# @since 2.0.0
|
113
|
-
ROOT_USER_PWD = (defined?(MONGODB_URI) && MONGODB_URI.credentials[:password]) || 'password'
|
114
|
-
|
115
|
-
# The root user auth source.
|
116
|
-
#
|
117
|
-
# @since 2.4.2
|
118
|
-
ROOT_USER_AUTH_SOURCE = (defined?(URI_OPTIONS) && URI_OPTIONS[:auth_source]) || Mongo::Database::ADMIN
|
73
|
+
TEST_OPTIONS = BASE_OPTIONS.merge(SpecConfig.instance.connect).merge(SSL_OPTIONS).merge(COMPRESSORS)
|
119
74
|
|
120
75
|
# Gets the root system administrator user.
|
121
76
|
#
|
122
77
|
# @since 2.0.0
|
123
78
|
ROOT_USER = Mongo::Auth::User.new(
|
124
|
-
user:
|
125
|
-
password:
|
79
|
+
user: SpecConfig.instance.user || 'root-user',
|
80
|
+
password: SpecConfig.instance.password || 'password',
|
126
81
|
roles: [
|
127
82
|
Mongo::Auth::Roles::USER_ADMIN_ANY_DATABASE,
|
128
83
|
Mongo::Auth::Roles::DATABASE_ADMIN_ANY_DATABASE,
|
@@ -171,7 +126,7 @@ TEST_READ_WRITE_USER = Mongo::Auth::User.new(
|
|
171
126
|
#
|
172
127
|
# @since 2.0.0
|
173
128
|
AUTHORIZED_CLIENT = Mongo::Client.new(
|
174
|
-
|
129
|
+
SpecConfig.instance.addresses,
|
175
130
|
TEST_OPTIONS.merge(
|
176
131
|
database: TEST_DB,
|
177
132
|
user: TEST_USER.name,
|
@@ -187,7 +142,7 @@ AUTHROIZED_CLIENT_WITH_RETRY_WRITES = AUTHORIZED_CLIENT.with(retry_writes: true)
|
|
187
142
|
#
|
188
143
|
# @since 2.0.0
|
189
144
|
UNAUTHORIZED_CLIENT = Mongo::Client.new(
|
190
|
-
|
145
|
+
SpecConfig.instance.addresses,
|
191
146
|
TEST_OPTIONS.merge(database: TEST_DB, monitoring: false)
|
192
147
|
)
|
193
148
|
|
@@ -196,7 +151,7 @@ UNAUTHORIZED_CLIENT = Mongo::Client.new(
|
|
196
151
|
#
|
197
152
|
# @since 2.0.0
|
198
153
|
ADMIN_UNAUTHORIZED_CLIENT = Mongo::Client.new(
|
199
|
-
|
154
|
+
SpecConfig.instance.addresses,
|
200
155
|
TEST_OPTIONS.merge(database: Mongo::Database::ADMIN, monitoring: false)
|
201
156
|
)
|
202
157
|
|
@@ -208,7 +163,7 @@ ADMIN_AUTHORIZED_TEST_CLIENT = ADMIN_UNAUTHORIZED_CLIENT.with(
|
|
208
163
|
user: ROOT_USER.name,
|
209
164
|
password: ROOT_USER.password,
|
210
165
|
database: TEST_DB,
|
211
|
-
auth_source:
|
166
|
+
auth_source: SpecConfig.instance.auth_source || Mongo::Database::ADMIN,
|
212
167
|
monitoring: false
|
213
168
|
)
|
214
169
|
|
@@ -216,7 +171,7 @@ ADMIN_AUTHORIZED_TEST_CLIENT = ADMIN_UNAUTHORIZED_CLIENT.with(
|
|
216
171
|
#
|
217
172
|
# @since 2.5.1
|
218
173
|
SUBSCRIBED_CLIENT = Mongo::Client.new(
|
219
|
-
|
174
|
+
SpecConfig.instance.addresses,
|
220
175
|
TEST_OPTIONS.merge(
|
221
176
|
database: TEST_DB,
|
222
177
|
user: TEST_USER.name,
|