mongo 2.8.0.rc0 → 2.8.0
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 +3 -1
- data.tar.gz.sig +0 -0
- data/lib/mongo/server/description.rb +1 -1
- data/lib/mongo/session.rb +1 -0
- data/lib/mongo/uri.rb +50 -12
- data/lib/mongo/version.rb +1 -1
- data/spec/mongo/server/description_spec.rb +14 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +55 -7
- data/spec/spec_tests/uri_options_spec.rb +1 -1
- metadata +4 -4
- 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: 9696938332fb0fee42821edacd510e1a83217adf91e8418655d54da3c14edbc3
         | 
| 4 | 
            +
              data.tar.gz: 12bd18e5b2f36f28f8efca9d5cd03851f0ca593a3bc0e72f57404479bd837e34
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: bf455a48c0b6def9c3e509660b3eacfe8a5cba5578cfd181f621edbaeef497fbd04da6706e80edcf5a879aedd54fdc95fa3f94e2a4d3f64e311291a53cd0c5b5
         | 
| 7 | 
            +
              data.tar.gz: 290186d4c7f26812685b26543a392dc5fe82847c8f2071746ba1d1d83af44c9a6ecedc69ebd41df09f96d7950844c41f44cdd1b02c5f1cc870a84b0416479684
         | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | @@ -1 +1,3 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            ����(F�����d�:�������ͯ�Z����� �eZ�)7~��g�̍w�c�o���0|_�JS���_�!��7�t��_�z���d��>�U�s�xY�>
         | 
| 2 | 
            +
            ?>	� ����g���Re
         | 
| 3 | 
            +
            v��^#߿+�6��I��D��6��+�t�(�E�Klԃ�[YA�ɲ���*Q�����큒�݃"����$��������le+y��t3�*�-�L���H�_i'�ʡ�Լ���K�ٝ�rc�
         | 
    
        data.tar.gz.sig
    CHANGED
    
    | Binary file | 
| @@ -196,7 +196,7 @@ module Mongo | |
| 196 196 | 
             
                      @features = Features.new(wire_versions, me || @address.to_s)
         | 
| 197 197 | 
             
                    end
         | 
| 198 198 | 
             
                    @average_round_trip_time = average_round_trip_time
         | 
| 199 | 
            -
                    @last_update_time = Time.now.freeze
         | 
| 199 | 
            +
                    @last_update_time = Time.now.dup.freeze
         | 
| 200 200 |  | 
| 201 201 | 
             
                    if Mongo::Lint.enabled?
         | 
| 202 202 | 
             
                      # prepopulate cache instance variables
         | 
    
        data/lib/mongo/session.rb
    CHANGED
    
    | @@ -812,6 +812,7 @@ module Mongo | |
| 812 812 | 
             
                        if e.label?(Mongo::Error::UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL)
         | 
| 813 813 | 
             
                          # WriteConcernFailed
         | 
| 814 814 | 
             
                          if e.is_a?(Mongo::Error::OperationFailure) && e.code == 64 && e.wtimeout?
         | 
| 815 | 
            +
                            transaction_in_progress = false
         | 
| 815 816 | 
             
                            raise
         | 
| 816 817 | 
             
                          end
         | 
| 817 818 | 
             
                          if Time.now >= deadline
         | 
    
        data/lib/mongo/uri.rb
    CHANGED
    
    | @@ -155,7 +155,7 @@ module Mongo | |
| 155 155 | 
             
                # @since 2.1.0
         | 
| 156 156 | 
             
                UNESCAPED_UNIX_SOCKET = "UNIX domain sockets must be urlencoded.".freeze
         | 
| 157 157 |  | 
| 158 | 
            -
                # Error details for a non-urlencoded auth  | 
| 158 | 
            +
                # Error details for a non-urlencoded auth database name.
         | 
| 159 159 | 
             
                #
         | 
| 160 160 | 
             
                # @since 2.1.0
         | 
| 161 161 | 
             
                UNESCAPED_DATABASE = "Auth database must be urlencoded.".freeze
         | 
| @@ -201,8 +201,13 @@ module Mongo | |
| 201 201 |  | 
| 202 202 | 
             
                # Options that are allowed to appear more than once in the uri.
         | 
| 203 203 | 
             
                #
         | 
| 204 | 
            +
                # In order to follow the URI options spec requirement that all instances of 'tls' and 'ssl' have
         | 
| 205 | 
            +
                # the same value, we need to keep track of all of the values passed in for those options.
         | 
| 206 | 
            +
                # Assuming they don't conflict, they will be condensed to a single value immediately after
         | 
| 207 | 
            +
                # parsing the URI.
         | 
