From 102dd8970c458a358b3cc36bfbe85590475db774 Mon Sep 17 00:00:00 2001 From: patrick-chinchill Date: Mon, 31 Aug 2026 18:18:52 -0700 Subject: [PATCH] test(teams): make the skip-auth fixture survive the SDK's flag rename microsoft-teams-apps 2.0.14+ renamed HttpServer.initialize's skip_auth keyword to dangerously_allow_unauthenticated_requests. The four test-side monkeypatches re-declared the old signature, so every Teams webhook test failed with 'unexpected keyword argument' as soon as CI resolved 2.0.16 (uv.lock is not tracked, so CI installs the latest matching 2.0.x). The fixtures now force whichever flag the installed SDK has and forward the rest untouched. Full suite green on both 2.0.13.4 and 2.0.16 (5147 passed). Claude-Session: https://claude.ai/code/session_01AxCf56kzyzW2AhTDoSc3wa --- tests/test_fixture_replay.py | 17 +++++++++++++++-- tests/test_teams_adapter.py | 17 +++++++++++++++-- tests/test_teams_coverage.py | 17 +++++++++++++++-- tests/test_teams_extended.py | 17 +++++++++++++++-- 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/tests/test_fixture_replay.py b/tests/test_fixture_replay.py index 3b28bdfd..076788ae 100644 --- a/tests/test_fixture_replay.py +++ b/tests/test_fixture_replay.py @@ -15,6 +15,7 @@ import hashlib import hmac +import inspect import json import time from typing import Any @@ -137,8 +138,20 @@ def _teams_skip_auth(): real_initialize = HttpServer.initialize - def _initialize_skip_auth(self, credentials=None, skip_auth=False, cloud=None): - return real_initialize(self, credentials=credentials, skip_auth=True, cloud=cloud) + # microsoft-teams-apps 2.0.14+ renamed the SDK's ``skip_auth`` flag to + # ``dangerously_allow_unauthenticated_requests``; force whichever flag this + # version has and forward everything else untouched (the SDK calls + # ``initialize`` with keywords only). + skip_flag = ( + "dangerously_allow_unauthenticated_requests" + if "dangerously_allow_unauthenticated_requests" in inspect.signature(real_initialize).parameters + else "skip_auth" + ) + + def _initialize_skip_auth(self, *args, **kwargs): + kwargs.pop("skip_auth", None) + kwargs.pop("dangerously_allow_unauthenticated_requests", None) + return real_initialize(self, *args, **{**kwargs, skip_flag: True}) return patch.object(HttpServer, "initialize", _initialize_skip_auth) diff --git a/tests/test_teams_adapter.py b/tests/test_teams_adapter.py index a70da72e..9f33190b 100644 --- a/tests/test_teams_adapter.py +++ b/tests/test_teams_adapter.py @@ -5,6 +5,7 @@ from __future__ import annotations +import inspect import re from datetime import datetime, timezone from unittest.mock import AsyncMock, MagicMock @@ -817,8 +818,20 @@ def _skip_jwt(self, monkeypatch): real_initialize = HttpServer.initialize - def _initialize_skip_auth(self, credentials=None, skip_auth=False, cloud=None): - return real_initialize(self, credentials=credentials, skip_auth=True, cloud=cloud) + # microsoft-teams-apps 2.0.14+ renamed the SDK's ``skip_auth`` flag to + # ``dangerously_allow_unauthenticated_requests``; force whichever flag this + # version has and forward everything else untouched (the SDK calls + # ``initialize`` with keywords only). + skip_flag = ( + "dangerously_allow_unauthenticated_requests" + if "dangerously_allow_unauthenticated_requests" in inspect.signature(real_initialize).parameters + else "skip_auth" + ) + + def _initialize_skip_auth(self, *args, **kwargs): + kwargs.pop("skip_auth", None) + kwargs.pop("dangerously_allow_unauthenticated_requests", None) + return real_initialize(self, *args, **{**kwargs, skip_flag: True}) monkeypatch.setattr(HttpServer, "initialize", _initialize_skip_auth) diff --git a/tests/test_teams_coverage.py b/tests/test_teams_coverage.py index 71675c5e..d6cfb89a 100644 --- a/tests/test_teams_coverage.py +++ b/tests/test_teams_coverage.py @@ -17,6 +17,7 @@ from __future__ import annotations +import inspect import json from typing import Any from unittest.mock import AsyncMock, MagicMock, patch @@ -57,8 +58,20 @@ def _skip_teams_jwt(monkeypatch): real_initialize = HttpServer.initialize - def _initialize_skip_auth(self, credentials=None, skip_auth=False, cloud=None): - return real_initialize(self, credentials=credentials, skip_auth=True, cloud=cloud) + # microsoft-teams-apps 2.0.14+ renamed the SDK's ``skip_auth`` flag to + # ``dangerously_allow_unauthenticated_requests``; force whichever flag this + # version has and forward everything else untouched (the SDK calls + # ``initialize`` with keywords only). + skip_flag = ( + "dangerously_allow_unauthenticated_requests" + if "dangerously_allow_unauthenticated_requests" in inspect.signature(real_initialize).parameters + else "skip_auth" + ) + + def _initialize_skip_auth(self, *args, **kwargs): + kwargs.pop("skip_auth", None) + kwargs.pop("dangerously_allow_unauthenticated_requests", None) + return real_initialize(self, *args, **{**kwargs, skip_flag: True}) monkeypatch.setattr(HttpServer, "initialize", _initialize_skip_auth) diff --git a/tests/test_teams_extended.py b/tests/test_teams_extended.py index 171d9195..5b057f06 100644 --- a/tests/test_teams_extended.py +++ b/tests/test_teams_extended.py @@ -15,6 +15,7 @@ from __future__ import annotations +import inspect import json from datetime import datetime from typing import Any @@ -63,8 +64,20 @@ def _skip_teams_jwt(monkeypatch): real_initialize = HttpServer.initialize - def _initialize_skip_auth(self, credentials=None, skip_auth=False, cloud=None): - return real_initialize(self, credentials=credentials, skip_auth=True, cloud=cloud) + # microsoft-teams-apps 2.0.14+ renamed the SDK's ``skip_auth`` flag to + # ``dangerously_allow_unauthenticated_requests``; force whichever flag this + # version has and forward everything else untouched (the SDK calls + # ``initialize`` with keywords only). + skip_flag = ( + "dangerously_allow_unauthenticated_requests" + if "dangerously_allow_unauthenticated_requests" in inspect.signature(real_initialize).parameters + else "skip_auth" + ) + + def _initialize_skip_auth(self, *args, **kwargs): + kwargs.pop("skip_auth", None) + kwargs.pop("dangerously_allow_unauthenticated_requests", None) + return real_initialize(self, *args, **{**kwargs, skip_flag: True}) monkeypatch.setattr(HttpServer, "initialize", _initialize_skip_auth)