mongo 2.4.0.rc0 → 2.4.0.rc1
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 +1 -2
- data/lib/mongo/bulk_write/validatable.rb +3 -1
- data/lib/mongo/client.rb +30 -3
- data/lib/mongo/cluster/app_metadata.rb +7 -2
- data/lib/mongo/collection.rb +3 -1
- data/lib/mongo/collection/view.rb +3 -1
- data/lib/mongo/collection/view/aggregation.rb +3 -1
- data/lib/mongo/collection/view/builder/find_command.rb +20 -5
- data/lib/mongo/collection/view/map_reduce.rb +3 -1
- data/lib/mongo/collection/view/writable.rb +12 -2
- data/lib/mongo/cursor/builder/get_more_command.rb +3 -2
- data/lib/mongo/error/closed_stream.rb +1 -1
- data/lib/mongo/error/invalid_server_preference.rb +1 -1
- data/lib/mongo/index/view.rb +3 -1
- data/lib/mongo/operation/write/bulk/mergable.rb +1 -1
- data/lib/mongo/operation/write/create_index.rb +1 -1
- data/lib/mongo/operation/write/delete.rb +1 -1
- data/lib/mongo/operation/write/update.rb +1 -1
- data/lib/mongo/protocol/delete.rb +4 -1
- data/lib/mongo/protocol/get_more.rb +4 -1
- data/lib/mongo/protocol/insert.rb +7 -3
- data/lib/mongo/protocol/kill_cursors.rb +4 -1
- data/lib/mongo/protocol/message.rb +5 -1
- data/lib/mongo/protocol/query.rb +11 -4
- data/lib/mongo/protocol/update.rb +4 -1
- data/lib/mongo/server/connectable.rb +8 -2
- data/lib/mongo/server/connection_pool.rb +3 -1
- data/lib/mongo/server/monitor.rb +1 -0
- data/lib/mongo/socket.rb +16 -8
- data/lib/mongo/socket/ssl.rb +24 -9
- data/lib/mongo/uri.rb +6 -6
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +1 -1
- data/spec/mongo/bulk_write_spec.rb +117 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +26 -0
- data/spec/mongo/collection/view/builder/find_command_spec.rb +244 -2
- data/spec/mongo/collection/view/map_reduce_spec.rb +13 -0
- data/spec/mongo/collection/view/readable_spec.rb +26 -0
- data/spec/mongo/collection/view/writable_spec.rb +104 -0
- data/spec/mongo/collection/view_spec.rb +13 -0
- data/spec/mongo/collection_spec.rb +226 -7
- data/spec/mongo/crud_spec.rb +5 -5
- data/spec/mongo/index/view_spec.rb +53 -0
- data/spec/mongo/server/connection_spec.rb +45 -26
- data/spec/mongo/socket/ssl_spec.rb +358 -22
- data/spec/spec_helper.rb +4 -0
- data/spec/support/authorization.rb +3 -3
- data/spec/support/certificates/client_cert.pem +21 -0
- data/spec/support/certificates/client_key.pem +28 -0
- data/spec/support/certificates/client_key_encrypted.pem +30 -0
- data/spec/support/crud.rb +67 -22
- data/spec/support/crud/read.rb +18 -36
- data/spec/support/crud/write.rb +0 -44
- data/spec/support/crud_tests/read/aggregate-collation.yml +17 -0
- data/spec/support/crud_tests/read/aggregate-out.yml +28 -0
- data/spec/support/crud_tests/read/aggregate.yml +1 -35
- data/spec/support/crud_tests/read/count-collation.yml +15 -0
- data/spec/support/crud_tests/read/count.yml +3 -15
- data/spec/support/crud_tests/read/distinct-collation.yml +17 -0
- data/spec/support/crud_tests/read/distinct.yml +1 -14
- data/spec/support/crud_tests/read/find-collation.yml +15 -0
- data/spec/support/crud_tests/read/find.yml +1 -12
- data/spec/support/crud_tests/write/deleteMany-collation.yml +22 -0
- data/spec/support/crud_tests/write/deleteMany.yml +1 -23
- data/spec/support/crud_tests/write/deleteOne-collation.yml +22 -0
- data/spec/support/crud_tests/write/deleteOne.yml +1 -21
- data/spec/support/crud_tests/write/findOneAndDelete-collation.yml +23 -0
- data/spec/support/crud_tests/write/findOneAndDelete.yml +2 -28
- data/spec/support/crud_tests/write/findOneAndReplace-collation.yml +24 -0
- data/spec/support/crud_tests/write/findOneAndReplace-upsert.yml +47 -0
- data/spec/support/crud_tests/write/findOneAndReplace.yml +13 -53
- data/spec/support/crud_tests/write/findOneAndUpdate-collation.yml +27 -0
- data/spec/support/crud_tests/write/findOneAndUpdate.yml +8 -51
- data/spec/support/crud_tests/write/insertMany.yml +1 -2
- data/spec/support/crud_tests/write/insertOne.yml +1 -2
- data/spec/support/crud_tests/write/replaceOne-collation.yml +23 -0
- data/spec/support/crud_tests/write/replaceOne-upsert.yml +48 -0
- data/spec/support/crud_tests/write/replaceOne.yml +11 -45
- data/spec/support/crud_tests/write/updateMany-collation.yml +27 -0
- data/spec/support/crud_tests/write/updateMany.yml +10 -42
- data/spec/support/crud_tests/write/updateOne-collation.yml +24 -0
- data/spec/support/crud_tests/write/updateOne.yml +7 -33
- data/spec/support/sdam/rs/new_primary_new_setversion.yml +1 -1
- data/spec/support/sdam/rs/null_election_id.yml +1 -0
- data/spec/support/sdam/rs/primary_disconnect_electionid.yml +2 -3
- data/spec/support/sdam/rs/primary_disconnect_setversion.yml +1 -2
- data/spec/support/sdam/single/direct_connection_rsarbiter.yml +1 -1
- data/spec/support/sdam/single/direct_connection_rsprimary.yml +1 -1
- data/spec/support/sdam/single/direct_connection_rssecondary.yml +1 -1
- metadata +40 -4
- metadata.gz.sig +0 -0
@@ -406,6 +406,41 @@ describe Mongo::Server::Connection do
|
|
406
406
|
end
|
407
407
|
end
|
408
408
|
|
409
|
+
context 'when a socket timeout is set' do
|
410
|
+
|
411
|
+
let(:connection) do
|
412
|
+
described_class.new(server, socket_timeout: 10)
|
413
|
+
end
|
414
|
+
|
415
|
+
it 'sets the timeout' do
|
416
|
+
expect(connection.timeout).to eq(10)
|
417
|
+
end
|
418
|
+
|
419
|
+
let(:client) do
|
420
|
+
authorized_client.with(socket_timeout: 1.5)
|
421
|
+
end
|
422
|
+
|
423
|
+
before do
|
424
|
+
authorized_collection.insert_one(a: 1)
|
425
|
+
end
|
426
|
+
|
427
|
+
after do
|
428
|
+
sleep(0.5)
|
429
|
+
authorized_collection.delete_many
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'raises a timeout when it expires' do
|
433
|
+
start = Time.now
|
434
|
+
expect {
|
435
|
+
Timeout::timeout(3) do
|
436
|
+
client[authorized_collection.name].find("$where" => "sleep(2000) || true").first
|
437
|
+
end
|
438
|
+
}.to raise_exception(Timeout::Error, "Took more than 1.5 seconds to receive data.")
|
439
|
+
end_time = Time.now
|
440
|
+
expect(end_time - start).to be_within(0.2).of(1.5)
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
409
444
|
context 'when the process is forked' do
|
410
445
|
|
411
446
|
let(:insert) do
|
@@ -448,8 +483,8 @@ describe Mongo::Server::Connection do
|
|
448
483
|
expect(connection.send(:socket)).to be_nil
|
449
484
|
end
|
450
485
|
|
451
|
-
it '
|
452
|
-
expect(connection.timeout).to
|
486
|
+
it 'does not set the timeout to the default' do
|
487
|
+
expect(connection.timeout).to be_nil
|
453
488
|
end
|
454
489
|
end
|
455
490
|
|
@@ -556,20 +591,14 @@ describe Mongo::Server::Connection do
|
|
556
591
|
|
557
592
|
context 'when the ismaster response indicates the auth mechanism is :scram' do
|
558
593
|
|
559
|
-
let(:
|
560
|
-
|
561
|
-
'maxWireVersion' => 3,
|
562
|
-
'minWireVersion' => 0,
|
563
|
-
'ok' => 1
|
564
|
-
}
|
594
|
+
let(:features) do
|
595
|
+
Mongo::Server::Description::Features.new(0..3)
|
565
596
|
end
|
566
597
|
|
567
598
|
context 'when the server auth mechanism is scram', if: scram_sha_1_enabled? do
|
568
599
|
|
569
600
|
it 'uses scram' do
|
570
|
-
|
571
|
-
max_message_size = connection.send(:max_message_size)
|
572
|
-
allow(Mongo::Protocol::Reply).to receive(:deserialize).with(socket, max_message_size).and_return(reply)
|
601
|
+
allow(Mongo::Server::Description::Features).to receive(:new).and_return(features)
|
573
602
|
connection.send(:handshake!)
|
574
603
|
expect(connection.send(:default_mechanism)).to eq(:scram)
|
575
604
|
end
|
@@ -578,9 +607,7 @@ describe Mongo::Server::Connection do
|
|
578
607
|
context 'when the server auth mechanism is the default (mongodb_cr)', unless: scram_sha_1_enabled? do
|
579
608
|
|
580
609
|
it 'uses scram' do
|
581
|
-
|
582
|
-
max_message_size = connection.send(:max_message_size)
|
583
|
-
allow(Mongo::Protocol::Reply).to receive(:deserialize).with(socket, max_message_size).and_return(reply)
|
610
|
+
allow(Mongo::Server::Description::Features).to receive(:new).and_return(features)
|
584
611
|
connection.send(:handshake!)
|
585
612
|
expect(connection.send(:default_mechanism)).to eq(:scram)
|
586
613
|
end
|
@@ -589,20 +616,14 @@ describe Mongo::Server::Connection do
|
|
589
616
|
|
590
617
|
context 'when the ismaster response indicates the auth mechanism is :mongodb_cr' do
|
591
618
|
|
592
|
-
let(:
|
593
|
-
|
594
|
-
'maxWireVersion' => 2,
|
595
|
-
'minWireVersion' => 0,
|
596
|
-
'ok' => 1
|
597
|
-
}
|
619
|
+
let(:features) do
|
620
|
+
Mongo::Server::Description::Features.new(0..2)
|
598
621
|
end
|
599
622
|
|
600
623
|
context 'when the server auth mechanism is scram', if: scram_sha_1_enabled? do
|
601
624
|
|
602
625
|
it 'uses scram' do
|
603
|
-
|
604
|
-
max_message_size = connection.send(:max_message_size)
|
605
|
-
allow(Mongo::Protocol::Reply).to receive(:deserialize).with(socket, max_message_size).and_return(reply)
|
626
|
+
allow(Mongo::Server::Description::Features).to receive(:new).and_return(features)
|
606
627
|
connection.send(:handshake!)
|
607
628
|
expect(connection.send(:default_mechanism)).to eq(:scram)
|
608
629
|
end
|
@@ -611,9 +632,7 @@ describe Mongo::Server::Connection do
|
|
611
632
|
context 'when the server auth mechanism is the default (mongodb_cr)', unless: scram_sha_1_enabled? do
|
612
633
|
|
613
634
|
it 'uses mongodb_cr' do
|
614
|
-
|
615
|
-
max_message_size = connection.send(:max_message_size)
|
616
|
-
allow(Mongo::Protocol::Reply).to receive(:deserialize).with(socket, max_message_size).and_return(reply)
|
635
|
+
allow(Mongo::Server::Description::Features).to receive(:new).and_return(features)
|
617
636
|
connection.send(:handshake!)
|
618
637
|
expect(connection.send(:default_mechanism)).to eq(:mongodb_cr)
|
619
638
|
end
|
@@ -9,12 +9,36 @@ describe Mongo::Socket::SSL, if: running_ssl? do
|
|
9
9
|
let(:options) do
|
10
10
|
{
|
11
11
|
:ssl => true,
|
12
|
-
:ssl_cert =>
|
13
|
-
:ssl_key =>
|
12
|
+
:ssl_cert => CLIENT_CERT_PEM,
|
13
|
+
:ssl_key => CLIENT_KEY_PEM,
|
14
14
|
:ssl_verify => false
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
18
|
+
let (:key_string) do
|
19
|
+
File.read(CLIENT_KEY_PEM)
|
20
|
+
end
|
21
|
+
|
22
|
+
let (:cert_string) do
|
23
|
+
File.read(CLIENT_CERT_PEM)
|
24
|
+
end
|
25
|
+
|
26
|
+
let (:ca_cert_string) do
|
27
|
+
File.read(CA_PEM)
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:key_encrypted_string) do
|
31
|
+
File.read(CLIENT_KEY_ENCRYPTED_PEM)
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:cert_object) do
|
35
|
+
OpenSSL::X509::Certificate.new(cert_string)
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:key_object) do
|
39
|
+
OpenSSL::PKey.read(key_string)
|
40
|
+
end
|
41
|
+
|
18
42
|
describe '#connect!' do
|
19
43
|
|
20
44
|
context 'when a certificate is provided' do
|
@@ -51,45 +75,357 @@ describe Mongo::Socket::SSL, if: running_ssl? do
|
|
51
75
|
end
|
52
76
|
end
|
53
77
|
|
78
|
+
context 'when a certificate and key are provided as strings' do
|
79
|
+
|
80
|
+
let(:options) do
|
81
|
+
{
|
82
|
+
:ssl => true,
|
83
|
+
:ssl_cert_string => cert_string,
|
84
|
+
:ssl_key_string => key_string,
|
85
|
+
:ssl_verify => false
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
before do
|
90
|
+
socket.connect!
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'connects to the server' do
|
94
|
+
expect(socket).to be_alive
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when certificate and an encrypted key are provided as strings' do
|
99
|
+
|
100
|
+
let(:options) do
|
101
|
+
{
|
102
|
+
:ssl => true,
|
103
|
+
:ssl_cert_string => cert_string,
|
104
|
+
:ssl_key_string => key_encrypted_string,
|
105
|
+
:ssl_key_pass_phrase => CLIENT_KEY_PASSPHRASE,
|
106
|
+
:ssl_verify => false
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
before do
|
111
|
+
socket.connect!
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'connects to the server' do
|
115
|
+
expect(socket).to be_alive
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'when a certificate and key are provided as objects' do
|
120
|
+
|
121
|
+
let(:options) do
|
122
|
+
{
|
123
|
+
:ssl => true,
|
124
|
+
:ssl_cert_object => cert_object,
|
125
|
+
:ssl_key_object => key_object,
|
126
|
+
:ssl_verify => false
|
127
|
+
}
|
128
|
+
end
|
129
|
+
|
130
|
+
before do
|
131
|
+
socket.connect!
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'connects to the server' do
|
135
|
+
expect(socket).to be_alive
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'when the certificate is specified using both a file and a PEM-encoded string' do
|
140
|
+
|
141
|
+
let(:options) do
|
142
|
+
super().merge(
|
143
|
+
:ssl_cert_string => 'This is a random string, not a PEM-encoded certificate'
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
before do
|
148
|
+
socket.connect!
|
149
|
+
end
|
150
|
+
|
151
|
+
# since the lower priority option is clearly invalid we verify priority by checking that it connects
|
152
|
+
it 'discards the value of :ssl_cert_string' do
|
153
|
+
expect(socket).to be_alive
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
context 'when the certificate is specified using both a file and an object' do
|
158
|
+
|
159
|
+
let(:options) do
|
160
|
+
super().merge(
|
161
|
+
:ssl_cert_object => 'This is a string, not a certificate'
|
162
|
+
)
|
163
|
+
end
|
164
|
+
|
165
|
+
before do
|
166
|
+
socket.connect!
|
167
|
+
end
|
168
|
+
|
169
|
+
# since the lower priority option is clearly invalid we verify priority by checking that it connects
|
170
|
+
it 'discards the value of :ssl_cert_object' do
|
171
|
+
expect(socket).to be_alive
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'when the certificate is specified using both a PEM-encoded string and an object' do
|
176
|
+
|
177
|
+
let(:options) do
|
178
|
+
{
|
179
|
+
:ssl => true,
|
180
|
+
:ssl_cert_string => cert_string,
|
181
|
+
:ssl_cert_object => 'This is a string, not a Certificate',
|
182
|
+
:ssl_key => CLIENT_KEY_PEM,
|
183
|
+
:ssl_verify => false
|
184
|
+
}
|
185
|
+
end
|
186
|
+
|
187
|
+
before do
|
188
|
+
socket.connect!
|
189
|
+
end
|
190
|
+
|
191
|
+
# since the lower priority option is clearly invalid we verify priority by checking that it connects
|
192
|
+
it 'discards the value of :ssl_cert_object' do
|
193
|
+
expect(socket).to be_alive
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context 'when the key is specified using both a file and a PEM-encoded string' do
|
198
|
+
|
199
|
+
let(:options) do
|
200
|
+
super().merge(
|
201
|
+
:ssl_key_string => 'This is a normal string, not a PEM-encoded key'
|
202
|
+
)
|
203
|
+
end
|
204
|
+
|
205
|
+
before do
|
206
|
+
socket.connect!
|
207
|
+
end
|
208
|
+
|
209
|
+
# since the lower priority option is clearly invalid we verify priority by checking that it connects
|
210
|
+
it 'discards the value of :ssl_key_string' do
|
211
|
+
expect(socket).to be_alive
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
context 'when the key is specified using both a file and an object' do
|
216
|
+
|
217
|
+
let(:options) do
|
218
|
+
super().merge(
|
219
|
+
:ssl_cert_object => 'This is a string, not a key'
|
220
|
+
)
|
221
|
+
end
|
222
|
+
|
223
|
+
before do
|
224
|
+
socket.connect!
|
225
|
+
end
|
226
|
+
|
227
|
+
# since the lower priority option is clearly invalid we verify priority by checking that it connects
|
228
|
+
it 'discards the value of :ssl_key_object' do
|
229
|
+
expect(socket).to be_alive
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
context 'when the key is specified using both a PEM-encoded string and an object' do
|
234
|
+
|
235
|
+
let(:options) do
|
236
|
+
{
|
237
|
+
:ssl => true,
|
238
|
+
:ssl_cert => CLIENT_CERT_PEM,
|
239
|
+
:ssl_key_string => key_string,
|
240
|
+
:ssl_key_object => 'This is a string, not a PKey',
|
241
|
+
:ssl_verify => false
|
242
|
+
}
|
243
|
+
end
|
244
|
+
|
245
|
+
before do
|
246
|
+
socket.connect!
|
247
|
+
end
|
248
|
+
|
249
|
+
# since the lower priority option is clearly invalid we verify priority by checking that it connects
|
250
|
+
it 'discards the value of :ssl_key_object' do
|
251
|
+
expect(socket).to be_alive
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
context 'when a certificate is passed, but it is not of the right type' do
|
256
|
+
|
257
|
+
let(:options) do
|
258
|
+
cert = "This is a string, not a X509 Certificate"
|
259
|
+
{
|
260
|
+
:ssl => true,
|
261
|
+
:ssl_cert_object => cert,
|
262
|
+
:ssl_key => CLIENT_KEY_PEM,
|
263
|
+
:ssl_verify => false
|
264
|
+
}
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'raises a TypeError' do
|
268
|
+
expect{
|
269
|
+
socket.connect!
|
270
|
+
}.to raise_exception(TypeError)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
context 'when a key is passed, but it is not of the right type' do
|
275
|
+
let(:options) do
|
276
|
+
key = "This is a string not a key"
|
277
|
+
{
|
278
|
+
:ssl => true,
|
279
|
+
:ssl_key_object => key,
|
280
|
+
:ssl_cert => CLIENT_CERT_PEM,
|
281
|
+
:ssl_verify => false
|
282
|
+
}
|
283
|
+
end
|
284
|
+
|
285
|
+
it 'raises a TypeError' do
|
286
|
+
expect{
|
287
|
+
socket.connect!
|
288
|
+
}.to raise_exception(TypeError)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
54
292
|
context 'when a bad certificate is provided' do
|
55
293
|
|
56
294
|
let(:options) do
|
57
|
-
super().merge(
|
295
|
+
super().merge(
|
58
296
|
:ssl_key => CRL_PEM
|
59
|
-
|
297
|
+
)
|
60
298
|
end
|
61
299
|
|
62
300
|
it 'raises an exception' do
|
63
301
|
expect {
|
64
302
|
socket.connect!
|
65
|
-
}.to raise_exception(
|
303
|
+
}.to raise_exception(ArgumentError)
|
66
304
|
end
|
67
305
|
end
|
68
306
|
|
69
307
|
context 'when a CA certificate is provided', if: testing_ssl_locally? do
|
70
308
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
309
|
+
context 'as a path to a file' do
|
310
|
+
|
311
|
+
let(:options) do
|
312
|
+
super().merge(
|
313
|
+
:ssl_ca_cert => CA_PEM,
|
314
|
+
:ssl_verify => true
|
315
|
+
)
|
316
|
+
end
|
317
|
+
|
318
|
+
before do
|
319
|
+
socket.connect!
|
320
|
+
end
|
321
|
+
|
322
|
+
it 'connects to the server' do
|
323
|
+
expect(socket).to be_alive
|
324
|
+
end
|
76
325
|
end
|
77
326
|
|
78
|
-
|
79
|
-
|
327
|
+
context 'as a string containg the PEM-encoded certificate' do
|
328
|
+
|
329
|
+
let (:options) do
|
330
|
+
super().merge(
|
331
|
+
:ssl_ca_cert_string => ca_cert_string,
|
332
|
+
:ssl_verify => true
|
333
|
+
)
|
334
|
+
end
|
335
|
+
|
336
|
+
before do
|
337
|
+
socket.connect!
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'connects to the server' do
|
341
|
+
expect(socket).to be_alive
|
342
|
+
end
|
80
343
|
end
|
81
344
|
|
82
|
-
|
83
|
-
|
345
|
+
context 'as an array of Certificate objects' do
|
346
|
+
let (:options) do
|
347
|
+
cert = [OpenSSL::X509::Certificate.new(ca_cert_string)]
|
348
|
+
super().merge(
|
349
|
+
:ssl_ca_cert_object => cert,
|
350
|
+
:ssl_verify => true
|
351
|
+
)
|
352
|
+
end
|
353
|
+
|
354
|
+
before do
|
355
|
+
socket.connect!
|
356
|
+
end
|
357
|
+
|
358
|
+
it 'connects to the server' do
|
359
|
+
expect(socket).to be_alive
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
context 'both as a file and a PEM-encoded parameter' do
|
364
|
+
|
365
|
+
let(:options) do
|
366
|
+
super().merge(
|
367
|
+
:ssl_ca_cert => CA_PEM,
|
368
|
+
:ssl_ca_cert_string => 'This is a string, not a certificate',
|
369
|
+
:ssl_verify => true
|
370
|
+
)
|
371
|
+
end
|
372
|
+
|
373
|
+
before do
|
374
|
+
socket.connect!
|
375
|
+
end
|
376
|
+
|
377
|
+
# since the lower priority option is clearly invalid we verify priority by checking that it connects
|
378
|
+
it 'discards the value of :ssl_ca_cert_string' do
|
379
|
+
expect(socket).to be_alive
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
context 'both as a file and as object parameter' do
|
384
|
+
|
385
|
+
let(:options) do
|
386
|
+
super().merge(
|
387
|
+
:ssl_ca_cert => CA_PEM,
|
388
|
+
:ssl_ca_cert_object => 'This is a string, not an array of certificates',
|
389
|
+
:ssl_verify => true
|
390
|
+
)
|
391
|
+
end
|
392
|
+
|
393
|
+
before do
|
394
|
+
socket.connect!
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'discards the value of :ssl_ca_cert_object' do
|
398
|
+
expect(socket).to be_alive
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
context 'both as a PEM-encoded string and as object parameter' do
|
403
|
+
|
404
|
+
let(:options) do
|
405
|
+
cert = File.read(CA_PEM)
|
406
|
+
super().merge(
|
407
|
+
:ssl_ca_cert_string => cert,
|
408
|
+
:ssl_ca_cert_object => 'This is a string, not an array of certificates',
|
409
|
+
:ssl_verify => true
|
410
|
+
)
|
411
|
+
end
|
412
|
+
|
413
|
+
before do
|
414
|
+
socket.connect!
|
415
|
+
end
|
416
|
+
|
417
|
+
it 'discards the value of :ssl_ca_cert_object' do
|
418
|
+
expect(socket).to be_alive
|
419
|
+
end
|
84
420
|
end
|
85
421
|
end
|
86
422
|
|
87
423
|
context 'when a CA certificate is not provided', if: testing_ssl_locally? do
|
88
424
|
|
89
425
|
let(:options) do
|
90
|
-
super().merge(
|
426
|
+
super().merge(
|
91
427
|
:ssl_verify => true
|
92
|
-
|
428
|
+
)
|
93
429
|
end
|
94
430
|
|
95
431
|
before do
|
@@ -105,9 +441,9 @@ describe Mongo::Socket::SSL, if: running_ssl? do
|
|
105
441
|
context 'when ssl_verify is not specified', if: testing_ssl_locally? do
|
106
442
|
|
107
443
|
let(:options) do
|
108
|
-
super().merge(
|
444
|
+
super().merge(
|
109
445
|
:ssl_ca_cert => CA_PEM
|
110
|
-
|
446
|
+
).tap { |options| options.delete(:ssl_verify) }
|
111
447
|
end
|
112
448
|
|
113
449
|
before do
|
@@ -122,10 +458,10 @@ describe Mongo::Socket::SSL, if: running_ssl? do
|
|
122
458
|
context 'when ssl_verify is true', if: testing_ssl_locally? do
|
123
459
|
|
124
460
|
let(:options) do
|
125
|
-
super().merge(
|
461
|
+
super().merge(
|
126
462
|
:ssl_ca_cert => CA_PEM,
|
127
463
|
:ssl_verify => true
|
128
|
-
|
464
|
+
)
|
129
465
|
end
|
130
466
|
|
131
467
|
before do
|
@@ -140,10 +476,10 @@ describe Mongo::Socket::SSL, if: running_ssl? do
|
|
140
476
|
context 'when ssl_verify is false' do
|
141
477
|
|
142
478
|
let(:options) do
|
143
|
-
super().merge(
|
479
|
+
super().merge(
|
144
480
|
:ssl_ca_cert => 'invalid',
|
145
481
|
:ssl_verify => false
|
146
|
-
|
482
|
+
)
|
147
483
|
end
|
148
484
|
|
149
485
|
before do
|