| 208 | 
            +
                #
         | 
| 204 209 | 
             
                # @since 2.1.0
         | 
| 205 | 
            -
                REPEATABLE_OPTIONS = [ :tag_sets ]
         | 
| 210 | 
            +
                REPEATABLE_OPTIONS = [ :tag_sets, :ssl ]
         | 
| 206 211 |  | 
| 207 212 | 
             
                # Get either a URI object or a SRVProtocol URI object.
         | 
| 208 213 | 
             
                #
         | 
| @@ -257,16 +262,25 @@ module Mongo | |
| 257 262 | 
             
                  raise_invalid_error!(INVALID_SCHEME) unless parsed_scheme == scheme
         | 
| 258 263 | 
             
                  parse!(remaining)
         | 
| 259 264 |  | 
| 260 | 
            -
                  #  | 
| 261 | 
            -
                   | 
| 262 | 
            -
             | 
| 263 | 
            -
             | 
| 264 | 
            -
             | 
| 265 | 
            +
                  # The URI options spec requires that we raise an error if there are conflicting values of
         | 
| 266 | 
            +
                  # 'tls' and 'ssl'. In order to fulfill this, we parse the values of each instance into an
         | 
| 267 | 
            +
                  # array; assuming all values in the array are the same, we replace the array with that value.
         | 
| 268 | 
            +
                  unless @uri_options[:ssl].nil? || @uri_options[:ssl].empty?
         | 
| 269 | 
            +
                    unless @uri_options[:ssl].uniq.length == 1
         | 
| 270 | 
            +
                      raise_invalid_error_no_fmt!("all instances of 'tls' and 'ssl' must have the same value")
         | 
| 271 | 
            +
                    end
         | 
| 272 | 
            +
             | 
| 273 | 
            +
                    @uri_options[:ssl] = @uri_options[:ssl].first
         | 
| 274 | 
            +
                  end
         | 
| 275 | 
            +
             | 
| 276 | 
            +
                  # Check for conflicting TLS insecure options.
         | 
| 277 | 
            +
                  unless @uri_options[:ssl_verify].nil?
         | 
| 278 | 
            +
                    unless @uri_options[:ssl_verify_certificate].nil?
         | 
| 279 | 
            +
                      raise_invalid_error_no_fmt!("'tlsInsecure' and 'tlsAllowInvalidCertificates' cannot both be specified")
         | 
| 265 280 | 
             
                    end
         | 
| 266 281 |  | 
| 267 | 
            -
             | 
| 268 | 
            -
                       | 
| 269 | 
            -
                                 "set to enable it; tlsAllowInvalidHostnames takes precedence")
         | 
| 282 | 
            +
                    unless @uri_options[:ssl_verify_hostname].nil?
         | 
| 283 | 
            +
                      raise_invalid_error_no_fmt!("tlsInsecure' and 'tlsAllowInvalidHostnames' cannot both be specified")
         | 
| 270 284 | 
             
                    end
         | 
| 271 285 | 
             
                  end
         | 
| 272 286 | 
             
                end
         | 
| @@ -413,6 +427,10 @@ module Mongo | |
| 413 427 | 
             
                  raise Error::InvalidURI.new(@string, details, FORMAT)
         | 
| 414 428 | 
             
                end
         | 
| 415 429 |  | 
| 430 | 
            +
                def raise_invalid_error_no_fmt!(details)
         | 
| 431 | 
            +
                  raise Error::InvalidURI.new(@string, details)
         | 
| 432 | 
            +
                end
         | 
| 433 | 
            +
             | 
| 416 434 | 
             
                def decode(value)
         | 
| 417 435 | 
             
                  ::URI.decode(value)
         | 
| 418 436 | 
             
                end
         | 
| @@ -463,8 +481,8 @@ module Mongo | |
| 463 481 | 
             
                uri_option 'waitqueuetimeoutms', :wait_queue_timeout, :type => :wait_queue_timeout
         | 
| 464 482 |  | 
| 465 483 | 
             
                # Security Options
         | 
| 466 | 
            -
                uri_option 'ssl', :ssl
         | 
| 467 | 
            -
                uri_option 'tls', :ssl
         | 
| 484 | 
            +
                uri_option 'ssl', :ssl, :type => :ssl
         | 
| 485 | 
            +
                uri_option 'tls', :ssl, :type => :tls
         | 
| 468 486 | 
             
                uri_option 'tlsallowinvalidcertificates', :ssl_verify_certificate,
         | 
| 469 487 | 
             
                           :type => :ssl_verify_certificate
         | 
| 470 488 | 
             
                uri_option 'tlsallowinvalidhostnames', :ssl_verify_hostname,
         | 
