mongo 2.4.2 → 2.4.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 +0 -0
- data.tar.gz.sig +0 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/mongo.rb +1 -1
- data/lib/mongo/address.rb +23 -8
- data/lib/mongo/address/ipv4.rb +5 -5
- data/lib/mongo/address/ipv6.rb +5 -5
- data/lib/mongo/address/unix.rb +3 -3
- data/lib/mongo/auth.rb +1 -1
- data/lib/mongo/auth/cr.rb +1 -1
- data/lib/mongo/auth/ldap.rb +1 -1
- data/lib/mongo/auth/roles.rb +1 -1
- data/lib/mongo/auth/user.rb +1 -1
- data/lib/mongo/auth/user/view.rb +1 -1
- data/lib/mongo/auth/x509.rb +1 -1
- data/lib/mongo/bson.rb +1 -1
- data/lib/mongo/bulk_write.rb +1 -1
- data/lib/mongo/bulk_write/combineable.rb +1 -1
- data/lib/mongo/bulk_write/ordered_combiner.rb +1 -1
- data/lib/mongo/bulk_write/result.rb +1 -1
- data/lib/mongo/bulk_write/result_combiner.rb +1 -1
- data/lib/mongo/bulk_write/transformable.rb +1 -1
- data/lib/mongo/bulk_write/unordered_combiner.rb +1 -1
- data/lib/mongo/bulk_write/validatable.rb +1 -1
- data/lib/mongo/client.rb +1 -1
- data/lib/mongo/cluster.rb +2 -2
- data/lib/mongo/cluster/topology.rb +1 -1
- data/lib/mongo/cluster/topology/replica_set.rb +1 -1
- data/lib/mongo/cluster/topology/sharded.rb +1 -1
- data/lib/mongo/cluster/topology/single.rb +1 -1
- data/lib/mongo/cluster/topology/unknown.rb +1 -1
- data/lib/mongo/collection.rb +1 -1
- data/lib/mongo/collection/view.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +1 -1
- data/lib/mongo/collection/view/builder.rb +1 -1
- data/lib/mongo/collection/view/builder/aggregation.rb +3 -2
- data/lib/mongo/collection/view/builder/find_command.rb +1 -1
- data/lib/mongo/collection/view/builder/flags.rb +1 -1
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/builder/modifiers.rb +1 -1
- data/lib/mongo/collection/view/builder/op_query.rb +1 -1
- data/lib/mongo/collection/view/explainable.rb +1 -1
- data/lib/mongo/collection/view/immutable.rb +1 -1
- data/lib/mongo/collection/view/iterable.rb +1 -1
- data/lib/mongo/collection/view/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/readable.rb +1 -1
- data/lib/mongo/collection/view/writable.rb +1 -1
- data/lib/mongo/cursor.rb +1 -1
- data/lib/mongo/cursor/builder.rb +1 -1
- data/lib/mongo/cursor/builder/get_more_command.rb +1 -1
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +1 -1
- data/lib/mongo/cursor/builder/op_get_more.rb +1 -1
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +1 -1
- data/lib/mongo/database.rb +1 -1
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/dbref.rb +1 -1
- data/lib/mongo/error.rb +1 -1
- data/lib/mongo/error/bulk_write_error.rb +1 -1
- data/lib/mongo/error/closed_stream.rb +1 -1
- data/lib/mongo/error/extra_file_chunk.rb +1 -1
- data/lib/mongo/error/file_not_found.rb +1 -1
- data/lib/mongo/error/invalid_bulk_operation.rb +1 -1
- data/lib/mongo/error/invalid_bulk_operation_type.rb +1 -1
- data/lib/mongo/error/invalid_collection_name.rb +1 -1
- data/lib/mongo/error/invalid_database_name.rb +1 -1
- data/lib/mongo/error/invalid_document.rb +1 -1
- data/lib/mongo/error/invalid_file.rb +1 -1
- data/lib/mongo/error/invalid_file_revision.rb +1 -1
- data/lib/mongo/error/invalid_min_pool_size.rb +1 -1
- data/lib/mongo/error/invalid_nonce.rb +1 -1
- data/lib/mongo/error/invalid_replacement_document.rb +1 -1
- data/lib/mongo/error/invalid_server_preference.rb +1 -1
- data/lib/mongo/error/invalid_signature.rb +1 -1
- data/lib/mongo/error/invalid_update_document.rb +1 -1
- data/lib/mongo/error/invalid_uri.rb +1 -1
- data/lib/mongo/error/invalid_write_concern.rb +1 -1
- data/lib/mongo/error/max_bson_size.rb +1 -1
- data/lib/mongo/error/max_message_size.rb +1 -1
- data/lib/mongo/error/missing_file_chunk.rb +1 -1
- data/lib/mongo/error/multi_index_drop.rb +1 -1
- data/lib/mongo/error/need_primary_server.rb +1 -1
- data/lib/mongo/error/no_server_available.rb +1 -1
- data/lib/mongo/error/operation_failure.rb +1 -1
- data/lib/mongo/error/parser.rb +1 -1
- data/lib/mongo/error/socket_error.rb +1 -1
- data/lib/mongo/error/socket_timeout_error.rb +1 -1
- data/lib/mongo/error/unchangeable_collection_option.rb +1 -1
- data/lib/mongo/error/unexpected_chunk_length.rb +1 -1
- data/lib/mongo/error/unexpected_response.rb +1 -1
- data/lib/mongo/error/unsupported_collation.rb +1 -1
- data/lib/mongo/error/unsupported_features.rb +1 -1
- data/lib/mongo/event.rb +1 -1
- data/lib/mongo/event/description_changed.rb +1 -1
- data/lib/mongo/event/publisher.rb +1 -1
- data/lib/mongo/event/subscriber.rb +1 -1
- data/lib/mongo/grid.rb +1 -1
- data/lib/mongo/grid/file.rb +1 -1
- data/lib/mongo/grid/file/chunk.rb +1 -1
- data/lib/mongo/grid/file/info.rb +1 -1
- data/lib/mongo/grid/fs_bucket.rb +1 -1
- data/lib/mongo/grid/stream.rb +1 -1
- data/lib/mongo/grid/stream/read.rb +1 -1
- data/lib/mongo/grid/stream/write.rb +1 -1
- data/lib/mongo/index.rb +1 -1
- data/lib/mongo/index/view.rb +1 -1
- data/lib/mongo/loggable.rb +1 -1
- data/lib/mongo/logger.rb +1 -1
- data/lib/mongo/monitoring.rb +1 -1
- data/lib/mongo/operation.rb +1 -1
- data/lib/mongo/operation/commands.rb +1 -1
- data/lib/mongo/operation/commands/aggregate.rb +1 -1
- data/lib/mongo/operation/commands/aggregate/result.rb +1 -1
- data/lib/mongo/operation/commands/collections_info.rb +1 -1
- data/lib/mongo/operation/commands/collections_info/result.rb +1 -1
- data/lib/mongo/operation/commands/command.rb +1 -1
- data/lib/mongo/operation/commands/create.rb +1 -1
- data/lib/mongo/operation/commands/drop.rb +1 -1
- data/lib/mongo/operation/commands/drop_database.rb +1 -1
- data/lib/mongo/operation/commands/indexes.rb +1 -1
- data/lib/mongo/operation/commands/list_collections.rb +1 -1
- data/lib/mongo/operation/commands/list_collections/result.rb +1 -1
- data/lib/mongo/operation/commands/list_indexes.rb +1 -1
- data/lib/mongo/operation/commands/list_indexes/result.rb +1 -1
- data/lib/mongo/operation/commands/map_reduce.rb +1 -1
- data/lib/mongo/operation/commands/map_reduce/result.rb +1 -1
- data/lib/mongo/operation/commands/user_query.rb +1 -1
- data/lib/mongo/operation/commands/users_info.rb +1 -1
- data/lib/mongo/operation/commands/users_info/result.rb +1 -1
- data/lib/mongo/operation/executable.rb +1 -1
- data/lib/mongo/operation/kill_cursors.rb +1 -1
- data/lib/mongo/operation/limited.rb +1 -1
- data/lib/mongo/operation/read.rb +1 -1
- data/lib/mongo/operation/read/get_more.rb +1 -1
- data/lib/mongo/operation/read/query.rb +1 -1
- data/lib/mongo/operation/read/query/result.rb +1 -1
- data/lib/mongo/operation/read_preference.rb +1 -1
- data/lib/mongo/operation/result.rb +1 -1
- data/lib/mongo/operation/specifiable.rb +1 -1
- data/lib/mongo/operation/takes_write_concern.rb +1 -1
- data/lib/mongo/operation/write.rb +1 -1
- data/lib/mongo/operation/write/bulk.rb +1 -1
- data/lib/mongo/operation/write/bulk/bulkable.rb +1 -1
- data/lib/mongo/operation/write/bulk/delete.rb +1 -1
- data/lib/mongo/operation/write/bulk/delete/result.rb +1 -1
- data/lib/mongo/operation/write/bulk/insert.rb +1 -1
- data/lib/mongo/operation/write/bulk/insert/result.rb +1 -1
- data/lib/mongo/operation/write/bulk/legacy_mergable.rb +1 -1
- data/lib/mongo/operation/write/bulk/mergable.rb +1 -1
- data/lib/mongo/operation/write/bulk/update.rb +1 -1
- data/lib/mongo/operation/write/bulk/update/result.rb +1 -1
- data/lib/mongo/operation/write/command.rb +1 -1
- data/lib/mongo/operation/write/command/create_index.rb +1 -1
- data/lib/mongo/operation/write/command/create_user.rb +1 -1
- data/lib/mongo/operation/write/command/delete.rb +1 -1
- data/lib/mongo/operation/write/command/drop_index.rb +1 -1
- data/lib/mongo/operation/write/command/insert.rb +1 -1
- data/lib/mongo/operation/write/command/remove_user.rb +1 -1
- data/lib/mongo/operation/write/command/update.rb +1 -1
- data/lib/mongo/operation/write/command/update_user.rb +1 -1
- data/lib/mongo/operation/write/command/writable.rb +1 -1
- data/lib/mongo/operation/write/create_index.rb +1 -1
- data/lib/mongo/operation/write/create_user.rb +1 -1
- data/lib/mongo/operation/write/delete.rb +1 -1
- data/lib/mongo/operation/write/delete/result.rb +1 -1
- data/lib/mongo/operation/write/drop_index.rb +1 -1
- data/lib/mongo/operation/write/gle.rb +1 -1
- data/lib/mongo/operation/write/idable.rb +1 -1
- data/lib/mongo/operation/write/insert.rb +1 -1
- data/lib/mongo/operation/write/insert/result.rb +1 -1
- data/lib/mongo/operation/write/remove_user.rb +1 -1
- data/lib/mongo/operation/write/update.rb +1 -1
- data/lib/mongo/operation/write/update/result.rb +1 -1
- data/lib/mongo/operation/write/update_user.rb +1 -1
- data/lib/mongo/operation/write/write_command_enabled.rb +1 -1
- data/lib/mongo/protocol/bit_vector.rb +1 -1
- data/lib/mongo/protocol/delete.rb +1 -1
- data/lib/mongo/protocol/get_more.rb +1 -1
- data/lib/mongo/protocol/insert.rb +1 -1
- data/lib/mongo/protocol/kill_cursors.rb +1 -1
- data/lib/mongo/protocol/message.rb +1 -1
- data/lib/mongo/protocol/query.rb +2 -2
- data/lib/mongo/protocol/reply.rb +1 -1
- data/lib/mongo/protocol/serializers.rb +1 -1
- data/lib/mongo/protocol/update.rb +1 -1
- data/lib/mongo/server.rb +6 -1
- data/lib/mongo/server/connectable.rb +1 -13
- data/lib/mongo/server/connection.rb +17 -3
- data/lib/mongo/server/connection_pool.rb +1 -1
- data/lib/mongo/server/connection_pool/queue.rb +1 -1
- data/lib/mongo/server/context.rb +1 -1
- data/lib/mongo/server/description.rb +2 -2
- data/lib/mongo/server/description/features.rb +1 -1
- data/lib/mongo/server/description/inspector/description_changed.rb +1 -1
- data/lib/mongo/server/monitor.rb +1 -1
- data/lib/mongo/server/monitor/connection.rb +15 -9
- data/lib/mongo/server_selector.rb +1 -1
- data/lib/mongo/server_selector/nearest.rb +1 -1
- data/lib/mongo/server_selector/primary.rb +1 -1
- data/lib/mongo/server_selector/primary_preferred.rb +1 -1
- data/lib/mongo/server_selector/secondary.rb +1 -1
- data/lib/mongo/server_selector/secondary_preferred.rb +1 -1
- data/lib/mongo/server_selector/selectable.rb +1 -1
- data/lib/mongo/socket.rb +1 -1
- data/lib/mongo/socket/ssl.rb +4 -4
- data/lib/mongo/socket/tcp.rb +4 -4
- data/lib/mongo/socket/unix.rb +3 -3
- data/lib/mongo/uri.rb +1 -1
- data/lib/mongo/version.rb +2 -2
- data/lib/mongo/write_concern/acknowledged.rb +1 -1
- data/lib/mongo/write_concern/normalizable.rb +1 -1
- data/lib/mongo/write_concern/unacknowledged.rb +1 -1
- data/mongo.gemspec +0 -1
- data/spec/mongo/address_spec.rb +8 -7
- data/spec/mongo/client_spec.rb +1 -1
- data/spec/mongo/collection/view/aggregation_spec.rb +11 -0
- data/spec/mongo/collection_spec.rb +11 -0
- data/spec/mongo/server/connection_spec.rb +108 -2
- data/spec/mongo/server/description_spec.rb +5 -1
- data/spec/mongo/server/monitor/connection_spec.rb +116 -0
- data/spec/mongo/socket/ssl_spec.rb +14 -12
- data/spec/support/authorization.rb +4 -2
- data/spec/support/command_monitoring.rb +1 -1
- data/spec/support/connection_string.rb +1 -1
- data/spec/support/connection_string_tests/invalid-uris.yml +32 -0
- data/spec/support/connection_string_tests/valid-auth.yml +4 -19
- data/spec/support/connection_string_tests/valid-db-with-dotted-name.yml +77 -0
- data/spec/support/connection_string_tests/valid-options.yml +0 -13
- data/spec/support/connection_string_tests/valid-unix_socket-absolute.yml +6 -6
- data/spec/support/connection_string_tests/valid-unix_socket-relative.yml +4 -4
- data/spec/support/crud.rb +1 -1
- data/spec/support/crud/read.rb +3 -3
- data/spec/support/crud/write.rb +8 -3
- data/spec/support/gridfs.rb +1 -1
- metadata +6 -2
- metadata.gz.sig +0 -0
data/mongo.gemspec
CHANGED
data/spec/mongo/address_spec.rb
CHANGED
@@ -206,17 +206,18 @@ describe Mongo::Address do
|
|
206
206
|
|
207
207
|
describe "#socket" do
|
208
208
|
|
209
|
-
|
209
|
+
let(:address) do
|
210
|
+
default_address
|
211
|
+
end
|
210
212
|
|
211
|
-
|
212
|
-
|
213
|
-
|
213
|
+
let(:host) do
|
214
|
+
address.host
|
215
|
+
end
|
214
216
|
|
215
|
-
|
216
|
-
address.host
|
217
|
-
end
|
217
|
+
context 'when providing a DNS entry that resolves to both IPv6 and IPv4' do
|
218
218
|
|
219
219
|
before do
|
220
|
+
address.instance_variable_set(:@resolver, nil)
|
220
221
|
allow(::Socket).to receive(:getaddrinfo).and_return(
|
221
222
|
[ ["AF_INET6", 0, '::1', '::1', ::Socket::AF_INET6, 1, 6],
|
222
223
|
["AF_INET", 0, host, host, ::Socket::AF_INET, 1, 6]]
|
data/spec/mongo/client_spec.rb
CHANGED
@@ -372,6 +372,17 @@ describe Mongo::Collection::View::Aggregation do
|
|
372
372
|
end
|
373
373
|
end
|
374
374
|
|
375
|
+
context 'when a hint is specified' do
|
376
|
+
|
377
|
+
let(:options) do
|
378
|
+
{ 'hint' => { 'y' => 1 } }
|
379
|
+
end
|
380
|
+
|
381
|
+
it 'includes the option in the spec' do
|
382
|
+
expect(aggregation.send(:aggregate_spec)[:selector][:hint]).to eq(options['hint'])
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
375
386
|
context 'when use_cursor is set' do
|
376
387
|
|
377
388
|
context 'when use_cursor is true' do
|
@@ -1170,6 +1170,17 @@ describe Mongo::Collection do
|
|
1170
1170
|
expect(authorized_collection.aggregate([], options).options).to eq(BSON::Document.new(options))
|
1171
1171
|
end
|
1172
1172
|
|
1173
|
+
context 'when a hint is provided' do
|
1174
|
+
|
1175
|
+
let(:options) do
|
1176
|
+
{ 'hint' => { 'y' => 1 } }
|
1177
|
+
end
|
1178
|
+
|
1179
|
+
it 'sets the options on the Aggregation object' do
|
1180
|
+
expect(authorized_collection.aggregate([], options).options).to eq(options)
|
1181
|
+
end
|
1182
|
+
end
|
1183
|
+
|
1173
1184
|
context 'when collation is provided' do
|
1174
1185
|
|
1175
1186
|
before do
|
@@ -38,8 +38,8 @@ describe Mongo::Server::Connection do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
after do
|
41
|
-
|
42
|
-
|
41
|
+
allow(cluster).to receive(:pool).with(server).and_return(pool)
|
42
|
+
allow(pool).to receive(:disconnect!).and_return(true)
|
43
43
|
server.disconnect!
|
44
44
|
end
|
45
45
|
|
@@ -432,6 +432,7 @@ describe Mongo::Server::Connection do
|
|
432
432
|
after do
|
433
433
|
sleep(0.5)
|
434
434
|
authorized_collection.delete_many
|
435
|
+
client.close
|
435
436
|
end
|
436
437
|
|
437
438
|
it 'raises a timeout when it expires' do
|
@@ -670,4 +671,109 @@ describe Mongo::Server::Connection do
|
|
670
671
|
end
|
671
672
|
end
|
672
673
|
end
|
674
|
+
|
675
|
+
context 'when different timeout options are set' do
|
676
|
+
|
677
|
+
let(:client) do
|
678
|
+
authorized_client.with(options)
|
679
|
+
end
|
680
|
+
|
681
|
+
let(:server) do
|
682
|
+
client.cluster.next_primary
|
683
|
+
end
|
684
|
+
|
685
|
+
let(:address) do
|
686
|
+
server.address
|
687
|
+
end
|
688
|
+
|
689
|
+
let(:connection) do
|
690
|
+
described_class.new(server, server.options)
|
691
|
+
end
|
692
|
+
|
693
|
+
after do
|
694
|
+
client.close
|
695
|
+
end
|
696
|
+
|
697
|
+
context 'when a connect_timeout is in the options' do
|
698
|
+
|
699
|
+
context 'when a socket_timeout is in the options' do
|
700
|
+
|
701
|
+
let(:options) do
|
702
|
+
TEST_OPTIONS.merge(connect_timeout: 3, socket_timeout: 5)
|
703
|
+
end
|
704
|
+
|
705
|
+
before do
|
706
|
+
connection.connect!
|
707
|
+
end
|
708
|
+
|
709
|
+
it 'uses the connect_timeout for the address' do
|
710
|
+
expect(connection.address.send(:connect_timeout)).to eq(3)
|
711
|
+
end
|
712
|
+
|
713
|
+
it 'uses the socket_timeout as the socket_timeout' do
|
714
|
+
expect(connection.send(:socket).timeout).to eq(5)
|
715
|
+
end
|
716
|
+
end
|
717
|
+
|
718
|
+
context 'when a socket_timeout is not in the options' do
|
719
|
+
|
720
|
+
let(:options) do
|
721
|
+
TEST_OPTIONS.merge(connect_timeout: 3, socket_timeout: nil)
|
722
|
+
end
|
723
|
+
|
724
|
+
before do
|
725
|
+
connection.connect!
|
726
|
+
end
|
727
|
+
|
728
|
+
it 'uses the connect_timeout for the address' do
|
729
|
+
expect(connection.address.send(:connect_timeout)).to eq(3)
|
730
|
+
end
|
731
|
+
|
732
|
+
it 'does not use a socket_timeout' do
|
733
|
+
expect(connection.send(:socket).timeout).to be(nil)
|
734
|
+
end
|
735
|
+
end
|
736
|
+
end
|
737
|
+
|
738
|
+
context 'when a connect_timeout is not in the options' do
|
739
|
+
|
740
|
+
context 'when a socket_timeout is in the options' do
|
741
|
+
|
742
|
+
let(:options) do
|
743
|
+
TEST_OPTIONS.merge(connect_timeout: nil, socket_timeout: 5)
|
744
|
+
end
|
745
|
+
|
746
|
+
before do
|
747
|
+
connection.connect!
|
748
|
+
end
|
749
|
+
|
750
|
+
it 'uses the default connect_timeout for the address' do
|
751
|
+
expect(connection.address.send(:connect_timeout)).to eq(10)
|
752
|
+
end
|
753
|
+
|
754
|
+
it 'uses the socket_timeout' do
|
755
|
+
expect(connection.send(:socket).timeout).to eq(5)
|
756
|
+
end
|
757
|
+
end
|
758
|
+
|
759
|
+
context 'when a socket_timeout is not in the options' do
|
760
|
+
|
761
|
+
let(:options) do
|
762
|
+
TEST_OPTIONS.merge(connect_timeout: nil, socket_timeout: nil)
|
763
|
+
end
|
764
|
+
|
765
|
+
before do
|
766
|
+
connection.connect!
|
767
|
+
end
|
768
|
+
|
769
|
+
it 'uses the default connect_timeout for the address' do
|
770
|
+
expect(connection.address.send(:connect_timeout)).to eq(10)
|
771
|
+
end
|
772
|
+
|
773
|
+
it 'does not use a socket_timeout' do
|
774
|
+
expect(connection.send(:socket).timeout).to be(nil)
|
775
|
+
end
|
776
|
+
end
|
777
|
+
end
|
778
|
+
end
|
673
779
|
end
|
@@ -23,6 +23,7 @@ describe Mongo::Server::Description do
|
|
23
23
|
'maxWireVersion' => 2,
|
24
24
|
'minWireVersion' => 0,
|
25
25
|
'localTime' => Time.now,
|
26
|
+
'lastWrite' => { 'lastWriteDate' => Time.now },
|
26
27
|
'ok' => 1
|
27
28
|
}
|
28
29
|
end
|
@@ -838,7 +839,10 @@ describe Mongo::Server::Description do
|
|
838
839
|
end
|
839
840
|
|
840
841
|
let(:other) do
|
841
|
-
described_class.new(address, replica.merge(
|
842
|
+
described_class.new(address, replica.merge(
|
843
|
+
'localTime' => 1,
|
844
|
+
'lastWrite' => { 'lastWriteDate' => 1 }
|
845
|
+
))
|
842
846
|
end
|
843
847
|
|
844
848
|
it 'excludes certain fields' do
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mongo::Server::Monitor::Connection do
|
4
|
+
|
5
|
+
let(:client) do
|
6
|
+
authorized_client.with(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:address) do
|
10
|
+
client.cluster.next_primary.address
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:cluster) do
|
14
|
+
double('cluster').tap do |cl|
|
15
|
+
allow(cl).to receive(:topology).and_return(double('topology'))
|
16
|
+
allow(cl).to receive(:app_metadata).and_return(Mongo::Cluster::AppMetadata.new(authorized_client.cluster))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:server) do
|
21
|
+
Mongo::Server.new(address,
|
22
|
+
cluster,
|
23
|
+
Mongo::Monitoring.new(monitoring: false),
|
24
|
+
Mongo::Event::Listeners.new, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:connection) do
|
28
|
+
server.monitor.connection
|
29
|
+
end
|
30
|
+
|
31
|
+
after do
|
32
|
+
client.close
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when a connect_timeout is in the options' do
|
36
|
+
|
37
|
+
context 'when a socket_timeout is in the options' do
|
38
|
+
|
39
|
+
let(:options) do
|
40
|
+
TEST_OPTIONS.merge(connect_timeout: 3, socket_timeout: 5)
|
41
|
+
end
|
42
|
+
|
43
|
+
before do
|
44
|
+
connection.connect!
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'uses the connect_timeout for the address' do
|
48
|
+
expect(connection.address.send(:connect_timeout)).to eq(3)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'uses the connect_timeout as the socket_timeout' do
|
52
|
+
expect(connection.send(:socket).timeout).to eq(3)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when a socket_timeout is not in the options' do
|
57
|
+
|
58
|
+
let(:options) do
|
59
|
+
TEST_OPTIONS.merge(connect_timeout: 3, socket_timeout: nil)
|
60
|
+
end
|
61
|
+
|
62
|
+
before do
|
63
|
+
connection.connect!
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'uses the connect_timeout for the address' do
|
67
|
+
expect(connection.address.send(:connect_timeout)).to eq(3)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'uses the connect_timeout as the socket_timeout' do
|
71
|
+
expect(connection.send(:socket).timeout).to eq(3)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when a connect_timeout is not in the options' do
|
77
|
+
|
78
|
+
context 'when a socket_timeout is in the options' do
|
79
|
+
|
80
|
+
let(:options) do
|
81
|
+
TEST_OPTIONS.merge(connect_timeout: nil, socket_timeout: 5)
|
82
|
+
end
|
83
|
+
|
84
|
+
before do
|
85
|
+
connection.connect!
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'uses the default connect_timeout for the address' do
|
89
|
+
expect(connection.address.send(:connect_timeout)).to eq(10)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'uses the connect_timeout as the socket_timeout' do
|
93
|
+
expect(connection.send(:socket).timeout).to eq(10)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'when a socket_timeout is not in the options' do
|
98
|
+
|
99
|
+
let(:options) do
|
100
|
+
TEST_OPTIONS.merge(connect_timeout: nil, socket_timeout: nil)
|
101
|
+
end
|
102
|
+
|
103
|
+
before do
|
104
|
+
connection.connect!
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'uses the default connect_timeout for the address' do
|
108
|
+
expect(connection.address.send(:connect_timeout)).to eq(10)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'uses the connect_timeout as the socket_timeout' do
|
112
|
+
expect(connection.send(:socket).timeout).to eq(10)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -2,22 +2,24 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mongo::Socket::SSL, if: running_ssl? do
|
4
4
|
|
5
|
-
let(:
|
6
|
-
|
7
|
-
|
5
|
+
let(:address) do
|
6
|
+
default_address
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:resolver) do
|
10
|
+
address.instance_variable_get(:@resolver)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:socket_timeout) do
|
14
|
+
1
|
8
15
|
end
|
9
16
|
|
10
17
|
let(:socket) do
|
11
|
-
|
18
|
+
resolver.socket(socket_timeout, options)
|
12
19
|
end
|
13
20
|
|
14
21
|
let(:options) do
|
15
|
-
|
16
|
-
:ssl => true,
|
17
|
-
:ssl_cert => CLIENT_CERT_PEM,
|
18
|
-
:ssl_key => CLIENT_KEY_PEM,
|
19
|
-
:ssl_verify => false
|
20
|
-
}
|
22
|
+
SSL_OPTIONS
|
21
23
|
end
|
22
24
|
|
23
25
|
let (:key_string) do
|
@@ -276,7 +278,7 @@ describe Mongo::Socket::SSL, if: running_ssl? do
|
|
276
278
|
end
|
277
279
|
end
|
278
280
|
|
279
|
-
context 'when ruby version is < 2.4.1', if: RUBY_VERSION < '2.4.1' do
|
281
|
+
context 'when ruby version is < 2.4.1', if: (RUBY_VERSION < '2.4.1' && running_ssl?) do
|
280
282
|
|
281
283
|
context 'when a key is passed, but it is not of the right type' do
|
282
284
|
|
@@ -300,7 +302,7 @@ describe Mongo::Socket::SSL, if: running_ssl? do
|
|
300
302
|
|
301
303
|
# Note that as of MRI 2.4, Creating a socket with the wrong key type raises
|
302
304
|
# a NoMethodError because #private? is attempted to be called on the key.
|
303
|
-
context 'when ruby version is >= 2.4.1', if: RUBY_VERSION >= '2.4.1' do
|
305
|
+
context 'when ruby version is >= 2.4.1', if: (RUBY_VERSION >= '2.4.1' && running_ssl?) do
|
304
306
|
|
305
307
|
context 'when a key is passed, but it is not of the right type' do
|
306
308
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2017 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -79,7 +79,9 @@ BASE_OPTIONS = {
|
|
79
79
|
max_pool_size: 1,
|
80
80
|
write: WRITE_CONCERN,
|
81
81
|
heartbeat_frequency: 20,
|
82
|
-
max_read_retries: 5
|
82
|
+
max_read_retries: 5,
|
83
|
+
wait_queue_timeout: 2,
|
84
|
+
connect_timeout: 3
|
83
85
|
}
|
84
86
|
|
85
87
|
# Options for test suite clients.
|
@@ -167,6 +167,14 @@ tests:
|
|
167
167
|
hosts: ~
|
168
168
|
auth: ~
|
169
169
|
options: ~
|
170
|
+
-
|
171
|
+
description: "Username with password containing an unescaped colon"
|
172
|
+
uri: "mongodb://alice:foo:bar@127.0.0.1"
|
173
|
+
valid: false
|
174
|
+
warning: ~
|
175
|
+
hosts: ~
|
176
|
+
auth: ~
|
177
|
+
options: ~
|
170
178
|
-
|
171
179
|
description: "Username containing an unescaped at-sign"
|
172
180
|
uri: "mongodb://alice@@127.0.0.1"
|
@@ -183,6 +191,30 @@ tests:
|
|
183
191
|
hosts: ~
|
184
192
|
auth: ~
|
185
193
|
options: ~
|
194
|
+
-
|
195
|
+
description: "Username containing an unescaped slash"
|
196
|
+
uri: "mongodb://alice/@127.0.0.1/db"
|
197
|
+
valid: false
|
198
|
+
warning: ~
|
199
|
+
hosts: ~
|
200
|
+
auth: ~
|
201
|
+
options: ~
|
202
|
+
-
|
203
|
+
description: "Username containing unescaped slash with password"
|
204
|
+
uri: "mongodb://alice/bob:foo@127.0.0.1/db"
|
205
|
+
valid: false
|
206
|
+
warning: ~
|
207
|
+
hosts: ~
|
208
|
+
auth: ~
|
209
|
+
options: ~
|
210
|
+
-
|
211
|
+
description: "Username with password containing an unescaped slash"
|
212
|
+
uri: "mongodb://alice:foo/bar@127.0.0.1/db"
|
213
|
+
valid: false
|
214
|
+
warning: ~
|
215
|
+
hosts: ~
|
216
|
+
auth: ~
|
217
|
+
options: ~
|
186
218
|
-
|
187
219
|
description: "Host with unescaped slash"
|
188
220
|
uri: "mongodb:///tmp/mongodb-27017.sock/"
|