Skip to content
Merged
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 @@ -28,9 +28,9 @@

class ChatClientSamples(object):
from azure.communication.identity import CommunicationIdentityClient
connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None)
connection_string = os.environ.get("COMMUNICATION_SAMPLES_CONNECTION_STRING", None)
if not connection_string:
raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.")
raise ValueError("Set COMMUNICATION_SAMPLES_CONNECTION_STRING env before run this sample.")

identity_client = CommunicationIdentityClient.from_connection_string(connection_string)
user = identity_client.create_user()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

class ChatClientSamplesAsync(object):
from azure.communication.identity import CommunicationIdentityClient
connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None)
connection_string = os.environ.get("COMMUNICATION_SAMPLES_CONNECTION_STRING", None)
if not connection_string:
raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.")
raise ValueError("Set COMMUNICATION_SAMPLES_CONNECTION_STRING env before run this sample.")

identity_client = CommunicationIdentityClient.from_connection_string(connection_string)
user = identity_client.create_user()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class ChatThreadClientSamples(object):
ChatClient,
CommunicationTokenCredential
)
connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None)
connection_string = os.environ.get("COMMUNICATION_SAMPLES_CONNECTION_STRING", None)
if not connection_string:
raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.")
raise ValueError("Set COMMUNICATION_SAMPLES_CONNECTION_STRING env before run this sample.")

identity_client = CommunicationIdentityClient.from_connection_string(connection_string)
user = identity_client.create_user()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class ChatThreadClientSamplesAsync(object):
from azure.communication.chat.aio import ChatClient, CommunicationTokenCredential
from azure.communication.identity import CommunicationIdentityClient

connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None)
connection_string = os.environ.get("COMMUNICATION_SAMPLES_CONNECTION_STRING", None)
if not connection_string:
raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.")
raise ValueError("Set COMMUNICATION_SAMPLES_CONNECTION_STRING env before run this sample.")

identity_client = CommunicationIdentityClient.from_connection_string(connection_string)
user = identity_client.create_user()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def setUp(self):
if self.is_playback():
self.connection_str = "endpoint=https://sanitized/;accesskey=fake==="
else:
self.connection_str = os.getenv('COMMUNICATION_CONNECTION_STRING')
self.connection_str = os.getenv('COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING')
endpoint, _ = parse_connection_str(self.connection_str)
self._resource_name = endpoint.split(".")[0]
self.scrubber.register_name_pair(self._resource_name, "sanitized")
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
USAGE:
python identity_samples.py
Set the environment variables with your own values before running the sample:
2) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - the connection string in your ACS account
2) COMMUNICATION_SAMPLES_CONNECTION_STRING - the connection string in your ACS account
3) AZURE_CLIENT_ID - the client ID of your active directory application
4) AZURE_CLIENT_SECRET - the secret of your active directory application
5) AZURE_TENANT_ID - the tenant ID of your active directory application
Expand All @@ -25,7 +25,7 @@
class CommunicationIdentityClientSamples(object):

def __init__(self):
self.connection_string = os.getenv('COMMUNICATION_CONNECTION_STRING')
self.connection_string = os.getenv('COMMUNICATION_SAMPLES_CONNECTION_STRING')
self.client_id = os.getenv('AZURE_CLIENT_ID')
self.client_secret = os.getenv('AZURE_CLIENT_SECRET')
self.tenant_id = os.getenv('AZURE_TENANT_ID')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
python identity_samples_async.py
Set the environment variables with your own values before running the sample:
1) AZURE_COMMUNICATION_SERVICE_ENDPOINT - Communication Service endpoint url
2) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - the connection string in your ACS account
2) COMMUNICATION_SAMPLES_CONNECTION_STRING - the connection string in your ACS account
3) AZURE_CLIENT_ID - the client ID of your active directory application
4) AZURE_CLIENT_SECRET - the secret of your active directory application
5) AZURE_TENANT_ID - the tenant ID of your active directory application
Expand All @@ -28,7 +28,7 @@
class CommunicationIdentityClientSamples(object):

def __init__(self):
self.connection_string = os.getenv('COMMUNICATION_CONNECTION_STRING')
self.connection_string = os.getenv('COMMUNICATION_SAMPLES_CONNECTION_STRING')
self.endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT')
self.client_id = os.getenv('AZURE_CLIENT_ID')
self.client_secret = os.getenv('AZURE_CLIENT_SECRET')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

CommunicationPreparer = functools.partial(
PowerShellPreparer, "communication",
communication_connection_string="endpoint=https://sanitized.communication.azure.com/;accesskey=fake==="
communication_livetest_dynamic_connection_string="endpoint=https://sanitized.communication.azure.com/;accesskey=fake==="
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def setUp(self):
URIIdentityReplacer()])

