mongo 2.4.0 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -538,62 +538,71 @@ describe Mongo::Collection do
538
538
  described_class.new(database, :specs)
539
539
  end
540
540
 
541
- before do
542
- collection.create
543
- end
541
+ context 'when the collection exists' do
542
+ before do
543
+ collection.create
544
+ end
544
545
 
545
- context 'when the collection does not have a write concern set' do
546
+ context 'when the collection does not have a write concern set' do
546
547
 
547
- let!(:response) do
548
- collection.drop
549
- end
548
+ let!(:response) do
549
+ collection.drop
550
+ end
550
551
 
551
- it 'executes the command' do
552
- expect(response).to be_successful
553
- end
552
+ it 'executes the command' do
553
+ expect(response).to be_successful
554
+ end
554
555
 
555
- it 'drops the collection from the database' do
556
- expect(database.collection_names).to_not include('specs')
557
- end
556
+ it 'drops the collection from the database' do
557
+ expect(database.collection_names).to_not include('specs')
558
+ end
558
559
 
559
- context 'when the collection does not exist' do
560
+ context 'when the collection does not exist' do
560
561
 
561
- it 'does not raise an error' do
562
- expect(database['non-existent-coll'].drop).to be(false)
562
+ it 'does not raise an error' do
563
+ expect(database['non-existent-coll'].drop).to be(false)
564
+ end
563
565
  end
564
566
  end
565
- end
566
567
 
567
- context 'when the collection has a write concern' do
568
+ context 'when the collection has a write concern' do
568
569
 
569
- let(:write_options) do
570
- {
571
- write: { w: WRITE_CONCERN[:w] + 1}
572
- }
573
- end
570
+ let(:write_options) do
571
+ {
572
+ write: { w: WRITE_CONCERN[:w] + 1}
573
+ }
574
+ end
574
575
 
575
- let(:collection_with_write_options) do
576
- collection.with(write_options)
577
- end
576
+ let(:collection_with_write_options) do
577
+ collection.with(write_options)
578
+ end
578
579
 
579
- after do
580
- collection.drop
581
- end
580
+ after do
581
+ collection.drop
582
+ end
583
+
584
+ context 'when the server supports write concern on the drop command', if: collation_enabled? do
582
585
 
583
- context 'when the server supports write concern on the drop command', if: collation_enabled? do
586
+ it 'applies the write concern' do
587
+ expect{
588
+ collection_with_write_options.drop
589
+ }.to raise_exception(Mongo::Error::OperationFailure)
590
+ end
591
+ end
592
+
593
+ context 'when the server does not support write concern on the drop command', unless: collation_enabled? do
584
594
 
585
- it 'applies the write concern' do
586
- expect{
587
- collection_with_write_options.drop
588
- }.to raise_exception(Mongo::Error::OperationFailure)
595
+ it 'does not apply the write concern' do
596
+ expect(collection_with_write_options.drop).to be_successful
597
+ end
589
598
  end
590
599
  end
600
+ end
591
601
 
592
- context 'when the server does not support write concern on the drop command', unless: collation_enabled? do
602
+ context 'when the collection does not exist' do
593
603
 
594
- it 'does not apply the write concern' do
595
- expect(collection_with_write_options.drop).to be_successful
596
- end
604
+ it 'returns false' do
605
+ expect(collection.drop).to be(false)
597
606
  end
598
607
  end
599
608
  end
@@ -1158,7 +1167,7 @@ describe Mongo::Collection do
1158
1167
  end
1159
1168
 
1160
1169
  it 'sets the options on the Aggregation object' do
1161
- expect(authorized_collection.aggregate([], options).options).to eq(options)
1170
+ expect(authorized_collection.aggregate([], options).options).to eq(BSON::Document.new(options))
1162
1171
  end
1163
1172
 
1164
1173
  context 'when collation is provided' do
@@ -10,9 +10,12 @@ describe 'Server Discovery and Monitoring' do
10
10
  context(spec.description) do
11
11
 
12
12
  before(:all) do
13
- Mongo::Client.new(spec.uri_string).tap do |client|
14
- @client = client.with(connect_timeout: 0.1, heartbeat_frequency: 100)
15
- end.close
13
+ @client = Mongo::Client.new([])
14
+ @client.send(:create_from_uri, spec.uri_string)
15
+ client_options = @client.instance_variable_get(:@options)
16
+ @client.instance_variable_set(:@options, client_options.merge(heartbeat_frequency: 100, connect_timeout: 0.1))
17
+ @client.cluster.instance_variable_set(:@options, client_options.merge(heartbeat_frequency: 100, connect_timeout: 0.1))
18
+ @client.cluster.instance_variable_get(:@servers).each { |s| s.disconnect!; s.unknown!; }
16
19
  end
17
20
 
18
21
  after(:all) do
@@ -26,13 +29,17 @@ describe 'Server Discovery and Monitoring' do
26
29
  before(:all) do
27
30
  phase.responses.each do |response|
28
31
  server = find_server(@client, response.address)
