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
2 changes: 2 additions & 0 deletions azure/durable_functions/models/TokenSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ManagedIdentityTokenSource(TokenSource):
def __init__(self, resource: str):
super().__init__()
self._resource: str = resource
self._kind: str = "AzureManagedIdentity"

@property
def resource(self) -> str:
Expand All @@ -51,4 +52,5 @@ def to_json(self) -> Dict[str, Union[str, int]]:
"""
json_dict: Dict[str, Union[str, int]] = {}
add_attrib(json_dict, self, 'resource')
json_dict["kind"] = self._kind
return json_dict
11 changes: 11 additions & 0 deletions tests/models/test_TokenSource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from azure.durable_functions.models.TokenSource import ManagedIdentityTokenSource

def test_serialization_fields():
"""Validates the TokenSource contains the expected fields when serialized to JSON"""
token_source = ManagedIdentityTokenSource(resource="TOKEN_SOURCE")
token_source_json = token_source.to_json()

# Output JSON should contain a resource field and a kind field set to `AzureManagedIdentity`
assert "resource" in token_source_json.keys()
assert "kind" in token_source_json.keys()
assert token_source_json["kind"] == "AzureManagedIdentity"