Skip to content

Commit f047698

Browse files
authored
Added missing 'kind' field in TokenSource's serialized form (#209)
1 parent 6c25a78 commit f047698

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

azure/durable_functions/models/TokenSource.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ManagedIdentityTokenSource(TokenSource):
3232
def __init__(self, resource: str):
3333
super().__init__()
3434
self._resource: str = resource
35+
self._kind: str = "AzureManagedIdentity"
3536

3637
@property
3738
def resource(self) -> str:
@@ -51,4 +52,5 @@ def to_json(self) -> Dict[str, Union[str, int]]:
5152
"""
5253
json_dict: Dict[str, Union[str, int]] = {}
5354
add_attrib(json_dict, self, 'resource')
55+
json_dict["kind"] = self._kind
5456
return json_dict

tests/models/test_TokenSource.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from azure.durable_functions.models.TokenSource import ManagedIdentityTokenSource
2+
3+
def test_serialization_fields():
4+
"""Validates the TokenSource contains the expected fields when serialized to JSON"""
5+
token_source = ManagedIdentityTokenSource(resource="TOKEN_SOURCE")
6+
token_source_json = token_source.to_json()
7+
8+
# Output JSON should contain a resource field and a kind field set to `AzureManagedIdentity`
9+
assert "resource" in token_source_json.keys()
10+
assert "kind" in token_source_json.keys()
11+
assert token_source_json["kind"] == "AzureManagedIdentity"

0 commit comments

Comments
 (0)