mongo 2.11.0.rc0 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Rakefile +2 -0
  5. data/lib/mongo/auth.rb +11 -2
  6. data/lib/mongo/auth/cr/conversation.rb +1 -1
  7. data/lib/mongo/auth/ldap/conversation.rb +1 -1
  8. data/lib/mongo/auth/scram/conversation.rb +4 -1
  9. data/lib/mongo/auth/user.rb +15 -1
  10. data/lib/mongo/auth/user/view.rb +10 -4
  11. data/lib/mongo/auth/x509.rb +11 -1
  12. data/lib/mongo/auth/x509/conversation.rb +15 -6
  13. data/lib/mongo/background_thread.rb +28 -13
  14. data/lib/mongo/client.rb +23 -15
  15. data/lib/mongo/collection/view/change_stream.rb +5 -1
  16. data/lib/mongo/collection/view/readable.rb +5 -2
  17. data/lib/mongo/collection/view/writable.rb +3 -1
  18. data/lib/mongo/cursor/builder/get_more_command.rb +4 -1
  19. data/lib/mongo/cursor/builder/kill_cursors_command.rb +16 -5
  20. data/lib/mongo/cursor/builder/op_get_more.rb +2 -2
  21. data/lib/mongo/cursor/builder/op_kill_cursors.rb +17 -5
  22. data/lib/mongo/error/operation_failure.rb +3 -3
  23. data/lib/mongo/monitoring/command_log_subscriber.rb +5 -3
  24. data/lib/mongo/monitoring/event/command_started.rb +13 -3
  25. data/lib/mongo/monitoring/publishable.rb +4 -2
  26. data/lib/mongo/operation/create_user/command.rb +1 -0
  27. data/lib/mongo/operation/remove_user/command.rb +1 -0
  28. data/lib/mongo/operation/update_user/command.rb +1 -0
  29. data/lib/mongo/protocol/get_more.rb +2 -1
  30. data/lib/mongo/protocol/kill_cursors.rb +6 -13
  31. data/lib/mongo/protocol/serializers.rb +10 -4
  32. data/lib/mongo/retryable.rb +1 -1
  33. data/lib/mongo/server/connection.rb +6 -2
  34. data/lib/mongo/server/connection_base.rb +2 -1
  35. data/lib/mongo/server/monitor.rb +1 -1
  36. data/lib/mongo/server/pending_connection.rb +6 -0
  37. data/lib/mongo/socket/ssl.rb +1 -1
  38. data/lib/mongo/uri.rb +5 -41
  39. data/lib/mongo/version.rb +1 -1
  40. data/mongo.gemspec +11 -2
  41. data/spec/README.md +105 -9
  42. data/spec/USERS.md +72 -0
  43. data/spec/integration/auth_spec.rb +20 -6
  44. data/spec/integration/client_construction_spec.rb +3 -1
  45. data/spec/integration/client_options_spec.rb +437 -0
  46. data/spec/integration/command_monitoring_spec.rb +4 -1
  47. data/spec/integration/connection_pool_populator_spec.rb +4 -0
  48. data/spec/integration/connection_spec.rb +4 -2
  49. data/spec/integration/cursor_reaping_spec.rb +1 -1
  50. data/spec/integration/get_more_spec.rb +32 -0
  51. data/spec/integration/retryable_errors_spec.rb +99 -0
  52. data/spec/integration/retryable_writes_errors_spec.rb +11 -10
  53. data/spec/lite_spec_helper.rb +2 -1
  54. data/spec/mongo/auth/scram_spec.rb +1 -0
  55. data/spec/mongo/auth/user/view_spec.rb +102 -1
  56. data/spec/mongo/auth/user_spec.rb +56 -15
  57. data/spec/mongo/auth/x509_spec.rb +31 -1
  58. data/spec/mongo/bulk_write_spec.rb +2 -2
  59. data/spec/mongo/collection/view/change_stream_spec.rb +2 -2
  60. data/spec/mongo/collection/view/readable_spec.rb +8 -4
  61. data/spec/mongo/cursor/builder/get_more_command_spec.rb +4 -2
  62. data/spec/mongo/cursor/builder/op_get_more_spec.rb +4 -2
  63. data/spec/mongo/cursor_spec.rb +3 -3
  64. data/spec/mongo/retryable_spec.rb +31 -52
  65. data/spec/mongo/server/connection_auth_spec.rb +3 -0
  66. data/spec/mongo/server/connection_pool_spec.rb +4 -0
  67. data/spec/mongo/server/connection_spec.rb +12 -4
  68. data/spec/mongo/server/monitor_spec.rb +19 -1
  69. data/spec/mongo/socket/ssl_spec.rb +1 -1
  70. data/spec/mongo/uri/srv_protocol_spec.rb +0 -13
  71. data/spec/mongo/uri_option_parsing_spec.rb +0 -8
  72. data/spec/mongo/uri_spec.rb +6 -20
  73. data/spec/runners/connection_string.rb +116 -0
  74. data/spec/runners/read_write_concern_document.rb +67 -0
  75. data/spec/spec_tests/change_streams_spec.rb +17 -2
  76. data/spec/spec_tests/connection_string_spec.rb +2 -59
  77. data/spec/spec_tests/data/change_streams/change-streams-errors.yml +3 -3
  78. data/spec/spec_tests/data/change_streams/change-streams.yml +88 -20
  79. data/spec/spec_tests/data/cmap/connection-must-have-id.yml +6 -0
  80. data/spec/spec_tests/data/cmap/connection-must-order-ids.yml +6 -0
  81. data/spec/spec_tests/data/cmap/pool-checkin-destroy-closed.yml +3 -0
  82. data/spec/spec_tests/data/cmap/pool-checkin-destroy-stale.yml +3 -0
  83. data/spec/spec_tests/data/cmap/pool-checkin-make-available.yml +3 -0
  84. data/spec/spec_tests/data/cmap/pool-checkin.yml +1 -0
  85. data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +2 -0
  86. data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +5 -0
  87. data/spec/spec_tests/data/cmap/pool-checkout-multiple.yml +3 -0
  88. data/spec/spec_tests/data/cmap/pool-checkout-no-idle.yml +4 -0
  89. data/spec/spec_tests/data/cmap/pool-checkout-no-stale.yml +4 -0
  90. data/spec/spec_tests/data/cmap/pool-close-destroy-conns.yml +2 -0
  91. data/spec/spec_tests/data/cmap/pool-create-max-size.yml +15 -0
  92. data/spec/spec_tests/data/cmap/pool-create-min-size.yml +4 -0
  93. data/spec/spec_tests/data/cmap/wait-queue-fairness.yml +31 -1
  94. data/spec/spec_tests/data/cmap/wait-queue-timeout.yml +5 -0
  95. data/spec/spec_tests/data/read_write_concern/connection-string/read-concern.yml +32 -0
  96. data/spec/spec_tests/data/read_write_concern/connection-string/write-concern.yml +82 -0
  97. data/spec/spec_tests/data/read_write_concern/document/read-concern.yml +37 -0
  98. data/spec/spec_tests/data/read_write_concern/document/write-concern.yml +100 -0
  99. data/spec/spec_tests/data/retryable_reads/aggregate-merge.yml +39 -0
  100. data/spec/spec_tests/data/retryable_reads/aggregate-serverErrors.yml +1 -1
  101. data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +2 -2
  102. data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +1 -1
  103. data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +2 -2
  104. data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +1 -1
  105. data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +2 -2
  106. data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +1 -1
  107. data/spec/spec_tests/data/retryable_reads/count-serverErrors.yml +1 -1
  108. data/spec/spec_tests/data/retryable_reads/countDocuments-serverErrors.yml +1 -1
  109. data/spec/spec_tests/data/retryable_reads/distinct-serverErrors.yml +1 -1
  110. data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors.yml +1 -1
  111. data/spec/spec_tests/data/retryable_reads/find-serverErrors.yml +1 -1
  112. data/spec/spec_tests/data/retryable_reads/findOne-serverErrors.yml +1 -1
  113. data/spec/spec_tests/data/retryable_reads/gridfs-download-serverErrors.yml +1 -1
  114. data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName-serverErrors.yml +1 -1
  115. data/spec/spec_tests/data/retryable_reads/listCollectionNames-serverErrors.yml +1 -1
  116. data/spec/spec_tests/data/retryable_reads/listCollectionObjects-serverErrors.yml +1 -1
  117. data/spec/spec_tests/data/retryable_reads/listCollections-serverErrors.yml +1 -1
  118. data/spec/spec_tests/data/retryable_reads/listDatabaseNames-serverErrors.yml +1 -1
  119. data/spec/spec_tests/data/retryable_reads/listDatabaseObjects-serverErrors.yml +1 -1
  120. data/spec/spec_tests/data/retryable_reads/listDatabases-serverErrors.yml +1 -1
  121. data/spec/spec_tests/data/retryable_reads/listIndexNames-serverErrors.yml +1 -1
  122. data/spec/spec_tests/data/retryable_reads/listIndexes-serverErrors.yml +1 -1
  123. data/spec/spec_tests/data/transactions/read-concern.yml +6 -6
  124. data/spec/spec_tests/data/transactions/transaction-options-repl.yml +117 -0
  125. data/spec/spec_tests/data/transactions/transaction-options.yml +14 -121
  126. data/spec/spec_tests/data/transactions/write-concern.yml +3 -0
  127. data/spec/spec_tests/data/transactions_api/transaction-options.yml +11 -12
  128. data/spec/spec_tests/dns_seedlist_discovery_spec.rb +17 -7
  129. data/spec/spec_tests/read_write_concern_connection_string_spec.rb +8 -0
  130. data/spec/spec_tests/read_write_concern_document_spec.rb +74 -0
  131. data/spec/spec_tests/retryable_reads_spec.rb +32 -1
  132. data/spec/spec_tests/uri_options_spec.rb +4 -2
  133. data/spec/support/auth.rb +5 -14
  134. data/spec/support/certificates/client-x509.crt +78 -0
  135. data/spec/support/certificates/client-x509.key +27 -0
  136. data/spec/support/certificates/client-x509.pem +105 -0
  137. data/spec/support/change_streams.rb +8 -11
  138. data/spec/support/client_registry.rb +26 -12
  139. data/spec/support/cluster_tools.rb +2 -2
  140. data/spec/support/cmap.rb +11 -7
  141. data/spec/support/command_monitoring.rb +8 -8
  142. data/spec/support/connection_string.rb +56 -28
  143. data/spec/support/constraints.rb +8 -0
  144. data/spec/support/crud/spec.rb +5 -8
  145. data/spec/support/event_subscriber.rb +7 -0
  146. data/spec/support/gridfs.rb +4 -7
  147. data/spec/support/server_discovery_and_monitoring.rb +3 -8
  148. data/spec/support/server_selection.rb +4 -9
  149. data/spec/support/server_selection_rtt.rb +4 -7
  150. data/spec/support/spec_config.rb +47 -19
  151. data/spec/support/spec_setup.rb +5 -0
  152. data/spec/support/utils.rb +46 -8
  153. metadata +637 -597
  154. metadata.gz.sig +0 -0
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ READ_WRITE_CONCERN_CONNECTION_STRING_TESTS =
4
+ Dir.glob("#{CURRENT_PATH}/spec_tests/data/read_write_concern/connection-string/*.yml").sort
5
+
6
+ describe 'Connection String' do
7
+ define_connection_string_spec_tests(READ_WRITE_CONCERN_CONNECTION_STRING_TESTS)
8
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+ require 'runners/read_write_concern_document'
3
+
4
+ READ_WRITE_CONCERN_DOCUMENT_TESTS =
5
+ Dir.glob("#{CURRENT_PATH}/spec_tests/data/read_write_concern/document/*.yml").sort
6
+
7
+ describe 'Connection String' do
8
+ READ_WRITE_CONCERN_DOCUMENT_TESTS.each do |test_path|
9
+ spec = ReadWriteConcernDocument::Spec.new(test_path)
10
+
11
+ context(spec.description) do
12
+
13
+ spec.tests.each_with_index do |test, index|
14
+
15
+ context test.description do
16
+
17
+ let(:actual) do
18
+ Mongo::WriteConcern.get(test.input_document)
19
+ end
20
+
21
+ let(:actual_server_document) do
22
+ Utils.camelize_hash(actual.options)
23
+ end
24
+
25
+ if test.valid?
26
+
27
+ it 'parses successfully' do
28
+ expect do
29
+ actual
30
+ end.not_to raise_error
31
+ end
32
+
33
+ it 'has expected server document' do
34
+ expect(actual_server_document).to eq(test.server_document)
35
+ end
36
+
37
+ if test.server_default?
38
+ it 'is server default' do
39
+ expect(actual.options).to eq({})
40
+ end
41
+ end
42
+
43
+ if test.server_default? == false
44
+ it 'is not server default' do
45
+ expect(actual.options).not_to eq({})
46
+ end
47
+ end
48
+
49
+ if test.acknowledged?
50
+ it 'is acknowledged' do
51
+ expect(actual.acknowledged?).to be true
52
+ end
53
+ end
54
+
55
+ if test.acknowledged? == false
56
+ it 'is not acknowledged' do
57
+ expect(actual.acknowledged?).to be false
58
+ end
59
+ end
60
+
61
+ else
62
+
63
+ it 'is invalid' do
64
+ expect do
65
+ actual
66
+ end.to raise_error(Mongo::Error::InvalidWriteConcern)
67
+ end
68
+
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -6,9 +6,40 @@ describe 'Retryable reads spec tests' do
6
6
 
