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
@@ -12,15 +12,15 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require '
|
16
|
-
require '
|
17
|
-
require '
|
18
|
-
require '
|
19
|
-
require '
|
20
|
-
require '
|
21
|
-
require '
|
22
|
-
require '
|
23
|
-
require '
|
15
|
+
require 'runners/gridfs'
|
16
|
+
require 'runners/crud/requirement'
|
17
|
+
require 'runners/crud/spec'
|
18
|
+
require 'runners/crud/test_base'
|
19
|
+
require 'runners/crud/test'
|
20
|
+
require 'runners/crud/outcome'
|
21
|
+
require 'runners/crud/context'
|
22
|
+
require 'runners/crud/operation'
|
23
|
+
require 'runners/crud/verifier'
|
24
24
|
|
25
25
|
def collection_data(collection)
|
26
26
|
collection.find.to_a
|
File without changes
|
@@ -28,7 +28,11 @@ module Mongo
|
|
28
28
|
@crud_test = crud_test
|
29
29
|
@spec = IceNine.deep_freeze(spec)
|
30
30
|
@name = spec['name']
|
31
|
-
|
31
|
+
if spec['arguments']
|
32
|
+
@arguments = BSON::ExtJSON.parse_obj(spec['arguments'])
|
33
|
+
else
|
34
|
+
@arguments = {}
|
35
|
+
end
|
32
36
|
@outcome = Outcome.new(outcome_spec || spec)
|
33
37
|
end
|
34
38
|
|
@@ -179,7 +183,7 @@ module Mongo
|
|
179
183
|
end
|
180
184
|
|
181
185
|
def download(fs_bucket, context)
|
182
|
-
stream = fs_bucket.open_download_stream(
|
186
|
+
stream = fs_bucket.open_download_stream(arguments['id'])
|
183
187
|
stream.read
|
184
188
|
end
|
185
189
|
|
@@ -190,7 +194,7 @@ module Mongo
|
|
190
194
|
|
191
195
|
def map_reduce(collection, context)
|
192
196
|
view = Mongo::Collection::View.new(collection)
|
193
|
-
mr = Mongo::Collection::View::MapReduce.new(view, arguments['map']
|
197
|
+
mr = Mongo::Collection::View::MapReduce.new(view, arguments['map'].javascript, arguments['reduce'].javascript)
|
194
198
|
mr.to_a
|
195
199
|
end
|
196
200
|
|
File without changes
|
@@ -42,7 +42,7 @@ module Mongo
|
|
42
42
|
ok &&= cc.fcv_ish >= short_min_server_version
|
43
43
|
end
|
44
44
|
if max_server_version
|
45
|
-
ok &&= cc.
|
45
|
+
ok &&= cc.short_server_version <= max_server_version
|
46
46
|
end
|
47
47
|
if topologies
|
48
48
|
ok &&= topologies.include?(cc.topology)
|
@@ -20,9 +20,13 @@ module Mongo
|
|
20
20
|
|
21
21
|
@spec = YAML.load(contents)
|
22
22
|
@description = File.basename(test_path)
|
23
|
-
@data = @spec['data']
|
23
|
+
@data = BSON::ExtJSON.parse_obj(@spec['data'])
|
24
24
|
@tests = @spec['tests']
|
25
25
|
|
26
|
+
# Introduced with Client-Side Encryption tests
|
27
|
+
@json_schema = BSON::ExtJSON.parse_obj(@spec['json_schema'])
|
28
|
+
@key_vault_data = BSON::ExtJSON.parse_obj(@spec['key_vault_data'])
|
29
|
+
|
26
30
|
@requirements = if run_on = @spec['runOn']
|
27
31
|
run_on.map do |spec|
|
28
32
|
Requirement.new(spec)
|
@@ -41,6 +45,13 @@ module Mongo
|
|
41
45
|
|
42
46
|
attr_reader :requirements
|
43
47
|
|
48
|
+
# @return [ Hash ] The jsonSchema collection validator.
|
49
|
+
attr_reader :json_schema
|
50
|
+
|
51
|
+
# @return [ Array<Hash> ] Data to insert into the key vault before
|
52
|
+
# running each test.
|
53
|
+
attr_reader :key_vault_data
|
54
|
+
|
44
55
|
def collection_name
|
45
56
|
# Older spec tests do not specify a collection name, thus
|
46
57
|
# we provide a default here
|
File without changes
|
File without changes
|
@@ -34,12 +34,7 @@ module Mongo
|
|
34
34
|
expect(actual_collection_data).to be_empty
|
35
35
|
else
|
36
36
|
expect(actual_collection_data).not_to be nil
|
37
|
-
|
38
|
-
expect(actual_collection_data).to include(doc)
|
39
|
-
end
|
40
|
-
actual_collection_data.each do |doc|
|
41
|
-
expect(expected_collection_data).to include(doc)
|
42
|
-
end
|
37
|
+
expect(actual_collection_data).to match_with_type(expected_collection_data)
|
43
38
|
end
|
44
39
|
end
|
45
40
|
|
@@ -105,15 +100,14 @@ EOT
|
|
105
100
|
expected_absence = expected_command.select { |k, v| v.nil? }
|
106
101
|
|
107
102
|
expected_presence.each do |k, v|
|
108
|
-
expect(
|
103
|
+
expect(actual_command[k]).to match_with_type(v)
|
109
104
|
end
|
110
105
|
|
111
106
|
expected_absence.each do |k, v|
|
112
107
|
expect(actual_command).not_to have_key(k)
|
113
108
|
end
|
114
109
|
|
115
|
-
|
116
|
-
expect(actual_event).to eq(expected_event)
|
110
|
+
expect(actual_event).to match_with_type(expected_event)
|
117
111
|
end
|
118
112
|
|
119
113
|
private
|
@@ -181,9 +175,13 @@ EOT
|
|
181
175
|
return
|
182
176
|
end
|
183
177
|
|
184
|
-
|
185
|
-
|
186
|
-
|
178
|
+
if expected[k].is_a?(Time)
|
179
|
+
expect({k => expected[k].utc.to_s}).to eq({k => actual[k].utc.to_s})
|
180
|
+
else
|
181
|
+
# This should produce a meaningful error message,
|
182
|
+
# even though we do not actually require that expected[k] == actual[k]
|
183
|
+
expect({k => expected[k]}).to eq({k => actual[k]})
|
184
|
+
end
|
187
185
|
end
|
188
186
|
end
|
189
187
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -12,10 +12,10 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require '
|
16
|
-
require '
|
17
|
-
require '
|
18
|
-
require '
|
15
|
+
require 'runners/transactions/context'
|
16
|
+
require 'runners/transactions/operation'
|
17
|
+
require 'runners/transactions/spec'
|
18
|
+
require 'runners/transactions/test'
|
19
19
|
|
20
20
|
def define_transactions_spec_tests(test_paths)
|
21
21
|
|
File without changes
|
File without changes
|
File without changes
|
@@ -70,11 +70,15 @@ module Mongo
|
|
70
70
|
Operation.new(self, op)
|
71
71
|
end
|
72
72
|
|
73
|
-
@expectations = test['expectations']
|
73
|
+
@expectations = BSON::ExtJSON.parse_obj(test['expectations'], mode: :bson)
|
74
|
+
|
74
75
|
if test['outcome']
|
75
|
-
@outcome = Mongo::CRUD::Outcome.new(test['outcome'])
|
76
|
+
@outcome = Mongo::CRUD::Outcome.new(BSON::ExtJSON.parse_obj(test['outcome'], mode: :bson))
|
76
77
|
end
|
78
|
+
|
77
79
|
@expected_results = @operations.map do |o|
|
80
|
+
o = BSON::ExtJSON.parse_obj(o)
|
81
|
+
|
78
82
|
# We check both o.key('error') and o['error'] to provide a better
|
79
83
|
# error message in case error: false is ever needed in the tests
|
80
84
|
if o.key?('error')
|
@@ -176,8 +180,8 @@ module Mongo
|
|
176
180
|
|
177
181
|
@results = {
|
178
182
|
results: results,
|
179
|
-
contents: @
|
180
|
-
|
183
|
+
contents: @result_collection.with(
|
184
|
+
read: {mode: 'primary'},
|
181
185
|
read_concern: { level: 'local' },
|
182
186
|
).find.to_a,
|
183
187
|
events: actual_events,
|
@@ -194,9 +198,33 @@ module Mongo
|
|
194
198
|
direct_client.command(configureFailPoint: 'failCommand', mode: 'off')
|
195
199
|
end
|
196
200
|
|
201
|
+
# Insert data into the key vault collection if required to do so by
|
202
|
+
# the tests.
|
203
|
+
if @spec.key_vault_data && !@spec.key_vault_data.empty?
|
204
|
+
key_vault_coll = support_client
|
205
|
+
.use(:admin)[:datakeys]
|
206
|
+
.with(write: { w: :majority })
|
207
|
+
|
208
|
+
key_vault_coll.drop
|
209
|
+
key_vault_coll.insert_many(@spec.key_vault_data)
|
210
|
+
end
|
211
|
+
|
197
212
|
coll = support_client[@spec.collection_name].with(write: { w: :majority })
|
198
213
|
coll.drop
|
199
|
-
|
214
|
+
|
215
|
+
# Place a jsonSchema validator on the collection if required to do so
|
216
|
+
# by the tests.
|
217
|
+
collection_validator = if @spec.json_schema
|
218
|
+
{ '$jsonSchema' => @spec.json_schema }
|
219
|
+
else
|
220
|
+
{}
|
221
|
+
end
|
222
|
+
|
223
|
+
support_client.command(
|
224
|
+
create: @spec.collection_name,
|
225
|
+
validator: collection_validator,
|
226
|
+
writeConcern: { w: :majority }
|
227
|
+
)
|
200
228
|
|
201
229
|
coll.insert_many(@data) unless @data.empty?
|
202
230
|
|
@@ -210,6 +238,10 @@ module Mongo
|
|
210
238
|
|
211
239
|
@collection = test_client[@spec.collection_name]
|
212
240
|
|
241
|
+
# Client-side encryption tests require the use of a separate client
|
242
|
+
# without auto_encryption_options for querying results.
|
243
|
+
@result_collection = support_client.use(@spec.database_name)[@spec.collection_name]
|
244
|
+
|
213
245
|
@session0 = test_client.start_session(@session_options[:session0] || {})
|
214
246
|
@session1 = test_client.start_session(@session_options[:session1] || {})
|
215
247
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
require 'lite_spec_helper'
|
2
2
|
|
3
|
-
# Replica set name can be overridden via replicaSet parameter in MONGODB_URI
|
4
|
-
# environment variable or by specifying RS_NAME environment variable when
|
5
|
-
# not using MONGODB_URI.
|
6
|
-
TEST_SET = 'ruby-driver-rs'
|
7
|
-
|
8
3
|
require 'support/authorization'
|
9
4
|
require 'support/primary_socket'
|
10
5
|
require 'support/constraints'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'lite_spec_helper'
|
2
2
|
|
3
3
|
describe 'Auth' do
|
4
4
|
include Mongo::Auth
|
@@ -15,9 +15,9 @@ describe 'Auth' do
|
|
15
15
|
|
16
16
|
context 'when the auth configuration is invalid', unless: test.valid? do
|
17
17
|
it 'raises an error' do
|
18
|
-
expect
|
18
|
+
expect do
|
19
19
|
test.client
|
20
|
-
|
20
|
+
end.to raise_error(Mongo::Auth::InvalidConfiguration)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Client-Side Encryption' do
|
4
|
+
require_libmongocrypt
|
5
|
+
require_enterprise
|
6
|
+
|
7
|
+
before do
|
8
|
+
unless ClusterConfig.instance.single_server?
|
9
|
+
skip "SPEC-2147: tests only work on single server"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
define_transactions_spec_tests(CLIENT_SIDE_ENCRYPTION_TESTS)
|
13
|
+
end
|
@@ -85,6 +85,14 @@ tests:
|
|
85
85
|
mechanism: "GSSAPI"
|
86
86
|
mechanism_properties:
|
87
87
|
SERVICE_NAME: "mongodb"
|
88
|
+
-
|
89
|
+
description: "must raise an error when the authSource is empty"
|
90
|
+
uri: "mongodb://user:password@localhost/foo?authSource="
|
91
|
+
valid: false
|
92
|
+
-
|
93
|
+
description: "must raise an error when the authSource is empty without credentials"
|
94
|
+
uri: "mongodb://localhost/admin?authSource="
|
95
|
+
valid: false
|
88
96
|
-
|
89
97
|
description: "should throw an exception if authSource is invalid (GSSAPI)"
|
90
98
|
uri: "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authSource=foo"
|
@@ -287,6 +295,11 @@ tests:
|
|
287
295
|
uri: "mongodb://localhost/foo"
|
288
296
|
valid: true
|
289
297
|
credential: ~
|
298
|
+
-
|
299
|
+
description: "authSource without username doesn't create credential"
|
300
|
+
uri: "mongodb://localhost/?authSource=foo"
|
301
|
+
valid: true
|
302
|
+
credential: ~
|
290
303
|
-
|
291
304
|
description: "should throw an exception if no username provided (userinfo implies default mechanism)"
|
292
305
|
uri: "mongodb://@localhost.com/"
|
@@ -0,0 +1,134 @@
|
|
1
|
+
runOn:
|
2
|
+
- minServerVersion: "4.1.10"
|
3
|
+
database_name: &database_name "default"
|
4
|
+
collection_name: &collection_name "default"
|
5
|
+
|
6
|
+
data:
|
7
|
+
- &doc0_encrypted { _id: 1, encrypted_string: {'$binary': {'base64': 'AQAAAAAAAAAAAAAAAAAAAAACwj+3zkv2VM+aTfk60RqhXq6a/77WlLwu/BxXFkL7EppGsju/m8f0x5kBDD3EZTtGALGXlym5jnpZAoSIkswHoA==', 'subType': '06'}} }
|
8
|
+
json_schema: {'properties': {'encrypted_w_altname': {'encrypt': {'keyId': '/altname', 'bsonType': 'string', 'algorithm': 'AEAD_AES_256_CBC_HMAC_SHA_512-Random'}}, 'encrypted_string': {'encrypt': {'keyId': [{'$binary': {'base64': 'AAAAAAAAAAAAAAAAAAAAAA==', 'subType': '04'}}], 'bsonType': 'string', 'algorithm': 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'}}, 'random': {'encrypt': {'keyId': [{'$binary': {'base64': 'AAAAAAAAAAAAAAAAAAAAAA==', 'subType': '04'}}], 'bsonType': 'string', 'algorithm': 'AEAD_AES_256_CBC_HMAC_SHA_512-Random'}}, 'encrypted_string_equivalent': {'encrypt': {'keyId': [{'$binary': {'base64': 'AAAAAAAAAAAAAAAAAAAAAA==', 'subType': '04'}}], 'bsonType': 'string', 'algorithm': 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'}}}, 'bsonType': 'object'}
|
9
|
+
key_vault_data: [{'status': 1, '_id': {'$binary': {'base64': 'AAAAAAAAAAAAAAAAAAAAAA==', 'subType': '04'}}, 'masterKey': {'provider': 'aws', 'key': 'arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0', 'region': 'us-east-1'}, 'updateDate': {'$date': {'$numberLong': '1552949630483'}}, 'keyMaterial': {'$binary': {'base64': 'AQICAHhQNmWG2CzOm1dq3kWLM+iDUZhEqnhJwH9wZVpuZ94A8gEqnsxXlR51T5EbEVezUqqKAAAAwjCBvwYJKoZIhvcNAQcGoIGxMIGuAgEAMIGoBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDHa4jo6yp0Z18KgbUgIBEIB74sKxWtV8/YHje5lv5THTl0HIbhSwM6EqRlmBiFFatmEWaeMk4tO4xBX65eq670I5TWPSLMzpp8ncGHMmvHqRajNBnmFtbYxN3E3/WjxmdbOOe+OXpnGJPcGsftc7cB2shRfA4lICPnE26+oVNXT6p0Lo20nY5XC7jyCO', 'subType': '00'}}, 'creationDate': {'$date': {'$numberLong': '1552949630483'}}, 'keyAltNames': ['altname', 'another_altname']}]
|
10
|
+
|
11
|
+
tests:
|
12
|
+
- description: "Aggregate with deterministic encryption"
|
13
|
+
skipReason: "SERVER-39395"
|
14
|
+
clientOptions:
|
15
|
+
autoEncryptOpts:
|
16
|
+
kmsProviders:
|
17
|
+
aws: {} # Credentials filled in from environment.
|
18
|
+
operations:
|
19
|
+
- name: aggregate
|
20
|
+
arguments:
|
21
|
+
pipeline:
|
22
|
+
- { $match: { encrypted_string: "457-55-5642" } }
|
23
|
+
result:
|
24
|
+
- &doc0 { _id: 1, encrypted_string: "string0" }
|
25
|
+
expectations:
|
26
|
+
# Auto encryption will request the collection info.
|
27
|
+
- command_started_event:
|
28
|
+
command:
|
29
|
+
listCollections: 1
|
30
|
+
filter:
|
31
|
+
name: *collection_name
|
32
|
+
command_name: listCollections
|
33
|
+
- command_started_event:
|
34
|
+
command:
|
35
|
+
listCollections: 1
|
36
|
+
filter:
|
37
|
+
name: "datakeys"
|
38
|
+
$db: admin
|
39
|
+
command_name: listCollections
|
40
|
+
# Then key is fetched from the key vault.
|
41
|
+
- command_started_event:
|
42
|
+
command:
|
43
|
+
find: datakeys
|
44
|
+
filter: {"$or": [{"_id": {"$in": [ {'$binary': {'base64': 'AAAAAAAAAAAAAAAAAAAAAA==', 'subType': '04'}} ] }}, {"keyAltNames": {"$in": []}}]}
|
45
|
+
$db: admin
|
46
|
+
readConcern: { level: "majority" }
|
47
|
+
command_name: find
|
48
|
+
- command_started_event:
|
49
|
+
command:
|
50
|
+
aggregate: *collection_name
|
51
|
+
pipeline:
|
52
|
+
- { $match: { encrypted_string: "457-55-5642" } }
|
53
|
+
command_name: aggregate
|
54
|
+
outcome:
|
55
|
+
collection:
|
56
|
+
# Outcome is checked using a separate MongoClient without auto encryption.
|
57
|
+
data:
|
58
|
+
- *doc0_encrypted
|
59
|
+
- description: "Aggregate with empty pipeline"
|
60
|
+
skipReason: "SERVER-40829 hides agg support behind enableTestCommands flag."
|
61
|
+
clientOptions:
|
62
|
+
autoEncryptOpts:
|
63
|
+
kmsProviders:
|
64
|
+
aws: {} # Credentials filled in from environment.
|
65
|
+
operations:
|
66
|
+
- name: aggregate
|
67
|
+
arguments:
|
68
|
+
pipeline: []
|
69
|
+
result:
|
70
|
+
- { _id: 1, encrypted_string: "string0" }
|
71
|
+
expectations:
|
72
|
+
# Auto encryption will request the collection info.
|
73
|
+
- command_started_event:
|
74
|
+
command:
|
75
|
+
listCollections: 1
|
76
|
+
filter:
|
77
|
+
name: *collection_name
|
78
|
+
command_name: listCollections
|
79
|
+
- command_started_event:
|
80
|
+
command:
|
81
|
+
aggregate: *collection_name
|
82
|
+
pipeline: []
|
83
|
+
cursor: {}
|
84
|
+
command_name: aggregate
|
85
|
+
# Needs to fetch key when decrypting results
|
86
|
+
- command_started_event:
|
87
|
+
command:
|
88
|
+
listCollections: 1
|
89
|
+
filter:
|
90
|
+
name: "datakeys"
|
91
|
+
$db: admin
|
92
|
+
command_name: listCollections
|
93
|
+
# Then key is fetched from the key vault.
|
94
|
+
- command_started_event:
|
95
|
+
command:
|
96
|
+
find: datakeys
|
97
|
+
filter: {"$or": [{"_id": {"$in": [ {'$binary': {'base64': 'AAAAAAAAAAAAAAAAAAAAAA==', 'subType': '04'}} ] }}, {"keyAltNames": {"$in": []}}]}
|
98
|
+
$db: admin
|
99
|
+
readConcern: { level: "majority" }
|
100
|
+
command_name: find
|
101
|
+
outcome:
|
102
|
+
collection:
|
103
|
+
# Outcome is checked using a separate MongoClient without auto encryption.
|
104
|
+
data:
|
105
|
+
- *doc0_encrypted
|
106
|
+
- description: "Aggregate should fail with random encryption"
|
107
|
+
skipReason: "SERVER-39395"
|
108
|
+
clientOptions:
|
109
|
+
autoEncryptOpts:
|
110
|
+
kmsProviders:
|
111
|
+
aws: {} # Credentials filled in from environment.
|
112
|
+
operations:
|
113
|
+
- name: aggregate
|
114
|
+
arguments:
|
115
|
+
pipeline:
|
116
|
+
- { $match: { random: "abc" } }
|
117
|
+
result:
|
118
|
+
errorContains: "Cannot query on fields encrypted with the randomized encryption"
|
119
|
+
- description: "Database aggregate should fail"
|
120
|
+
clientOptions:
|
121
|
+
autoEncryptOpts:
|
122
|
+
kmsProviders:
|
123
|
+
aws: {} # Credentials filled in from environment.
|
124
|
+
operations:
|
125
|
+
- name: aggregate
|
126
|
+
object: database
|
127
|
+
arguments:
|
128
|
+
pipeline:
|
129
|
+
- $currentOp: { allUsers: false, idleConnections: false, localOps: true }
|
130
|
+
- $match: { command.aggregate: { $eq: 1 } }
|
131
|
+
- $project: { command: 1 }
|
132
|
+
- $project: { command.lsid: 0 }
|
133
|
+
result:
|
134
|
+
errorContains: "non-collection command not supported for auto encryption: aggregate"
|