Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure service bus: fix TypeError when using Managed Identities #1825

Merged
merged 4 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions kombu/transport/azureservicebus.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def parse_uri(uri: str) -> tuple[str, str | DefaultAzureCredential |
@classmethod
def as_uri(cls, uri: str, include_password=False, mask='**') -> str:
namespace, credential = cls.parse_uri(uri)
if ":" in credential:
if isinstance(credential, str) and ":" in credential:
policy, sas_key = credential.split(':', 1)
return 'azureservicebus://{}:{}@{}'.format(
policy,
Expand All @@ -490,6 +490,6 @@ def as_uri(cls, uri: str, include_password=False, mask='**') -> str:
)

return 'azureservicebus://{}@{}'.format(
credential,
credential.__class__.__name__,
namespace
)
18 changes: 18 additions & 0 deletions t/unit/transport/test_azureservicebus.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,21 @@ def test_basic_ack_reject_message_when_raises_exception(
assert mock_queue.channel._get_asb_receiver.call_count == 1
assert queue_object_mock.receiver.complete_message.call_count == 1
assert super_basic_reject.call_count == 1


def test_returning_sas():
conn = Connection(URL_CREDS_SAS, transport=azureservicebus.Transport)
print(conn.as_uri(True))
auvipy marked this conversation as resolved.
Show resolved Hide resolved
assert conn.as_uri(True) == URL_CREDS_SAS


def test_returning_da():
conn = Connection(URL_CREDS_DA, transport=azureservicebus.Transport)
print(conn.as_uri(True))
auvipy marked this conversation as resolved.
Show resolved Hide resolved
assert conn.as_uri(True) == URL_CREDS_DA


def test_returning_mi():
conn = Connection(URL_CREDS_MI, transport=azureservicebus.Transport)
print(conn.as_uri(True))
auvipy marked this conversation as resolved.
Show resolved Hide resolved
assert conn.as_uri(True) == URL_CREDS_MI