| @@ -703,6 +721,26 @@ module Mongo | |
| 703 721 | 
             
                  bool('journal', value)
         | 
| 704 722 | 
             
                end
         | 
| 705 723 |  | 
| 724 | 
            +
                # Parses the ssl value from the URI.
         | 
| 725 | 
            +
                #
         | 
| 726 | 
            +
                # @param value [ String ] The ssl value.
         | 
| 727 | 
            +
                #
         | 
| 728 | 
            +
                # @return [ Array<true | false> ] The ssl value parsed out (stored in an array to facilitate
         | 
| 729 | 
            +
                #   keeping track of all values).
         | 
| 730 | 
            +
                def ssl(value)
         | 
| 731 | 
            +
                  [bool('ssl', value)]
         | 
| 732 | 
            +
                end
         | 
| 733 | 
            +
             | 
| 734 | 
            +
                # Parses the tls value from the URI.
         | 
| 735 | 
            +
                #
         | 
| 736 | 
            +
                # @param value [ String ] The tls value.
         | 
| 737 | 
            +
                #
         | 
| 738 | 
            +
                # @return [ Array<true | false> ] The tls value parsed out (stored in an array to facilitate
         | 
| 739 | 
            +
                #   keeping track of all values).
         | 
| 740 | 
            +
                def tls(value)
         | 
| 741 | 
            +
                  [bool('tls', value)]
         | 
| 742 | 
            +
                end
         | 
| 743 | 
            +
             | 
| 706 744 | 
             
                # Parses the ssl_verify value from the tlsInsecure URI value. Note that this will be the inverse
         | 
| 707 745 | 
             
                # of the value of tlsInsecure (if present).
         | 
| 708 746 | 
             
                #
         | 
    
        data/lib/mongo/version.rb
    CHANGED
    
    
| @@ -49,6 +49,20 @@ describe Mongo::Server::Description do | |
| 49 49 | 
             
                end
         | 
| 50 50 | 
             
              end
         | 
| 51 51 |  | 
| 52 | 
            +
              describe '#initialize' do
         | 
| 53 | 
            +
                context 'when Time.now is mocked' do
         | 
| 54 | 
            +
                  it 'does not freeze mocked time' do
         | 
| 55 | 
            +
                    obj = Time.now
         | 
| 56 | 
            +
                    expect(Time).to receive(:now).at_least(:once).and_return(obj)
         | 
| 57 | 
            +
                    expect(obj.frozen?).to be false
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    description = described_class.new(address)
         | 
| 60 | 
            +
                    expect(description.last_update_time).to eq(obj)
         | 
| 61 | 
            +
                    expect(obj.frozen?).to be false
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
             | 
| 52 66 | 
             
              describe '#arbiters' do
         | 
| 53 67 |  | 
| 54 68 | 
             
                context 'when the replica set has arbiters' do
         | 
| @@ -71,19 +71,67 @@ tests: | |
| 71 71 | 
             
                    auth: ~
         | 
| 72 72 | 
             
                    options: {}
         | 
| 73 73 | 
             
                -
         | 
| 74 | 
            -
                    description: "tlsInsecure | 
| 75 | 
            -
                    uri: "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidCertificates= | 
| 74 | 
            +
                    description: "tlsInsecure and tlsAllowInvalidCertificates both present (and true) raises an error"
         | 
| 75 | 
            +
                    uri: "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidCertificates=true"
         | 
| 76 | 
            +
                    valid: false
         | 
| 77 | 
            +
                    warning: false
         | 
| 78 | 
            +
                    hosts: ~
         | 
| 79 | 
            +
                    auth: ~
         | 
| 80 | 
            +
                    options: {}
         | 
| 81 | 
            +
                -
         | 
| 82 | 
            +
                    description: "tlsInsecure and tlsAllowInvalidCertificates both present (and false) raises an error"
         | 
| 83 | 
            +
                    uri: "mongodb://example.com/?tlsInsecure=false&tlsAllowInvalidCertificates=false"
         | 
| 84 | 
            +
                    valid: false
         | 
| 85 | 
            +
                    warning: false
         | 
| 86 | 
            +
                    hosts: ~
         | 
| 87 | 
            +
                    auth: ~
         | 
| 88 | 
            +
                    options: {}
         | 
| 89 | 
            +
                -
         | 
| 90 | 
            +
                    description: "tlsInsecure and tlsAllowInvalidHostnames both present (and true) raises an error"
         | 
| 91 | 
            +
                    uri: "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidHostnames=true"
         | 
| 92 | 
            +
                    valid: false
         | 
| 93 | 
            +
                    warning: false
         | 
