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

Revert "[Communication] - Phone Number Management - Added support for AAD auth" #16516

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ Caller must provide one of the following:
- Added `MicrosoftTeamsUserIdentifier`

##### `IdentityClient`
- Added support for Azure Active Directory authentication
- Added support for Azure Active Directory authentication for the Identity client


#### `PhoneNumberAdministrationClient`
- Added support for Azure Active Directory authentication
## 1.0.0b3 (2020-11-16)

### Breaking Changes
Expand Down
17 changes: 0 additions & 17 deletions sdk/communication/azure-communication-administration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@ pip install azure-communication-administration

## CommunicationPhoneNumberClient
### Initializing Phone Number Client
```python
# You can find your endpoint and access token from your resource in the Azure Portal
import os
from azure.communication.administration import PhoneNumberAdministrationClient
from azure.identity import DefaultAzureCredential

endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT')

# To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have your
# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables.
phone_number_administration_client = PhoneNumberAdministrationClient(endpoint, DefaultAzureCredential())

```
### Initializing Phone Number Client Using Connection String
Connection string authentication is also available for Phone Number Client.

```python
# You can find your endpoint and access token from your resource in the Azure Portal
import os
Expand All @@ -44,7 +28,6 @@ from azure.communication.administration import PhoneNumberAdministrationClient
connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING')
phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str)
```

### Phone plans overview

Phone plans come in two types; Geographic and Toll-Free. Geographic phone plans are phone plans associated with a location, whose phone numbers' area codes are associated with the area code of a geographic location. Toll-Free phone plans are phone plans not associated location. For example, in the US, toll-free numbers can come with area codes such as 800 or 888.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
UpdatePhoneNumberCapabilitiesResponse
)

from ._shared.utils import parse_connection_str, get_authentication_policy
from ._shared.utils import parse_connection_str
from ._shared.policy import HMACCredentialsPolicy
from ._version import SDK_MONIKER

class PhoneNumberAdministrationClient(object):
Expand Down Expand Up @@ -63,7 +64,7 @@ def __init__(
self._endpoint = endpoint
self._phone_number_administration_client = PhoneNumberAdministrationClientGen(
self._endpoint,
authentication_policy=get_authentication_policy(endpoint, credential),
authentication_policy=HMACCredentialsPolicy(endpoint, credential),
sdk_moniker=SDK_MONIKER,
**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
UpdatePhoneNumberCapabilitiesResponse
)

from .._shared.utils import parse_connection_str, get_authentication_policy
from .._shared.utils import parse_connection_str
from .._shared.policy import HMACCredentialsPolicy

class PhoneNumberAdministrationClient(object):
"""Azure Communication Services Phone Number Management client.
Expand Down Expand Up @@ -69,7 +70,7 @@ def __init__(
self._endpoint = endpoint
self._phone_number_administration_client = PhoneNumberAdministrationClientGen(
self._endpoint,
authentication_policy=get_authentication_policy(endpoint, credential, is_async=True),
authentication_policy=HMACCredentialsPolicy(endpoint, credential),
sdk_moniker=SDK_MONIKER,
**kwargs)

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
NumberUpdateCapabilities,
CreateSearchOptions
)
from azure.core.credentials import AccessToken
from phone_number_helper import PhoneNumberUriReplacer
from phone_number_testcase import PhoneNumberCommunicationTestCase
from _shared.testcase import BodyReplacerProcessor
from _shared.utils import create_token_credential
from azure.communication.administration._shared.utils import parse_connection_str

SKIP_PHONE_NUMBER_TESTS = True
PHONE_NUMBER_TEST_SKIP_REASON= "Phone Number Administration live tests infra not ready yet"

class PhoneNumberAdministrationClientTest(PhoneNumberCommunicationTestCase):

def setUp(self):
super(PhoneNumberAdministrationClientTest, self).setUp()
self.recording_processors.extend([
Expand Down Expand Up @@ -127,15 +125,6 @@ def setUp(self):
self.capabilities_id = "capabilities_id"
self.release_id = "release_id"

@pytest.mark.live_test_only
@pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON)
def test_list_all_phone_numbers_from_managed_identity(self):
endpoint, access_key = parse_connection_str(self.connection_str)
credential = create_token_credential()
phone_number_client = PhoneNumberAdministrationClient(endpoint, credential)
pages = phone_number_client.list_all_phone_numbers()
assert pages.next()

@pytest.mark.live_test_only
@pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON)
def test_list_all_phone_numbers(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# --------------------------------------------------------------------------
import pytest
from azure.communication.administration.aio import PhoneNumberAdministrationClient
from azure.communication.administration._shared.utils import parse_connection_str
from azure.communication.administration import (
PstnConfiguration,
NumberUpdateCapabilities,
Expand All @@ -15,7 +14,6 @@
from phone_number_helper import PhoneNumberUriReplacer
from phone_number_testcase_async import AsyncPhoneNumberCommunicationTestCase
from _shared.testcase import BodyReplacerProcessor, ResponseReplacerProcessor
from _shared.utils import create_token_credential
import os

SKIP_PHONE_NUMBER_TESTS = True
Expand Down Expand Up @@ -128,20 +126,6 @@ def setUp(self):
self.capabilities_id = "capabilities_id"
self.release_id = "release_id"

@AsyncPhoneNumberCommunicationTestCase.await_prepared_test
@pytest.mark.live_test_only
@pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON)
async def test_list_all_phone_numbers_from_managed_identity(self):
endpoint, access_key = parse_connection_str(self.connection_str)
credential = create_token_credential()
phone_number_client = PhoneNumberAdministrationClient(endpoint, credential)
async with phone_number_client:
pages = phone_number_client.list_all_phone_numbers()
items = []
async for item in pages:
items.append(item)
assert len(items) > 0

@AsyncPhoneNumberCommunicationTestCase.await_prepared_test
@pytest.mark.live_test_only
@pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON)
Expand Down