Skip to content
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
17 changes: 15 additions & 2 deletions tests/test_fixture_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import hashlib
import hmac
import inspect
import json
import time
from typing import Any
Expand Down Expand Up @@ -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)

Expand Down
17 changes: 15 additions & 2 deletions tests/test_teams_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import annotations

import inspect
import re
from datetime import datetime, timezone
from unittest.mock import AsyncMock, MagicMock
Expand Down Expand Up @@ -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)

Expand Down
17 changes: 15 additions & 2 deletions tests/test_teams_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from __future__ import annotations

import inspect
import json
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
Expand Down Expand Up @@ -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)

Expand Down
17 changes: 15 additions & 2 deletions tests/test_teams_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from __future__ import annotations

import inspect
import json
from datetime import datetime
from typing import Any
Expand Down Expand Up @@ -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)

Expand Down
Loading