예제 #1
0
 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()
    def setUp(self):
        super(ChatThreadClientTestAsync, self).setUp()

        self.recording_processors.extend([
            BodyReplacerProcessor(keys=[
                "id", "token", "senderId", "chatMessageId", "nextLink",
                "members", "multipleStatus", "value"
            ]),
            URIIdentityReplacer(),
            ResponseReplacerProcessor(keys=[self._resource_name]),
            ChatURIReplacer()
        ])

        endpoint, _ = parse_connection_str(self.connection_str)
        self.endpoint = endpoint

        self.identity_client = CommunicationIdentityClient.from_connection_string(
            self.connection_str)

        # create user
        self.user = self.identity_client.create_user()
        token_response = self.identity_client.issue_token(self.user,
                                                          scopes=["chat"])
        self.token = token_response.token

        # create another user
        self.new_user = self.identity_client.create_user()

        # create ChatClient
        self.chat_client = ChatClient(self.endpoint,
                                      CommunicationUserCredential(self.token))
예제 #3
0
 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
예제 #4
0
    def test_create_user_from_managed_identity(self, connection_string):
        endpoint, access_key = parse_connection_str(connection_string)
        from devtools_testutils import is_live
        if not is_live():
            credential = FakeTokenCredential()
        else:
            credential = DefaultAzureCredential()
        identity_client = CommunicationIdentityClient(endpoint, credential)
        user = identity_client.create_user()

        assert user.identifier is not None
예제 #5
0
    def setUp(self):
        super(PhoneNumberCommunicationTestCase, self).setUp()

        if self.is_playback():
            self.connection_str = "endpoint=https://sanitized/;accesskey=fake==="
        else:
            self.connection_str = os.getenv(
                'AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING')
            endpoint, _ = parse_connection_str(self.connection_str)
            self._resource_name = endpoint.split(".")[0]
            self.scrubber.register_name_pair(self._resource_name, "sanitized")
예제 #6
0
    def test_issue_token_from_managed_identity(self, connection_string):
        endpoint, access_key = parse_connection_str(connection_string)
        from devtools_testutils import is_live
        if not is_live():
            credential = FakeTokenCredential()
        else:
            credential = DefaultAzureCredential()
        identity_client = CommunicationIdentityClient(endpoint, credential)
        user = identity_client.create_user()

        token_response = identity_client.issue_token(user, scopes=["chat"])

        assert user.identifier is not None
        assert token_response.token is not None
    def setUp(self):
        super(ChatClientTestAsync, self).setUp()

        self.recording_processors.extend([
            BodyReplacerProcessor(keys=["id", "token", "createdBy", "members", "multipleStatus", "value"]),
            URIIdentityReplacer(),
            ResponseReplacerProcessor(keys=[self._resource_name]),
            ChatURIReplacer()])

        endpoint, _ = parse_connection_str(self.connection_str)
        self.endpoint = endpoint

        self.identity_client = CommunicationIdentityClient.from_connection_string(self.connection_str)

        # create user
        self.user = self.identity_client.create_user()
        token_response = self.identity_client.issue_token(self.user, scopes=["chat"])
        self.token = token_response.token

        # create ChatClient
        refresh_options = CommunicationTokenRefreshOptions(self.token)
        self.chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(refresh_options))