mongo 2.2.5 → 2.2.6

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/mongo/auth/scram/conversation.rb +9 -3
  5. data/lib/mongo/error.rb +1 -0
  6. data/lib/mongo/error/unexpected_response.rb +38 -0
  7. data/lib/mongo/operation/commands/map_reduce/result.rb +1 -1
  8. data/lib/mongo/operation/commands/user_query.rb +1 -1
  9. data/lib/mongo/operation/commands/users_info/result.rb +6 -0
  10. data/lib/mongo/protocol/message.rb +10 -3
  11. data/lib/mongo/retryable.rb +23 -0
  12. data/lib/mongo/server/connectable.rb +7 -6
  13. data/lib/mongo/server/connection.rb +18 -2
  14. data/lib/mongo/server/connection_pool.rb +4 -6
  15. data/lib/mongo/server/monitor/connection.rb +6 -3
  16. data/lib/mongo/uri.rb +7 -8
  17. data/lib/mongo/version.rb +1 -1
  18. data/mongo.gemspec +1 -0
  19. data/spec/mongo/address_spec.rb +2 -2
  20. data/spec/mongo/auth/cr_spec.rb +1 -1
  21. data/spec/mongo/auth/ldap_spec.rb +1 -1
  22. data/spec/mongo/auth/scram_spec.rb +1 -1
  23. data/spec/mongo/auth/user/view_spec.rb +12 -0
  24. data/spec/mongo/auth/x509_spec.rb +1 -1
  25. data/spec/mongo/client_spec.rb +1 -9
  26. data/spec/mongo/operation/result_spec.rb +3 -3
  27. data/spec/mongo/operation/write/update_spec.rb +1 -1
  28. data/spec/mongo/server/connection_spec.rb +168 -4
  29. data/spec/mongo/server/monitor_spec.rb +34 -4
  30. data/spec/mongo/server_selector/nearest_spec.rb +4 -4
  31. data/spec/mongo/server_selector/primary_preferred_spec.rb +4 -4
  32. data/spec/mongo/server_selector/primary_spec.rb +2 -2
  33. data/spec/mongo/server_selector/secondary_preferred_spec.rb +4 -4
  34. data/spec/mongo/server_selector/secondary_spec.rb +3 -3
  35. data/spec/mongo/server_spec.rb +3 -3
  36. data/spec/mongo/socket/ssl_spec.rb +1 -1
  37. data/spec/mongo/uri_spec.rb +124 -23
  38. data/spec/support/authorization.rb +10 -6
  39. data/spec/support/shared/server_selector.rb +1 -1
  40. metadata +18 -3
  41. metadata.gz.sig +0 -0
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Mongo::Socket::SSL, if: running_ssl? do
4
4
 
5
5
  let(:socket) do
6
- described_class.new(*DEFAULT_ADDRESS.split(":"), DEFAULT_ADDRESS.split(":")[0], 5, Socket::PF_INET, options)
6
+ described_class.new(*default_address.to_s.split(":"), default_address.host, 5, Socket::PF_INET, options)
7
7
  end
8
8
 
9
9
  let(:options) do
@@ -4,7 +4,7 @@ describe Mongo::URI do
4
4
  let(:scheme) { 'mongodb://' }
5
5
  let(:uri) { described_class.new(string) }
6
6
 
7
- describe 'invalid uris' do
7
+ describe 'invalid uris' do
8
8
 
9
9
  context 'string is not uri' do
10
10
 
@@ -370,6 +370,10 @@ describe 'invalid uris' do
370
370
  it 'sets the write concern options' do
371
371
  expect(uri.uri_options[:write]).to eq(concern)
372
372
  end
373
+
374
+ it 'sets the options on a client created with the uri' do
375
+ expect(Mongo::Client.new(string).options[:write]).to eq(concern)
376
+ end
373
377
  end
374
378
 
375
379
  context 'w=majority' do
@@ -379,6 +383,10 @@ describe 'invalid uris' do
379
383
  it 'sets the write concern options' do
380
384
  expect(uri.uri_options[:write]).to eq(concern)
381
385
  end
