Skip to content

PYTHON-3909 Fix OIDC reauth for bulk write operations #1353

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

Merged
merged 6 commits into from
Aug 15, 2023
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
1 change: 0 additions & 1 deletion .evergreen/run-mongodb-oidc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ if [ -z "$PYTHON_BINARY" ]; then
fi

export TEST_AUTH_OIDC=1
export AUTH_MECH="SCRAM-SHA-256"
export AUTH="auth"
export SET_XTRACE_ON=1
bash ./.evergreen/tox.sh -m test-eg
3 changes: 2 additions & 1 deletion pymongo/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def _handle_exception() -> None:
def _handle_reauth(func: F) -> F:
def inner(*args: Any, **kwargs: Any) -> Any:
no_reauth = kwargs.pop("no_reauth", False)
from pymongo.message import _BulkWriteContext
from pymongo.pool import Connection

try:
Expand All @@ -324,7 +325,7 @@ def inner(*args: Any, **kwargs: Any) -> Any:
if isinstance(arg, Connection):
conn = arg
break
if hasattr(arg, "connection"):
if isinstance(arg, _BulkWriteContext):
conn = arg.conn
break
if conn:
Expand Down
4 changes: 0 additions & 4 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
TEST_SERVERLESS = bool(os.environ.get("TEST_SERVERLESS"))
SINGLE_MONGOS_LB_URI = os.environ.get("SINGLE_MONGOS_LB_URI")
MULTI_MONGOS_LB_URI = os.environ.get("MULTI_MONGOS_LB_URI")
AUTH_MECH = os.environ.get("AUTH_MECH")

if TEST_LOADBALANCER:
res = parse_uri(SINGLE_MONGOS_LB_URI or "")
Expand Down Expand Up @@ -278,8 +277,6 @@ def __init__(self):
self.is_data_lake = False
self.load_balancer = TEST_LOADBALANCER
self.serverless = TEST_SERVERLESS
if AUTH_MECH:
self.default_client_options["authMechanism"] = AUTH_MECH
if self.load_balancer or self.serverless:
self.default_client_options["loadBalanced"] = True
if COMPRESSORS:
Expand Down Expand Up @@ -347,7 +344,6 @@ def _connect(self, host, port, **kwargs):

def _init_client(self):
self.client = self._connect(host, port)

if self.client is not None:
# Return early when connected to dataLake as mongohoused does not
# support the getCmdLineOpts command and is tested without TLS.
Expand Down