| 94 | 
            +
                    hosts: ~
         | 
| 95 | 
            +
                    auth: ~
         | 
| 96 | 
            +
                    options: {}
         | 
| 97 | 
            +
                -
         | 
| 98 | 
            +
                    description: "tlsInsecure and tlsAllowInvalidHostnames both present (and false) raises an error"
         | 
| 99 | 
            +
                    uri: "mongodb://example.com/?tlsInsecure=false&tlsAllowInvalidHostnames=false"
         | 
| 100 | 
            +
                    valid: false
         | 
| 101 | 
            +
                    warning: false
         | 
| 102 | 
            +
                    hosts: ~
         | 
| 103 | 
            +
                    auth: ~
         | 
| 104 | 
            +
                    options: {}
         | 
| 105 | 
            +
                -
         | 
| 106 | 
            +
                    description: "tls=true and ssl=true doesn't warn"
         | 
| 107 | 
            +
                    uri: "mongodb://example.com/?tls=true&ssl=true"
         | 
| 76 108 | 
             
                    valid: true
         | 
| 77 | 
            -
                    warning:  | 
| 109 | 
            +
                    warning: false
         | 
| 78 110 | 
             
                    hosts: ~
         | 
| 79 111 | 
             
                    auth: ~
         | 
| 80 112 | 
             
                    options: {}
         | 
| 81 113 | 
             
                -
         | 
| 82 | 
            -
                    description: " | 
| 83 | 
            -
                    uri: "mongodb://example.com/? | 
| 114 | 
            +
                    description: "tls=false and ssl=false doesn't warn"
         | 
| 115 | 
            +
                    uri: "mongodb://example.com/?tls=false&ssl=false"
         | 
| 84 116 | 
             
                    valid: true
         | 
| 85 | 
            -
                    warning:  | 
| 117 | 
            +
                    warning: false
         | 
| 118 | 
            +
                    hosts: ~
         | 
| 119 | 
            +
                    auth: ~
         | 
| 120 | 
            +
                    options: {}
         | 
| 121 | 
            +
                -
         | 
| 122 | 
            +
                    description: "tls=false and ssl=true raises error"
         | 
| 123 | 
            +
                    uri: "mongodb://example.com/?tls=false&ssl=true"
         | 
| 124 | 
            +
                    valid: false
         | 
| 125 | 
            +
                    warning: false
         | 
| 126 | 
            +
                    hosts: ~
         | 
| 127 | 
            +
                    auth: ~
         | 
| 128 | 
            +
                    options: {}
         | 
| 129 | 
            +
                -
         | 
| 130 | 
            +
                    description: "tls=true and ssl=false raises error"
         | 
| 131 | 
            +
                    uri: "mongodb://example.com/?tls=true&ssl=false"
         | 
| 132 | 
            +
                    valid: false
         | 
| 133 | 
            +
                    warning: false
         | 
| 86 134 | 
             
                    hosts: ~
         | 
| 87 135 | 
             
                    auth: ~
         | 
| 88 136 | 
             
                    options: {}
         | 
| 89 | 
            -
             | 
| 137 | 
            +
             | 
    
        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.8.0 | 
| 4 | 
            +
              version: 2.8.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Tyler Brock
         | 
| @@ -31,7 +31,7 @@ cert_chain: | |
| 31 31 | 
             
              bMYVwXXhV8czdzgkQB/ZPWHSbEWXnmkze1mzvqWBCPOVXYrcnL9cnEl/RoxtS1hr
         | 
| 32 32 | 
             
              Db6Ac6mCUSYfYHBWpWqxjc45n70i5Xi1
         | 
| 33 33 | 
             
              -----END CERTIFICATE-----
         | 
| 34 | 
            -
            date: 2019- | 
| 34 | 
            +
            date: 2019-03-21 00:00:00.000000000 Z
         | 
| 35 35 | 
             
            dependencies:
         | 
| 36 36 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 37 | 
             
              name: bson
         | 
| @@ -971,9 +971,9 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 971 971 | 
             
                  version: '0'
         | 
| 972 972 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 973 973 | 
             
              requirements:
         | 
| 974 | 
            -
              - - " | 
| 974 | 
            +
              - - ">="
         | 
| 975 975 | 
             
                - !ruby/object:Gem::Version
         | 
| 976 | 
            -
                  version:  | 
| 976 | 
            +
                  version: '0'
         | 
| 977 977 | 
             
            requirements: []
         | 
| 978 978 | 
             
            rubygems_version: 3.0.1
         | 
| 979 979 | 
             
            signing_key: 
         | 
    
        metadata.gz.sig
    CHANGED
    
    | Binary file |