7
7
  define_crud_spec_tests(RETRYABLE_READS_TESTS) do |spec, req, test|
8
8
  let(:client) do
9
- root_authorized_client.with({max_read_retries: 0}.update(test.client_options)).tap do |client|
9
+ authorized_client.with({max_read_retries: 0}.update(test.client_options)).tap do |client|
10
10
  client.subscribe(Mongo::Monitoring::COMMAND, event_subscriber)
11
11
  end
12
12
  end
13
13
  end
14
14
  end
15
+
16
+ describe 'Retryable reads spec tests - legacy' do
17
+ require_no_multi_shard
18
+
19
+ define_crud_spec_tests(RETRYABLE_READS_TESTS) do |spec, req, test|
20
+ let(:client_options) do
21
+ {
22
+ max_read_retries: 1,
23
+ read_retry_interval: 0,
24
+ retry_reads: false,
25
+ }.update(test.client_options)
26
+ end
27
+
28
+ let(:client) do
29
+ authorized_client.with(client_options).tap do |client|
30
+ client.subscribe(Mongo::Monitoring::COMMAND, event_subscriber)
31
+ end
32
+ end
33
+
34
+ around do |example|
35
+ desc = example.full_description
36
+ # Skip tests that disable modern retryable reads because they expect
37
+ # no retries - and since legacy retryable reads are used, the tests
38
+ # will fail.
39
+ if desc =~/retryReads is false|fails on first attempt/
40
+ skip 'Test not applicable to legacy read retries'
41
+ end
42
+ example.run
43
+ end
44
+ end
45
+ end
@@ -55,8 +55,10 @@ describe 'Uri Options' do
55
55
 
