Skip to content

Commit

Permalink
Raise error when specifying 'tenant_id' in ctor of dac (#23322)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

Co-authored-by: McCoy Patiño <[email protected]>
  • Loading branch information
xiangyan99 and mccoyp authored Mar 4, 2022
1 parent 28785f7 commit c247151
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
15 changes: 5 additions & 10 deletions sdk/identity/azure-identity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# Release History

## 1.9.0b1 (Unreleased)
## 1.9.0b1 (2022-03-08)

### Features Added

- Added `validate_authority` support for msal client #22625
- Added `resource_id` support for user-assigned managed identity #22329
- Added `ClientAssertionCredential` support #22328

### Breaking Changes

### Bugs Fixed

### Other Changes
- Added `validate_authority` support for msal client ([#22625](https://github.com/Azure/azure-sdk-for-python/issues/22625))
- Added `resource_id` support for user-assigned managed identity ([#22329](https://github.com/Azure/azure-sdk-for-python/issues/22329))
- Added `ClientAssertionCredential` support ([#22328](https://github.com/Azure/azure-sdk-for-python/issues/22328))
- Updated App service API version to "2019-08-01" ([#23034](https://github.com/Azure/azure-sdk-for-python/issues/23034))

## 1.8.0 (2022-03-01)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class DefaultAzureCredential(ChainedTokenCredential):

def __init__(self, **kwargs):
# type: (**Any) -> None
if "tenant_id" in kwargs:
raise TypeError("'tenant_id' is not supported in DefaultAzureCredential.")

authority = kwargs.pop("authority", None)

vscode_tenant_id = kwargs.pop(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class DefaultAzureCredential(ChainedTokenCredential):
"""

def __init__(self, **kwargs: "Any") -> None:
if "tenant_id" in kwargs:
raise TypeError("'tenant_id' is not supported in DefaultAzureCredential.")

authority = kwargs.pop("authority", None)

vscode_tenant_id = kwargs.pop(
Expand Down
5 changes: 5 additions & 0 deletions sdk/identity/azure-identity/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,8 @@ def validate_client_id(credential):
def test_unexpected_kwarg():
"""the credential shouldn't raise when given an unexpected keyword argument"""
DefaultAzureCredential(foo=42)


def test_error_tenant_id():
with pytest.raises(TypeError):
DefaultAzureCredential(tenant_id="foo")
5 changes: 5 additions & 0 deletions sdk/identity/azure-identity/tests/test_default_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,8 @@ def get_credential_for_shared_cache_test(expected_refresh_token, expected_access
def test_unexpected_kwarg():
"""the credential shouldn't raise when given an unexpected keyword argument"""
DefaultAzureCredential(foo=42)


def test_error_tenant_id():
with pytest.raises(TypeError):
DefaultAzureCredential(tenant_id="foo")

0 comments on commit c247151

Please sign in to comment.