@CommunicationPreparer()
def test_create_user_from_managed_identity(self, communication_connection_string):
endpoint, access_key = parse_connection_str(communication_connection_string)
def test_create_user_from_managed_identity(self, communication_livetest_dynamic_connection_string):
endpoint, access_key = parse_connection_str(communication_livetest_dynamic_connection_string)
from devtools_testutils import is_live
if not is_live():
credential = FakeTokenCredential()
Expand All @@ -51,17 +51,17 @@ def test_create_user_from_managed_identity(self, communication_connection_string
assert user.properties.get('id') is not None

@CommunicationPreparer()
def test_create_user(self, communication_connection_string):
def test_create_user(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)
user = identity_client.create_user()

@CommunicationPreparer()
def test_create_user_and_token(self, communication_connection_string):
def test_create_user_and_token(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)
user, token_response = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
Expand All @@ -70,8 +70,8 @@ def test_create_user_and_token(self, communication_connection_string):
assert token_response.token is not None

@CommunicationPreparer()
def test_get_token_from_managed_identity(self, communication_connection_string):
endpoint, access_key = parse_connection_str(communication_connection_string)
def test_get_token_from_managed_identity(self, communication_livetest_dynamic_connection_string):
endpoint, access_key = parse_connection_str(communication_livetest_dynamic_connection_string)
from devtools_testutils import is_live
if not is_live():
credential = FakeTokenCredential()
Expand All @@ -90,9 +90,9 @@ def test_get_token_from_managed_identity(self, communication_connection_string):
assert token_response.token is not None

@CommunicationPreparer()
def test_get_token(self, communication_connection_string):
def test_get_token(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)
user = identity_client.create_user()
Expand All @@ -103,8 +103,8 @@ def test_get_token(self, communication_connection_string):
assert token_response.token is not None

@CommunicationPreparer()
def test_revoke_tokens_from_managed_identity(self, communication_connection_string):
endpoint, access_key = parse_connection_str(communication_connection_string)
def test_revoke_tokens_from_managed_identity(self, communication_livetest_dynamic_connection_string):
endpoint, access_key = parse_connection_str(communication_livetest_dynamic_connection_string)
from devtools_testutils import is_live
if not is_live():
credential = FakeTokenCredential()
Expand All @@ -124,9 +124,9 @@ def test_revoke_tokens_from_managed_identity(self, communication_connection_stri
assert token_response.token is not None

@CommunicationPreparer()
def test_revoke_tokens(self, communication_connection_string):
def test_revoke_tokens(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)
user = identity_client.create_user()
Expand All @@ -138,8 +138,8 @@ def test_revoke_tokens(self, communication_connection_string):
assert token_response.token is not None

@CommunicationPreparer()
def test_delete_user_from_managed_identity(self, communication_connection_string):
endpoint, access_key = parse_connection_str(communication_connection_string)
def test_delete_user_from_managed_identity(self, communication_livetest_dynamic_connection_string):
endpoint, access_key = parse_connection_str(communication_livetest_dynamic_connection_string)
from devtools_testutils import is_live
if not is_live():
credential = FakeTokenCredential()
Expand All @@ -157,9 +157,9 @@ def test_delete_user_from_managed_identity(self, communication_connection_string
assert user.properties.get('id') is not None

@CommunicationPreparer()
def test_delete_user(self, communication_connection_string):
def test_delete_user(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)
user = identity_client.create_user()
Expand All @@ -169,49 +169,49 @@ def test_delete_user(self, communication_connection_string):
assert user.properties.get('id') is not None

@CommunicationPreparer()
def test_create_user_and_token_with_no_scopes(self, communication_connection_string):
def test_create_user_and_token_with_no_scopes(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)

with pytest.raises(Exception) as ex:
user, token_response = identity_client.create_user_and_token(scopes=None)

@CommunicationPreparer()
def test_delete_user_with_no_user(self, communication_connection_string):
def test_delete_user_with_no_user(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)

with pytest.raises(Exception) as ex:
identity_client.delete_user(user=None)

@CommunicationPreparer()
def test_revoke_tokens_with_no_user(self, communication_connection_string):
def test_revoke_tokens_with_no_user(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)

with pytest.raises(Exception) as ex:
identity_client.revoke_tokens(user=None)

@CommunicationPreparer()
def test_get_token_with_no_user(self, communication_connection_string):
def test_get_token_with_no_user(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)

with pytest.raises(Exception) as ex:
token_response = identity_client.get_token(user=None, scopes=[CommunicationTokenScope.CHAT])

@CommunicationPreparer()
def test_get_token_with_no_scopes(self, communication_connection_string):
def test_get_token_with_no_scopes(self, communication_livetest_dynamic_connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(
communication_connection_string,
communication_livetest_dynamic_connection_string,
http_logging_policy=get_http_logging_policy()
)
user = identity_client.create_user()
Expand Down
Loading