FrankYang0529 commented on code in PR #68490:
URL: https://github.com/apache/airflow/pull/68490#discussion_r3407703479
##########
providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_wasb.py:
##########
@@ -361,10 +371,14 @@ def test_sas_token_connection(self, conn_id_str,
extra_key):
hook_conn = hook.get_connection(hook.conn_id)
sas_token = hook_conn.extra_dejson[extra_key]
assert isinstance(conn, BlobServiceClient)
- assert conn.url.startswith("https://")
- if hook_conn.login:
- assert hook_conn.login in conn.url
- assert conn.url.endswith(sas_token + "/")
+ if sas_token.startswith("https"):
+ # HTTPS SAS URL: the full URL is passed to BlobServiceClient as-is;
+ # credential handling is left to the SDK.
+ assert conn.url.startswith("https://")
+ else:
+ # Plain SAS token: the hook wraps it in AzureSasCredential.
+ assert isinstance(conn.credential, AzureSasCredential)
+ assert conn.credential.signature == sas_token
Review Comment:
> DO we need both branches?
Yes. The sas_token field accepts two forms, and `WasbHook.get_conn()`
handles them on two separate branches.
https://github.com/apache/airflow/blob/0823e7ad189379fd0e474473326121cdac938aa1/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py#L125
https://github.com/apache/airflow/blob/0823e7ad189379fd0e474473326121cdac938aa1/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py#L203-L206
> are there other test methods?
Partly. The bare-token → `AzureSasCredential path` is also covered by
`test_sas_token_provided_and_active_directory_id_used_as_host`. But the SAS url
(account url) path and the `extra__wasb__sas_token` key resolution are only
covered here, so dropping either branch would leave them untested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]