386
+
387
+ it 'sets the options on a client created with the uri' do
388
+ expect(Mongo::Client.new(string).options[:write]).to eq(concern)
389
+ end
382
390
  end
383
391
 
384
392
  context 'journal' do
@@ -388,6 +396,10 @@ describe 'invalid uris' do
388
396
  it 'sets the write concern options' do
389
397
  expect(uri.uri_options[:write]).to eq(concern)
390
398
  end
399
+
400
+ it 'sets the options on a client created with the uri' do
401
+ expect(Mongo::Client.new(string).options[:write]).to eq(concern)
402
+ end
391
403
  end
392
404
 
393
405
  context 'fsync' do
@@ -397,6 +409,10 @@ describe 'invalid uris' do
397
409
  it 'sets the write concern options' do
398
410
  expect(uri.uri_options[:write]).to eq(concern)
399
411
  end
412
+
413
+ it 'sets the options on a client created with the uri' do
414
+ expect(Mongo::Client.new(string).options[:write]).to eq(concern)
415
+ end
400
416
  end
401
417
 
402
418
  context 'wtimeoutMS' do
@@ -407,6 +423,10 @@ describe 'invalid uris' do
407
423
  it 'sets the write concern options' do
408
424
  expect(uri.uri_options[:write]).to eq(concern)
409
425
  end
426
+
427
+ it 'sets the options on a client created with the uri' do
428
+ expect(Mongo::Client.new(string).options[:write]).to eq(concern)
429
+ end
410
430
  end
411
431
  end
412
432
 
@@ -420,6 +440,10 @@ describe 'invalid uris' do
420
440
  it 'sets the read preference' do
421
441
  expect(uri.uri_options[:read]).to eq(read)
422
442
  end
443
+
444
+ it 'sets the options on a client created with the uri' do
445
+ expect(Mongo::Client.new(string).options[:read]).to eq(read)
446
+ end
423
447
  end
424
448
 
425
449
  context 'primaryPreferred' do
@@ -429,6 +453,10 @@ describe 'invalid uris' do
429
453
  it 'sets the read preference' do
430
454
  expect(uri.uri_options[:read]).to eq(read)
431
455
  end
456
+
457
+ it 'sets the options on a client created with the uri' do
458
+ expect(Mongo::Client.new(string).options[:read]).to eq(read)
459
+ end
432
460
  end
433
461
 
434
462
  context 'secondary' do
@@ -438,6 +466,10 @@ describe 'invalid uris' do
438
466
  it 'sets the read preference' do
439
467
  expect(uri.uri_options[:read]).to eq(read)
440
468
  end
469
+
470
+ it 'sets the options on a client created with the uri' do
471
+ expect(Mongo::Client.new(string).options[:read]).to eq(read)
472
+ end
441
473
  end
442
474
 
443
475
  context 'secondaryPreferred' do
@@ -447,6 +479,10 @@ describe 'invalid uris' do
447
479
  it 'sets the read preference' do
448
480
  expect(uri.uri_options[:read]).to eq(read)
449
481
  end
482
+
483
+ it 'sets the options on a client created with the uri' do
484
+ expect(Mongo::Client.new(string).options[:read]).to eq(read)
485
+ end
450
486
  end
451
487
 
452
488
  context 'nearest' do
@@ -456,6 +492,10 @@ describe 'invalid uris' do
456
492
  it 'sets the read preference' do
457
493
  expect(uri.uri_options[:read]).to eq(read)
458
494
  end
495
+
496
+ it 'sets the options on a client created with the uri' do
497
+ expect(Mongo::Client.new(string).options[:read]).to eq(read)
498
+ end
459
499
  end
460
500
  end
461
501
 
@@ -473,6 +513,10 @@ describe 'invalid uris' do
473
513
  it 'sets the read preference tag set' do
474
514
  expect(uri.uri_options[:read]).to eq(read)
475
515
  end
516
+
517
+ it 'sets the options on a client created with the uri' do
518
+ expect(Mongo::Client.new(string).options[:read]).to eq(read)
519
+ end
476
520
  end
477
521
 
478
522
  context 'multiple read preference tag sets' do
