Skip to content

Commit 02de1ba

Browse files
PYTHON-3909 Fix OIDC reauth for bulk write operations, remove unneeded AUTH_MECH (#1353)
Co-authored-by: Steven Silvester <[email protected]>
1 parent 43845c3 commit 02de1ba

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

.evergreen/run-mongodb-oidc-test.sh

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ if [ -z "$PYTHON_BINARY" ]; then
5151
fi
5252

5353
export TEST_AUTH_OIDC=1
54-
export AUTH_MECH="SCRAM-SHA-256"
5554
export AUTH="auth"
5655
export SET_XTRACE_ON=1
5756
bash ./.evergreen/tox.sh -m test-eg

pymongo/helpers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ def _handle_exception() -> None:
308308
def _handle_reauth(func: F) -> F:
309309
def inner(*args: Any, **kwargs: Any) -> Any:
310310
no_reauth = kwargs.pop("no_reauth", False)
311+
from pymongo.message import _BulkWriteContext
311312
from pymongo.pool import Connection
312313

313314
try:
@@ -324,7 +325,7 @@ def inner(*args: Any, **kwargs: Any) -> Any:
324325
if isinstance(arg, Connection):
325326
conn = arg
326327
break
327-
if hasattr(arg, "connection"):
328+
if isinstance(arg, _BulkWriteContext):
328329
conn = arg.conn
329330
break
330331
if conn:

test/__init__.py

-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
TEST_SERVERLESS = bool(os.environ.get("TEST_SERVERLESS"))
9696
SINGLE_MONGOS_LB_URI = os.environ.get("SINGLE_MONGOS_LB_URI")
9797
MULTI_MONGOS_LB_URI = os.environ.get("MULTI_MONGOS_LB_URI")
98-
AUTH_MECH = os.environ.get("AUTH_MECH")
9998

10099
if TEST_LOADBALANCER:
101100
res = parse_uri(SINGLE_MONGOS_LB_URI or "")
@@ -278,8 +277,6 @@ def __init__(self):
278277
self.is_data_lake = False
279278
self.load_balancer = TEST_LOADBALANCER
280279
self.serverless = TEST_SERVERLESS
281-
if AUTH_MECH:
282-
self.default_client_options["authMechanism"] = AUTH_MECH
283280
if self.load_balancer or self.serverless:
284281
self.default_client_options["loadBalanced"] = True
285282
if COMPRESSORS:
@@ -347,7 +344,6 @@ def _connect(self, host, port, **kwargs):
347344

348345
def _init_client(self):
349346
self.client = self._connect(host, port)
350-
351347
if self.client is not None:
352348
# Return early when connected to dataLake as mongohoused does not
353349
# support the getCmdLineOpts command and is tested without TLS.

0 commit comments

Comments
 (0)