29
- server ||= Mongo::Server.new(
30
- Mongo::Address.new(response.address),
31
- @client.cluster,
32
- @client.instance_variable_get(:@monitoring),
33
- @client.cluster.send(:event_listeners),
34
- @client.cluster.options
35
- )
32
+ unless server
33
+ server = Mongo::Server.new(
34
+ Mongo::Address.new(response.address),
35
+ @client.cluster,
36
+ @client.instance_variable_get(:@monitoring),
37
+ @client.cluster.send(:event_listeners),
38
+ @client.cluster.options
39
+ )
40
+ server.disconnect!
41
+ server.unknown!
42
+ end
36
43
  monitor = server.instance_variable_get(:@monitor)
37
44
  description = monitor.inspector.run(server.description, response.ismaster, 0.5)
38
45
  monitor.instance_variable_set(:@description, description)
@@ -667,6 +667,31 @@ describe Mongo::URI do
667
667
  expect(Mongo::Client.new(string.downcase).options[:auth_mech]).to eq(expected)
668
668
  end
669
669
  end
670
+
671
+ context 'mongodb-x509' do
672
+ let(:mechanism) { 'MONGODB-X509' }
673
+ let(:expected) { :mongodb_x509 }
674
+
675
+ it 'sets the auth mechanism to :mongodb_x509' do
676
+ expect(uri.uri_options[:auth_mech]).to eq(expected)
677
+ end
678
+
679
+ it 'sets the options on a client created with the uri' do
680
+ expect(Mongo::Client.new(string).options[:auth_mech]).to eq(expected)
681
+ end
682
+
683
+ it 'is case-insensitive' do
684
+ expect(Mongo::Client.new(string.downcase).options[:auth_mech]).to eq(expected)
685
+ end
686
+
687
+ context 'when a username is not provided' do
688
+
689
+ it 'recognizes the mechanism with no username' do
690
+ expect(Mongo::Client.new(string.downcase).options[:auth_mech]).to eq(expected)
691
+ expect(Mongo::Client.new(string.downcase).options[:user]).to be_nil
692
+ end
693
+ end
694
+ end
670
695
  end
671
696
 
672
697
  context 'auth source provided' do
@@ -192,7 +192,11 @@ end
192
192
  # @since 2.2.0
193
193
  def auth_enabled?
194
194
  $mongo_client ||= initialize_scanned_client!
195
- begin; $mongo_client.use(:admin).command(getCmdLineOpts: 1); rescue; return true; end
195
+ begin
196
+ $mongo_client.use(:admin).command(getCmdLineOpts: 1).first["argv"].include?("--auth")
197
+ rescue
198
+ return true
199
+ end
196
200
  false
197
201
  end
198
202
 
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "responses": [
20
20
  [
21
- "lhost:27017",
21
+ "localhost:27017",
22
22
  {
23
23
  "me": "a:27017",
24
24
  "hosts": [
@@ -33,5 +33,5 @@
33
33
  ]
34
34
  }
35
35
  ],
36
- "uri": "mongodb://lhost:27017/?replicaSet=rs"
36
+ "uri": "mongodb://localhost:27017/?replicaSet=rs"
37
37
  }
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "responses": [
20
20
  [
21
- "lhost:27017",
21
+ "localhost:27017",
22
22
  {
23
23
  "me": "a:27017",
24
24
  "hosts": [
@@ -33,5 +33,5 @@
33
33
  ]
34
34
  }
35
35
  ],
36
- "uri": "mongodb://lhost:27017/?replicaSet=rs"
36
+ "uri": "mongodb://localhost:27017/?replicaSet=rs"
37
37
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -14,7 +14,7 @@ cert_chain:
14
14
  -----BEGIN CERTIFICATE-----
15
15
  MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
16
16
  ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
17
- Y29tMB4XDTE1MTIwNzE1MTcyNloXDTE2MTIwNjE1MTcyNlowQjEUMBIGA1UEAwwL
17
+ Y29tMB4XDTE2MTIyMDEzMzc1N1oXDTE3MTIyMDEzMzc1N1owQjEUMBIGA1UEAwwL
18
18
  ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZAEZFgUxMGdlbjETMBEGCgmSJomT8ixk
19
19
  ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANFdSAa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5U+sUyArQXg+lk=
34
34
  -----END CERTIFICATE-----
35
- date: 2016-11-29 00:00:00.000000000 Z
35
+ date: 2016-12-20 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bson
39
39
  requirement: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "~>"
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 4.2.0
43
+ version: 4.2.1
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 5.0.0
44
47
  type: :runtime
45
48
  prerelease: false
46
49
  version_requirements: !ruby/object:Gem::Requirement
47
50
  requirements:
48
- - - "~>"
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 4.2.1
54
+ - - "<"
49
55
  - !ruby/object:Gem::Version
50
- version: 4.2.0
56
+ version: 5.0.0
51
57
  description: A Ruby driver for MongoDB
52
58
  email: mongodb-dev@googlegroups.com
53
59
  executables:
@@ -665,7 +671,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
665
671
  version: '0'
666
672
  requirements: []
667
673
  rubyforge_project:
668
- rubygems_version: 2.5.2
674
+ rubygems_version: 2.4.5.1
669
675
  signing_key:
670
676
  specification_version: 4
671
677
  summary: Ruby driver for MongoDB
metadata.gz.sig CHANGED
Binary file