@@ -487,6 +531,10 @@ describe 'invalid uris' do
487
531
  it 'sets the read preference tag sets' do
488
532
  expect(uri.uri_options[:read]).to eq(read)
489
533
  end
534
+
535
+ it 'sets the options on a client created with the uri' do
536
+ expect(Mongo::Client.new(string).options[:read]).to eq(read)
537
+ end
490
538
  end
491
539
  end
492
540
 
@@ -497,6 +545,10 @@ describe 'invalid uris' do
497
545
  it 'sets the replica set option' do
498
546
  expect(uri.uri_options[:replica_set]).to eq(rs_name)
499
547
  end
548
+
549
+ it 'sets the options on a client created with the uri' do
550
+ expect(Mongo::Client.new(string).options[:replica_set]).to eq(rs_name)
551
+ end
500
552
  end
501
553
 
502
554
  context 'auth mechanism provided' do
@@ -509,6 +561,14 @@ describe 'invalid uris' do
509
561
  it 'sets the auth mechanism to :plain' do
510
562
  expect(uri.uri_options[:auth_mech]).to eq(expected)
511
563
  end
564
+
565
+ it 'sets the options on a client created with the uri' do
566
+ expect(Mongo::Client.new(string).options[:auth_mech]).to eq(expected)
567
+ end
568
+
569
+ it 'is case-insensitive' do
570
+ expect(Mongo::Client.new(string.downcase).options[:auth_mech]).to eq(expected)
571
+ end
512
572
  end
513
573
 
514
574
  context 'mongodb-cr' do
@@ -518,6 +578,14 @@ describe 'invalid uris' do
518
578
  it 'sets the auth mechanism to :mongodb_cr' do
519
579
  expect(uri.uri_options[:auth_mech]).to eq(expected)
520
580
  end
581
+
582
+ it 'sets the options on a client created with the uri' do
583
+ expect(Mongo::Client.new(string).options[:auth_mech]).to eq(expected)
584
+ end
585
+
586
+ it 'is case-insensitive' do
587
+ expect(Mongo::Client.new(string.downcase).options[:auth_mech]).to eq(expected)
588
+ end
521
589
  end
522
590
 
523
591
  context 'gssapi' do
@@ -527,6 +595,14 @@ describe 'invalid uris' do
527
595
  it 'sets the auth mechanism to :gssapi' do
528
596
  expect(uri.uri_options[:auth_mech]).to eq(expected)
529
597
  end
598
+
599
+ it 'sets the options on a client created with the uri' do
600
+ expect(Mongo::Client.new(string).options[:auth_mech]).to eq(expected)
601
+ end
602
+
603
+ it 'is case-insensitive' do
604
+ expect(Mongo::Client.new(string.downcase).options[:auth_mech]).to eq(expected)
605
+ end
530
606
  end
531
607
 
532
608
  context 'scram-sha-1' do
@@ -536,6 +612,14 @@ describe 'invalid uris' do
536
612
  it 'sets the auth mechanism to :scram' do
537
613
  expect(uri.uri_options[:auth_mech]).to eq(expected)
538
614
  end
615
+
616
+ it 'sets the options on a client created with the uri' do
617
+ expect(Mongo::Client.new(string).options[:auth_mech]).to eq(expected)
618
+ end
619
+
620
+ it 'is case-insensitive' do
621
+ expect(Mongo::Client.new(string.downcase).options[:auth_mech]).to eq(expected)
622
+ end
539
623
  end
540
624
  end
541
625
 
@@ -544,19 +628,26 @@ describe 'invalid uris' do
544
628
 
545
629
  context 'regular db' do
546
630
  let(:source) { 'foo' }
547
- let(:auth) { Mongo::Options::Redacted.new(:source => 'foo') }
548
631
 
549
632
  it 'sets the auth source to the database' do
550
- expect(uri.uri_options[:auth]).to eq(auth)
633
+ expect(uri.uri_options[:auth_source]).to eq(source)
634
+ end
635
+
636
+ it 'sets the options on a client created with the uri' do
637
+ expect(Mongo::Client.new(string).options[:auth_source]).to eq(source)
551
638
  end
