A Client MUST use options specified in the Connection String, and options passed in as parameters in code to the MongoClient constructor (or equivalent API for each driver), to override options provided through TXT records.
Further down as an example:
Then the default in the TXT record for authSource is not used as the value in the connection string overrides it. The Client MUST treat the host information as if the following URI was used instead:
The documentation for mongodb () also provides the following example:
Given the override for the authSource, the equivalent connection string in the standard format would be: mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?connectTimeoutMS=300000&replicaSet=mySet&authSource=aDifferentAuthDB
The spec tests in the driver also include a test for this:
But it is not processed correctly:
To reproduce there are two options:
- Fix the test and run the unit tests and see there's a failure.
- Run this minimal code:
The code will fail if the user exists in otherDB and not in the TXT record defined thisDB.
I have a PR ready for this which I will post forthwith.