mongo 2.11.6 → 2.12.0.rc0
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 +2 -2
- data.tar.gz.sig +0 -0
- data/CONTRIBUTING.md +1 -1
- data/lib/mongo.rb +3 -0
- data/lib/mongo/address.rb +13 -2
- data/lib/mongo/auth.rb +1 -0
- data/lib/mongo/auth/credential_cache.rb +51 -0
- data/lib/mongo/auth/scram/conversation.rb +20 -16
- data/lib/mongo/auth/user.rb +0 -8
- data/lib/mongo/auth/user/view.rb +4 -4
- data/lib/mongo/background_thread.rb +1 -1
- data/lib/mongo/bulk_write.rb +5 -5
- data/lib/mongo/client.rb +126 -11
- data/lib/mongo/client_encryption.rb +103 -0
- data/lib/mongo/cluster.rb +2 -2
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +18 -6
- data/lib/mongo/cluster/sdam_flow.rb +54 -58
- data/lib/mongo/cluster/srv_monitor.rb +1 -1
- data/lib/mongo/collection.rb +3 -3
- data/lib/mongo/collection/view.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +12 -3
- data/lib/mongo/collection/view/iterable.rb +14 -5
- data/lib/mongo/collection/view/map_reduce.rb +2 -2
- data/lib/mongo/collection/view/readable.rb +7 -9
- data/lib/mongo/collection/view/writable.rb +7 -7
- data/lib/mongo/crypt.rb +33 -0
- data/lib/mongo/crypt/auto_decryption_context.rb +42 -0
- data/lib/mongo/crypt/auto_encrypter.rb +169 -0
- data/lib/mongo/crypt/auto_encryption_context.rb +44 -0
- data/lib/mongo/crypt/binary.rb +155 -0
- data/lib/mongo/crypt/binding.rb +1162 -0
- data/lib/mongo/crypt/context.rb +135 -0
- data/lib/mongo/crypt/data_key_context.rb +162 -0
- data/lib/mongo/crypt/encryption_io.rb +283 -0
- data/lib/mongo/crypt/explicit_decryption_context.rb +40 -0
- data/lib/mongo/crypt/explicit_encrypter.rb +117 -0
- data/lib/mongo/crypt/explicit_encryption_context.rb +89 -0
- data/lib/mongo/crypt/handle.rb +293 -0
- data/lib/mongo/crypt/hooks.rb +90 -0
- data/lib/mongo/crypt/kms_context.rb +67 -0
- data/lib/mongo/crypt/status.rb +131 -0
- data/lib/mongo/cursor.rb +64 -32
- data/lib/mongo/database.rb +13 -6
- data/lib/mongo/database/view.rb +13 -4
- data/lib/mongo/dbref.rb +9 -2
- data/lib/mongo/error.rb +5 -1
- data/lib/mongo/error/crypt_error.rb +31 -0
- data/lib/mongo/error/{failed_stringprep_validation.rb → failed_string_prep_validation.rb} +0 -0
- data/lib/mongo/error/invalid_cursor_operation.rb +27 -0
- data/lib/mongo/error/kms_error.rb +22 -0
- data/lib/mongo/error/max_bson_size.rb +14 -3
- data/lib/mongo/error/mongocryptd_spawn_error.rb +22 -0
- data/lib/mongo/error/no_server_available.rb +8 -3
- data/lib/mongo/error/operation_failure.rb +1 -0
- data/lib/mongo/grid/file.rb +0 -5
- data/lib/mongo/grid/file/chunk.rb +0 -2
- data/lib/mongo/grid/file/info.rb +2 -1
- data/lib/mongo/grid/fs_bucket.rb +13 -15
- data/lib/mongo/grid/stream/write.rb +3 -9
- data/lib/mongo/index/view.rb +3 -3
- data/lib/mongo/monitoring/event/command_started.rb +6 -1
- data/lib/mongo/operation/collections_info.rb +6 -3
- data/lib/mongo/operation/delete/op_msg.rb +1 -1
- data/lib/mongo/operation/find/op_msg.rb +4 -1
- data/lib/mongo/operation/get_more/op_msg.rb +4 -1
- data/lib/mongo/operation/insert/command.rb +2 -2
- data/lib/mongo/operation/insert/legacy.rb +2 -2
- data/lib/mongo/operation/insert/op_msg.rb +3 -3
- data/lib/mongo/operation/result.rb +36 -27
- data/lib/mongo/operation/shared/executable.rb +10 -8
- data/lib/mongo/operation/shared/executable_no_validate.rb +2 -2
- data/lib/mongo/operation/shared/op_msg_or_command.rb +2 -2
- data/lib/mongo/operation/shared/op_msg_or_find_command.rb +2 -2
- data/lib/mongo/operation/shared/op_msg_or_list_indexes_command.rb +2 -2
- data/lib/mongo/operation/shared/write.rb +17 -10
- data/lib/mongo/operation/update/op_msg.rb +1 -1
- data/lib/mongo/protocol/compressed.rb +6 -5
- data/lib/mongo/protocol/insert.rb +3 -1
- data/lib/mongo/protocol/message.rb +72 -8
- data/lib/mongo/protocol/msg.rb +191 -37
- data/lib/mongo/protocol/query.rb +7 -9
- data/lib/mongo/protocol/serializers.rb +6 -2
- data/lib/mongo/server.rb +10 -4
- data/lib/mongo/server/connection.rb +20 -9
- data/lib/mongo/server/connection_base.rb +81 -12
- data/lib/mongo/server/connection_common.rb +61 -0
- data/lib/mongo/server/connection_pool.rb +37 -1
- data/lib/mongo/server/description.rb +9 -11
- data/lib/mongo/server/monitor.rb +2 -0
- data/lib/mongo/server/monitor/connection.rb +3 -18
- data/lib/mongo/server/pending_connection.rb +2 -1
- data/lib/mongo/session.rb +2 -2
- data/lib/mongo/session/session_pool.rb +8 -3
- data/lib/mongo/socket.rb +29 -16
- data/lib/mongo/socket/ssl.rb +23 -8
- data/lib/mongo/socket/tcp.rb +12 -3
- data/lib/mongo/timeout.rb +49 -0
- data/lib/mongo/uri.rb +30 -1
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +1 -1
- data/spec/README.md +134 -7
- data/spec/integration/auth_spec.rb +53 -0
- data/spec/integration/{client_options_spec.rb → client_authentication_options_spec.rb} +10 -10
- data/spec/integration/client_construction_spec.rb +76 -1
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +351 -0
- data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +301 -0
- data/spec/integration/client_side_encryption/auto_encryption_mongocryptd_spawn_spec.rb +71 -0
- data/spec/integration/client_side_encryption/auto_encryption_old_wire_version_spec.rb +76 -0
- data/spec/integration/client_side_encryption/auto_encryption_reconnect_spec.rb +216 -0
- data/spec/integration/client_side_encryption/auto_encryption_spec.rb +600 -0
- data/spec/integration/client_side_encryption/bson_size_limit_spec.rb +183 -0
- data/spec/integration/client_side_encryption/bypass_mongocryptd_spawn_spec.rb +74 -0
- data/spec/integration/client_side_encryption/client_close_spec.rb +59 -0
- data/spec/integration/client_side_encryption/corpus_spec.rb +228 -0
- data/spec/integration/client_side_encryption/custom_endpoint_spec.rb +132 -0
- data/spec/integration/client_side_encryption/data_key_spec.rb +163 -0
- data/spec/integration/client_side_encryption/explicit_encryption_spec.rb +114 -0
- data/spec/integration/client_side_encryption/external_key_vault_spec.rb +137 -0
- data/spec/integration/client_side_encryption/views_spec.rb +42 -0
- data/spec/integration/client_update_spec.rb +120 -0
- data/spec/integration/command_monitoring_spec.rb +3 -1
- data/spec/integration/command_spec.rb +44 -10
- data/spec/integration/connection_spec.rb +57 -0
- data/spec/integration/reconnect_spec.rb +7 -6
- data/spec/integration/size_limit_spec.rb +94 -0
- data/spec/integration/srv_monitoring_spec.rb +14 -6
- data/spec/lite_spec_helper.rb +31 -22
- data/spec/mongo/auth/cr_spec.rb +8 -0
- data/spec/mongo/auth/ldap_spec.rb +5 -1
- data/spec/mongo/auth/scram/conversation_spec.rb +5 -6
- data/spec/mongo/auth/scram/negotiation_spec.rb +74 -75
- data/spec/mongo/auth/scram_spec.rb +45 -35
- data/spec/mongo/auth/x509_spec.rb +5 -1
- data/spec/mongo/client_construction_spec.rb +206 -3
- data/spec/mongo/client_encryption_spec.rb +408 -0
- data/spec/mongo/cluster/cursor_reaper_spec.rb +12 -8
- data/spec/mongo/cluster/socket_reaper_spec.rb +14 -3
- data/spec/mongo/collection/view/aggregation_spec.rb +0 -2
- data/spec/mongo/collection/view/change_stream_spec.rb +7 -7
- data/spec/mongo/collection/view/map_reduce_spec.rb +3 -3
- data/spec/mongo/collection/view_spec.rb +1 -1
- data/spec/mongo/collection_spec.rb +4 -33
- data/spec/mongo/crypt/auto_decryption_context_spec.rb +90 -0
- data/spec/mongo/crypt/auto_encrypter_spec.rb +182 -0
- data/spec/mongo/crypt/auto_encryption_context_spec.rb +107 -0
- data/spec/mongo/crypt/binary_spec.rb +115 -0
- data/spec/mongo/crypt/binding/binary_spec.rb +56 -0
- data/spec/mongo/crypt/binding/context_spec.rb +257 -0
- data/spec/mongo/crypt/binding/helpers_spec.rb +46 -0
- data/spec/mongo/crypt/binding/mongocrypt_spec.rb +144 -0
- data/spec/mongo/crypt/binding/status_spec.rb +99 -0
- data/spec/mongo/crypt/binding/version_spec.rb +22 -0
- data/spec/mongo/crypt/binding_unloaded_spec.rb +20 -0
- data/spec/mongo/crypt/data_key_context_spec.rb +213 -0
- data/spec/mongo/crypt/encryption_io_spec.rb +136 -0
- data/spec/mongo/crypt/explicit_decryption_context_spec.rb +72 -0
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +170 -0
- data/spec/mongo/crypt/handle_spec.rb +198 -0
- data/spec/mongo/crypt/helpers/mongo_crypt_spec_helper.rb +108 -0
- data/spec/mongo/crypt/status_spec.rb +152 -0
- data/spec/mongo/cursor_spec.rb +24 -4
- data/spec/mongo/database_spec.rb +20 -0
- data/spec/mongo/error/crypt_error_spec.rb +26 -0
- data/spec/mongo/error/max_bson_size_spec.rb +35 -0
- data/spec/mongo/error/no_server_available_spec.rb +11 -1
- data/spec/mongo/error/operation_failure_spec.rb +6 -6
- data/spec/mongo/operation/aggregate_spec.rb +1 -1
- data/spec/mongo/operation/collections_info_spec.rb +1 -1
- data/spec/mongo/operation/command_spec.rb +3 -3
- data/spec/mongo/operation/create_index_spec.rb +3 -3
- data/spec/mongo/operation/create_user_spec.rb +3 -3
- data/spec/mongo/operation/delete/bulk_spec.rb +6 -6
- data/spec/mongo/operation/delete/op_msg_spec.rb +1 -6
- data/spec/mongo/operation/delete_spec.rb +7 -7
- data/spec/mongo/operation/drop_index_spec.rb +2 -2
- data/spec/mongo/operation/find/legacy_spec.rb +1 -1
- data/spec/mongo/operation/get_more_spec.rb +1 -1
- data/spec/mongo/operation/indexes_spec.rb +1 -1
- data/spec/mongo/operation/insert/bulk_spec.rb +7 -7
- data/spec/mongo/operation/insert/op_msg_spec.rb +3 -6
- data/spec/mongo/operation/insert_spec.rb +12 -12
- data/spec/mongo/operation/map_reduce_spec.rb +2 -2
- data/spec/mongo/operation/remove_user_spec.rb +3 -3
- data/spec/mongo/operation/update/bulk_spec.rb +6 -6
- data/spec/mongo/operation/update/op_msg_spec.rb +3 -6
- data/spec/mongo/operation/update_spec.rb +7 -7
- data/spec/mongo/operation/update_user_spec.rb +1 -1
- data/spec/mongo/protocol/compressed_spec.rb +2 -3
- data/spec/mongo/protocol/delete_spec.rb +9 -8
- data/spec/mongo/protocol/get_more_spec.rb +9 -8
- data/spec/mongo/protocol/insert_spec.rb +9 -8
- data/spec/mongo/protocol/kill_cursors_spec.rb +6 -5
- data/spec/mongo/protocol/msg_spec.rb +57 -53
- data/spec/mongo/protocol/query_spec.rb +12 -12
- data/spec/mongo/protocol/registry_spec.rb +1 -1
- data/spec/mongo/protocol/reply_spec.rb +1 -1
- data/spec/mongo/protocol/update_spec.rb +10 -9
- data/spec/mongo/server/connection_pool_spec.rb +1 -1
- data/spec/mongo/server/connection_spec.rb +28 -7
- data/spec/mongo/socket_spec.rb +1 -1
- data/spec/mongo/timeout_spec.rb +85 -0
- data/spec/mongo/uri/srv_protocol_spec.rb +2 -2
- data/spec/mongo/uri_spec.rb +52 -5
- data/spec/mongo/write_concern_spec.rb +13 -1
- data/spec/{support → runners}/auth.rb +14 -1
- data/spec/{support → runners}/change_streams.rb +1 -1
- data/spec/{support → runners}/change_streams/operation.rb +0 -0
- data/spec/{support → runners}/cmap.rb +1 -1
- data/spec/{support → runners}/cmap/verifier.rb +0 -0
- data/spec/{support → runners}/command_monitoring.rb +0 -0
- data/spec/runners/connection_string.rb +358 -4
- data/spec/{support → runners}/crud.rb +9 -9
- data/spec/{support → runners}/crud/context.rb +0 -0
- data/spec/{support → runners}/crud/operation.rb +7 -3
- data/spec/{support → runners}/crud/outcome.rb +0 -0
- data/spec/{support → runners}/crud/requirement.rb +1 -1
- data/spec/{support → runners}/crud/spec.rb +12 -1
- data/spec/{support → runners}/crud/test.rb +0 -0
- data/spec/{support → runners}/crud/test_base.rb +0 -0
- data/spec/{support → runners}/crud/verifier.rb +10 -12
- data/spec/{support → runners}/gridfs.rb +0 -0
- data/spec/{support → runners}/sdam_monitoring.rb +0 -0
- data/spec/{support → runners}/server_discovery_and_monitoring.rb +0 -0
- data/spec/{support → runners}/server_selection.rb +0 -0
- data/spec/{support → runners}/server_selection_rtt.rb +0 -0
- data/spec/{support → runners}/transactions.rb +4 -4
- data/spec/{support → runners}/transactions/context.rb +0 -0
- data/spec/{support → runners}/transactions/operation.rb +0 -0
- data/spec/{support → runners}/transactions/spec.rb +0 -0
- data/spec/{support → runners}/transactions/test.rb +37 -5
- data/spec/spec_helper.rb +0 -5
- data/spec/spec_tests/auth_spec.rb +3 -3
- data/spec/spec_tests/client_side_encryption_spec.rb +13 -0
- data/spec/spec_tests/connection_string_spec.rb +1 -1
- data/spec/spec_tests/data/auth/connection-string.yml +13 -0
- data/spec/spec_tests/data/client_side_encryption/aggregate.yml +134 -0
- data/spec/spec_tests/data/client_side_encryption/badQueries.yml +526 -0
- data/spec/spec_tests/data/client_side_encryption/badSchema.yml +73 -0
- data/spec/spec_tests/data/client_side_encryption/basic.yml +116 -0
- data/spec/spec_tests/data/client_side_encryption/bulk.yml +85 -0
- data/spec/spec_tests/data/client_side_encryption/bypassAutoEncryption.yml +100 -0
- data/spec/spec_tests/data/client_side_encryption/bypassedCommand.yml +42 -0
- data/spec/spec_tests/data/client_side_encryption/count.yml +61 -0
- data/spec/spec_tests/data/client_side_encryption/countDocuments.yml +59 -0
- data/spec/spec_tests/data/client_side_encryption/delete.yml +105 -0
- data/spec/spec_tests/data/client_side_encryption/distinct.yml +73 -0
- data/spec/spec_tests/data/client_side_encryption/explain.yml +64 -0
- data/spec/spec_tests/data/client_side_encryption/find.yml +119 -0
- data/spec/spec_tests/data/client_side_encryption/findOneAndDelete.yml +57 -0
- data/spec/spec_tests/data/client_side_encryption/findOneAndReplace.yml +57 -0
- data/spec/spec_tests/data/client_side_encryption/findOneAndUpdate.yml +57 -0
- data/spec/spec_tests/data/client_side_encryption/getMore.yml +68 -0
- data/spec/spec_tests/data/client_side_encryption/insert.yml +102 -0
- data/spec/spec_tests/data/client_side_encryption/keyAltName.yml +71 -0
- data/spec/spec_tests/data/client_side_encryption/localKMS.yml +54 -0
- data/spec/spec_tests/data/client_side_encryption/localSchema.yml +72 -0
- data/spec/spec_tests/data/client_side_encryption/malformedCiphertext.yml +69 -0
- data/spec/spec_tests/data/client_side_encryption/maxWireVersion.yml +20 -0
- data/spec/spec_tests/data/client_side_encryption/missingKey.yml +49 -0
- data/spec/spec_tests/data/client_side_encryption/replaceOne.yml +61 -0
- data/spec/spec_tests/data/client_side_encryption/types.yml +527 -0
- data/spec/spec_tests/data/client_side_encryption/unsupportedCommand.yml +25 -0
- data/spec/spec_tests/data/client_side_encryption/updateMany.yml +77 -0
- data/spec/spec_tests/data/client_side_encryption/updateOne.yml +168 -0
- data/spec/spec_tests/data/read_write_concern/connection-string/write-concern.yml +1 -4
- data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +21 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_ghost.yml +2 -4
- data/spec/spec_tests/data/sdam/rs/incompatible_other.yml +1 -1
- data/spec/spec_tests/data/sdam/rs/primary_mismatched_me_not_removed.yml +73 -0
- data/spec/spec_tests/data/sdam/rs/primary_to_no_primary_mismatched_me.yml +1 -2
- data/spec/spec_tests/data/sdam/rs/repeated.yml +101 -0
- data/spec/spec_tests/data/sdam/rs/{primary_address_change.yml → ruby_primary_address_change.yml} +2 -0
- data/spec/spec_tests/data/sdam/rs/{secondary_wrong_set_name_with_primary_second.yml → ruby_secondary_wrong_set_name_with_primary_second.yml} +0 -0
- data/spec/spec_tests/data/sdam/sharded/ruby_discovered_single_mongos.yml +27 -0
- data/spec/spec_tests/data/sdam/sharded/{primary_address_change.yml → ruby_primary_different_address.yml} +1 -1
- data/spec/spec_tests/data/sdam/sharded/{primary_mismatched_me.yml → ruby_primary_mismatched_me.yml} +1 -1
- data/spec/spec_tests/data/sdam/single/{primary_address_change.yml → ruby_primary_different_address.yml} +1 -1
- data/spec/spec_tests/data/sdam/single/{primary_mismatched_me.yml → ruby_primary_mismatched_me.yml} +1 -1
- data/spec/spec_tests/data/sdam_monitoring/{replica_set_with_primary_change.yml → replica_set_primary_address_change.yml} +27 -5
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_me_mismatch.yml +26 -74
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_removal.yml +20 -16
- data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +73 -0
- data/spec/spec_tests/data/transactions/pin-mongos.yml +2 -3
- data/spec/spec_tests/data/uri_options/auth-options.yml +10 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +75 -4
- data/spec/spec_tests/read_write_concern_connection_string_spec.rb +1 -1
- data/spec/spec_tests/uri_options_spec.rb +6 -8
- data/spec/stress/connection_pool_timing_spec.rb +6 -3
- data/spec/support/certificates/README.md +4 -0
- data/spec/support/certificates/server-second-level-bundle.pem +77 -77
- data/spec/support/certificates/server-second-level.crt +52 -52
- data/spec/support/certificates/server-second-level.key +25 -25
- data/spec/support/certificates/server-second-level.pem +77 -77
- data/spec/support/client_registry.rb +19 -3
- data/spec/support/cluster_config.rb +9 -1
- data/spec/support/common_shortcuts.rb +12 -0
- data/spec/support/constraints.rb +16 -0
- data/spec/support/crypt.rb +140 -0
- data/spec/support/crypt/corpus/corpus-key-aws.json +33 -0
- data/spec/support/crypt/corpus/corpus-key-local.json +31 -0
- data/spec/support/crypt/corpus/corpus-schema.json +2057 -0
- data/spec/support/crypt/corpus/corpus.json +3657 -0
- data/spec/support/crypt/corpus/corpus_encrypted.json +4152 -0
- data/spec/support/crypt/data_keys/key_document_aws.json +34 -0
- data/spec/support/crypt/data_keys/key_document_local.json +31 -0
- data/spec/support/crypt/external/external-key.json +31 -0
- data/spec/support/crypt/external/external-schema.json +19 -0
- data/spec/support/crypt/limits/limits-doc.json +102 -0
- data/spec/support/crypt/limits/limits-key.json +31 -0
- data/spec/support/crypt/limits/limits-schema.json +1405 -0
- data/spec/support/crypt/schema_maps/schema_map_aws.json +17 -0
- data/spec/support/crypt/schema_maps/schema_map_aws_key_alt_names.json +12 -0
- data/spec/support/crypt/schema_maps/schema_map_local.json +18 -0
- data/spec/support/crypt/schema_maps/schema_map_local_key_alt_names.json +12 -0
- data/spec/support/lite_constraints.rb +17 -1
- data/spec/support/matchers.rb +19 -0
- data/spec/support/shared/protocol.rb +2 -0
- data/spec/support/spec_config.rb +43 -13
- data/spec/support/utils.rb +132 -10
- metadata +277 -81
- metadata.gz.sig +0 -0
- data/spec/integration/grid_fs_bucket_spec.rb +0 -48
- data/spec/integration/zlib_compression_spec.rb +0 -25
- data/spec/spec_tests/data/sdam/sharded/single_mongos.yml +0 -33
- data/spec/support/connection_string.rb +0 -354
@@ -91,18 +91,16 @@ describe Mongo::Cluster::CursorReaper do
|
|
91
91
|
|
92
92
|
describe '#register_cursor' do
|
93
93
|
|
94
|
-
before do
|
95
|
-
reaper.register_cursor(cursor_id)
|
96
|
-
end
|
97
|
-
|
98
94
|
context 'when the cursor id is nil' do
|
99
95
|
|
100
96
|
let(:cursor_id) do
|
101
97
|
nil
|
102
98
|
end
|
103
99
|
|
104
|
-
it '
|
105
|
-
expect
|
100
|
+
it 'raises exception' do
|
101
|
+
expect do
|
102
|
+
reaper.register_cursor(cursor_id)
|
103
|
+
end.to raise_error(ArgumentError, /register_cursor called with nil cursor_id/)
|
106
104
|
end
|
107
105
|
end
|
108
106
|
|
@@ -112,8 +110,10 @@ describe Mongo::Cluster::CursorReaper do
|
|
112
110
|
0
|
113
111
|
end
|
114
112
|
|
115
|
-
it '
|
116
|
-
expect
|
113
|
+
it 'raises exception' do
|
114
|
+
expect do
|
115
|
+
reaper.register_cursor(cursor_id)
|
116
|
+
end.to raise_error(ArgumentError, /register_cursor called with cursor_id=0/)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -123,6 +123,10 @@ describe Mongo::Cluster::CursorReaper do
|
|
123
123
|
2
|
124
124
|
end
|
125
125
|
|
126
|
+
before do
|
127
|
+
reaper.register_cursor(cursor_id)
|
128
|
+
end
|
129
|
+
|
126
130
|
it 'registers the cursor id as active' do
|
127
131
|
expect(active_cursors).to eq(Set.new([2]))
|
128
132
|
end
|
@@ -20,13 +20,24 @@ describe Mongo::Cluster::SocketReaper do
|
|
20
20
|
describe '#execute' do
|
21
21
|
|
22
22
|
before do
|
23
|
-
|
24
|
-
|
23
|
+
# Ensure all servers are discovered
|
24
|
+
cluster.servers_list.each do |server|
|
25
|
+
server.scan!
|
25
26
|
end
|
27
|
+
|
28
|
+
# Stop the reaper that is attached to the cluster, since it
|
29
|
+
# runs the same code we are running and can interfere with our assertions
|
30
|
+
cluster.instance_variable_get('@periodic_executor').stop!
|
26
31
|
end
|
27
32
|
|
28
33
|
it 'calls close_idle_sockets on each connection pool in the cluster' do
|
29
|
-
|
34
|
+
RSpec::Mocks.with_temporary_scope do
|
35
|
+
cluster.servers.each do |s|
|
36
|
+
expect(s.pool).to receive(:close_idle_sockets).and_call_original
|
37
|
+
end
|
38
|
+
|
39
|
+
reaper.execute
|
40
|
+
end
|
30
41
|
end
|
31
42
|
end
|
32
43
|
end
|
@@ -372,7 +372,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
372
372
|
context 'when documents have not been retrieved and the stream is closed' do
|
373
373
|
|
374
374
|
before do
|
375
|
-
expect(cursor).to receive(:
|
375
|
+
expect(cursor).to receive(:close).and_call_original
|
376
376
|
change_stream.close
|
377
377
|
end
|
378
378
|
|
@@ -448,7 +448,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
448
448
|
max_server_version '4.0'
|
449
449
|
|
450
450
|
it 'driver raises an exception and closes the cursor' do
|
451
|
-
expect(cursor).to receive(:
|
451
|
+
expect(cursor).to receive(:close).and_call_original
|
452
452
|
expect {
|
453
453
|
change_stream.to_enum.next
|
454
454
|
}.to raise_exception(Mongo::Error::MissingResumeToken)
|
@@ -459,7 +459,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
459
459
|
min_server_fcv '4.2'
|
460
460
|
|
461
461
|
it 'server errors, driver closes the cursor' do
|
462
|
-
expect(cursor).to receive(:
|
462
|
+
expect(cursor).to receive(:close).and_call_original
|
463
463
|
expect {
|
464
464
|
change_stream.to_enum.next
|
465
465
|
}.to raise_exception(Mongo::Error::OperationFailure, /Encountered an event whose _id field, which contains the resume token, was modified by the pipeline. Modifying the _id field of an event makes it impossible to resume the stream from that point. Only transformations that retain the unmodified _id field are allowed./)
|
@@ -663,7 +663,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
663
663
|
enum.next
|
664
664
|
collection.insert_one(a: 2)
|
665
665
|
expect(cursor).to receive(:get_more).once.and_raise(error)
|
666
|
-
expect(cursor).to receive(:
|
666
|
+
expect(cursor).to receive(:close).and_call_original
|
667
667
|
expect(view.send(:server_selector)).to receive(:select_server).once.and_call_original
|
668
668
|
expect(Mongo::Operation::Aggregate).to receive(:new).and_call_original
|
669
669
|
end
|
@@ -723,7 +723,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
723
723
|
|
724
724
|
let(:error) do
|
725
725
|
Mongo::Error::OperationFailure.new('not master',
|
726
|
-
Mongo::Operation::GetMore::Result.new(
|
726
|
+
Mongo::Operation::GetMore::Result.new(nil))
|
727
727
|
end
|
728
728
|
|
729
729
|
it_behaves_like 'a change stream that encounters an error from a getMore'
|
@@ -733,7 +733,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
733
733
|
|
734
734
|
let(:error) do
|
735
735
|
Mongo::Error::OperationFailure.new('node is recovering',
|
736
|
-
Mongo::Operation::GetMore::Result.new(
|
736
|
+
Mongo::Operation::GetMore::Result.new(nil))
|
737
737
|
end
|
738
738
|
|
739
739
|
it_behaves_like 'a change stream that encounters an error from a getMore'
|
@@ -748,7 +748,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
748
748
|
enum.next
|
749
749
|
collection.insert_one(a: 2)
|
750
750
|
expect(cursor).to receive(:get_more).and_raise(Mongo::Error::MissingResumeToken)
|
751
|
-
expect(cursor).to receive(:
|
751
|
+
expect(cursor).to receive(:close).and_call_original
|
752
752
|
expect(Mongo::Operation::Aggregate).not_to receive(:new)
|
753
753
|
end
|
754
754
|
|
@@ -66,7 +66,7 @@ describe Mongo::Collection::View::MapReduce do
|
|
66
66
|
|
67
67
|
describe '#reduce_function' do
|
68
68
|
|
69
|
-
it 'returns the
|
69
|
+
it 'returns the reduce function' do
|
70
70
|
expect(map_reduce.reduce_function).to eq(reduce)
|
71
71
|
end
|
72
72
|
end
|
@@ -80,7 +80,7 @@ describe Mongo::Collection::View::MapReduce do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'calls the Enumerable method' do
|
83
|
-
expect(results).to eq(map_reduce.to_a)
|
83
|
+
expect(results.sort_by { |d| d['_id'] }).to eq(map_reduce.to_a.sort_by { |d| d['_id'] })
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -186,7 +186,7 @@ describe Mongo::Collection::View::MapReduce do
|
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'executes the map reduce' do
|
189
|
-
expect(
|
189
|
+
expect(new_map_reduce.to_a.sort_by { |d| d['_id'] }).to eq(map_reduce.to_a.sort_by { |d| d['_id'] })
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
@@ -147,7 +147,7 @@ describe Mongo::Collection::View do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'sends a kill cursors command for the cursor' do
|
150
|
-
expect(cursor).to receive(:
|
150
|
+
expect(cursor).to receive(:close).and_call_original
|
151
151
|
view.close_query
|
152
152
|
end
|
153
153
|
end
|
@@ -203,11 +203,11 @@ describe Mongo::Collection do
|
|
203
203
|
end
|
204
204
|
|
205
205
|
let(:database) do
|
206
|
-
Mongo::Database.new(client,
|
206
|
+
Mongo::Database.new(client, SpecConfig.instance.test_db)
|
207
207
|
end
|
208
208
|
|
209
209
|
let(:collection) do
|
210
|
-
database.collection(
|
210
|
+
database.collection('test-collection')
|
211
211
|
end
|
212
212
|
|
213
213
|
let(:new_collection) do
|
@@ -241,12 +241,9 @@ describe Mongo::Collection do
|
|
241
241
|
end
|
242
242
|
|
243
243
|
context 'when the client has a read preference set' do
|
244
|
-
clean_slate_on_evergreen
|
245
244
|
|
246
245
|
let(:client) do
|
247
|
-
authorized_client.with(
|
248
|
-
client_options
|
249
|
-
)).tap do |client|
|
246
|
+
authorized_client.with(client_options).tap do |client|
|
250
247
|
expect(client.options[:read]).to eq(Mongo::Options::Redacted.new(
|
251
248
|
mode: :primary_preferred))
|
252
249
|
end
|
@@ -278,9 +275,7 @@ describe Mongo::Collection do
|
|
278
275
|
require_topology :replica_set
|
279
276
|
|
280
277
|
let(:client_options) do
|
281
|
-
|
282
|
-
read: { mode: :primary_preferred },
|
283
|
-
)
|
278
|
+
{read: { mode: :primary_preferred }}
|
284
279
|
end
|
285
280
|
|
286
281
|
let(:subscriber) { EventSubscriber.new }
|
@@ -945,30 +940,6 @@ describe Mongo::Collection do
|
|
945
940
|
it_behaves_like 'a failed operation using a session'
|
946
941
|
end
|
947
942
|
end
|
948
|
-
|
949
|
-
context 'when collation has a strength' do
|
950
|
-
min_server_fcv '3.4'
|
951
|
-
|
952
|
-
let(:band_collection) do
|
953
|
-
described_class.new(database, :bands)
|
954
|
-
end
|
955
|
-
|
956
|
-
before do
|
957
|
-
band_collection.delete_many
|
958
|
-
band_collection.insert_many([{ name: "Depeche Mode" }, { name: "New Order" }])
|
959
|
-
end
|
960
|
-
|
961
|
-
let(:options) do
|
962
|
-
{ collation: { locale: 'en_US', strength: 2 } }
|
963
|
-
end
|
964
|
-
let(:band_result) do
|
965
|
-
band_collection.find({ name: 'DEPECHE MODE' }, options)
|
966
|
-
end
|
967
|
-
|
968
|
-
it 'finds Capitalize from UPPER CASE' do
|
969
|
-
expect(band_result.count_documents).to eq(1)
|
970
|
-
end
|
971
|
-
end
|
972
943
|
end
|
973
944
|
|
974
945
|
describe '#drop' do
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
require 'lite_spec_helper'
|
3
|
+
|
4
|
+
describe Mongo::Crypt::AutoDecryptionContext do
|
5
|
+
require_libmongocrypt
|
6
|
+
include_context 'define shared FLE helpers'
|
7
|
+
|
8
|
+
let(:mongocrypt) { Mongo::Crypt::Handle.new(kms_providers, logger: logger) }
|
9
|
+
let(:context) { described_class.new(mongocrypt, io, command) }
|
10
|
+
|
11
|
+
let(:logger) { nil }
|
12
|
+
|
13
|
+
let(:io) { double("Mongo::ClientEncryption::IO") }
|
14
|
+
let(:command) do
|
15
|
+
{
|
16
|
+
"find": "test",
|
17
|
+
"filter": {
|
18
|
+
"ssn": "457-55-5462"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#initialize' do
|
24
|
+
shared_examples 'a functioning AutoDecryptionContext' do
|
25
|
+
it 'initializes without error' do
|
26
|
+
expect do
|
27
|
+
context
|
28
|
+
end.not_to raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with nil command' do
|
32
|
+
let(:command) { nil }
|
33
|
+
|
34
|
+
it 'raises an exception' do
|
35
|
+
expect do
|
36
|
+
context
|
37
|
+
end.to raise_error(Mongo::Error::CryptError, /Attempted to pass nil data to libmongocrypt/)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with non-document command' do
|
42
|
+
let(:command) { 'command-to-decrypt' }
|
43
|
+
|
44
|
+
it 'raises an exception' do
|
45
|
+
expect do
|
46
|
+
context
|
47
|
+
end.to raise_error(Mongo::Error::CryptError, /Attempted to pass invalid data to libmongocrypt/)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when mongocrypt is initialized with local KMS provider options' do
|
53
|
+
include_context 'with local kms_providers'
|
54
|
+
it_behaves_like 'a functioning AutoDecryptionContext'
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when mongocrypt is initialized with AWS KMS provider options' do
|
58
|
+
include_context 'with AWS kms_providers'
|
59
|
+
it_behaves_like 'a functioning AutoDecryptionContext'
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'with verbose logging' do
|
63
|
+
include_context 'with local kms_providers'
|
64
|
+
|
65
|
+
before(:all) do
|
66
|
+
# Logging from libmongocrypt requires the C library to be built with the -DENABLE_TRACE=ON
|
67
|
+
# option; none of the pre-built packages on Evergreen have been built with logging enabled.
|
68
|
+
#
|
69
|
+
# It is still useful to be able to run these tests locally to confirm that logging is working
|
70
|
+
# while debugging any problems.
|
71
|
+
#
|
72
|
+
# For now, skip this test by default and revisit once we have determined how we want to
|
73
|
+
# package libmongocrypt with the Ruby driver (see: https://jira.mongodb.org/browse/RUBY-1966)
|
74
|
+
skip "These tests require libmongocrypt to be built with the '-DENABLE_TRACE=ON' cmake option." +
|
75
|
+
" They also require the MONGOCRYPT_TRACE environment variable to be set to 'ON'."
|
76
|
+
end
|
77
|
+
|
78
|
+
let(:logger) do
|
79
|
+
::Logger.new($stdout).tap do |logger|
|
80
|
+
logger.level = ::Logger::DEBUG
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'receives log messages from libmongocrypt' do
|
85
|
+
expect(logger).to receive(:debug).with(/mongocrypt_ctx_decrypt_init/)
|
86
|
+
context
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mongo::Crypt::AutoEncrypter do
|
4
|
+
require_libmongocrypt
|
5
|
+
min_server_fcv '4.2'
|
6
|
+
require_enterprise
|
7
|
+
clean_slate
|
8
|
+
|
9
|
+
include_context 'define shared FLE helpers'
|
10
|
+
|
11
|
+
let(:auto_encrypter) do
|
12
|
+
described_class.new(auto_encryption_options.merge(client: authorized_client.use(:auto_encryption)))
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:client) { authorized_client }
|
16
|
+
|
17
|
+
let(:db_name) { 'auto_encryption' }
|
18
|
+
let(:collection_name) { 'users' }
|
19
|
+
|
20
|
+
let(:command) do
|
21
|
+
{
|
22
|
+
'insert' => collection_name,
|
23
|
+
'ordered' => true,
|
24
|
+
'lsid' => {
|
25
|
+
'id' => BSON::Binary.new(Base64.decode64("CzgjT+byRK+FKUWG6QbyjQ==\n"), :uuid)
|
26
|
+
},
|
27
|
+
'documents' => [
|
28
|
+
{
|
29
|
+
'ssn' => ssn,
|
30
|
+
'_id' => BSON::ObjectId('5e16516e781d8a89b94df6df')
|
31
|
+
}
|
32
|
+
]
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:encrypted_command) do
|
37
|
+
command.merge(
|
38
|
+
'documents' => [
|
39
|
+
{
|
40
|
+
'ssn' => BSON::Binary.new(Base64.decode64(encrypted_ssn), :ciphertext),
|
41
|
+
'_id' => BSON::ObjectId('5e16516e781d8a89b94df6df')
|
42
|
+
}
|
43
|
+
]
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
shared_context 'with jsonSchema validator' do
|
48
|
+
before do
|
49
|
+
users_collection = client.use(db_name)[collection_name]
|
50
|
+
users_collection.drop
|
51
|
+
client.use(db_name)[collection_name,
|
52
|
+
{
|
53
|
+
'validator' => { '$jsonSchema' => schema_map }
|
54
|
+
}
|
55
|
+
].create
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
shared_context 'without jsonSchema validator' do
|
60
|
+
before do
|
61
|
+
users_collection = client.use(db_name)[collection_name]
|
62
|
+
users_collection.drop
|
63
|
+
users_collection.create
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
shared_examples 'a functioning auto encrypter' do
|
68
|
+
describe '#encrypt' do
|
69
|
+
it 'replaces the ssn field with a BSON::Binary' do
|
70
|
+
result = auto_encrypter.encrypt(db_name, command)
|
71
|
+
expect(result).to eq(encrypted_command)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#decrypt' do
|
76
|
+
it 'returns the unencrypted document' do
|
77
|
+
result = auto_encrypter.decrypt(encrypted_command)
|
78
|
+
expect(result).to eq(command)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
before do
|
84
|
+
key_vault_collection = client.use(key_vault_db)[key_vault_coll]
|
85
|
+
key_vault_collection.drop
|
86
|
+
key_vault_collection.insert_one(data_key)
|
87
|
+
end
|
88
|
+
|
89
|
+
after do
|
90
|
+
auto_encrypter.close
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'with schema map in auto encryption commands' do
|
94
|
+
include_context 'without jsonSchema validator'
|
95
|
+
|
96
|
+
let(:auto_encryption_options) do
|
97
|
+
{
|
98
|
+
kms_providers: kms_providers,
|
99
|
+
key_vault_namespace: key_vault_namespace,
|
100
|
+
schema_map: { "#{db_name}.#{collection_name}": schema_map }
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'with AWS KMS providers' do
|
105
|
+
include_context 'with AWS kms_providers'
|
106
|
+
it_behaves_like 'a functioning auto encrypter'
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'with local KMS providers' do
|
110
|
+
include_context 'with local kms_providers'
|
111
|
+
it_behaves_like 'a functioning auto encrypter'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'with schema map collection validator' do
|
116
|
+
include_context 'with jsonSchema validator'
|
117
|
+
|
118
|
+
let(:auto_encryption_options) do
|
119
|
+
{
|
120
|
+
kms_providers: kms_providers,
|
121
|
+
key_vault_namespace: key_vault_namespace
|
122
|
+
}
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'with AWS KMS providers' do
|
126
|
+
include_context 'with AWS kms_providers'
|
127
|
+
it_behaves_like 'a functioning auto encrypter'
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'with local KMS providers' do
|
131
|
+
include_context 'with local kms_providers'
|
132
|
+
it_behaves_like 'a functioning auto encrypter'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'with no validator or client option' do
|
137
|
+
include_context 'without jsonSchema validator'
|
138
|
+
|
139
|
+
let(:auto_encryption_options) do
|
140
|
+
{
|
141
|
+
kms_providers: kms_providers,
|
142
|
+
key_vault_namespace: key_vault_namespace,
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'with AWS KMS providers' do
|
147
|
+
include_context 'with AWS kms_providers'
|
148
|
+
|
149
|
+
describe '#encrypt' do
|
150
|
+
it 'does not perform encryption' do
|
151
|
+
result = auto_encrypter.encrypt(db_name, command)
|
152
|
+
expect(result).to eq(command)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '#decrypt' do
|
157
|
+
it 'still performs decryption' do
|
158
|
+
result = auto_encrypter.decrypt(encrypted_command)
|
159
|
+
expect(result).to eq(command)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'with local KMS providers' do
|
165
|
+
include_context 'with local kms_providers'
|
166
|
+
|
167
|
+
describe '#encrypt' do
|
168
|
+
it 'does not perform encryption' do
|
169
|
+
result = auto_encrypter.encrypt(db_name, command)
|
170
|
+
expect(result).to eq(command)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe '#decrypt' do
|
175
|
+
it 'still performs decryption' do
|
176
|
+
result = auto_encrypter.decrypt(encrypted_command)
|
177
|
+
expect(result).to eq(command)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|