Skip to content

Commit c247151

Browse files
xiangyan99mccoyp
andauthored
Raise error when specifying 'tenant_id' in ctor of dac (Azure#23322)
* Raise error when specifying 'tenant_id' in ctor of dac * update * add tests * Update sdk/identity/azure-identity/azure/identity/_credentials/default.py Co-authored-by: McCoy Patiño <39780829+mccoyp@users.noreply.github.com> Co-authored-by: McCoy Patiño <39780829+mccoyp@users.noreply.github.com>
1 parent 28785f7 commit c247151

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

sdk/identity/azure-identity/CHANGELOG.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
# Release History
22

3-
## 1.9.0b1 (Unreleased)
3+
## 1.9.0b1 (2022-03-08)
44

55
### Features Added
66

7-
- Added `validate_authority` support for msal client #22625
8-
- Added `resource_id` support for user-assigned managed identity #22329
9-
- Added `ClientAssertionCredential` support #22328
10-
11-
### Breaking Changes
12-
13-
### Bugs Fixed
14-
15-
### Other Changes
7+
- Added `validate_authority` support for msal client ([#22625](https://github.com/Azure/azure-sdk-for-python/issues/22625))
8+
- Added `resource_id` support for user-assigned managed identity ([#22329](https://github.com/Azure/azure-sdk-for-python/issues/22329))
9+
- Added `ClientAssertionCredential` support ([#22328](https://github.com/Azure/azure-sdk-for-python/issues/22328))
10+
- Updated App service API version to "2019-08-01" ([#23034](https://github.com/Azure/azure-sdk-for-python/issues/23034))
1611

1712
## 1.8.0 (2022-03-01)
1813

sdk/identity/azure-identity/azure/identity/_credentials/default.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ class DefaultAzureCredential(ChainedTokenCredential):
8181

8282
def __init__(self, **kwargs):
8383
# type: (**Any) -> None
84+
if "tenant_id" in kwargs:
85+
raise TypeError("'tenant_id' is not supported in DefaultAzureCredential.")
86+
8487
authority = kwargs.pop("authority", None)
8588

8689
vscode_tenant_id = kwargs.pop(

sdk/identity/azure-identity/azure/identity/aio/_credentials/default.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ class DefaultAzureCredential(ChainedTokenCredential):
6868
"""
6969

7070
def __init__(self, **kwargs: "Any") -> None:
71+
if "tenant_id" in kwargs:
72+
raise TypeError("'tenant_id' is not supported in DefaultAzureCredential.")
73+
7174
authority = kwargs.pop("authority", None)
7275

7376
vscode_tenant_id = kwargs.pop(

sdk/identity/azure-identity/tests/test_default.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,8 @@ def validate_client_id(credential):
405405
def test_unexpected_kwarg():
406406
"""the credential shouldn't raise when given an unexpected keyword argument"""
407407
DefaultAzureCredential(foo=42)
408+
409+
410+
def test_error_tenant_id():
411+
with pytest.raises(TypeError):
412+
DefaultAzureCredential(tenant_id="foo")

sdk/identity/azure-identity/tests/test_default_async.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,8 @@ def get_credential_for_shared_cache_test(expected_refresh_token, expected_access
315315
def test_unexpected_kwarg():
316316
"""the credential shouldn't raise when given an unexpected keyword argument"""
317317
DefaultAzureCredential(foo=42)
318+
319+
320+
def test_error_tenant_id():
321+
with pytest.raises(TypeError):
322+
DefaultAzureCredential(tenant_id="foo")

0 commit comments

Comments
 (0)