Skip to content

Commit 4e12c13

Browse files
authored
DRIVERS-2789 Connection String Spec to Markdown (#1515)
1 parent d2800b6 commit 4e12c13

File tree

9 files changed

+545
-478
lines changed

9 files changed

+545
-478
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Collection Management Tests
2+
3+
This directory contains tests for collection management. They are implemented in the
4+
[Unified Test Format](../../unified-test-format/unified-test-format.md).

source/collection-management/tests/README.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

source/connection-string/connection-string-spec.md

Lines changed: 480 additions & 0 deletions
Large diffs are not rendered by default.

source/connection-string/connection-string-spec.rst

Lines changed: 0 additions & 393 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Connection String Tests
2+
3+
The YAML and JSON files in this directory tree are platform-independent tests that drivers can use to prove their
4+
conformance to the Connection String Spec.
5+
6+
As the spec is primarily concerned with parsing the parts of a URI, these tests do not focus on host and option
7+
validation. Where necessary, the tests use options known to be (un)supported by drivers to assert behavior such as
8+
issuing a warning on repeated option keys. As such these YAML tests are in no way a replacement for more thorough
9+
testing. However, they can provide an initial verification of your implementation.
10+
11+
## Version
12+
13+
Files in the "specifications" repository have no version scheme. They are not tied to a MongoDB server version.
14+
15+
## Format
16+
17+
Each YAML file contains an object with a single `tests` key. This key is an array of test case objects, each of which
18+
have the following keys:
19+
20+
- `description`: A string describing the test.
21+
- `uri`: A string containing the URI to be parsed.
22+
- `valid:` A boolean indicating if the URI should be considered valid.
23+
- `warning:` A boolean indicating whether URI parsing should emit a warning (independent of whether or not the URI is
24+
valid).
25+
- `hosts`: An array of host objects, each of which have the following keys:
26+
- `type`: A string denoting the type of host. Possible values are "ipv4", "ip_literal", "hostname", and "unix".
27+
Asserting the type is *optional*.
28+
- `host`: A string containing the parsed host.
29+
- `port`: An integer containing the parsed port number.
30+
- `auth`: An object containing the following keys:
31+
- `username`: A string containing the parsed username. For auth mechanisms that do not utilize a password, this may be
32+
the entire `userinfo` token (as discussed in [RFC 2396](https://www.ietf.org/rfc/rfc2396.txt)).
33+
- `password`: A string containing the parsed password.
34+
- `db`: A string containing the parsed authentication database. For legacy implementations that support namespaces
35+
(databases and collections) this may be the full namespace eg: `<db>.<coll>`
36+
- `options`: An object containing key/value pairs for each parsed query string option.
37+
38+
If a test case includes a null value for one of these keys (e.g. `auth: ~`, `port: ~`), no assertion is necessary. This
39+
both simplifies parsing of the test files (keys should always exist) and allows flexibility for drivers that might
40+
substitute default values *during* parsing (e.g. omitted `port` could be parsed as 27017).
41+
42+
The `valid` and `warning` fields are boolean in order to keep the tests flexible. We are not concerned with asserting
43+
the format of specific error or warnings messages strings.
44+
45+
### Use as unit tests
46+
47+
Testing whether a URI is valid or not should simply be a matter of checking whether URI parsing (or MongoClient
48+
construction) raises an error or exception. Testing for emitted warnings may require more legwork (e.g. configuring a
49+
log handler and watching for output).
50+
51+
Not all drivers may be able to directly assert the hosts, auth credentials, and options. Doing so may require exposing
52+
the driver's URI parsing component.
53+
54+
The file `valid-db-with-dotted-name.yml` is a special case for testing drivers that allow dotted namespaces, instead of
55+
only database names, in the Auth Database portion of the URI.

source/connection-string/tests/README.rst

Lines changed: 0 additions & 73 deletions
This file was deleted.

source/initial-dns-seedlist-discovery/initial-dns-seedlist-discovery.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ maintain seed lists at an application level.
2626
This specification builds on the `Connection String`_ specification. It adds a
2727
new protocol scheme and modifies how the `Host Information`_ is interpreted.
2828

29-
.. _`Connection String`: ../connection-string/connection-string-spec.rst
30-
.. _`Host Information`: ../connection-string/connection-string-spec.rst#host-information
29+
.. _`Connection String`: ../connection-string/connection-string-spec.md
30+
.. _`Host Information`: ../connection-string/connection-string-spec.md#host-information
3131

3232
META
3333
====
@@ -196,7 +196,7 @@ A Client MUST use options specified in the Connection String, and options
196196
passed in as parameters in code to the MongoClient constructor (or equivalent
197197
API for each driver), to override options provided through TXT records.
198198

199-
.. _`Connection String spec`: ../connection-string/connection-string-spec.rst#defining-connection-options
199+
.. _`Connection String spec`: ../connection-string/connection-string-spec.md#defining-connection-options
200200

201201
If any connection string option in a TXT record is incorrectly formatted, a
202202
Client MUST throw a parse exception.

source/initial-dns-seedlist-discovery/tests/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ These YAML and JSON files contain the following fields:
116116
- ``comment``: a comment to indicate why a test would fail.
117117
- ``ping``: if false, the test runner should not run a "ping" operation.
118118

119-
.. _`Connection String`: ../../connection-string/connection-string-spec.rst
119+
.. _`Connection String`: ../../connection-string/connection-string-spec.md
120120
.. _`URI options`: ../../uri-options/uri-options.rst
121121

122122
For each YAML file:

source/uri-options/uri-options.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ document are to be interpreted as described in
3030
Conflicting TLS options
3131
~~~~~~~~~~~~~~~~~~~~~~~
3232

33-
Per the `Connection String spec <https://github.com/mongodb/specifications/blob/master/source/connection-string/connection-string-spec.rst#repeated-keys>`__,
33+
Per the `Connection String spec <../connection-string/connection-string-spec.md#repeated-keys>`__,
3434
the behavior of duplicates of most URI options is undefined. However, due
3535
to the security implications of certain options, drivers MUST raise an
3636
error to the user during parsing if any of the following circumstances
@@ -104,7 +104,7 @@ implement the old and new names as aliases. All keys and values MUST be
104104
encoded in UTF-8. All integer options are 32-bit unless specified otherwise.
105105
Note that all requirements and recommendations described in the `Connection
106106
String spec
107-
<https://github.com/mongodb/specifications/blob/master/source/connection-string/connection-string-spec.rst>`_
107+
<../connection-string/connection-string-spec.md>`_
108108
pertaining to URI options apply here.
109109

110110
.. _uri.options:

0 commit comments

Comments
 (0)