Skip to content

Commit

Permalink
test(srv): update to the latest spec files (#1649)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jessica Lord authored Jan 23, 2018
1 parent 2921668 commit d3e6be1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 21 deletions.
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

0 comments on commit d3e6be1

Please sign in to comment.