mongo 2.11.4 → 2.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +2 -1
- data/lib/mongo.rb +3 -0
- data/lib/mongo/address.rb +44 -19
- 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 +143 -14
- data/lib/mongo/client_encryption.rb +103 -0
- data/lib/mongo/cluster.rb +8 -4
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +18 -6
- data/lib/mongo/cluster/sdam_flow.rb +54 -58
- 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 +9 -7
- data/lib/mongo/collection/view/writable.rb +7 -7
- data/lib/mongo/crypt.rb +33 -0
- data/lib/mongo/crypt/auto_decryption_context.rb +40 -0
- data/lib/mongo/crypt/auto_encrypter.rb +179 -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 +1229 -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 +289 -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 +315 -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 +23 -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/bulk_write_error.rb +16 -14
- 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/notable.rb +0 -15
- data/lib/mongo/error/operation_failure.rb +1 -0
- data/lib/mongo/error/parser.rb +1 -1
- data/lib/mongo/grid/file.rb +5 -0
- data/lib/mongo/grid/file/chunk.rb +2 -0
- data/lib/mongo/grid/file/info.rb +3 -2
- data/lib/mongo/grid/fs_bucket.rb +15 -13
- data/lib/mongo/grid/stream/write.rb +9 -3
- data/lib/mongo/index/view.rb +3 -3
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +1 -1
- 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 +3 -2
- data/lib/mongo/operation/insert/legacy.rb +3 -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 +11 -9
- 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/read_preference_supported.rb +68 -19
- data/lib/mongo/operation/shared/response_handling.rb +1 -1
- data/lib/mongo/operation/shared/sessions_supported.rb +44 -3
- data/lib/mongo/operation/shared/write.rb +17 -10
- data/lib/mongo/operation/update/op_msg.rb +1 -1
- data/lib/mongo/protocol/bit_vector.rb +2 -1
- data/lib/mongo/protocol/compressed.rb +6 -5
- data/lib/mongo/protocol/insert.rb +3 -1
- data/lib/mongo/protocol/message.rb +94 -15
- data/lib/mongo/protocol/msg.rb +207 -37
- data/lib/mongo/protocol/query.rb +7 -9
- data/lib/mongo/protocol/serializers.rb +43 -15
- data/lib/mongo/retryable.rb +1 -1
- data/lib/mongo/server.rb +10 -4
- data/lib/mongo/server/connection.rb +20 -9
- data/lib/mongo/server/connection_base.rb +118 -18
- data/lib/mongo/server/connection_common.rb +61 -0
- data/lib/mongo/server/connection_pool.rb +37 -1
- data/lib/mongo/server/connection_pool/populator.rb +1 -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 +3 -3
- 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/srv/monitor.rb +73 -42
- data/lib/mongo/srv/result.rb +0 -1
- data/lib/mongo/timeout.rb +49 -0
- data/lib/mongo/uri.rb +30 -1
- data/lib/mongo/uri/srv_protocol.rb +1 -1
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +1 -3
- data/spec/README.md +228 -7
- data/spec/integration/auth_spec.rb +53 -0
- data/spec/integration/bulk_write_spec.rb +19 -0
- data/spec/integration/{client_options_spec.rb → client_authentication_options_spec.rb} +10 -10
- data/spec/integration/client_construction_spec.rb +100 -1
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +353 -0
- data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +303 -0
- data/spec/integration/client_side_encryption/auto_encryption_mongocryptd_spawn_spec.rb +72 -0
- data/spec/integration/client_side_encryption/auto_encryption_old_wire_version_spec.rb +79 -0
- data/spec/integration/client_side_encryption/auto_encryption_reconnect_spec.rb +221 -0
- data/spec/integration/client_side_encryption/auto_encryption_spec.rb +601 -0
- data/spec/integration/client_side_encryption/bson_size_limit_spec.rb +187 -0
- data/spec/integration/client_side_encryption/bypass_mongocryptd_spawn_spec.rb +78 -0
- data/spec/integration/client_side_encryption/client_close_spec.rb +63 -0
- data/spec/integration/client_side_encryption/corpus_spec.rb +233 -0
- data/spec/integration/client_side_encryption/custom_endpoint_spec.rb +132 -0
- data/spec/integration/client_side_encryption/data_key_spec.rb +165 -0
- data/spec/integration/client_side_encryption/explicit_encryption_spec.rb +114 -0
- data/spec/integration/client_side_encryption/external_key_vault_spec.rb +141 -0
- data/spec/integration/client_side_encryption/views_spec.rb +44 -0
- data/spec/integration/client_update_spec.rb +154 -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/crud_spec.rb +89 -0
- data/spec/integration/grid_fs_bucket_spec.rb +48 -0
- data/spec/integration/read_preference_spec.rb +26 -0
- data/spec/integration/reconnect_spec.rb +7 -6
- data/spec/integration/size_limit_spec.rb +111 -0
- data/spec/integration/srv_monitoring_spec.rb +16 -8
- data/spec/integration/zlib_compression_spec.rb +25 -0
- data/spec/kerberos/kerberos_spec.rb +87 -0
- data/spec/lite_spec_helper.rb +34 -29
- 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/user/view_spec.rb +3 -6
- data/spec/mongo/auth/x509_spec.rb +5 -1
- data/spec/mongo/bulk_write/result_spec.rb +11 -7
- data/spec/mongo/client_construction_spec.rb +206 -2
- data/spec/mongo/client_encryption_spec.rb +405 -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 +28 -9
- data/spec/mongo/crypt/auto_decryption_context_spec.rb +90 -0
- data/spec/mongo/crypt/auto_encrypter_spec.rb +187 -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 +232 -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/bulk_write_error_spec.rb +49 -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/notable_spec.rb +59 -0
- 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 +2 -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/read_preference_legacy_spec.rb +351 -0
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +194 -0
- 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/srv/monitor_spec.rb +88 -69
- 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 +9 -11
- 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 +8 -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 +88 -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 +64 -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 +171 -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/cluster_tools.rb +6 -1
- data/spec/support/common_shortcuts.rb +12 -0
- data/spec/support/constraints.rb +16 -0
- data/spec/support/crypt.rb +154 -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 +19 -1
- data/spec/support/matchers.rb +19 -0
- data/spec/support/shared/protocol.rb +2 -0
- data/spec/support/spec_config.rb +53 -13
- data/spec/support/utils.rb +140 -10
- metadata +894 -687
- metadata.gz.sig +0 -0
- data/lib/mongo/cluster/srv_monitor.rb +0 -127
- data/lib/mongo/srv/warning_result.rb +0 -35
- data/spec/enterprise_auth/kerberos_spec.rb +0 -58
- data/spec/mongo/cluster/srv_monitor_spec.rb +0 -214
- data/spec/mongo/operation/read_preference_spec.rb +0 -245
- data/spec/spec_tests/data/sdam/sharded/single_mongos.yml +0 -33
- data/spec/support/connection_string.rb +0 -354
data/lib/mongo/srv/result.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (C) 2020 MongoDB, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
module Timeout
|
17
|
+
|
18
|
+
# A wrapper around Ruby core's Timeout::timeout method that provides
|
19
|
+
# a standardized API for Ruby versions older and newer than 2.4.0,
|
20
|
+
# which is when the third argument was introduced.
|
21
|
+
#
|
22
|
+
# @param [ Numeric ] sec The number of seconds before timeout.
|
23
|
+
# @param [ Class ] klass The exception class to raise on timeout, optional.
|
24
|
+
# When no error exception is provided, Timeout::Error is raised.
|
25
|
+
# @param [ String ] message The error message passed to the exception raised
|
26
|
+
# on timeout, optional. When no error message is provided, the default
|
27
|
+
# error message is "execution expired".
|
28
|
+
#
|
29
|
+
# @note Ruby versions older than 2.4.0 do not support specifying a custom
|
30
|
+
# error message, and any error message passed in as an argument will be
|
31
|
+
# ignored.
|
32
|
+
def timeout(sec, klass=nil, message=nil)
|
33
|
+
if RUBY_VERSION < '2.4.0'
|
34
|
+
::Timeout.timeout(sec, klass) do
|
35
|
+
yield
|
36
|
+
end
|
37
|
+
else
|
38
|
+
# Jruby Timeout::timeout method does not support passing nil arguments.
|
39
|
+
# Remove the nil arguments before passing them along to the core
|
40
|
+
# Timeout::timeout method.
|
41
|
+
optional_args = [klass, message].compact
|
42
|
+
::Timeout.timeout(sec, *optional_args) do
|
43
|
+
yield
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
module_function :timeout
|
48
|
+
end
|
49
|
+
end
|
data/lib/mongo/uri.rb
CHANGED
@@ -215,10 +215,22 @@ module Mongo
|
|
215
215
|
# @example Get the uri object.
|
216
216
|
# URI.get(string)
|
217
217
|
#
|
218
|
+
# @param [ String ] string The URI to parse.
|
219
|
+
# @param [ Hash ] opts The options.
|
220
|
+
#
|
221
|
+
# @option options [ Logger ] :logger A custom logger to use.
|
222
|
+
#
|
218
223
|
# @return [URI, URI::SRVProtocol] The uri object.
|
219
224
|
#
|
220
225
|
# @since 2.5.0
|
221
226
|
def self.get(string, opts = {})
|
227
|
+
unless string
|
228
|
+
raise Error::InvalidURI.new(string, 'URI must be a string, not nil.')
|
229
|
+
end
|
230
|
+
if string.empty?
|
231
|
+
raise Error::InvalidURI.new(string, 'Cannot parse an empty URI.')
|
232
|
+
end
|
233
|
+
|
222
234
|
scheme, _, remaining = string.partition(SCHEME_DELIM)
|
223
235
|
case scheme
|
224
236
|
when MONGODB_SCHEME
|
@@ -257,13 +269,22 @@ module Mongo
|
|
257
269
|
# @example Create the new URI.
|
258
270
|
# URI.new('mongodb://localhost:27017')
|
259
271
|
#
|
260
|
-
# @param [ String ] string The
|
272
|
+
# @param [ String ] string The URI to parse.
|
261
273
|
# @param [ Hash ] options The options.
|
262
274
|
#
|
275
|
+
# @option options [ Logger ] :logger A custom logger to use.
|
276
|
+
#
|
263
277
|
# @raise [ Error::InvalidURI ] If the uri does not match the spec.
|
264
278
|
#
|
265
279
|
# @since 2.0.0
|
266
280
|
def initialize(string, options = {})
|
281
|
+
unless string
|
282
|
+
raise Error::InvalidURI.new(string, 'URI must be a string, not nil.')
|
283
|
+
end
|
284
|
+
if string.empty?
|
285
|
+
raise Error::InvalidURI.new(string, 'Cannot parse an empty URI.')
|
286
|
+
end
|
287
|
+
|
267
288
|
@string = string
|
268
289
|
@options = options
|
269
290
|
parsed_scheme, _, remaining = string.partition(SCHEME_DELIM)
|
@@ -302,6 +323,14 @@ module Mongo
|
|
302
323
|
if @uri_options[:ssl_cert]
|
303
324
|
@uri_options[:ssl_key] = @uri_options[:ssl_cert]
|
304
325
|
end
|
326
|
+
|
327
|
+
if uri_options[:write_concern] && !uri_options[:write_concern].empty?
|
328
|
+
begin
|
329
|
+
WriteConcern.get(uri_options[:write_concern])
|
330
|
+
rescue Error::InvalidWriteConcern => e
|
331
|
+
raise_invalid_error_no_fmt!("#{e.class}: #{e}")
|
332
|
+
end
|
333
|
+
end
|
305
334
|
end
|
306
335
|
|
307
336
|
# Get the credentials provided in the URI.
|
@@ -17,7 +17,7 @@ module Mongo
|
|
17
17
|
class URI
|
18
18
|
|
19
19
|
# Parser for a URI using the mongodb+srv protocol, which specifies a DNS to query for SRV records.
|
20
|
-
# The driver will query the DNS server for SRV records on
|
20
|
+
# The driver will query the DNS server for SRV records on <hostname>.<domainname>,
|
21
21
|
# prefixed with _mongodb._tcp
|
22
22
|
# The SRV records can then be used as the seedlist for a Mongo::Client.
|
23
23
|
# The driver also queries for a TXT record providing default connection string options.
|
data/lib/mongo/version.rb
CHANGED
data/mongo.gemspec
CHANGED
@@ -8,7 +8,6 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
|
10
10
|
s.authors = ['Tyler Brock', 'Emily Stolfo', 'Durran Jordan']
|
11
|
-
s.email = 'mongodb-dev@googlegroups.com'
|
12
11
|
s.homepage = 'https://docs.mongodb.com/ruby-driver/'
|
13
12
|
s.summary = 'Ruby driver for MongoDB'
|
14
13
|
s.description = 'A Ruby driver for MongoDB'
|
@@ -19,7 +18,6 @@ Gem::Specification.new do |s|
|
|
19
18
|
'changelog_uri' => 'https://github.com/mongodb/mongo-ruby-driver/releases',
|
20
19
|
'documentation_uri' => 'https://docs.mongodb.com/ruby-driver/',
|
21
20
|
'homepage_uri' => 'https://docs.mongodb.com/ruby-driver/',
|
22
|
-
'mailing_list_uri' => 'https://groups.google.com/group/mongodb-user',
|
23
21
|
'source_code_uri' => 'https://github.com/mongodb/mongo-ruby-driver',
|
24
22
|
}
|
25
23
|
|
@@ -40,5 +38,5 @@ Gem::Specification.new do |s|
|
|
40
38
|
|
41
39
|
s.required_ruby_version = ">= 2.3"
|
42
40
|
|
43
|
-
s.add_dependency 'bson', '>=4.
|
41
|
+
s.add_dependency 'bson', '>=4.8.2', '<5.0.0'
|
44
42
|
end
|
data/spec/README.md
CHANGED
@@ -20,8 +20,13 @@ configuration are given later in this document.
|
|
20
20
|
## MongoDB Server Deployment
|
21
21
|
|
22
22
|
The tests require a running MongoDB deployment, configured and started
|
23
|
-
externally to the test suite.
|
24
|
-
|
23
|
+
externally to the test suite.
|
24
|
+
|
25
|
+
Tests that are not appropriate for the running deployment will be skipped,
|
26
|
+
with one exception: the test suite assumes that fail points are enabled in
|
27
|
+
the deployment (see the Fail Points section below). Not every test uses fail
|
28
|
+
points, therefore it is possible to launch the server without fail points
|
29
|
+
being enabled and still pass many of the tests in the test suite.
|
25
30
|
|
26
31
|
## Starting MongoDB Deployment
|
27
32
|
|
@@ -41,7 +46,7 @@ launched as follows:
|
|
41
46
|
|
42
47
|
# Launch mongod in one terminal
|
43
48
|
mkdir /tmp/mdb
|
44
|
-
mongod --dbpath /tmp/mdb
|
49
|
+
mongod --dbpath /tmp/mdb --setParameter enableTestCommands=1
|
45
50
|
|
46
51
|
# Run tests in another terminal
|
47
52
|
rake
|
@@ -133,7 +138,7 @@ the top of the driver source tree:
|
|
133
138
|
|
134
139
|
mlaunch init --single --dir /tmp/mdb-ssl --sslMode requireSSL \
|
135
140
|
--sslPEMKeyFile `pwd`/spec/support/certificates/server.pem \
|
136
|
-
--sslCAFile `pwd`/spec/support/certificates/ca.
|
141
|
+
--sslCAFile `pwd`/spec/support/certificates/ca.crt \
|
137
142
|
--sslClientCertificate `pwd`/spec/support/certificates/client.pem
|
138
143
|
|
139
144
|
To test that the driver works when the server's certificate is signed by an
|
@@ -142,7 +147,7 @@ server certificate bundle:
|
|
142
147
|
|
143
148
|
mlaunch init --single --dir /tmp/mdb-ssl --sslMode requireSSL \
|
144
149
|
--sslPEMKeyFile `pwd`/spec/support/certificates/server-second-level-bundle.pem \
|
145
|
-
--sslCAFile `pwd`/spec/support/certificates/ca.
|
150
|
+
--sslCAFile `pwd`/spec/support/certificates/ca.crt \
|
146
151
|
--sslClientCertificate `pwd`/spec/support/certificates/client.pem
|
147
152
|
|
148
153
|
The driver's test suite is configured to verify certificates by default.
|
@@ -168,7 +173,7 @@ case a standalone server can be started as follows:
|
|
168
173
|
|
169
174
|
mlaunch init --single --dir /tmp/mdb-ssl --sslMode requireSSL \
|
170
175
|
--sslPEMKeyFile `pwd`/spec/support/certificates/server.pem \
|
171
|
-
--sslCAFile `pwd`/spec/support/certificates/ca.
|
176
|
+
--sslCAFile `pwd`/spec/support/certificates/ca.crt \
|
172
177
|
--sslAllowConnectionsWithoutCertificates \
|
173
178
|
--sslAllowInvalidCertificates
|
174
179
|
|
@@ -264,9 +269,183 @@ To run the test suite against such a server, run:
|
|
264
269
|
|
265
270
|
MONGODB_URI="mongodb://localhost:27017/?authMechanism=MONGODB-X509&tls=true&tlsCAFile=spec/support/certificates/ca.crt&tlsCertificateKeyFile=spec/support/certificates/client-x509.pem" rake
|
266
271
|
|
272
|
+
## Kerberos
|
273
|
+
|
274
|
+
The Kerberos-related functionality is packaged in a separate gem,
|
275
|
+
`mongo_kerberos`. To run any of the Kerberos tests, a special gemfile must
|
276
|
+
be used that references `mongo_kerberos`:
|
277
|
+
|
278
|
+
export BUNDLE_GEMFILE=gemfiles/mongo_kerberos.gemfile
|
279
|
+
bundle install
|
280
|
+
|
281
|
+
Ensure that BUNDLE_GEMFILE is set in the environment for both the
|
282
|
+
`bundle install` invocation and the `rake` / `rspec` invocation.
|
283
|
+
|
284
|
+
### Unit Tests
|
285
|
+
|
286
|
+
The driver test suite includes a number of Kerberos-related unit tests that
|
287
|
+
are skipped by default. To run them as part of the test suite, set the
|
288
|
+
`MONGO_RUBY_DRIVER_KERBEROS` environment variable to `1`, `yes` or `true`
|
289
|
+
as follows:
|
290
|
+
|
291
|
+
export MONGO_RUBY_DRIVER_KERBEROS=1
|
292
|
+
rake
|
293
|
+
|
294
|
+
Note that running the full test suite requires a MongoDB deployment. It is
|
295
|
+
possible to run just the Kerberos-related unit tests without provisioning a
|
296
|
+
MongoDB deployment; consult the `.evergreen/run-tests-kerberos-unit.sh` file
|
297
|
+
for the full list of relevant test files.
|
298
|
+
|
299
|
+
### Integration Tests
|
300
|
+
|
301
|
+
The driver test suite includes a number of Kerberos-related integration tests
|
302
|
+
in the `spec/kerberos` directory. These require a provisioned Kerberos
|
303
|
+
deployment and appropriately configured MongoDB deployment. One such deployment
|
304
|
+
is provided internally by MongoDB and is used in the driver's Evergreen
|
305
|
+
configuration; it is also possible to provision a test deployment locally.
|
306
|
+
|
307
|
+
The following additional environment variables must be set to run the
|
308
|
+
Kerberos integration tests:
|
309
|
+
|
310
|
+
- `MONGO_RUBY_DRIVER_KERBEROS_INTEGRATION=1`
|
311
|
+
- `SASL_HOST`: the host name of the MongoDB server that is configured to
|
312
|
+
use Kerberos. Note that this is NOT the Kerberos domain controller (KDC).
|
313
|
+
- `SASL_PORT`: the port number that the Kerberized MongoDB server is
|
314
|
+
listenin on.
|
315
|
+
- `SASL_USER`: the username to provide to MongoDB for authentication.
|
316
|
+
- `SASL_PASS`: the password to provide to MongoDB for authentication.
|
317
|
+
- `SASL_DB`: the database that stores the user used for authentication. This
|
318
|
+
is the "auth soure" in MongoDB parlance. Normally this should be `$external`.
|
319
|
+
- `PRINCIPAL`: the Kerberos principal to use for authentication, in the
|
320
|
+
form of `username@realm`. Note that the realm is commonly uppercased.
|
321
|
+
- `KERBEROS_DB`: the database that the user has access to.
|
322
|
+
- `KEYTAB_BASE64`: Base64 encoded keytab for the user. Used instead of the
|
323
|
+
password.
|
324
|
+
|
325
|
+
There are several steps that must be taken in order to set up Kerberos on
|
326
|
+
the client side before it is usable by the driver for authentication against
|
327
|
+
a Kerberized server. Consult the `.evergreen/run-tests-kerberos-integration.sh`
|
328
|
+
file for details.
|
329
|
+
|
330
|
+
## Client-Side Encryption
|
331
|
+
|
332
|
+
NOTE: Client-side encryption tests require an enterprise build of MongoDB
|
333
|
+
server version 4.2 or higher. These builds of the MongoDB server come packaged with
|
334
|
+
mongocryptd, a daemon that is spawned by the driver during automatic encryption.
|
335
|
+
The client-side encryption tests require the mongocryptd binary to be in the
|
336
|
+
system path.
|
337
|
+
|
338
|
+
Download enterprise versions of MongoDB here: https://www.mongodb.com/download-center/enterprise
|
339
|
+
Read more about installing mongocryptd here: https://docs.mongodb.com/manual/reference/security-client-side-encryption-appendix/#mongocryptd
|
340
|
+
|
341
|
+
Install libmongocrypt on your machine:
|
342
|
+
|
343
|
+
Option 1: Download a pre-built binary
|
344
|
+
- Download a tarball of all libmongocrypt variations from this link:
|
345
|
+
https://s3.amazonaws.com/mciuploads/libmongocrypt/all/master/latest/libmongocrypt-all.tar.gz
|
346
|
+
- Unzip the file you downloaded. You will see a list of folders, each
|
347
|
+
corresponding to an operating system. Find the folder that matches
|
348
|
+
your operating system and open it.
|
349
|
+
- Inside that folder, open the folder called "nocrypto." In either the
|
350
|
+
lib or lb64 folder, you will find the libmongocrypt.so or
|
351
|
+
libmongocrypt.dylib or libmongocrypt.dll file, depending on your OS.
|
352
|
+
- Move that file to wherever you want to keep it on your machine.
|
353
|
+
|
354
|
+
Option 2: Build from source
|
355
|
+
- To build libmongocrypt from source, follow the instructions in the README on the libmongocrypt GitHub repo: https://github.com/mongodb/libmongocrypt
|
356
|
+
|
357
|
+
Create AWS KMS keys
|
358
|
+
Many of the Client-Side Encryption tests require that you have an encryption
|
359
|
+
master key hosted on AWS's Key Management Service. Set up a master key by following
|
360
|
+
these steps:
|
361
|
+
|
362
|
+
1. Sign up for an AWS account at this link if you don't already have one: https://aws.amazon.com/resources/create-account/
|
363
|
+
|
364
|
+
2. Create a new IAM user that you want to have permissions to access your new
|
365
|
+
master key by following this guide: the "Creating an Administrator IAM User and Group (Console)"
|
366
|
+
section of this guide: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user.html
|
367
|
+
|
368
|
+
3. Create an access key for your new IAM user and store the access key credentials
|
369
|
+
in environment variables on your local machine. Create an access key by following the
|
370
|
+
"Managing Access Keys (Console)" instructions in this guide:
|
371
|
+
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey
|
372
|
+
Once an access key has been created, store the access key id and the access key
|
373
|
+
secret in environment variables. If you plan to frequently run Client-Side
|
374
|
+
Encryption tests, it may be a good idea to put these lines in your .bash_profile
|
375
|
+
or .bashrc file. Otherwise, you can run them in the terminal window where you
|
376
|
+
plan to run your tests.
|
377
|
+
|
378
|
+
```
|
379
|
+
export MONGO_RUBY_DRIVER_AWS_KEY="YOUR-ACCESS-KEY-ID"
|
380
|
+
export MONGO_RUBY_DRIVER_AWS_SECRET="YOUR-ACCESS-KEY-SECRET"
|
381
|
+
```
|
382
|
+
|
383
|
+
4. Create a new symmetric Customer Master Key (CMK) by following the "Creating Symmetric CMKs (Console)"
|
384
|
+
section of this guide: https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html
|
385
|
+
|
386
|
+
5. Store information about your CMK in the following environment variables:
|
387
|
+
|
388
|
+
a. **Region:** Find your AWS region by following this guide: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#using-regions-availability-zones-describe
|
389
|
+
(for example, your region might be "us-east-1" or "ap-south-2").
|
390
|
+
|
391
|
+
b. **Amazon Resource Name (ARN):** Read the following guide to learn more about ARNs
|
392
|
+
and how to view your key's ARN: https://docs.aws.amazon.com/kms/latest/developerguide/viewing-keys-console.html
|
393
|
+
|
394
|
+
Store these two pieces of information in environment variables. If you plan
|
395
|
+
to frequently run Client-Side Encryption tests, it may be a good idea to put
|
396
|
+
these lines in your .bash_profile or .bashrc file. Otherwise, you can run
|
397
|
+
them in the terminal window where you plan to run your tests.
|
398
|
+
|
399
|
+
```
|
400
|
+
export MONGO_RUBY_DRIVER_AWS_REGION="YOUR-AWS-REGION"
|
401
|
+
export MONGO_RUBY_DRIVER_AWS_ARN="YOUR-AWS-ARN"
|
402
|
+
```
|
403
|
+
|
404
|
+
6. Give your IAM user "Key administrator" and "Key user" privileges on your new CMK
|
405
|
+
by following the "Using the AWS Management Console Default View" section of this guide:
|
406
|
+
https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-modifying.html
|
407
|
+
|
408
|
+
In one terminal, launch MongoDB:
|
409
|
+
|
410
|
+
```
|
411
|
+
mkdir /tmp/mdb
|
412
|
+
mongod --dbpath /tmp/mdb --setParameter enableTestCommands=1
|
413
|
+
```
|
414
|
+
|
415
|
+
In another terminal run the tests, making sure to set the `LIBMONGOCRYPT_PATH`
|
416
|
+
environment variable to the full path to the .so/.dll/.dylib
|
417
|
+
```
|
418
|
+
LIBMONGOCRYPT_PATH=/path/to/your/libmongocrypt/nocrypto/libmongocrypt.so bundle exec rake
|
419
|
+
```
|
420
|
+
|
421
|
+
If you would like to run the client-side encryption tests on a replica set or
|
422
|
+
sharded cluster, be aware that the driver will try to spawn the mongocryptd daemon on
|
423
|
+
port 27020 by default. If port 27020 is already in use by a mongod or mongos
|
424
|
+
process, spawning mongocryptd will fail, causing the tests to fail as well.
|
425
|
+
|
426
|
+
To avoid this problem, set the MONGO_RUBY_DRIVER_MONGOCRYPTD_PORT environment
|
427
|
+
variable to the port at which you would like the driver to spawn mongocryptd.
|
428
|
+
For example, to always have the mongocryptd process listen on port 27090:
|
429
|
+
|
430
|
+
```
|
431
|
+
export MONGO_RUBY_DRIVER_MONGOCRYPTD_PORT=27090
|
432
|
+
```
|
433
|
+
|
434
|
+
Keep in mind that this will only impact the behavior of the Ruby Driver test suite,
|
435
|
+
not the behavior of the driver itself.
|
436
|
+
|
267
437
|
## Compression
|
268
438
|
|
269
|
-
To
|
439
|
+
To test compression, set the `compressors` URI option:
|
440
|
+
|
441
|
+
MONGODB_URI="mongodb://localhost:27017/?compressors=zlib" rake
|
442
|
+
|
443
|
+
Note that as of this writing, the driver only supports zlib compression.
|
444
|
+
Servers 4.2+ enable zlib by default; to test older servers, explicitly enable
|
445
|
+
zlib compression when launching the server:
|
446
|
+
|
447
|
+
mongod --dbpath /tmp/mdb --setParameter enableTestCommands=1 \
|
448
|
+
--networkMessageCompressors snappy,zlib
|
270
449
|
|
271
450
|
## Other Options
|
272
451
|
|
@@ -360,3 +539,45 @@ Then, any of the standard RSpec invocations will work:
|
|
360
539
|
To have the test suite report its current configuration, run:
|
361
540
|
|
362
541
|
rake spec:config
|
542
|
+
|
543
|
+
## Color Output
|
544
|
+
|
545
|
+
The test suite uses color output by default. To view the output in `less`
|
546
|
+
with color, use the `-R` option:
|
547
|
+
|
548
|
+
rake 2>&1 | tee rake.log
|
549
|
+
less -R rake.log
|
550
|
+
|
551
|
+
## Debugging
|
552
|
+
|
553
|
+
The test suite is configured to use [Byebug](https://github.com/deivid-rodriguez/byebug)
|
554
|
+
for debugging on MRI and [ruby-debug](https://github.com/jruby/jruby/wiki/UsingTheJRubyDebugger)
|
555
|
+
on JRuby.
|
556
|
+
|
557
|
+
### MRI
|
558
|
+
|
559
|
+
Call `byebug` anywhere in the test suite to break into Byebug.
|
560
|
+
|
561
|
+
### JRuby
|
562
|
+
|
563
|
+
To debug on JRuby, the test suite must be started with the `--debug` argument
|
564
|
+
to `jruby`. This can be achieved by starting the test suite as follows:
|
565
|
+
|
566
|
+
jruby --debug -S rspec [rspec args...]
|
567
|
+
|
568
|
+
Call `debugger` anywhere in the test suite to break into the debugger.
|
569
|
+
|
570
|
+
### Docker
|
571
|
+
|
572
|
+
By default, when the test suite is running in a CI environment the debuggers
|
573
|
+
are not loaded. The Docker runner emulates the CI environment, therefore
|
574
|
+
to debug in Docker the debugger must be explicitly loaded first. To break
|
575
|
+
into the debugger on MRI, call:
|
576
|
+
|
577
|
+
require 'byebug'
|
578
|
+
byebug
|
579
|
+
|
580
|
+
To break into the debugger on JRuby, call:
|
581
|
+
|
582
|
+
require 'ruby-debug'
|
583
|
+
debugger
|
@@ -190,4 +190,57 @@ describe 'Auth' do
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
193
|
+
|
194
|
+
describe 'scram-sha-1 client key caching' do
|
195
|
+
clean_slate
|
196
|
+
min_server_version '3.0'
|
197
|
+
require_no_x509_auth
|
198
|
+
|
199
|
+
let(:client) { authorized_client.with(max_pool_size: 2) }
|
200
|
+
|
201
|
+
it 'caches' do
|
202
|
+
client.close
|
203
|
+
Mongo::Auth::CredentialCache.clear
|
204
|
+
|
205
|
+
RSpec::Mocks.with_temporary_scope do
|
206
|
+
expect_any_instance_of(Mongo::Auth::SCRAM::Conversation).to receive(:hi).exactly(:once).and_call_original
|
207
|
+
|
208
|
+
client.reconnect
|
209
|
+
server = client.cluster.next_primary
|
210
|
+
server.with_connection do
|
211
|
+
server.with_connection do
|
212
|
+
# nothing
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
context 'when only auth source is specified' do
|
220
|
+
require_no_auth
|
221
|
+
|
222
|
+
let(:client) do
|
223
|
+
new_local_client(SpecConfig.instance.addresses, SpecConfig.instance.ssl_options.merge(
|
224
|
+
auth_source: 'foo'))
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'does not authenticate' do
|
228
|
+
expect(Mongo::Auth::User).not_to receive(:new)
|
229
|
+
client.database.command(ping: 1)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
context 'when only auth mechanism is specified' do
|
234
|
+
require_x509_auth
|
235
|
+
|
236
|
+
let(:client) do
|
237
|
+
new_local_client(SpecConfig.instance.addresses, SpecConfig.instance.ssl_options.merge(
|
238
|
+
auth_mech: :mongodb_x509))
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'authenticates' do
|
242
|
+
expect(Mongo::Auth::User).to receive(:new).and_call_original
|
243
|
+
client.database.command(ping: 1)
|
244
|
+
end
|
245
|
+
end
|
193
246
|
end
|