552
639
  end
553
640
 
554
641
  context '$external' do
555
642
  let(:source) { '$external' }
556
- let(:auth) { Mongo::Options::Redacted.new(:source => :external) }
643
+ let(:expected) { :external }
557
644
 
558
645
  it 'sets the auth source to :external' do
559
- expect(uri.uri_options[:auth]).to eq(auth)
646
+ expect(uri.uri_options[:auth_source]).to eq(expected)
647
+ end
648
+
649
+ it 'sets the options on a client created with the uri' do
650
+ expect(Mongo::Client.new(string).options[:auth_source]).to eq(expected)
560
651
  end
561
652
  end
562
653
  end
@@ -569,12 +660,14 @@ describe 'invalid uris' do
569
660
  end
570
661
 
571
662
  let(:service_name) { 'foo' }
572
- let(:auth) do
573
- Mongo::Options::Redacted.new(auth_mech_properties: { service_name: service_name })
574
- end
663
+ let(:expected) { Mongo::Options::Redacted.new({ service_name: service_name }) }
575
664
 
576
665
  it 'sets the auth mechanism properties' do
577
- expect(uri.uri_options[:auth]).to eq(auth)
666
+ expect(uri.uri_options[:auth_mech_properties]).to eq(expected)
667
+ end
668
+
669
+ it 'sets the options on a client created with the uri' do
670
+ expect(Mongo::Client.new(string).options[:auth_mech_properties]).to eq(expected)
578
671
  end
579
672
  end
580
673
 
@@ -582,14 +675,15 @@ describe 'invalid uris' do
582
675
  let(:options) do
583
676
  "authMechanismProperties=CANONICALIZE_HOST_NAME:#{canonicalize_host_name}"
584
677
  end
585
-
586
678
  let(:canonicalize_host_name) { 'true' }
587
- let(:auth) do
588
- Mongo::Options::Redacted.new(auth_mech_properties: { canonicalize_host_name: true })
589
- end
679
+ let(:expected) { Mongo::Options::Redacted.new({ canonicalize_host_name: true }) }
590
680
 
591
681
  it 'sets the auth mechanism properties' do
592
- expect(uri.uri_options[:auth]).to eq(auth)
682
+ expect(uri.uri_options[:auth_mech_properties]).to eq(expected)
683
+ end
684
+
685
+ it 'sets the options on a client created with the uri' do
686
+ expect(Mongo::Client.new(string).options[:auth_mech_properties]).to eq(expected)
593
687
  end
594
688
  end
595
689
 
@@ -599,12 +693,15 @@ describe 'invalid uris' do
599
693
  end
600
694
 
601
695
  let(:service_realm) { 'dumdum' }
602
- let(:auth) do
603
- Mongo::Options::Redacted.new(auth_mech_properties: { service_realm: service_realm })
604
- end
696
+ let(:expected) { Mongo::Options::Redacted.new({ service_realm: service_realm }) }
697
+
605
698
 
606
699
  it 'sets the auth mechanism properties' do
607
- expect(uri.uri_options[:auth]).to eq(auth)
700
+ expect(uri.uri_options[:auth_mech_properties]).to eq(expected)
701
+ end
702
+
703
+ it 'sets the options on a client created with the uri' do
704
+ expect(Mongo::Client.new(string).options[:auth_mech_properties]).to eq(expected)
608
705
  end
609
706
  end
610
707
 
@@ -619,14 +716,18 @@ describe 'invalid uris' do
619
716
  let(:canonicalize_host_name) { 'true' }
620
717
  let(:service_realm) { 'dumdum' }
621
718
 
622
- let(:auth) do
623
- Mongo::Options::Redacted.new(auth_mech_properties: { service_name: service_name,
624
- canonicalize_host_name: true,
625
- service_realm: service_realm })
719
+ let(:expected) do
720
+ Mongo::Options::Redacted.new({ service_name: service_name,
721
+ canonicalize_host_name: true,
722
+ service_realm: service_realm })
626
723
  end
627
724
 
628
725
  it 'sets the auth mechanism properties' do