56
56
  context 'when the uri is valid', if: test.valid? do
57
57
 
58
- it 'creates a client with the correct hosts' do
59
- expect(test.client).to have_hosts(test)
58
+ if test.hosts
59
+ it 'creates a client with the correct hosts' do
60
+ expect(test.client).to have_hosts(test, test.hosts)
61
+ end
60
62
  end
61
63
 
62
64
  it 'creates a client with the correct authentication properties' do
@@ -11,7 +11,7 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- RSpec::Matchers.define :have_blank_credentials do
14
+ RSpec::Matchers.define :have_blank_credentials do
15
15
  match do |client|
16
16
  %i(auth_mech auth_mech_properties auth_source password user).all? do |key|
17
17
  client.options[key].nil?
@@ -31,11 +31,9 @@ module Mongo
31
31
  attr_reader :description
32
32
  attr_reader :tests
33
33
 
34
- def initialize(file)
35
- file = File.new(file)
36
- @spec = YAML.load(ERB.new(file.read).result)
37
- file.close
38
- @description = File.basename(file)
34
+ def initialize(test_path)
35
+ @spec = YAML.load(File.read(test_path))
36
+ @description = File.basename(test_path)
39
37
  end
40
38
 
41
39
  def tests
@@ -68,9 +66,7 @@ module Mongo
68
66
  end
