From b20e8c13fb8ecdff7e4e52eb33fe65d9af08111e Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Mon, 22 Jan 2018 15:20:39 -0500 Subject: [PATCH 1/2] test(srv): add new test files --- .../functional/specs/dns-txt-records/README.rst | 9 +++++++-- .../specs/dns-txt-records/uri-with-auth.json | 17 +++++++++++++++++ .../specs/dns-txt-records/uri-with-auth.yml | 12 ++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 test/functional/specs/dns-txt-records/uri-with-auth.json create mode 100644 test/functional/specs/dns-txt-records/uri-with-auth.yml diff --git a/test/functional/specs/dns-txt-records/README.rst b/test/functional/specs/dns-txt-records/README.rst index 5b093e19dff..5999557948e 100644 --- a/test/functional/specs/dns-txt-records/README.rst +++ b/test/functional/specs/dns-txt-records/README.rst @@ -73,6 +73,8 @@ These YAML and JSON files contain the following fields: - ``hosts``: the discovered topology's list of hosts once SDAM completes a scan - ``options``: the parsed connection string options as discovered from URI and TXT records +- ``parsed_options``: additional options present in the URI such as user/password +credentials - ``error``: indicates that the parsing of the URI, or the resolving or contents of the SRV or TXT records included errors. - ``comment``: a comment to indicate why a test would fail. @@ -83,5 +85,8 @@ seeds. You MUST verify that the set of ServerDescriptions in the client's TopologyDescription eventually matches the list of hosts. You MUST verify that each of the values of the Connection String Options under ``options`` match the Client's parsed value for that option. There may be other options parsed by -the Client as well, which a test does not verify. You MUST verify that an -error has been thrown if ``error`` is present. +the Client as well, which a test does not verify. In ``uri-with-auth`` the URI +contains a user/password set and additional options are provided in +``parsed_options`` so that tests can verify authentication is maintained when +evaluating URIs. You MUST verify that an error has been thrown if ``error`` is +present. diff --git a/test/functional/specs/dns-txt-records/uri-with-auth.json b/test/functional/specs/dns-txt-records/uri-with-auth.json new file mode 100644 index 00000000000..cc7257d85ba --- /dev/null +++ b/test/functional/specs/dns-txt-records/uri-with-auth.json @@ -0,0 +1,17 @@ +{ + "uri": "mongodb+srv://auser:apass@test1.test.build.10gen.cc/?replicaSet=repl0", + "seeds": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "hosts": [ + "localhost:27017", + "localhost:27018", + "localhost:27019" + ], + "parsed_options": { + "user": "auser", + "password": "apass" + }, + "comment": "Should preserve auth credentials" +} diff --git a/test/functional/specs/dns-txt-records/uri-with-auth.yml b/test/functional/specs/dns-txt-records/uri-with-auth.yml new file mode 100644 index 00000000000..9ecfca73ea9 --- /dev/null +++ b/test/functional/specs/dns-txt-records/uri-with-auth.yml @@ -0,0 +1,12 @@ +uri: "mongodb+srv://auser:apass@test1.test.build.10gen.cc/?replicaSet=repl0" +seeds: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +hosts: + - localhost:27017 + - localhost:27018 + - localhost:27019 +parsed_options: + user: auser + password: apass +comment: Should preserve auth credentials From cd09a7261044f145eb8eb1ae40c7fb510d7f562c Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Mon, 22 Jan 2018 15:20:49 -0500 Subject: [PATCH 2/2] test(srv): add auth check --- test/functional/mongodb_srv_tests.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/functional/mongodb_srv_tests.js b/test/functional/mongodb_srv_tests.js index 6ffe9a12b4e..0d2e69ac64a 100644 --- a/test/functional/mongodb_srv_tests.js +++ b/test/functional/mongodb_srv_tests.js @@ -41,6 +41,11 @@ exports['mongodb+srv tests'] = { if (options.ssl) { test.equal(object.server_options.ssl, options.ssl); } + + if (options.parsed_options) { + test.equal(object.auth.user, options.parsed_options.user); + test.equal(object.auth.password, options.parsed_options.password); + } } }); });