Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SRV tests with latest from specifications #1649

Merged
merged 2 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions test/functional/mongodb_srv_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,18 @@ describe('DNS and TXT record tests', function() {
if (test[1].options && test[1].options.ssl) {
expect(object.server_options.ssl).to.equal(test[1].options.ssl);
}
if (
test[1].parsed_options &&
test[1].parsed_options.user &&
test[1].parsed_options.password
) {
expect(object.auth.user).to.equal(test[1].parsed_options.user);
expect(object.auth.password).to.equal(test[1].parsed_options.password);
}
}
done();
});
}
});
});

it('preserves auth credentials in the connection string', {
metadata: {
requires: { topology: ['single'] }
},
test: function(done) {
let user = 'auser';
let password = 'apass';
let uri = `mongodb+srv://${user}:${password}@test18.test.build.10gen.cc/?replicaSet=repl0`;
parse(uri, function(err, object) {
expect(err).to.not.exist;
expect(object.auth.user).to.not.be.undefined;
expect(object.auth.user).to.equal(user);
expect(object.auth.password).to.not.be.undefined;
expect(object.auth.password).to.equal(password);
done();
});
}
});
});
9 changes: 7 additions & 2 deletions test/functional/spec/dns-txt-records/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
17 changes: 17 additions & 0 deletions test/functional/spec/dns-txt-records/uri-with-auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"uri": "mongodb+srv://auser:[email protected]/?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"
}
12 changes: 12 additions & 0 deletions test/functional/spec/dns-txt-records/uri-with-auth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
uri: "mongodb+srv://auser:[email protected]/?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