629
- expect(uri.uri_options[:auth]).to eq(auth)
726
+ expect(uri.uri_options[:auth_mech_properties]).to eq(expected)
727
+ end
728
+
729
+ it 'sets the options on a client created with the uri' do
730
+ expect(Mongo::Client.new(string).options[:auth_mech_properties]).to eq(expected)
630
731
  end
631
732
  end
632
733
  end
@@ -28,11 +28,6 @@ TEST_COLL = 'test'.freeze
28
28
  ADDRESSES = ENV['MONGODB_ADDRESSES'] ? ENV['MONGODB_ADDRESSES'].split(',').freeze :
29
29
  [ '127.0.0.1:27017' ].freeze
30
30
 
31
- # A default address to use in tests.
32
- #
33
- # @since 2.0.0
34
- DEFAULT_ADDRESS = ADDRESSES.first
35
-
36
31
  # The topology type.
37
32
  #
38
33
  # @since 2.0.0
@@ -65,7 +60,9 @@ SSL_OPTIONS = {
65
60
  # @since 2.1.0
66
61
  BASE_OPTIONS = {
67
62
  max_pool_size: 1,
68
- write: WRITE_CONCERN
63
+ write: WRITE_CONCERN,
64
+ heartbeat_frequency: 5,
65
+ max_read_retries: 5
69
66
  }
70
67
 
71
68
  # Options for test suite clients.
@@ -245,5 +242,12 @@ module Authorization
245
242
  context.let(:unauthorized_primary) do
246
243
  authorized_client.cluster.next_primary
247
244
  end
245
+
246
+ # Get a default address (of the primary).
247
+ #
248
+ # @since 2.2.6
249
+ context.let(:default_address) do
250
+ authorized_client.cluster.next_primary.address
251
+ end
248
252
  end
249
253
  end
@@ -12,7 +12,7 @@ def server(mode, options = {})
12
12
 
13
13
  listeners = Mongo::Event::Listeners.new
14
14
  monitoring = Mongo::Monitoring.new
15
- address = Mongo::Address.new(DEFAULT_ADDRESS)
15
+ address = options[:address]
16
16
 
17
17
  server = Mongo::Server.new(address, double('cluster'), monitoring, listeners, TEST_OPTIONS)
18
18
  description = Mongo::Server::Description.new(address, ismaster, average_round_trip_time)
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.2.5
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -32,7 +32,7 @@ cert_chain:
32
32
  EhIn2f8suSc9QAqYt7w4T+PMtjxWTVcXs+Uy2PbDtjhtEBz6ZsP6YSsOpJbrCjCV
33
33
  wZtXjpRUvWz86V5vjhHCTE8fqfEb85aeDwUCckPzpio=
34
34
  -----END CERTIFICATE-----
35
- date: 2016-04-29 00:00:00.000000000 Z
35
+ date: 2016-07-12 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bson
@@ -48,6 +48,20 @@ dependencies:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
50
  version: '4.0'
51
+ - !ruby/object:Gem::Dependency
52
+ name: pry
53
+ requirement: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ type: :runtime
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
51
65
  description: A Ruby driver for MongoDB
52
66
  email: mongodb-dev@googlegroups.com
53
67
  executables:
@@ -151,6 +165,7 @@ files:
151
165
  - lib/mongo/error/socket_timeout_error.rb
152
166
  - lib/mongo/error/unchangeable_collection_option.rb
153
167
  - lib/mongo/error/unexpected_chunk_length.rb
168
+ - lib/mongo/error/unexpected_response.rb
154
169
  - lib/mongo/error/unsupported_features.rb
155
170
  - lib/mongo/event.rb
156
171
  - lib/mongo/event/description_changed.rb
@@ -578,7 +593,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
578
593
  version: '0'
579
594
  requirements: []
580
595
  rubyforge_project:
581
- rubygems_version: 2.4.5.1
596
+ rubygems_version: 2.5.1
582
597
  signing_key:
583
598
  specification_version: 4
584
599
  summary: Ruby driver for MongoDB
metadata.gz.sig CHANGED
Binary file