mongo 2.10.5 → 2.11.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CONTRIBUTING.md +1 -1
  5. data/lib/mongo.rb +2 -0
  6. data/lib/mongo/address.rb +4 -0
  7. data/lib/mongo/address/validator.rb +99 -0
  8. data/lib/mongo/auth.rb +7 -2
  9. data/lib/mongo/auth/user.rb +1 -7
  10. data/lib/mongo/background_thread.rb +135 -0
  11. data/lib/mongo/bulk_write/transformable.rb +3 -3
  12. data/lib/mongo/client.rb +74 -16
  13. data/lib/mongo/cluster.rb +193 -41
  14. data/lib/mongo/cluster/periodic_executor.rb +31 -43
  15. data/lib/mongo/cluster/sdam_flow.rb +26 -3
  16. data/lib/mongo/cluster/srv_monitor.rb +127 -0
  17. data/lib/mongo/collection/view/readable.rb +3 -5
  18. data/lib/mongo/collection/view/writable.rb +3 -3
  19. data/lib/mongo/cursor/builder/get_more_command.rb +1 -4
  20. data/lib/mongo/cursor/builder/kill_cursors_command.rb +5 -23
  21. data/lib/mongo/cursor/builder/op_get_more.rb +2 -2
  22. data/lib/mongo/cursor/builder/op_kill_cursors.rb +5 -24
  23. data/lib/mongo/error.rb +1 -0
  24. data/lib/mongo/error/auth_error.rb +1 -1
  25. data/lib/mongo/error/connection_check_out_timeout.rb +7 -8
  26. data/lib/mongo/error/invalid_address.rb +24 -0
  27. data/lib/mongo/error/notable.rb +2 -2
  28. data/lib/mongo/error/operation_failure.rb +3 -3
  29. data/lib/mongo/error/pool_closed_error.rb +11 -4
  30. data/lib/mongo/event.rb +1 -1
  31. data/lib/mongo/grid/file.rb +0 -5
  32. data/lib/mongo/grid/file/chunk.rb +0 -2
  33. data/lib/mongo/grid/fs_bucket.rb +13 -15
  34. data/lib/mongo/grid/stream/write.rb +3 -9
  35. data/lib/mongo/loggable.rb +5 -1
  36. data/lib/mongo/monitoring.rb +1 -0
  37. data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +7 -0
  38. data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +11 -3
  39. data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +11 -3
  40. data/lib/mongo/monitoring/event/cmap/pool_closed.rb +11 -3
  41. data/lib/mongo/monitoring/event/cmap/pool_created.rb +12 -3
  42. data/lib/mongo/monitoring/unified_sdam_log_subscriber.rb +62 -0
  43. data/lib/mongo/operation/shared/executable.rb +5 -10
  44. data/lib/mongo/operation/shared/sessions_supported.rb +1 -5
  45. data/lib/mongo/protocol/get_more.rb +1 -2
  46. data/lib/mongo/protocol/kill_cursors.rb +13 -6
  47. data/lib/mongo/protocol/serializers.rb +4 -20
  48. data/lib/mongo/retryable.rb +9 -34
  49. data/lib/mongo/semaphore.rb +1 -1
  50. data/lib/mongo/server.rb +113 -42
  51. data/lib/mongo/server/connection.rb +12 -5
  52. data/lib/mongo/server/connection_pool.rb +250 -40
  53. data/lib/mongo/server/connection_pool/populator.rb +58 -0
  54. data/lib/mongo/server/description.rb +9 -2
  55. data/lib/mongo/server/monitor.rb +68 -93
  56. data/lib/mongo/server/monitor/connection.rb +2 -0
  57. data/lib/mongo/server_selector/selectable.rb +13 -5
  58. data/lib/mongo/session.rb +0 -13
  59. data/lib/mongo/srv.rb +17 -0
  60. data/lib/mongo/srv/monitor.rb +96 -0
  61. data/lib/mongo/srv/resolver.rb +130 -0
  62. data/lib/mongo/srv/result.rb +126 -0
  63. data/lib/mongo/srv/warning_result.rb +35 -0
  64. data/lib/mongo/uri.rb +45 -55
  65. data/lib/mongo/uri/srv_protocol.rb +89 -42
  66. data/lib/mongo/version.rb +1 -1
  67. data/mongo.gemspec +3 -4
  68. data/spec/README.md +6 -1
  69. data/spec/enterprise_auth/kerberos_spec.rb +7 -6
  70. data/spec/integration/change_stream_examples_spec.rb +0 -4
  71. data/spec/integration/client_construction_spec.rb +14 -2
  72. data/spec/integration/connect_single_rs_name_spec.rb +2 -2
  73. data/spec/integration/connection_pool_populator_spec.rb +296 -0
  74. data/spec/integration/connection_spec.rb +31 -22
  75. data/spec/integration/cursor_reaping_spec.rb +1 -2
  76. data/spec/integration/docs_examples_spec.rb +0 -4
  77. data/spec/integration/heartbeat_events_spec.rb +17 -15
  78. data/spec/integration/reconnect_spec.rb +144 -1
  79. data/spec/integration/retryable_writes_errors_spec.rb +0 -4
  80. data/spec/integration/retryable_writes_spec.rb +36 -36
  81. data/spec/integration/sdam_error_handling_spec.rb +31 -25
  82. data/spec/integration/sdam_events_spec.rb +2 -6
  83. data/spec/integration/server_monitor_spec.rb +28 -0
  84. data/spec/integration/server_selector_spec.rb +7 -5
  85. data/spec/integration/srv_monitoring_spec.rb +360 -0
  86. data/spec/integration/step_down_spec.rb +4 -6
  87. data/spec/lite_spec_helper.rb +22 -0
  88. data/spec/mongo/address/validator_spec.rb +51 -0
  89. data/spec/mongo/auth/cr_spec.rb +1 -29
  90. data/spec/mongo/auth/ldap_spec.rb +1 -29
  91. data/spec/mongo/auth/scram/conversation_spec.rb +0 -2
  92. data/spec/mongo/auth/scram/negotiation_spec.rb +1 -1
  93. data/spec/mongo/auth/scram_spec.rb +1 -29
  94. data/spec/mongo/auth/user/view_spec.rb +1 -36
  95. data/spec/mongo/auth/user_spec.rb +0 -12
  96. data/spec/mongo/auth/x509_spec.rb +1 -29
  97. data/spec/mongo/bulk_write_spec.rb +2 -2
  98. data/spec/mongo/client_construction_spec.rb +56 -15
  99. data/spec/mongo/client_spec.rb +31 -27
  100. data/spec/mongo/cluster/periodic_executor_spec.rb +16 -0
  101. data/spec/mongo/cluster/srv_monitor_spec.rb +214 -0
  102. data/spec/mongo/cluster/topology/replica_set_spec.rb +16 -11
  103. data/spec/mongo/cluster/topology/sharded_spec.rb +12 -9
  104. data/spec/mongo/cluster/topology/single_spec.rb +20 -11
  105. data/spec/mongo/cluster_spec.rb +45 -29
  106. data/spec/mongo/collection/view/map_reduce_spec.rb +14 -9
  107. data/spec/mongo/collection/view/readable_spec.rb +0 -16
  108. data/spec/mongo/collection_spec.rb +0 -44
  109. data/spec/mongo/cursor/builder/get_more_command_spec.rb +2 -4
  110. data/spec/mongo/cursor/builder/op_get_more_spec.rb +2 -4
  111. data/spec/mongo/cursor_spec.rb +27 -7
  112. data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +10 -3
  113. data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +10 -3
  114. data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +10 -3
  115. data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +10 -3
  116. data/spec/mongo/operation/delete/op_msg_spec.rb +17 -8
  117. data/spec/mongo/operation/insert/op_msg_spec.rb +50 -35
  118. data/spec/mongo/operation/update/op_msg_spec.rb +14 -7
  119. data/spec/mongo/retryable_spec.rb +52 -31
  120. data/spec/mongo/server/app_metadata_spec.rb +0 -8
  121. data/spec/mongo/server/connection_auth_spec.rb +5 -2
  122. data/spec/mongo/server/connection_pool/populator_spec.rb +101 -0
  123. data/spec/mongo/server/connection_pool_spec.rb +256 -107
  124. data/spec/mongo/server/connection_spec.rb +22 -33
  125. data/spec/mongo/server/description_spec.rb +42 -4
  126. data/spec/mongo/server/monitor/connection_spec.rb +22 -11
  127. data/spec/mongo/server/monitor_spec.rb +66 -107
  128. data/spec/mongo/server_spec.rb +82 -60
  129. data/spec/mongo/session/session_pool_spec.rb +1 -5
  130. data/spec/mongo/session_spec.rb +0 -4
  131. data/spec/mongo/socket/ssl_spec.rb +2 -2
  132. data/spec/mongo/srv/monitor_spec.rb +211 -0
  133. data/spec/mongo/srv/result_spec.rb +54 -0
  134. data/spec/mongo/uri/srv_protocol_spec.rb +30 -15
  135. data/spec/mongo/uri_spec.rb +125 -4
  136. data/spec/spec_helper.rb +6 -0
  137. data/spec/spec_tests/auth_spec.rb +39 -0
  138. data/spec/spec_tests/cmap_spec.rb +55 -8
  139. data/spec/spec_tests/connection_string_spec.rb +6 -31
  140. data/spec/spec_tests/data/auth/connection-string.yml +297 -0
  141. data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +4 -1
  142. data/spec/spec_tests/data/cmap/pool-create-with-options.yml +1 -0
  143. data/spec/spec_tests/data/command_monitoring/insertMany.yml +1 -1
  144. data/spec/spec_tests/data/connection_string/invalid-uris.yml +20 -0
  145. data/spec/spec_tests/data/connection_string/valid-auth.yml +16 -0
  146. data/spec/spec_tests/data/connection_string/valid-warnings.yml +26 -30
  147. data/spec/spec_tests/data/transactions/abort.yml +3 -3
  148. data/spec/spec_tests/data/transactions/error-labels.yml +3 -3
  149. data/spec/spec_tests/data/transactions_api/callback-retry.yml +3 -3
  150. data/spec/spec_tests/data/uri_options/auth-options.yml +1 -1
  151. data/spec/spec_tests/max_staleness_spec.rb +7 -2
  152. data/spec/spec_tests/retryable_reads_spec.rb +0 -31
  153. data/spec/spec_tests/sdam_monitoring_spec.rb +12 -12
  154. data/spec/spec_tests/sdam_spec.rb +4 -7
  155. data/spec/spec_tests/server_selection_spec.rb +6 -2
  156. data/spec/spec_tests/transactions_spec.rb +0 -2
  157. data/spec/spec_tests/uri_options_spec.rb +4 -2
  158. data/spec/stress/connection_pool_stress_spec.rb +203 -0
  159. data/spec/stress/connection_pool_timing_spec.rb +181 -0
  160. data/spec/support/auth.rb +113 -0
  161. data/spec/support/background_thread_registry.rb +63 -0
  162. data/spec/support/client_registry.rb +11 -2
  163. data/spec/support/cluster_config.rb +65 -46
  164. data/spec/support/cluster_tools.rb +2 -2
  165. data/spec/support/cmap.rb +13 -14
  166. data/spec/support/cmap/verifier.rb +4 -5
  167. data/spec/support/command_monitoring.rb +0 -5
  168. data/spec/support/common_shortcuts.rb +101 -1
  169. data/spec/support/constraints.rb +25 -0
  170. data/spec/support/dns.rb +13 -0
  171. data/spec/support/event_subscriber.rb +0 -7
  172. data/spec/support/json_ext_formatter.rb +5 -1
  173. data/spec/support/lite_constraints.rb +22 -6
  174. data/spec/support/local_resource_registry.rb +34 -0
  175. data/spec/support/sdam_monitoring.rb +115 -0
  176. data/spec/support/spec_config.rb +20 -6
  177. data/spec/support/spec_setup.rb +2 -2
  178. data/spec/support/transactions.rb +1 -1
  179. data/spec/support/transactions/test.rb +1 -1
  180. data/spec/support/utils.rb +1 -16
  181. metadata +685 -659
  182. metadata.gz.sig +0 -0
  183. data/lib/mongo/event/description_changed.rb +0 -52
  184. data/spec/integration/bson_symbol_spec.rb +0 -34
  185. data/spec/integration/crud_spec.rb +0 -45
  186. data/spec/integration/get_more_spec.rb +0 -32
  187. data/spec/integration/grid_fs_bucket_spec.rb +0 -48
  188. data/spec/integration/retryable_errors_spec.rb +0 -265
  189. data/spec/integration/size_limit_spec.rb~12e1e9c4f... RUBY-2242 Fix zlib compression (#2021) +0 -98
  190. data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +0 -56
  191. data/spec/runners/sdam/verifier.rb +0 -88
@@ -1,46 +1,21 @@
1
- require 'lite_spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'ConnectionString' do
4
4
  include Mongo::ConnectionString
5
5
 
6
+ clean_slate_for_all
7
+
6
8
  CONNECTION_STRING_TESTS.each do |file|
7
9
 
8
10
  spec = Mongo::ConnectionString::Spec.new(file)
9
11
 
10
12
  context(spec.description) do
11
13
 
12
- before(:all) do
13
-
14
- module Mongo
15
- class Address
16
-
17
- private
18
-
19
- alias :original_create_resolver :create_resolver
20
- def create_resolver(timeout, ssl_options)
21
- family = (host == 'localhost') ? ::Socket::AF_INET : ::Socket::AF_UNSPEC
22
- info = ::Socket.getaddrinfo(host, nil, family, ::Socket::SOCK_STREAM)
23
- FAMILY_MAP[info.first[4]].new(info[3], port, host)
24
- end
25
- end
26
- end
27
- end
28
-
29
- after(:all) do
30
-
31
- module Mongo
32
- # Return the implementations to their originals for the other
33
- # tests in the suite.
34
- class Address
35
- alias :create_resolver :original_create_resolver
36
- remove_method(:original_create_resolver)
37
- end
38
- end
39
- end
40
-
41
14
  spec.tests.each_with_index do |test, index|
42
-
43
15
  context "when a #{test.description} is provided" do
16
+ if test.description.downcase.include?("gssapi")
17
+ require_mongo_kerberos
18
+ end
44
19
 
45
20
  context 'when the uri is invalid', unless: test.valid? do
46
21
 
@@ -0,0 +1,297 @@
1
+ tests:
2
+ -
3
+ description: "should use the default source and mechanism"
4
+ uri: "mongodb://user:password@localhost"
5
+ valid: true
6
+ credential:
7
+ username: "user"
8
+ password: "password"
9
+ source: "admin"
10
+ mechanism: ~
11
+ mechanism_properties: ~
12
+ -
13
+ description: "should use the database when no authSource is specified"
14
+ uri: "mongodb://user:password@localhost/foo"
15
+ valid: true
16
+ credential:
17
+ username: "user"
18
+ password: "password"
19
+ source: "foo"
20
+ mechanism: ~
21
+ mechanism_properties: ~
22
+ -
23
+ description: "should use the authSource when specified"
24
+ uri: "mongodb://user:password@localhost/foo?authSource=bar"
25
+ valid: true
26
+ credential:
27
+ username: "user"
28
+ password: "password"
29
+ source: "bar"
30
+ mechanism: ~
31
+ mechanism_properties: ~
32
+ -
33
+ description: "should recognise the mechanism (GSSAPI)"
34
+ uri: "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI"
35
+ valid: true
36
+ credential:
37
+ username: "user@DOMAIN.COM"
38
+ password: ~
39
+ source: "$external"
40
+ mechanism: "GSSAPI"
41
+ mechanism_properties:
42
+ SERVICE_NAME: "mongodb"
43
+ -
44
+ description: "should ignore the database (GSSAPI)"
45
+ uri: "mongodb://user%40DOMAIN.COM@localhost/foo?authMechanism=GSSAPI"
46
+ valid: true
47
+ credential:
48
+ username: "user@DOMAIN.COM"
49
+ password: ~
50
+ source: "$external"
51
+ mechanism: "GSSAPI"
52
+ mechanism_properties:
53
+ SERVICE_NAME: "mongodb"
54
+ -
55
+ description: "should accept valid authSource (GSSAPI)"
56
+ uri: "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authSource=$external"
57
+ valid: true
58
+ credential:
59
+ username: "user@DOMAIN.COM"
60
+ password: ~
61
+ source: "$external"
62
+ mechanism: "GSSAPI"
63
+ mechanism_properties:
64
+ SERVICE_NAME: "mongodb"
65
+ -
66
+ description: "should accept generic mechanism property (GSSAPI)"
67
+ uri: "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true"
68
+ valid: true
69
+ credential:
70
+ username: "user@DOMAIN.COM"
71
+ password: ~
72
+ source: "$external"
73
+ mechanism: "GSSAPI"
74
+ mechanism_properties:
75
+ SERVICE_NAME: "other"
76
+ CANONICALIZE_HOST_NAME: true
77
+ -
78
+ description: "should accept the password (GSSAPI)"
79
+ uri: "mongodb://user%40DOMAIN.COM:password@localhost/?authMechanism=GSSAPI&authSource=$external"
80
+ valid: true
81
+ credential:
82
+ username: "user@DOMAIN.COM"
83
+ password: "password"
84
+ source: "$external"
85
+ mechanism: "GSSAPI"
86
+ mechanism_properties:
87
+ SERVICE_NAME: "mongodb"
88
+ -
89
+ description: "should throw an exception if authSource is invalid (GSSAPI)"
90
+ uri: "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authSource=foo"
91
+ valid: false
92
+ -
93
+ description: "should throw an exception if no username (GSSAPI)"
94
+ uri: "mongodb://localhost/?authMechanism=GSSAPI"
95
+ valid: false
96
+ -
97
+ description: "should recognize the mechanism (MONGODB-CR)"
98
+ uri: "mongodb://user:password@localhost/?authMechanism=MONGODB-CR"
99
+ valid: true
100
+ credential:
101
+ username: "user"
102
+ password: "password"
103
+ source: "admin"
104
+ mechanism: "MONGODB-CR"
105
+ mechanism_properties: ~
106
+ -
107
+ description: "should use the database when no authSource is specified (MONGODB-CR)"
108
+ uri: "mongodb://user:password@localhost/foo?authMechanism=MONGODB-CR"
109
+ valid: true
110
+ credential:
111
+ username: "user"
112
+ password: "password"
113
+ source: "foo"
114
+ mechanism: "MONGODB-CR"
115
+ mechanism_properties: ~
116
+ -
117
+ description: "should use the authSource when specified (MONGODB-CR)"
118
+ uri: "mongodb://user:password@localhost/foo?authMechanism=MONGODB-CR&authSource=bar"
119
+ valid: true
120
+ credential:
121
+ username: "user"
122
+ password: "password"
123
+ source: "bar"
124
+ mechanism: "MONGODB-CR"
125
+ mechanism_properties: ~
126
+ -
127
+ description: "should throw an exception if no username is supplied (MONGODB-CR)"
128
+ uri: "mongodb://localhost/?authMechanism=MONGODB-CR"
129
+ valid: false
130
+ -
131
+ description: "should recognize the mechanism (MONGODB-X509)"
132
+ uri: "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509"
133
+ valid: true
134
+ credential:
135
+ username: "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"
136
+ password: ~
137
+ source: "$external"
138
+ mechanism: "MONGODB-X509"
139
+ mechanism_properties: ~
140
+ -
141
+ description: "should ignore the database (MONGODB-X509)"
142
+ uri: "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/foo?authMechanism=MONGODB-X509"
143
+ valid: true
144
+ credential:
145
+ username: "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"
146
+ password: ~
147
+ source: "$external"
148
+ mechanism: "MONGODB-X509"
149
+ mechanism_properties: ~
150
+ -
151
+ description: "should accept valid authSource (MONGODB-X509)"
152
+ uri: "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509&authSource=$external"
153
+ valid: true
154
+ credential:
155
+ username: "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"
156
+ password: ~
157
+ source: "$external"
158
+ mechanism: "MONGODB-X509"
159
+ mechanism_properties: ~
160
+ -
161
+ description: "should recognize the mechanism with no username (MONGODB-X509)"
162
+ uri: "mongodb://localhost/?authMechanism=MONGODB-X509"
163
+ valid: true
164
+ credential:
165
+ username: ~
166
+ password: ~
167
+ source: "$external"
168
+ mechanism: "MONGODB-X509"
169
+ mechanism_properties: ~
170
+ -
171
+ description: "should throw an exception if supplied a password (MONGODB-X509)"
172
+ uri: "mongodb://user:password@localhost/?authMechanism=MONGODB-X509"
173
+ valid: false
174
+ -
175
+ description: "should throw an exception if authSource is invalid (MONGODB-X509)"
176
+ uri: "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/foo?authMechanism=MONGODB-X509&authSource=bar"
177
+ valid: false
178
+ -
179
+ description: "should recognize the mechanism (PLAIN)"
180
+ uri: "mongodb://user:password@localhost/?authMechanism=PLAIN"
181
+ valid: true
182
+ credential:
183
+ username: "user"
184
+ password: "password"
185
+ source: "$external"
186
+ mechanism: "PLAIN"
187
+ mechanism_properties: ~
188
+ -
189
+ description: "should use the database when no authSource is specified (PLAIN)"
190
+ uri: "mongodb://user:password@localhost/foo?authMechanism=PLAIN"
191
+ valid: true
192
+ credential:
193
+ username: "user"
194
+ password: "password"
195
+ source: "foo"
196
+ mechanism: "PLAIN"
197
+ mechanism_properties: ~
198
+ -
199
+ description: "should use the authSource when specified (PLAIN)"
200
+ uri: "mongodb://user:password@localhost/foo?authMechanism=PLAIN&authSource=bar"
201
+ valid: true
202
+ credential:
203
+ username: "user"
204
+ password: "password"
205
+ source: "bar"
206
+ mechanism: "PLAIN"
207
+ mechanism_properties: ~
208
+ -
209
+ description: "should throw an exception if no username (PLAIN)"
210
+ uri: "mongodb://localhost/?authMechanism=PLAIN"
211
+ valid: false
212
+ -
213
+ description: "should recognize the mechanism (SCRAM-SHA-1)"
214
+ uri: "mongodb://user:password@localhost/?authMechanism=SCRAM-SHA-1"
215
+ valid: true
216
+ credential:
217
+ username: "user"
218
+ password: "password"
219
+ source: "admin"
220
+ mechanism: "SCRAM-SHA-1"
221
+ mechanism_properties: ~
222
+ -
223
+ description: "should use the database when no authSource is specified (SCRAM-SHA-1)"
224
+ uri: "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-1"
225
+ valid: true
226
+ credential:
227
+ username: "user"
228
+ password: "password"
229
+ source: "foo"
230
+ mechanism: "SCRAM-SHA-1"
231
+ mechanism_properties: ~
232
+ -
233
+ description: "should accept valid authSource (SCRAM-SHA-1)"
234
+ uri: "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-1&authSource=bar"
235
+ valid: true
236
+ credential:
237
+ username: "user"
238
+ password: "password"
239
+ source: "bar"
240
+ mechanism: "SCRAM-SHA-1"
241
+ mechanism_properties: ~
242
+ -
243
+ description: "should throw an exception if no username (SCRAM-SHA-1)"
244
+ uri: "mongodb://localhost/?authMechanism=SCRAM-SHA-1"
245
+ valid: false
246
+ -
247
+ description: "should recognize the mechanism (SCRAM-SHA-256)"
248
+ uri: "mongodb://user:password@localhost/?authMechanism=SCRAM-SHA-256"
249
+ valid: true
250
+ credential:
251
+ username: "user"
252
+ password: "password"
253
+ source: "admin"
254
+ mechanism: "SCRAM-SHA-256"
255
+ mechanism_properties: ~
256
+ -
257
+ description: "should use the database when no authSource is specified (SCRAM-SHA-256)"
258
+ uri: "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-256"
259
+ valid: true
260
+ credential:
261
+ username: "user"
262
+ password: "password"
263
+ source: "foo"
264
+ mechanism: "SCRAM-SHA-256"
265
+ mechanism_properties: ~
266
+ -
267
+ description: "should accept valid authSource (SCRAM-SHA-256)"
268
+ uri: "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-256&authSource=bar"
269
+ valid: true
270
+ credential:
271
+ username: "user"
272
+ password: "password"
273
+ source: "bar"
274
+ mechanism: "SCRAM-SHA-256"
275
+ mechanism_properties: ~
276
+ -
277
+ description: "should throw an exception if no username (SCRAM-SHA-256)"
278
+ uri: "mongodb://localhost/?authMechanism=SCRAM-SHA-256"
279
+ valid: false
280
+ -
281
+ description: "URI with no auth-related info doesn't create credential"
282
+ uri: "mongodb://localhost/"
283
+ valid: true
284
+ credential: ~
285
+ -
286
+ description: "database in URI path doesn't create credentials"
287
+ uri: "mongodb://localhost/foo"
288
+ valid: true
289
+ credential: ~
290
+ -
291
+ description: "should throw an exception if no username provided (userinfo implies default mechanism)"
292
+ uri: "mongodb://@localhost.com/"
293
+ valid: false
294
+ -
295
+ description: "should throw an exception if no username/password provided (userinfo implies default mechanism)"
296
+ uri: "mongodb://:@localhost.com/"
297
+ valid: false
@@ -15,14 +15,17 @@ events:
15
15
  - type: ConnectionPoolCreated
16
16
  address: 42
17
17
  options: 42
18
+ - type: ConnectionCheckOutStarted
18
19
  - type: ConnectionCheckedOut
19
20
  connectionId: 42
20
21
  - type: ConnectionCheckedIn
21
22
  connectionId: 42
22
23
  - type: ConnectionPoolClosed
23
24
  address: 42
25
+ - type: ConnectionCheckOutStarted
26
+ - type: ConnectionCheckOutFailed
27
+ reason: poolClosed
24
28
  ignore:
25
29
  - ConnectionCreated
26
30
  - ConnectionReady
27
31
  - ConnectionClosed
28
- - ConnectionCheckOutStarted
@@ -18,3 +18,4 @@ events:
18
18
  maxIdleTimeMS: 100
19
19
  ignore:
20
20
  - ConnectionCreated
21
+ - ConnectionReady
@@ -58,7 +58,7 @@ tests:
58
58
  arguments:
59
59
  documents:
60
60
  - { _id: 2, x: 22 }
61
- ordered: false
61
+ options: { ordered: false }
62
62
  expectations:
63
63
  -
64
64
  command_started_event:
@@ -239,3 +239,23 @@ tests:
239
239
  hosts: ~
240
240
  auth: ~
241
241
  options: ~
242
+
243
+ -
244
+ description: "Username with password containing an unescaped percent sign and an escaped one"
245
+ uri: "mongodb://user%20%:password@localhost"
246
+ valid: false
247
+ warning: ~
248
+ hosts: ~
249
+ auth: ~
250
+ options: ~
251
+
252
+ -
253
+ description: "Username with password containing an unescaped percent sign (non hex digit)"
254
+ uri: "mongodb://user%w:password@localhost"
255
+ valid: false
256
+ warning: ~
257
+ hosts: ~
258
+ auth: ~
259
+ options: ~
260
+
261
+
@@ -188,6 +188,22 @@ tests:
188
188
  db: "admin?"
189
189
  options:
190
190
  authmechanism: "MONGODB-CR"
191
+ -
192
+ description: "Subdelimiters in user/pass don't need escaping (MONGODB-CR)"
193
+ uri: "mongodb://!$&'()*+,;=:!$&'()*+,;=@127.0.0.1/admin?authMechanism=MONGODB-CR"
194
+ valid: true
195
+ warning: false
196
+ hosts:
197
+ -
198
+ type: "ipv4"
199
+ host: "127.0.0.1"
200
+ port: ~
201
+ auth:
202
+ username: "!$&'()*+,;="
203
+ password: "!$&'()*+,;="
204
+ db: "admin"
205
+ options:
206
+ authmechanism: "MONGODB-CR"
191
207
  -
192
208
  description: "Escaped username (MONGODB-X509)"
193
209
  uri: "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509"
@@ -11,21 +11,19 @@ tests:
11
11
  port: ~
12
12
  auth: ~
13
13
  options: ~
14
- #
15
- # A Mongo::Client doesn't validate option values when initialized so the uri doesn't either.
16
- # -
17
- # description: "Unsupported option values are ignored"
18
- # uri: "mongodb://example.com/?fsync=ifPossible"
19
- # valid: true
20
- # warning: true
21
- # hosts:
22
- # -
23
- # type: "hostname"
24
- # host: "example.com"
25
- # port: ~
26
- # auth: ~
27
- # options: ~
28
- # -
14
+ -
15
+ description: "Unsupported option values are ignored"
16
+ uri: "mongodb://example.com/?fsync=ifPossible"
17
+ valid: true
18
+ warning: true
19
+ hosts:
20
+ -
21
+ type: "hostname"
22
+ host: "example.com"
23
+ port: ~
24
+ auth: ~
25
+ options: ~
26
+ -
29
27
  description: "Repeated option keys"
30
28
  uri: "mongodb://example.com/?replicaSet=test&replicaSet=test"
31
29
  valid: true
@@ -38,18 +36,16 @@ tests:
38
36
  auth: ~
39
37
  options:
40
38
  replicaset: "test"
41
- #
42
- # Change this test in the future if there is a deprecated option in driver 2.0
43
- # -
44
- # description: "Deprecated (or unknown) options are ignored if replacement exists"
45
- # uri: "mongodb://example.com/?wtimeout=5&wtimeoutMS=10"
46
- # valid: true
47
- # warning: true
48
- # hosts:
49
- # -
50
- # type: "hostname"
51
- # host: "example.com"
52
- # port: ~
53
- # auth: ~
54
- # options:
55
- # wtimeoutms: 10
39
+ -
40
+ description: "Deprecated (or unknown) options are ignored if replacement exists"
41
+ uri: "mongodb://example.com/?wtimeout=5&wtimeoutMS=10"
42
+ valid: true
43
+ warning: true
44
+ hosts:
45
+ -
46
+ type: "hostname"
47
+ host: "example.com"
48
+ port: ~
49
+ auth: ~
50
+ options:
51
+ wtimeoutms: 10