summaryrefslogtreecommitdiff
path: root/buildscripts/resmokelib/testing/fixtures/interface.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/resmokelib/testing/fixtures/interface.py')
-rw-r--r--buildscripts/resmokelib/testing/fixtures/interface.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/buildscripts/resmokelib/testing/fixtures/interface.py b/buildscripts/resmokelib/testing/fixtures/interface.py
index 57d22f87ec6..1f9bf738fca 100644
--- a/buildscripts/resmokelib/testing/fixtures/interface.py
+++ b/buildscripts/resmokelib/testing/fixtures/interface.py
@@ -403,13 +403,15 @@ def create_fixture_table(fixture):
return "Fixture status:\n" + table
-def authenticate(client, auth_options=None):
+def build_client(node, auth_options=None, read_preference=pymongo.ReadPreference.PRIMARY):
"""Authenticate client for the 'authenticationDatabase' and return the client."""
if auth_options is not None:
- auth_db = client[auth_options["authenticationDatabase"]]
- auth_db.authenticate(auth_options["username"], password=auth_options["password"],
- mechanism=auth_options["authenticationMechanism"])
- return client
+ return node.mongo_client(
+ username=auth_options["username"], password=auth_options["password"],
+ authSource=auth_options["authenticationDatabase"],
+ authMechanism=auth_options["authenticationMechanism"], read_preference=read_preference)
+ else:
+ return node.mongo_client(read_preference=read_preference)
# Represents a row in a node info table.