69
67
 
70
68
  def expected_credential
71
- expected_credential = {
72
- 'auth_source' => expected_auth_source,
73
- }
69
+ expected_credential = { 'auth_source' => credential['source'] }
74
70
 
75
71
  if credential['username']
76
72
  expected_credential['user'] = credential['username']
@@ -103,11 +99,6 @@ module Mongo
103
99
  def expected_auth_mech_properties
104
100
  credential['mechanism_properties'].keys.map(&:downcase)
105
101
  end
106
-
107
- def expected_auth_source
108
- return :external if credential['source'] == '$external'
109
- credential['source']
110
- end
111
102
  end
112
103
  end
113
104
  end
@@ -0,0 +1,78 @@
1
+ Certificate:
2
+ Data:
3
+ Version: 3 (0x2)
4
+ Serial Number: 602210 (0x93062)
5
+ Signature Algorithm: sha256WithRSAEncryption
6
+ Issuer: CN = Ruby Driver CA, OU = Drivers, O = MongoDB, L = New York City, ST = New York, C = US
7
+ Validity
8
+ Not Before: Sep 4 21:17:42 2019 GMT
9
+ Not After : Sep 4 21:17:42 2039 GMT
10
+ Subject: CN = localhost, OU = x509, O = MongoDB, L = New York City, ST = New York, C = US
11
+ Subject Public Key Info:
12
+ Public Key Algorithm: rsaEncryption
13
+ RSA Public-Key: (2048 bit)
14
+ Modulus:
15
+ 00:c4:e6:20:8f:58:42:53:51:24:64:b4:d0:25:cf:
16
+ 79:e0:71:f8:9e:97:35:a8:df:fa:d9:63:eb:63:b2:
17
+ b4:77:60:af:8e:09:6d:72:50:bc:ea:7c:57:3f:17:
18
+ 51:b0:05:85:e8:3b:67:4b:97:84:61:bb:68:09:b4:
19
+ 96:da:c8:3b:7d:53:b8:10:fe:0d:71:2f:b8:5d:83:
20
+ 86:3f:06:57:e2:6c:d5:2f:c8:6c:74:fb:d8:6f:77:
21
+ df:ba:6d:52:61:3c:33:76:a5:5f:62:68:af:a4:e8:
22
+ dc:36:2a:b9:54:47:91:ec:4f:09:b9:2e:ef:37:4d:
23
+ d7:04:db:48:fc:8d:c2:44:f1:9f:79:21:f0:06:fe:
24
+ b4:e5:50:3c:cf:d1:3f:59:b5:8d:dc:d0:39:31:53:
25
+ 95:42:d7:92:c3:c9:d5:93:48:e8:dc:16:ce:61:ec:
26
+ 6f:ce:91:5c:91:2e:59:18:1f:fc:a8:ff:52:51:cf:
27
+ 10:c0:be:a0:ad:cb:63:98:30:66:0e:42:e3:ca:6b:
28
+ 2d:f8:92:c7:24:a7:03:65:96:0a:9c:ce:09:e7:ae:
29
+ c2:a7:ea:6c:54:bb:e8:24:62:31:48:fb:d0:df:e1:
30
+ a2:3c:5f:d2:89:29:de:4f:6b:73:88:2a:68:57:08:
31
+ 7a:1e:aa:bd:70:79:e7:dc:f5:e1:9f:39:83:7b:70:
32
+ 55:bb
33
+ Exponent: 65537 (0x10001)
34
+ X509v3 extensions:
35
+ X509v3 Key Usage:
36
+ Digital Signature
37
+ X509v3 Extended Key Usage:
38
+ TLS Web Client Authentication
39
+ X509v3 Subject Alternative Name:
40
+ DNS:localhost, IP Address:127.0.0.1
41
+ Signature Algorithm: sha256WithRSAEncryption
42
+ 92:04:8c:a5:56:c0:01:37:65:ff:d2:0e:5b:be:dd:78:9c:e2:
43
+ 45:3d:fc:34:e5:23:f3:75:fb:70:3b:06:9f:e9:63:e9:f0:8a:
44
+ 14:54:3d:d9:6a:22:af:04:00:25:95:80:e8:83:0b:c7:6f:f0:
45
+ f1:58:2b:07:86:6b:e3:eb:b0:ea:09:b2:5e:15:05:14:89:2b:
46
+ 02:99:09:97:6d:49:19:ac:c2:50:91:2b:03:e6:75:ce:27:9d:
47
+ 8f:c0:b5:cd:b2:1f:7d:66:75:c7:d1:a7:16:b3:cf:8b:1e:9b:
48
+ e4:46:da:e2:02:2c:55:74:56:8c:e6:d9:27:53:9f:b2:f5:09:
49
+ ba:fe:df:e2:e1:b7:7d:43:8a:9d:bb:f0:3d:b9:d4:ce:26:8f:
50
+ d9:cc:e6:2e:1c:81:fc:6e:a0:5f:01:23:68:9d:fe:1b:ee:03:
51
+ 69:f1:10:af:5a:0e:dc:96:e2:56:ae:ca:35:b3:08:61:34:37:
52
+ e1:e6:53:ef:68:84:87:f4:56:c5:49:45:08:90:46:3e:1c:b5:
53
+ 40:08:f7:09:51:d7:24:53:49:b5:b1:2f:85:39:b9:0b:0e:f9:
54
+ 05:ea:a3:d0:47:6d:69:6b:9c:25:8e:ad:61:01:86:96:28:3b:
55
+ fd:6f:78:79:66:b1:cc:de:fc:18:45:cf:84:f1:d0:e2:46:4f:
56
+ f8:9d:95:a4
57
+ -----BEGIN CERTIFICATE-----
58
+ MIIDnzCCAoegAwIBAgIDCTBiMA0GCSqGSIb3DQEBCwUAMHUxFzAVBgNVBAMTDlJ1
59
+ YnkgRHJpdmVyIENBMRAwDgYDVQQLEwdEcml2ZXJzMRAwDgYDVQQKEwdNb25nb0RC
60
+ MRYwFAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkG
61
+ A1UEBhMCVVMwHhcNMTkwOTA0MjExNzQyWhcNMzkwOTA0MjExNzQyWjBtMRIwEAYD
62
+ VQQDEwlsb2NhbGhvc3QxDTALBgNVBAsTBHg1MDkxEDAOBgNVBAoTB01vbmdvREIx
63
+ FjAUBgNVBAcTDU5ldyBZb3JrIENpdHkxETAPBgNVBAgTCE5ldyBZb3JrMQswCQYD
64
+ VQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMTmII9YQlNR
65
+ JGS00CXPeeBx+J6XNajf+tlj62OytHdgr44JbXJQvOp8Vz8XUbAFheg7Z0uXhGG7
66
+ aAm0ltrIO31TuBD+DXEvuF2Dhj8GV+Js1S/IbHT72G9337ptUmE8M3alX2Jor6To
67
+ 3DYquVRHkexPCbku7zdN1wTbSPyNwkTxn3kh8Ab+tOVQPM/RP1m1jdzQOTFTl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3/mahZxc6hXrwBTshpgYB78
23
+ g5o9WxymmppDsHWN9EqTpdhH7ahibxD1RSep95OBRSIO704u68lqEo7O/5FUuuFA
24
+ urEzVIECgYEAyX44ZLYW7c68fS2zTvnGBBINgntookhRK0sMUwuYvDL5RobnKusP
25
+ 2Fz4gZtTmpRfgxcglih+EJPUhqqn6UteXG/TNatrf27DOuQgJHliQa/GDcANkEkT
26
+ UtGu2aCxd0Na9lPvEzor37PPzLKdkaiAmAnyLmTpn5whGFgpXa32Ups=
27
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,105 @@
1
+ Certificate:
2
+ Data:
3
+ Version: 3 (0x2)
4
+ Serial Number: 602210 (0x93062)
5
+ Signature Algorithm: sha256WithRSAEncryption
6
+ Issuer: CN = Ruby Driver CA, OU = Drivers, O = MongoDB, L = New York City, ST = New York, C = US
7
+ Validity
8
+ Not Before: Sep 4 21:17:42 2019 GMT
9
+ Not After : Sep 4 21:17:42 2039 GMT
10
+ Subject: CN = localhost, OU = x509, O = MongoDB, L = New York City, ST = New York, C = US
11
+ Subject Public Key Info:
12
+ Public Key Algorithm: rsaEncryption
13
+ RSA Public-Key: (2048 bit)
14
+ Modulus:
15
+ 00:c4:e6:20:8f:58:42:53:51:24:64:b4:d0:25:cf:
16
+ 79:e0:71:f8:9e:97:35:a8:df:fa:d9:63:eb:63:b2:
17
+ b4:77:60:af:8e:09:6d:72:50:bc:ea:7c:57:3f:17:
18
+ 51:b0:05:85:e8:3b:67:4b:97:84:61:bb:68:09:b4:
19
+ 96:da:c8:3b:7d:53:b8:10:fe:0d:71:2f:b8:5d:83:
20
+ 86:3f:06:57:e2:6c:d5:2f:c8:6c:74:fb:d8:6f:77:
21
+ df:ba:6d:52:61:3c:33:76:a5:5f:62:68:af:a4:e8:
22
+ dc:36:2a:b9:54:47:91:ec:4f:09:b9:2e:ef:37:4d:
23
+ d7:04:db:48:fc:8d:c2:44:f1:9f:79:21:f0:06:fe:
24
+ b4:e5:50:3c:cf:d1:3f:59:b5:8d:dc:d0:39:31:53:
25
+ 95:42:d7:92:c3:c9:d5:93:48:e8:dc:16:ce:61:ec:
26
+ 6f:ce:91:5c:91:2e:59:18:1f:fc:a8:ff:52:51:cf:
27
+ 10:c0:be:a0:ad:cb:63:98:30:66:0e:42:e3:ca:6b:
28
+ 2d:f8:92:c7:24:a7:03:65:96:0a:9c:ce:09:e7:ae:
29
+ c2:a7:ea:6c:54:bb:e8:24:62:31:48:fb:d0:df:e1:
30
+ a2:3c:5f:d2:89:29:de:4f:6b:73:88:2a:68:57:08:
31
+ 7a:1e:aa:bd:70:79:e7:dc:f5:e1:9f:39:83:7b:70:
32
+ 55:bb
33
+ Exponent: 65537 (0x10001)
34
+ X509v3 extensions:
35
+ X509v3 Key Usage:
36
+ Digital Signature
37
+ X509v3 Extended Key Usage:
38
+ TLS Web Client Authentication
39
+ X509v3 Subject Alternative Name:
40
+ DNS:localhost, IP Address:127.0.0.1
41
+ Signature Algorithm: sha256WithRSAEncryption
42
+ 92:04:8c:a5:56:c0:01:37:65:ff:d2:0e:5b:be:dd:78:9c:e2:
43
+ 45:3d:fc:34:e5:23:f3:75:fb:70:3b:06:9f:e9:63:e9:f0:8a:
44
+ 14:54:3d:d9:6a:22:af:04:00:25:95:80:e8:83:0b:c7:6f:f0:
45
+ f1:58:2b:07:86:6b:e3:eb:b0:ea:09:b2:5e:15:05:14:89:2b:
46
+ 02:99:09:97:6d:49:19:ac:c2:50:91:2b:03:e6:75:ce:27:9d:
47
+ 8f:c0:b5:cd:b2:1f:7d:66:75:c7:d1:a7:16:b3:cf:8b:1e:9b:
48
+ e4:46:da:e2:02:2c:55:74:56:8c:e6:d9:27:53:9f:b2:f5:09:
49
+ ba:fe:df:e2:e1:b7:7d:43:8a:9d:bb:f0:3d:b9:d4:ce:26:8f:
50
+ d9:cc:e6:2e:1c:81:fc:6e:a0:5f:01:23:68:9d:fe:1b:ee:03:
51
+ 69:f1:10:af:5a:0e:dc:96:e2:56:ae:ca:35:b3:08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nKusP
103
+ 2Fz4gZtTmpRfgxcglih+EJPUhqqn6UteXG/TNatrf27DOuQgJHliQa/GDcANkEkT
104
+ UtGu2aCxd0Na9lPvEzor37PPzLKdkaiAmAnyLmTpn5whGFgpXa32Ups=
105
+ -----END RSA PRIVATE KEY-----
@@ -37,17 +37,12 @@ module Mongo
37
37
 
