mongo 2.11.2 → 2.11.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d52eaac2e54a90b6aad27aa1ef965c67cb36d4ea61907092e867b40eac1f9539
4
- data.tar.gz: c118c191fac15467052a316eadd13035ed43968af1e46bd50ea45e6ad4884900
3
+ metadata.gz: f1ec5495bf06a11fa0003454eb892099bc1a86da8ef1694fc25990c18d2f64ba
4
+ data.tar.gz: b07b2a3f5b71e89e66d6117253e1c85e4c6c90b8a8bb2f17cee24a8b47b9dad8
5
5
  SHA512:
6
- metadata.gz: f652bbcf6b01f172199d467953d8f0ab3b9bc83b2e790d87a2c2f3b3251e5c0139234cbe1c2a1fbb6791ab5bf18be001b9be271ef0a0a9bfa75f9d20be9441f5
7
- data.tar.gz: 82a0273865415d0ce911b96a0f80fa59610539d23e8182acd706cade06226df0d9a5ca931a3ae1b05a6191e4d4e934cb713c232a67c4dcedb48d03cf696ed79b
6
+ metadata.gz: 6e88a5e7d0a2bd2917c4ba887d38786229fd9f64e2056b894ccd3289983b52f7aa8b293d77c46df4412d1fb01faed8bb41bfe93fa08e5085a8ec88fe22aaed34
7
+ data.tar.gz: fe47a5b889ff2b9449475e040d6e189bc984158e5c6b0cfab055dcce83d7efb090ec129eb5afee5cfed7a4b30ddda6bcc0d60e1b8720ff96f188548f28a75460
@@ -1,2 +1,2 @@
1
- Vn��i�'P��zQ��il|�� )8i�=���:\ʜ���ڭ)��V)�8���uH2�����q8D�����k���us@��`:&V�2'0$ť'aޒ@{j����gI�.}�Ո�Y~�y8~�>��QX-��)2�N��r
2
- ����ECzꅚ �n�,��y�ڋ�X��Ϊr4���]V�
1
+ �|A�i� 7Z����$��^�H� jC˴C�8Δ�����>�6�%�&�a�������[���epR@U='�ӯYR�ԡ�ΉȢ�:�yZ'N�#��|���i*{v�n�\�yV]}�����+r
2
+ ?������Jtz[���8d� �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
@@ -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
- { pwd: password, roles: roles }
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[:upsert] = true
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[:upsert] = true
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[:upsert] = true
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]
@@ -109,6 +109,8 @@ module Mongo
109
109
  options[:cleanup] = false
110
110
  end
111
111
 
112
+ seeds = seeds.uniq
113
+
112
114
  @servers = []
113
115
  @monitoring = monitoring
114
116
  @event_listeners = Event::Listeners.new
@@ -234,7 +234,7 @@ module Mongo
234
234
  Operation::U => replacement,
235
235
  }
236
236
  if opts[:upsert]
237
- update_doc[:upsert] = true
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[:upsert] = true
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[:upsert] = true
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(&:value)
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(&:value)
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
- value = value.value
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
- value = value.value
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
@@ -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.message}")
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
 
@@ -454,7 +454,7 @@ module Mongo
454
454
  end
455
455
 
456
456
  def decode(value)
457
- ::URI.decode(value)
457
+ ::URI::DEFAULT_PARSER.unescape(value)
458
458
  end
459
459
 
460
460
  def encode(value)
@@ -17,5 +17,5 @@ module Mongo
17
17
  # The current version of the driver.
18
18
  #
19
19
  # @since 2.0.0
20
- VERSION = '2.11.2'.freeze
20
+ VERSION = '2.11.3'.freeze
21
21
  end
@@ -40,5 +40,5 @@ Gem::Specification.new do |s|
40
40
 
41
41
  s.required_ruby_version = ">= 2.3"
42
42
 
43
- s.add_dependency 'bson', '>=4.6.0', '<5.0.0'
43
+ s.add_dependency 'bson', '>=4.4.2', '<5.0.0'
44
44
  end
@@ -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', default_auth_source: 'admin'
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', default_auth_source: 'admin'
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', default_auth_source: 'admin'
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', default_auth_source: '$external'
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'] && event.command['cursors'].map(&:value).include?(cursor_id)
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
@@ -127,6 +127,7 @@ RSpec.configure do |config|
127
127
  end
128
128
 
129
129
  config.expect_with :rspec do |c|
130
+ c.syntax = [:should, :expect]
130
131
  c.max_formatted_output_length = 10000
131
132
  end
132
133
  end
@@ -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(root_authorized_client.database)
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'].value
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'].value
1931
+ Utils.int64_value(started_events[-1].command['txnNumber'])
1932
1932
  end
1933
1933
 
1934
1934
  it 'inserts the documents' do
@@ -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