mongo 2.13.0.rc1 → 2.13.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mongo/auth/aws/request.rb +27 -3
- data/lib/mongo/client.rb +35 -0
- data/lib/mongo/error.rb +2 -0
- data/lib/mongo/error/invalid_server_auth_host.rb +22 -0
- data/lib/mongo/index/view.rb +3 -0
- data/lib/mongo/protocol/msg.rb +19 -0
- data/lib/mongo/server/app_metadata.rb +27 -3
- data/lib/mongo/server/connection_base.rb +34 -8
- data/lib/mongo/version.rb +1 -1
- data/spec/integration/bulk_write_spec.rb +19 -0
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +3 -3
- data/spec/integration/size_limit_spec.rb +23 -10
- data/spec/mongo/auth/aws/request_region_spec.rb +42 -0
- data/spec/mongo/auth/aws/request_spec.rb +32 -32
- data/spec/mongo/client_construction_spec.rb +112 -0
- data/spec/mongo/index/view_spec.rb +146 -0
- data/spec/mongo/server/app_metadata_shared.rb +80 -0
- metadata +985 -984
- metadata.gz.sig +0 -0
- data/spec/integration/size_limit_spec.rb~12e1e9c4f... RUBY-2242 Fix zlib compression (#2021) +0 -98
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Auth::Aws::Request do
|
3
|
+
describe Mongo::Auth::Aws::Request do
|
4
4
|
|
5
|
-
describe "#formatted_time" do
|
6
|
-
context "when time is provided and frozen" do
|
5
|
+
describe "#formatted_time" do
|
6
|
+
context "when time is provided and frozen" do
|
7
7
|
let(:original_time) { Time.at(1592399523).freeze }
|
8
|
-
let(:request) do
|
9
|
-
described_class.new(access_key_id: 'access_key_id',
|
10
|
-
secret_access_key: 'secret_access_key',
|
11
|
-
session_token: 'session_token',
|
12
|
-
host: 'host',
|
8
|
+
let(:request) do
|
9
|
+
described_class.new(access_key_id: 'access_key_id',
|
10
|
+
secret_access_key: 'secret_access_key',
|
11
|
+
session_token: 'session_token',
|
12
|
+
host: 'host',
|
13
13
|
server_nonce: 'server_nonce',
|
14
14
|
time: original_time
|
15
15
|
)
|
@@ -24,12 +24,12 @@ describe Mongo::Auth::Aws::Request do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
context "when time is not provided" do
|
28
|
-
let(:request) do
|
29
|
-
described_class.new(access_key_id: 'access_key_id',
|
30
|
-
secret_access_key: 'secret_access_key',
|
31
|
-
session_token: 'session_token',
|
32
|
-
host: 'host',
|
27
|
+
context "when time is not provided" do
|
28
|
+
let(:request) do
|
29
|
+
described_class.new(access_key_id: 'access_key_id',
|
30
|
+
secret_access_key: 'secret_access_key',
|
31
|
+
session_token: 'session_token',
|
32
|
+
host: 'host',
|
33
33
|
server_nonce: 'server_nonce'
|
34
34
|
)
|
35
35
|
end
|
@@ -40,37 +40,37 @@ describe Mongo::Auth::Aws::Request do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe "#signature" do
|
44
|
-
context "when time is provided and frozen" do
|
43
|
+
describe "#signature" do
|
44
|
+
context "when time is provided and frozen" do
|
45
45
|
let(:original_time) { Time.at(1592399523).freeze }
|
46
|
-
let(:request) do
|
47
|
-
described_class.new(access_key_id: 'access_key_id',
|
48
|
-
secret_access_key: 'secret_access_key',
|
49
|
-
session_token: 'session_token',
|
50
|
-
host: 'host',
|
46
|
+
let(:request) do
|
47
|
+
described_class.new(access_key_id: 'access_key_id',
|
48
|
+
secret_access_key: 'secret_access_key',
|
49
|
+
session_token: 'session_token',
|
50
|
+
host: 'host',
|
51
51
|
server_nonce: 'server_nonce',
|
52
52
|
time: original_time
|
53
53
|
)
|
54
54
|
end
|
55
|
-
|
56
|
-
it 'doesn\'t raise error on signature' do
|
55
|
+
|
56
|
+
it 'doesn\'t raise error on signature' do
|
57
57
|
expect { request.signature }.to_not raise_error
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context "when time is not provided" do
|
62
|
-
let(:request) do
|
63
|
-
described_class.new(access_key_id: 'access_key_id',
|
64
|
-
secret_access_key: 'secret_access_key',
|
65
|
-
session_token: 'session_token',
|
66
|
-
host: 'host',
|
61
|
+
context "when time is not provided" do
|
62
|
+
let(:request) do
|
63
|
+
described_class.new(access_key_id: 'access_key_id',
|
64
|
+
secret_access_key: 'secret_access_key',
|
65
|
+
session_token: 'session_token',
|
66
|
+
host: 'host',
|
67
67
|
server_nonce: 'server_nonce'
|
68
68
|
)
|
69
69
|
end
|
70
|
-
|
71
|
-
it 'doesn\'t raise error on signature' do
|
70
|
+
|
71
|
+
it 'doesn\'t raise error on signature' do
|
72
72
|
expect { request.signature }.to_not raise_error
|
73
73
|
end
|
74
|
-
end
|
74
|
+
end
|
75
75
|
end
|
76
76
|
end
|
@@ -1382,6 +1382,118 @@ describe Mongo::Client do
|
|
1382
1382
|
end
|
1383
1383
|
end
|
1384
1384
|
=end
|
1385
|
+
|
1386
|
+
context ':wrapping_libraries option' do
|
1387
|
+
let(:options) do
|
1388
|
+
{wrapping_libraries: wrapping_libraries}
|
1389
|
+
end
|
1390
|
+
|
1391
|
+
context 'valid input' do
|
1392
|
+
context 'symbol keys' do
|
1393
|
+
let(:wrapping_libraries) do
|
1394
|
+
[name: 'Mongoid', version: '7.1.2'].freeze
|
1395
|
+
end
|
1396
|
+
|
1397
|
+
it 'works' do
|
1398
|
+
client.options[:wrapping_libraries].should == ['name' => 'Mongoid', 'version' => '7.1.2']
|
1399
|
+
end
|
1400
|
+
end
|
1401
|
+
|
1402
|
+
context 'string keys' do
|
1403
|
+
let(:wrapping_libraries) do
|
1404
|
+
['name' => 'Mongoid', 'version' => '7.1.2'].freeze
|
1405
|
+
end
|
1406
|
+
|
1407
|
+
it 'works' do
|
1408
|
+
client.options[:wrapping_libraries].should == ['name' => 'Mongoid', 'version' => '7.1.2']
|
1409
|
+
end
|
1410
|
+
end
|
1411
|
+
|
1412
|
+
context 'Redacted keys' do
|
1413
|
+
let(:wrapping_libraries) do
|
1414
|
+
[Mongo::Options::Redacted.new(name: 'Mongoid', version: '7.1.2')].freeze
|
1415
|
+
end
|
1416
|
+
|
1417
|
+
it 'works' do
|
1418
|
+
client.options[:wrapping_libraries].should == ['name' => 'Mongoid', 'version' => '7.1.2']
|
1419
|
+
end
|
1420
|
+
end
|
1421
|
+
|
1422
|
+
context 'two libraries' do
|
1423
|
+
let(:wrapping_libraries) do
|
1424
|
+
[
|
1425
|
+
{name: 'Mongoid', version: '7.1.2'},
|
1426
|
+
{name: 'Rails', version: '4.0', platform: 'Foobar'},
|
1427
|
+
].freeze
|
1428
|
+
end
|
1429
|
+
|
1430
|
+
it 'works' do
|
1431
|
+
client.options[:wrapping_libraries].should == [
|
1432
|
+
{'name' => 'Mongoid', 'version' => '7.1.2'},
|
1433
|
+
{'name' => 'Rails', 'version' => '4.0', 'platform' => 'Foobar'},
|
1434
|
+
]
|
1435
|
+
end
|
1436
|
+
end
|
1437
|
+
|
1438
|
+
context 'empty array' do
|
1439
|
+
let(:wrapping_libraries) do
|
1440
|
+
[]
|
1441
|
+
end
|
1442
|
+
|
1443
|
+
it 'works' do
|
1444
|
+
client.options[:wrapping_libraries].should == []
|
1445
|
+
end
|
1446
|
+
end
|
1447
|
+
|
1448
|
+
context 'empty array' do
|
1449
|
+
let(:wrapping_libraries) do
|
1450
|
+
nil
|
1451
|
+
end
|
1452
|
+
|
1453
|
+
it 'works' do
|
1454
|
+
client.options[:wrapping_libraries].should be nil
|
1455
|
+
end
|
1456
|
+
end
|
1457
|
+
end
|
1458
|
+
|
1459
|
+
context 'valid input' do
|
1460
|
+
context 'hash given instead of an array' do
|
1461
|
+
let(:wrapping_libraries) do
|
1462
|
+
{name: 'Mongoid', version: '7.1.2'}.freeze
|
1463
|
+
end
|
1464
|
+
|
1465
|
+
it 'is rejected' do
|
1466
|
+
lambda do
|
1467
|
+
client
|
1468
|
+
end.should raise_error(ArgumentError, /:wrapping_libraries must be an array of hashes/)
|
1469
|
+
end
|
1470
|
+
end
|
1471
|
+
|
1472
|
+
context 'invalid keys' do
|
1473
|
+
let(:wrapping_libraries) do
|
1474
|
+
[name: 'Mongoid', invalid: '7.1.2'].freeze
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
it 'is rejected' do
|
1478
|
+
lambda do
|
1479
|
+
client
|
1480
|
+
end.should raise_error(ArgumentError, /:wrapping_libraries element has invalid keys/)
|
1481
|
+
end
|
1482
|
+
end
|
1483
|
+
|
1484
|
+
context 'value includes |' do
|
1485
|
+
let(:wrapping_libraries) do
|
1486
|
+
[name: 'Mongoid|on|Rails', version: '7.1.2'].freeze
|
1487
|
+
end
|
1488
|
+
|
1489
|
+
it 'is rejected' do
|
1490
|
+
lambda do
|
1491
|
+
client
|
1492
|
+
end.should raise_error(ArgumentError, /:wrapping_libraries element value cannot include '|'/)
|
1493
|
+
end
|
1494
|
+
end
|
1495
|
+
end
|
1496
|
+
end
|
1385
1497
|
end
|
1386
1498
|
|
1387
1499
|
context 'when making a block client' do
|
@@ -325,6 +325,81 @@ describe Mongo::Index::View do
|
|
325
325
|
end
|
326
326
|
end
|
327
327
|
|
328
|
+
context 'when hidden is specified' do
|
329
|
+
let(:index) { view.get('with_hidden_1') }
|
330
|
+
|
331
|
+
context 'on server versions <= 3.2' do
|
332
|
+
# DRIVERS-1220 Server versions 3.2 and older do not perform any option
|
333
|
+
# checking on index creation. The server will allow the user to create
|
334
|
+
# the index with the hidden option, but the server does not support this
|
335
|
+
# option and will not use it.
|
336
|
+
max_server_fcv '3.2'
|
337
|
+
|
338
|
+
let!(:result) do
|
339
|
+
view.create_many({ key: { with_hidden: 1 }, hidden: true })
|
340
|
+
end
|
341
|
+
|
342
|
+
it 'returns ok' do
|
343
|
+
expect(result).to be_successful
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'creates an index' do
|
347
|
+
expect(index).to_not be_nil
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
context 'on server versions between 3.4 and 4.2' do
|
352
|
+
max_server_fcv '4.2'
|
353
|
+
min_server_fcv '3.4'
|
354
|
+
|
355
|
+
it 'raises an exception' do
|
356
|
+
expect do
|
357
|
+
view.create_many({ key: { with_hidden: 1 }, hidden: true })
|
358
|
+
end.to raise_error(/The field 'hidden' is not valid for an index specification/)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
context 'on server versions >= 4.4' do
|
363
|
+
min_server_fcv '4.4'
|
364
|
+
|
365
|
+
context 'when hidden is true' do
|
366
|
+
let!(:result) do
|
367
|
+
view.create_many({ key: { with_hidden: 1 }, hidden: true })
|
368
|
+
end
|
369
|
+
|
370
|
+
it 'returns ok' do
|
371
|
+
expect(result).to be_successful
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'creates an index' do
|
375
|
+
expect(index).to_not be_nil
|
376
|
+
end
|
377
|
+
|
378
|
+
it 'applies the hidden option to the index' do
|
379
|
+
expect(index['hidden']).to be true
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
context 'when hidden is false' do
|
384
|
+
let!(:result) do
|
385
|
+
view.create_many({ key: { with_hidden: 1 }, hidden: false })
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'returns ok' do
|
389
|
+
expect(result).to be_successful
|
390
|
+
end
|
391
|
+
|
392
|
+
it 'creates an index' do
|
393
|
+
expect(index).to_not be_nil
|
394
|
+
end
|
395
|
+
|
396
|
+
it 'does not apply the hidden option to the index' do
|
397
|
+
expect(index['hidden']).to be_nil
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
328
403
|
context 'when collation is specified' do
|
329
404
|
min_server_fcv '3.4'
|
330
405
|
|
@@ -773,6 +848,77 @@ describe Mongo::Index::View do
|
|
773
848
|
end
|
774
849
|
end
|
775
850
|
|
851
|
+
context 'when providing hidden option' do
|
852
|
+
let(:index) { view.get('with_hidden_1') }
|
853
|
+
|
854
|
+
context 'on server versions <= 3.2' do
|
855
|
+
# DRIVERS-1220 Server versions 3.2 and older do not perform any option
|
856
|
+
# checking on index creation. The server will allow the user to create
|
857
|
+
# the index with the hidden option, but the server does not support this
|
858
|
+
# option and will not use it.
|
859
|
+
max_server_fcv '3.2'
|
860
|
+
|
861
|
+
let!(:result) do
|
862
|
+
view.create_one({ 'with_hidden' => 1 }, { hidden: true })
|
863
|
+
end
|
864
|
+
|
865
|
+
it 'returns ok' do
|
866
|
+
expect(result).to be_successful
|
867
|
+
end
|
868
|
+
|
869
|
+
it 'creates an index' do
|
870
|
+
expect(index).to_not be_nil
|
871
|
+
end
|
872
|
+
end
|
873
|
+
|
874
|
+
context 'on server versions between 3.4 and 4.2' do
|
875
|
+
max_server_fcv '4.2'
|
876
|
+
min_server_fcv '3.4'
|
877
|
+
|
878
|
+
it 'raises an exception' do
|
879
|
+
expect do
|
880
|
+
view.create_one({ 'with_hidden' => 1 }, { hidden: true })
|
881
|
+
end.to raise_error(/The field 'hidden' is not valid for an index specification/)
|
882
|
+
end
|
883
|
+
end
|
884
|
+
|
885
|
+
context 'on server versions >= 4.4' do
|
886
|
+
min_server_fcv '4.4'
|
887
|
+
|
888
|
+
context 'when hidden is true' do
|
889
|
+
let!(:result) { view.create_one({ 'with_hidden' => 1 }, { hidden: true }) }
|
890
|
+
|
891
|
+
it 'returns ok' do
|
892
|
+
expect(result).to be_successful
|
893
|
+
end
|
894
|
+
|
895
|
+
it 'creates an index' do
|
896
|
+
expect(index).to_not be_nil
|
897
|
+
end
|
898
|
+
|
899
|
+
it 'applies the hidden option to the index' do
|
900
|
+
expect(index['hidden']).to be true
|
901
|
+
end
|
902
|
+
end
|
903
|
+
|
904
|
+
context 'when hidden is false' do
|
905
|
+
let!(:result) { view.create_one({ 'with_hidden' => 1 }, { hidden: false }) }
|
906
|
+
|
907
|
+
it 'returns ok' do
|
908
|
+
expect(result).to be_successful
|
909
|
+
end
|
910
|
+
|
911
|
+
it 'creates an index' do
|
912
|
+
expect(index).to_not be_nil
|
913
|
+
end
|
914
|
+
|
915
|
+
it 'does not apply the hidden option to the index' do
|
916
|
+
expect(index['hidden']).to be_nil
|
917
|
+
end
|
918
|
+
end
|
919
|
+
end
|
920
|
+
end
|
921
|
+
|
776
922
|
context 'when providing commit_quorum option' do
|
777
923
|
require_topology :replica_set, :sharded
|
778
924
|
context 'on server versions >= 4.4' do
|
@@ -53,4 +53,84 @@ shared_examples 'app metadata document' do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
context 'when wrapping libraries are specified' do
|
58
|
+
let(:app_metadata) do
|
59
|
+
described_class.new(wrapping_libraries: wrapping_libraries)
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'one' do
|
63
|
+
let(:wrapping_libraries) { [wrapping_library] }
|
64
|
+
|
65
|
+
context 'no fields' do
|
66
|
+
let(:wrapping_library) do
|
67
|
+
{}
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'adds empty strings' do
|
71
|
+
document[:client][:driver][:name].should == 'mongo-ruby-driver|'
|
72
|
+
document[:client][:driver][:version].should == "#{Mongo::VERSION}|"
|
73
|
+
document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\z/
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'some fields' do
|
78
|
+
let(:wrapping_library) do
|
79
|
+
{name: 'Mongoid'}
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'adds the fields' do
|
83
|
+
document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid'
|
84
|
+
document[:client][:driver][:version].should == "#{Mongo::VERSION}|"
|
85
|
+
document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\z/
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'all fields' do
|
90
|
+
let(:wrapping_library) do
|
91
|
+
{name: 'Mongoid', version: '7.1.2', platform: 'OS9000'}
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'adds the fields' do
|
95
|
+
document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid'
|
96
|
+
document[:client][:driver][:version].should == "#{Mongo::VERSION}|7.1.2"
|
97
|
+
document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|OS9000\z/
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'two' do
|
103
|
+
context 'some fields' do
|
104
|
+
let(:wrapping_libraries) do
|
105
|
+
[
|
106
|
+
{name: 'Mongoid', version: '42'},
|
107
|
+
# All libraries should be specifying their versions, in theory,
|
108
|
+
# but test not specifying a version.
|
109
|
+
{version: '4.0', platform: 'OS9000'},
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'adds the fields' do
|
114
|
+
document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid|'
|
115
|
+
document[:client][:driver][:version].should == "#{Mongo::VERSION}|42|4.0"
|
116
|
+
document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\|OS9000\z/
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'a realistic Mongoid & Rails wrapping' do
|
121
|
+
let(:wrapping_libraries) do
|
122
|
+
[
|
123
|
+
{name: 'Mongoid', version: '7.1.2'},
|
124
|
+
{name: 'Rails', version: '6.0.3'},
|
125
|
+
]
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'adds the fields' do
|
129
|
+
document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid|Rails'
|
130
|
+
document[:client][:driver][:version].should == "#{Mongo::VERSION}|7.1.2|6.0.3"
|
131
|
+
document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\|\z/
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
56
136
|
end
|