diff --git a/sdk/cosmos/azure-cosmos/test/test_config.py b/sdk/cosmos/azure-cosmos/test/test_config.py index 7334d7f7a88a..80102a84cde0 100644 --- a/sdk/cosmos/azure-cosmos/test/test_config.py +++ b/sdk/cosmos/azure-cosmos/test/test_config.py @@ -27,10 +27,10 @@ class TestConfig(object): - local_host = 'https://localhost:8081/' + local_host = 'https://localhost:8081/' # Will need to change this to your account endpoint if you're not running the emulator # [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Cosmos DB Emulator Key")] masterKey = os.getenv('ACCOUNT_KEY', - 'C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==') + 'C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==') # Will need to change this to your account key if you're not running the emulator host = os.getenv('ACCOUNT_HOST', local_host) connection_str = os.getenv('ACCOUNT_CONNECTION_STR', 'AccountEndpoint={};AccountKey={};'.format(host, masterKey)) diff --git a/sdk/cosmos/azure-cosmos/test/test_crud.py b/sdk/cosmos/azure-cosmos/test/test_crud.py index a96654cec6c0..9df8275f3059 100644 --- a/sdk/cosmos/azure-cosmos/test/test_crud.py +++ b/sdk/cosmos/azure-cosmos/test/test_crud.py @@ -27,6 +27,7 @@ from azure.cosmos import _retry_utility from azure.cosmos.http_constants import HttpHeaders, StatusCodes from azure.cosmos.partition_key import PartitionKey +from azure.identity import DefaultAzureCredential class TimeoutTransport(RequestsTransport): @@ -81,7 +82,8 @@ def setUpClass(cls): "You must specify your Azure Cosmos account values for " "'masterKey' and 'host' at the top of this class to run the " "tests.") - cls.client = cosmos_client.CosmosClient(cls.host, cls.masterKey) + credentials = DefaultAzureCredential() + cls.client = cosmos_client.CosmosClient(cls.host, credentials) cls.databaseForTest = cls.client.get_database_client(cls.configs.TEST_DATABASE_ID) def test_database_crud(self): diff --git a/sdk/cosmos/azure-cosmos/test/test_crud_async.py b/sdk/cosmos/azure-cosmos/test/test_crud_async.py index 00517d23ef8e..06c47c6a8fd8 100644 --- a/sdk/cosmos/azure-cosmos/test/test_crud_async.py +++ b/sdk/cosmos/azure-cosmos/test/test_crud_async.py @@ -25,6 +25,7 @@ from azure.cosmos.aio import CosmosClient, _retry_utility_async, DatabaseProxy from azure.cosmos.http_constants import HttpHeaders, StatusCodes from azure.cosmos.partition_key import PartitionKey +from azure.identity.aio import DefaultAzureCredential class TimeoutTransport(AsyncioRequestsTransport): @@ -82,7 +83,8 @@ def setUpClass(cls): "tests.") async def asyncSetUp(self): - self.client = CosmosClient(self.host, self.masterKey) + credentials = DefaultAzureCredential() + self.client = CosmosClient(self.host, credentials) self.database_for_test = self.client.get_database_client(self.configs.TEST_DATABASE_ID) async def asyncTearDown(self):