38
38
  # Instantiate the new spec.
39
39
  #
40
- # @example Create the spec.
41
- # Spec.new(file)
42
- #
43
- # @param [ String ] file The name of the file.
40
+ # @param [ String ] test_path The path to the file.
44
41
  #
45
42
  # @since 2.6.0
46
- def initialize(file)
47
- file = File.new(file)
48
- @spec = YAML.load(ERB.new(file.read).result)
49
- file.close
50
- @description = File.basename(file)
43
+ def initialize(test_path)
44
+ @spec = YAML.load(File.read(test_path))
45
+ @description = File.basename(test_path)
51
46
  @spec_tests = @spec['tests']
52
47
  @coll1 = @spec['collection_name']
53
48
  @coll2 = @spec['collection2_name']
@@ -129,7 +124,7 @@ module Mongo
129
124
 
130
125
  def run
131
126
  change_stream = begin
132
- @target.watch(@pipeline, @options)
127
+ @target.watch(@pipeline, Utils.snakeize_hash(@options))
133
128
  rescue Mongo::Error::OperationFailure => e
134
129
  return {
135
130
  result: { 'error' => { 'code' => e.code } },
@@ -195,9 +190,11 @@ module Mongo
195
190
 
196
191
  private
197
192
 
193
+ IGNORE_COMMANDS = %w(saslStart saslContinue killCursors getMore)
194
+
198
195
  def events
199
196
  EventSubscriber.started_events.reduce([]) do |evs, e|
200
- next evs if %w(saslStart saslContinue killCursors).include?(e.command_name)
197
+ next evs if IGNORE_COMMANDS.include?(e.command_name)
201
198
 
202
199
  evs << {
203
200
  'command_started_event' => {
@@ -95,17 +95,21 @@ class ClientRegistry
95
95
  when 'unauthorized'
96
96
  Mongo::Client.new(
97
97
  SpecConfig.instance.addresses,
98
- SpecConfig.instance.test_options.merge(database: SpecConfig.instance.test_db, monitoring: false),
98
+ SpecConfig.instance.test_options.merge(database: SpecConfig.instance.test_db),
99
99
  )
100
100
  # Provides an authorized mongo client on the default test database for the
101
101
  # default test user.
102
102
  when 'authorized'
103
+ client_options = {
104
+ database: SpecConfig.instance.test_db,
105
+ }.update(SpecConfig.instance.credentials_or_x509(
106
+ user: SpecConfig.instance.test_user.name,
107
+ password: SpecConfig.instance.test_user.password,
108
+ ))
109
+
103
110
  Mongo::Client.new(
104
111
  SpecConfig.instance.addresses,
105
- SpecConfig.instance.test_options.merge(
106
- database: SpecConfig.instance.test_db,
107
- user: SpecConfig.instance.test_user.name,
108
- password: SpecConfig.instance.test_user.password),
112
+ SpecConfig.instance.test_options.merge(client_options)
109
113
  )
110
114
  # Provides an authorized mongo client that retries writes.
111
115
  when 'authorized_with_retry_writes'
@@ -165,15 +169,23 @@ class ClientRegistry
165
169
  # Get an authorized client on the test database logged in as the admin
166
170
  # root user.
167
171
  when 'root_authorized'
168
- Mongo::Client.new(
169
- SpecConfig.instance.addresses,
170
- SpecConfig.instance.test_options.merge(
172
+ if SpecConfig.instance.x509_auth?
173
+ client_options = SpecConfig.instance.auth_options.merge(
174
+ database: SpecConfig.instance.test_db,
175
+ )
176
+ else
177
+ client_options = {
178
+ database: SpecConfig.instance.test_db,
179
+ }.update(SpecConfig.instance.credentials_or_x509(
171
180
  user: SpecConfig.instance.root_user.name,
172
181
  password: SpecConfig.instance.root_user.password,
173
- database: SpecConfig.instance.test_db,
174
182
  auth_source: SpecConfig.instance.auth_source || Mongo::Database::ADMIN,
175
- monitoring: false
176
- ),
183
+ ))
184
+ end
185
+
186
+ Mongo::Client.new(
187
+ SpecConfig.instance.addresses,
188
+ SpecConfig.instance.test_options.merge(client_options),
177
189
  )
178
190
  # A client that has an event subscriber for commands.
179
191
  when 'subscribed'
@@ -181,8 +193,10 @@ class ClientRegistry
181
193
  SpecConfig.instance.addresses,
182
194
  SpecConfig.instance.test_options.merge(
183
195
  database: SpecConfig.instance.test_db,
196
+ ).merge(SpecConfig.instance.credentials_or_x509(
184
197
  user: SpecConfig.instance.test_user.name,
185
- password: SpecConfig.instance.test_user.password),
198
+ password: SpecConfig.instance.test_user.password,
199
+ ))
186
200
  ).tap do |client|
187
201
  client.subscribe(Mongo::Monitoring::COMMAND, EventSubscriber)
188
202
  end