mongo 2.11.2 → 2.11.3
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 +2 -2
- data.tar.gz.sig +0 -0
- data/lib/mongo/auth/user.rb +7 -1
- data/lib/mongo/bulk_write/transformable.rb +3 -3
- data/lib/mongo/cluster.rb +2 -0
- data/lib/mongo/collection/view/writable.rb +3 -3
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +8 -1
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +8 -1
- data/lib/mongo/protocol/serializers.rb +12 -2
- data/lib/mongo/server/connection.rb +2 -2
- data/lib/mongo/server/monitor.rb +1 -1
- data/lib/mongo/server/monitor/connection.rb +1 -1
- data/lib/mongo/uri.rb +1 -1
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +1 -1
- data/spec/integration/client_options_spec.rb +5 -5
- data/spec/integration/crud_spec.rb +45 -0
- data/spec/integration/cursor_reaping_spec.rb +2 -1
- data/spec/lite_spec_helper.rb +1 -0
- data/spec/mongo/auth/user/view_spec.rb +36 -1
- data/spec/mongo/auth/user_spec.rb +12 -0
- data/spec/mongo/bulk_write_spec.rb +2 -2
- data/spec/mongo/cluster_spec.rb +19 -0
- data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +56 -0
- data/spec/mongo/server/connection_spec.rb +3 -2
- data/spec/mongo/server/monitor/connection_spec.rb +8 -1
- data/spec/mongo/uri_spec.rb +1 -1
- data/spec/support/command_monitoring.rb +1 -1
- data/spec/support/utils.rb +11 -1
- metadata +646 -642
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1ec5495bf06a11fa0003454eb892099bc1a86da8ef1694fc25990c18d2f64ba
|
4
|
+
data.tar.gz: b07b2a3f5b71e89e66d6117253e1c85e4c6c90b8a8bb2f17cee24a8b47b9dad8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e88a5e7d0a2bd2917c4ba887d38786229fd9f64e2056b894ccd3289983b52f7aa8b293d77c46df4412d1fb01faed8bb41bfe93fa08e5085a8ec88fe22aaed34
|
7
|
+
data.tar.gz: fe47a5b889ff2b9449475e040d6e189bc984158e5c6b0cfab055dcce83d7efb090ec129eb5afee5cfed7a4b30ddda6bcc0d60e1b8720ff96f188548f28a75460
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
�|A�i��7Z����$��^�H��jC˴C�8Δ�����>�6�%�&�a�������[���epR@U='�ӯY�R�ԡ�ΉȢ�:�yZ'N�#��|���i*{�v�n�\�yV]}�����+r
|
2
|
+
?������Jtz�[���8�d��L���_�r����\�s�~z��;C n��5>�t" M��F��I}�µa��{{l�ȋr���;����pG��?M S��PL��D*zA�X��
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mongo/auth/user.rb
CHANGED
@@ -151,6 +151,8 @@ module Mongo
|
|
151
151
|
# authorized for.
|
152
152
|
# @option options [ String ] :user The user name.
|
153
153
|
# @option options [ String ] :password The user's password.
|
154
|
+
# @option options [ String ] :pwd Legacy option for the user's password.
|
155
|
+
# If :password and :pwd are both specified, :password takes precedence.
|
154
156
|
# @option options [ Symbol ] :auth_mech The authorization mechanism.
|
155
157
|
# @option options [ Array<String>, Array<Hash> ] roles The user roles.
|
156
158
|
# @option options [ String ] :client_key The user's client key cached from a previous
|
@@ -196,7 +198,11 @@ module Mongo
|
|
196
198
|
#
|
197
199
|
# @since 2.0.0
|
198
200
|
def spec
|
199
|
-
{
|
201
|
+
{roles: roles}.tap do |spec|
|
202
|
+
if password
|
203
|
+
spec[:pwd] = password
|
204
|
+
end
|
205
|
+
end
|
200
206
|
end
|
201
207
|
|
202
208
|
private
|
@@ -92,7 +92,7 @@ module Mongo
|
|
92
92
|
Operation::U => doc[:replacement],
|
93
93
|
}.tap do |d|
|
94
94
|
if doc[:upsert]
|
95
|
-
d[
|
95
|
+
d['upsert'] = true
|
96
96
|
end
|
97
97
|
d[Operation::COLLATION] = doc[:collation] if doc[:collation]
|
98
98
|
end
|
@@ -108,7 +108,7 @@ module Mongo
|
|
108
108
|
Operation::MULTI => true,
|
109
109
|
}.tap do |d|
|
110
110
|
if doc[:upsert]
|
111
|
-
d[
|
111
|
+
d['upsert'] = true
|
112
112
|
end
|
113
113
|
d[Operation::COLLATION] = doc[:collation] if doc[:collation]
|
114
114
|
d[Operation::ARRAY_FILTERS] = doc[:array_filters] if doc[:array_filters]
|
@@ -124,7 +124,7 @@ module Mongo
|
|
124
124
|
Operation::U => doc[:update],
|
125
125
|
}.tap do |d|
|
126
126
|
if doc[:upsert]
|
127
|
-
d[
|
127
|
+
d['upsert'] = true
|
128
128
|
end
|
129
129
|
d[Operation::COLLATION] = doc[:collation] if doc[:collation]
|
130
130
|
d[Operation::ARRAY_FILTERS] = doc[:array_filters] if doc[:array_filters]
|
data/lib/mongo/cluster.rb
CHANGED
@@ -234,7 +234,7 @@ module Mongo
|
|
234
234
|
Operation::U => replacement,
|
235
235
|
}
|
236
236
|
if opts[:upsert]
|
237
|
-
update_doc[
|
237
|
+
update_doc['upsert'] = true
|
238
238
|
end
|
239
239
|
with_session(opts) do |session|
|
240
240
|
write_concern = write_concern_with_session(session)
|
@@ -281,7 +281,7 @@ module Mongo
|
|
281
281
|
Operation::MULTI => true,
|
282
282
|
}
|
283
283
|
if opts[:upsert]
|
284
|
-
update_doc[
|
284
|
+
update_doc['upsert'] = true
|
285
285
|
end
|
286
286
|
with_session(opts) do |session|
|
287
287
|
write_concern = write_concern_with_session(session)
|
@@ -325,7 +325,7 @@ module Mongo
|
|
325
325
|
Operation::U => spec,
|
326
326
|
}
|
327
327
|
if opts[:upsert]
|
328
|
-
update_doc[
|
328
|
+
update_doc['upsert'] = true
|
329
329
|
end
|
330
330
|
with_session(opts) do |session|
|
331
331
|
write_concern = write_concern_with_session(session)
|
@@ -92,7 +92,14 @@ module Mongo
|
|
92
92
|
#
|
93
93
|
# @since 2.3.0
|
94
94
|
def get_cursors_list(spec)
|
95
|
-
spec[:selector][:cursors].map
|
95
|
+
spec[:selector][:cursors].map do |value|
|
96
|
+
if value.respond_to?(:value)
|
97
|
+
# bson-ruby >= 4.6.0
|
98
|
+
value = value.value
|
99
|
+
else
|
100
|
+
value = value.instance_variable_get('@integer')
|
101
|
+
end
|
102
|
+
end
|
96
103
|
end
|
97
104
|
end
|
98
105
|
end
|
@@ -87,7 +87,14 @@ module Mongo
|
|
87
87
|
#
|
88
88
|
# @since 2.3.0
|
89
89
|
def get_cursors_list(spec)
|
90
|
-
spec[:cursor_ids].map
|
90
|
+
spec[:cursor_ids].map do |value|
|
91
|
+
if value.respond_to?(:value)
|
92
|
+
# bson-ruby >= 4.6.0
|
93
|
+
value.value
|
94
|
+
else
|
95
|
+
value.instance_variable_get('@integer')
|
96
|
+
end
|
97
|
+
end
|
91
98
|
end
|
92
99
|
end
|
93
100
|
end
|
@@ -110,7 +110,12 @@ module Mongo
|
|
110
110
|
# @return [String] Buffer with serialized value.
|
111
111
|
def self.serialize(buffer, value, validating_keys = BSON::Config.validating_keys?)
|
112
112
|
if value.is_a?(BSON::Int32)
|
113
|
-
|
113
|
+
if value.respond_to?(:value)
|
114
|
+
# bson-ruby >= 4.6.0
|
115
|
+
value = value.value
|
116
|
+
else
|
117
|
+
value = value.instance_variable_get('@integer')
|
118
|
+
end
|
114
119
|
end
|
115
120
|
buffer.put_int32(value)
|
116
121
|
end
|
@@ -138,7 +143,12 @@ module Mongo
|
|
138
143
|
# @return [ String ] Buffer with serialized value.
|
139
144
|
def self.serialize(buffer, value, validating_keys = BSON::Config.validating_keys?)
|
140
145
|
if value.is_a?(BSON::Int64)
|
141
|
-
|
146
|
+
if value.respond_to?(:value)
|
147
|
+
# bson-ruby >= 4.6.0
|
148
|
+
value = value.value
|
149
|
+
else
|
150
|
+
value = value.instance_variable_get('@integer')
|
151
|
+
end
|
142
152
|
end
|
143
153
|
buffer.put_int64(value)
|
144
154
|
end
|
@@ -322,7 +322,7 @@ module Mongo
|
|
322
322
|
raise exc
|
323
323
|
end
|
324
324
|
rescue => e
|
325
|
-
log_warn("Failed to handshake with #{address}: #{e.class}: #{e}")
|
325
|
+
log_warn("Failed to handshake with #{address}: #{e.class}: #{e}:\n#{e.backtrace[0..5].join("\n")}")
|
326
326
|
raise
|
327
327
|
end
|
328
328
|
end
|
@@ -379,7 +379,7 @@ module Mongo
|
|
379
379
|
begin
|
380
380
|
Auth.get(user).login(pending_connection)
|
381
381
|
rescue => e
|
382
|
-
log_warn("Failed to handshake with #{address}: #{e.class}: #{e}")
|
382
|
+
log_warn("Failed to handshake with #{address}: #{e.class}: #{e}:\n#{e.backtrace[0..5].join("\n")}")
|
383
383
|
raise
|
384
384
|
end
|
385
385
|
end
|
data/lib/mongo/server/monitor.rb
CHANGED
@@ -204,7 +204,7 @@ module Mongo
|
|
204
204
|
connection.ismaster
|
205
205
|
end
|
206
206
|
if exc
|
207
|
-
log_debug("Error running ismaster on #{server.address}: #{exc.class}: #{exc.
|
207
|
+
log_debug("Error running ismaster on #{server.address}: #{exc.class}: #{exc}:\n#{exc.backtrace[0..5].join("\n")}")
|
208
208
|
if monitoring.monitoring?
|
209
209
|
monitoring.failed(
|
210
210
|
Monitoring::SERVER_HEARTBEAT,
|
@@ -232,7 +232,7 @@ module Mongo
|
|
232
232
|
log_warn("Asked to handshake with #{address} but there was no app metadata provided")
|
233
233
|
end
|
234
234
|
rescue => e
|
235
|
-
log_warn("Failed to handshake with #{address}: #{e.class}: #{e}")
|
235
|
+
log_warn("Failed to handshake with #{address}: #{e.class}: #{e}:\n#{e.backtrace[0..5].join("\n")}")
|
236
236
|
raise
|
237
237
|
end
|
238
238
|
|
data/lib/mongo/uri.rb
CHANGED
data/lib/mongo/version.rb
CHANGED
data/mongo.gemspec
CHANGED
@@ -38,7 +38,7 @@ describe 'Client options' do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
shared_examples_for 'auth mechanism that uses database or default auth source' do |default_auth_source
|
41
|
+
shared_examples_for 'auth mechanism that uses database or default auth source' do |default_auth_source|
|
42
42
|
context 'where no database is provided' do
|
43
43
|
context 'with URI options' do
|
44
44
|
let(:credentials) { "#{user}:#{pwd}@" }
|
@@ -198,7 +198,7 @@ describe 'Client options' do
|
|
198
198
|
let(:auth_mech_sym) { :mongodb_cr }
|
199
199
|
|
200
200
|
it_behaves_like 'a supported auth mechanism'
|
201
|
-
it_behaves_like 'auth mechanism that uses database or default auth source',
|
201
|
+
it_behaves_like 'auth mechanism that uses database or default auth source', 'admin'
|
202
202
|
it_behaves_like 'an auth mechanism that doesn\'t support auth_mech_properties'
|
203
203
|
end
|
204
204
|
|
@@ -207,7 +207,7 @@ describe 'Client options' do
|
|
207
207
|
let(:auth_mech_sym) { :scram }
|
208
208
|
|
209
209
|
it_behaves_like 'a supported auth mechanism'
|
210
|
-
it_behaves_like 'auth mechanism that uses database or default auth source',
|
210
|
+
it_behaves_like 'auth mechanism that uses database or default auth source', 'admin'
|
211
211
|
it_behaves_like 'an auth mechanism that doesn\'t support auth_mech_properties'
|
212
212
|
end
|
213
213
|
|
@@ -216,7 +216,7 @@ describe 'Client options' do
|
|
216
216
|
let(:auth_mech_sym) { :scram256 }
|
217
217
|
|
218
218
|
it_behaves_like 'a supported auth mechanism'
|
219
|
-
it_behaves_like 'auth mechanism that uses database or default auth source',
|
219
|
+
it_behaves_like 'auth mechanism that uses database or default auth source', 'admin'
|
220
220
|
it_behaves_like 'an auth mechanism that doesn\'t support auth_mech_properties'
|
221
221
|
end
|
222
222
|
|
@@ -263,7 +263,7 @@ describe 'Client options' do
|
|
263
263
|
let(:auth_mech_sym) { :plain }
|
264
264
|
|
265
265
|
it_behaves_like 'a supported auth mechanism'
|
266
|
-
it_behaves_like 'auth mechanism that uses database or default auth source',
|
266
|
+
it_behaves_like 'auth mechanism that uses database or default auth source', '$external'
|
267
267
|
it_behaves_like 'an auth mechanism with ssl'
|
268
268
|
it_behaves_like 'an auth mechanism that doesn\'t support auth_mech_properties'
|
269
269
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'CRUD operations' do
|
4
|
+
let(:collection) { authorized_client['crud_integration'] }
|
5
|
+
|
6
|
+
before do
|
7
|
+
collection.delete_many
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'upsert' do
|
11
|
+
context 'with default write concern' do
|
12
|
+
it 'upserts' do
|
13
|
+
collection.count_documents({}).should == 0
|
14
|
+
|
15
|
+
res = collection.find(_id: 'foo').update_one({'$set' => {foo: 'bar'}}, upsert: true)
|
16
|
+
|
17
|
+
res.documents.first['upserted'].length.should == 1
|
18
|
+
|
19
|
+
collection.count_documents({}).should == 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'unacknowledged write' do
|
24
|
+
let(:unack_collection) do
|
25
|
+
collection.with(write_concern: {w: 0})
|
26
|
+
end
|
27
|
+
|
28
|
+
before do
|
29
|
+
unack_collection.write_concern.acknowledged?.should be false
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'upserts' do
|
33
|
+
unack_collection.count_documents({}).should == 0
|
34
|
+
|
35
|
+
res = unack_collection.find(_id: 'foo').update_one({'$set' => {foo: 'bar'}}, upsert: true)
|
36
|
+
|
37
|
+
# since write concern is unacknowledged, wait for the data to be
|
38
|
+
# persisted (hopefully)
|
39
|
+
sleep 0.25
|
40
|
+
|
41
|
+
unack_collection.count_documents({}).should == 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -59,7 +59,8 @@ describe 'Cursor reaping' do
|
|
59
59
|
client.cluster.instance_variable_get('@periodic_executor').execute
|
60
60
|
|
61
61
|
started_event = EventSubscriber.started_events.detect do |event|
|
62
|
-
event.command['killCursors'] &&
|
62
|
+
event.command['killCursors'] &&
|
63
|
+
event.command['cursors'].map { |c| Utils.int64_value(c) }.include?(cursor_id)
|
63
64
|
end
|
64
65
|
|
65
66
|
expect(started_event).not_to be_nil
|
data/spec/lite_spec_helper.rb
CHANGED
@@ -2,8 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mongo::Auth::User::View do
|
4
4
|
|
5
|
+
let(:database) { root_authorized_client.database }
|
6
|
+
|
5
7
|
let(:view) do
|
6
|
-
described_class.new(
|
8
|
+
described_class.new(database)
|
7
9
|
end
|
8
10
|
|
9
11
|
before do
|
@@ -51,6 +53,39 @@ describe Mongo::Auth::User::View do
|
|
51
53
|
|
52
54
|
describe '#create' do
|
53
55
|
|
56
|
+
context 'when password is not provided' do
|
57
|
+
|
58
|
+
let(:database) { root_authorized_client.use('$external').database }
|
59
|
+
|
60
|
+
let(:username) { 'passwordless-user' }
|
61
|
+
|
62
|
+
let(:response) do
|
63
|
+
view.create(
|
64
|
+
username,
|
65
|
+
# https://stackoverflow.com/questions/55939832/mongodb-external-database-cannot-create-new-user-with-user-defined-role
|
66
|
+
roles: [{role: 'read', db: 'admin'}],
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
before do
|
71
|
+
begin
|
72
|
+
view.remove(username)
|
73
|
+
rescue Mongo::Error::OperationFailure
|
74
|
+
# can be user not found, ignore
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'creates the user' do
|
79
|
+
view.info(username).should == []
|
80
|
+
|
81
|
+
lambda do
|
82
|
+
response
|
83
|
+
end.should_not raise_error
|
84
|
+
|
85
|
+
view.info(username).first['user'].should == username
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
54
89
|
context 'when a session is not used' do
|
55
90
|
|
56
91
|
let!(:response) do
|
@@ -325,4 +325,16 @@ describe Mongo::Auth::User do
|
|
325
325
|
end
|
326
326
|
end
|
327
327
|
end
|
328
|
+
|
329
|
+
describe '#spec' do
|
330
|
+
context 'when no password and no roles are set' do
|
331
|
+
let(:user) do
|
332
|
+
described_class.new(user: 'foo')
|
333
|
+
end
|
334
|
+
|
335
|
+
it 'is a hash with empty roles' do
|
336
|
+
user.spec.should == {roles: []}
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
328
340
|
end
|
@@ -1924,11 +1924,11 @@ describe Mongo::BulkWrite do
|
|
1924
1924
|
end
|
1925
1925
|
|
1926
1926
|
let(:first_txn_number) do
|
1927
|
-
started_events[-2].command['txnNumber']
|
1927
|
+
Utils.int64_value(started_events[-2].command['txnNumber'])
|
1928
1928
|
end
|
1929
1929
|
|
1930
1930
|
let(:second_txn_number) do
|
1931
|
-
started_events[-1].command['txnNumber']
|
1931
|
+
Utils.int64_value(started_events[-1].command['txnNumber'])
|
1932
1932
|
end
|
1933
1933
|
|
1934
1934
|
it 'inserts the documents' do
|
data/spec/mongo/cluster_spec.rb
CHANGED
@@ -20,6 +20,25 @@ describe Mongo::Cluster do
|
|
20
20
|
|
21
21
|
let(:cluster) { cluster_without_io }
|
22
22
|
|
23
|
+
describe 'initialize' do
|
24
|
+
|
25
|
+
context 'when there are duplicate addresses' do
|
26
|
+
|
27
|
+
let(:addresses) do
|
28
|
+
SpecConfig.instance.addresses + SpecConfig.instance.addresses
|
29
|
+
end
|
30
|
+
let(:cluster_with_dup_addresses) do
|
31
|
+
register_cluster(
|
32
|
+
described_class.new(addresses, monitoring, SpecConfig.instance.test_options))
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'does not raise an exception' do
|
36
|
+
expect { cluster_with_dup_addresses }.not_to raise_error
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
23
42
|
describe '#==' do
|
24
43
|
|
25
44
|
context 'when the other is a cluster' do
|