Skip to content

Commit 3b67ba8

Browse files
committed
merge
1 parent 919cc84 commit 3b67ba8

File tree

7 files changed

+117
-16
lines changed

7 files changed

+117
-16
lines changed

packages/api/src/microsoft/teams/api/auth/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
Licensed under the MIT License.
44
"""
55

6-
from .caller import CALLER_IDS, CallerType
6+
from .caller import CallerIds, CallerType
77
from .credentials import ClientCredentials, Credentials, TokenCredentials
88
from .json_web_token import JsonWebToken, JsonWebTokenPayload
99
from .token import IToken
1010

1111
__all__ = [
12-
"CALLER_IDS",
12+
"CallerIds",
1313
"CallerType",
1414
"ClientCredentials",
1515
"Credentials",

packages/api/src/microsoft/teams/api/auth/caller.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
Licensed under the MIT License.
44
"""
55

6+
from enum import Enum
67
from typing import Literal
78

8-
CallerType = Literal["azure", "gov", "bot"]
99

10-
CALLER_IDS = {
11-
"azure": "urn:botframework:azure",
12-
"gov": "urn:botframework:azureusgov",
13-
"bot": "urn:botframework:aadappid",
14-
}
10+
class CallerIds(str, Enum):
11+
"""Enum for caller ID types."""
12+
13+
AZURE = "azure"
14+
GOV = "gov"
15+
BOT = "bot"
16+
17+
18+
CallerType = Literal["azure", "gov", "bot"]

packages/api/src/microsoft/teams/api/auth/credentials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from typing import Awaitable, Callable, Optional, Union
77

8-
from ..custom_base_model import CustomBaseModel
8+
from ..models import CustomBaseModel
99

1010

1111
class ClientCredentials(CustomBaseModel):

packages/api/src/microsoft/teams/api/auth/json_web_token.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import jwt
1010
from pydantic import BaseModel, ConfigDict
1111

12-
from .caller import CALLER_IDS, CallerType
12+
from .caller import CallerIds, CallerType
1313
from .token import IToken
1414

1515

@@ -100,8 +100,8 @@ def from_(self) -> CallerType:
100100
def from_id(self) -> str:
101101
"""The id of the activity sender."""
102102
if self.from_ == "bot":
103-
return f"{CALLER_IDS['bot']}:{self.app_id}"
104-
return CALLER_IDS["azure"]
103+
return f"{CallerIds.BOT}:{self.app_id}"
104+
return CallerIds.AZURE
105105

106106
@property
107107
def expiration(self) -> Optional[int]:

packages/api/src/microsoft/teams/api/clients/bot/token_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from microsoft.teams.common.http import Client, ClientOptions
1010

1111
from ...auth import Credentials, TokenCredentials
12+
from ...models import CustomBaseModel
1213
from ..base_client import BaseClient
1314

1415

packages/api/tests/unit/test_json_web_token.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
import jwt
7-
from microsoft.teams.api.auth import CALLER_IDS, JsonWebToken
7+
from microsoft.teams.api.auth import CallerIds, JsonWebToken
88

99

1010
def build_token(token_payload: str):
@@ -39,7 +39,7 @@ def test_should_be_from_bot(self):
3939
assert token.tenant_id == "789"
4040
assert token.version is None
4141
assert token.from_ == "bot"
42-
assert token.from_id == f"{CALLER_IDS['bot']}:test"
42+
assert token.from_id == f"{CallerIds.BOT}:test"
4343
assert token.service_url == "https://smba.test.com"
4444
assert str(token) == str_token
4545

@@ -55,7 +55,7 @@ def test_should_be_from_azure(self):
5555
assert token is not None
5656
assert token.app_id == ""
5757
assert token.from_ == "azure"
58-
assert token.from_id == CALLER_IDS["azure"]
58+
assert token.from_id == CallerIds.AZURE
5959
assert token.service_url == "https://smba.test.com"
6060

6161
def test_should_have_default_service_url(self):
@@ -68,7 +68,7 @@ def test_should_have_default_service_url(self):
6868
assert token is not None
6969
assert token.app_id == ""
7070
assert token.from_ == "azure"
71-
assert token.from_id == CALLER_IDS["azure"]
71+
assert token.from_id == CallerIds.AZURE
7272
assert token.service_url == "https://smba.trafficmanager.net/teams"
7373

7474
def test_expiration_handling(self):

uv.lock

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)