From 72977e1161e868b9eaae55f19a7ddff514e012c5 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 8 Sep 2026 09:46:37 -0700 Subject: [PATCH 1/6] fixing key isolation --- .../assets.json | 2 +- .../key_vault/test_async_secret_refresh.py | 49 ++-- .../tests/aio/test_async_provider_refresh.py | 266 ++++++++---------- .../tests/key_vault/test_secret_refresh.py | 50 ++-- .../tests/test_provider_refresh.py | 251 ++++++++--------- 5 files changed, 278 insertions(+), 340 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json index 712bcd27c378..7335b2f84ff1 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/appconfiguration/azure-appconfiguration-provider", - "Tag": "python/appconfiguration/azure-appconfiguration-provider_05f22217b9" + "Tag": "python/appconfiguration/azure-appconfiguration-provider_293f160543" } diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py index 0b485c103ee5..6836a3f08d0e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py @@ -10,6 +10,7 @@ from devtools_testutils import EnvironmentVariableLoader from devtools_testutils.aio import recorded_by_proxy_async from asynctestcase import AppConfigTestCase +from testcase import create_secret_config_setting from test_constants import ( APPCONFIGURATION_ENDPOINT_STRING, APPCONFIGURATION_KEYVAULT_SECRET_URL, @@ -82,35 +83,28 @@ async def test_secret_refresh_with_updated_values( ): """Test that secrets are refreshed with updated values.""" mock_callback = Mock() - - # Create client with the mock secret resolver - client = await self.create_client( - endpoint=appconfiguration_endpoint_string, - selects={SettingSelector(key_filter="*", label_filter="prod")}, - keyvault_secret_url=appconfiguration_keyvault_secret_url, - keyvault_secret_url2=appconfiguration_keyvault_secret_url2, - on_refresh_success=mock_callback, - refresh_on=[WatchKey("secret", "prod")], - refresh_interval=1, - secret_refresh_interval=1, # Using a short interval for testing - ) - - # Add a key vault reference to the client (this will use mock resolver) + secret_key = f"{self.get_resource_name('test')}-secret" appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) - - # Get and modify a key vault reference setting - kv_setting = await appconfig_client.get_configuration_setting(key="secret", label="prod") - assert kv_setting is not None - - # Verify initial value from mock resolver - assert client["secret"] == "Very secret value" - assert kv_setting is not None - assert isinstance(kv_setting, SecretReferenceConfigurationSetting) - # Update the secret_id (which is the value for SecretReferenceConfigurationSetting) - kv_setting.secret_id = appconfiguration_keyvault_secret_url2 + kv_setting = create_secret_config_setting(secret_key, "prod", appconfiguration_keyvault_secret_url) await appconfig_client.set_configuration_setting(kv_setting) try: + client = await self.create_client( + endpoint=appconfiguration_endpoint_string, + selects={SettingSelector(key_filter=secret_key, label_filter="prod")}, + keyvault_secret_url=appconfiguration_keyvault_secret_url, + keyvault_secret_url2=appconfiguration_keyvault_secret_url2, + on_refresh_success=mock_callback, + refresh_on=[WatchKey(secret_key, "prod")], + refresh_interval=1, + secret_refresh_interval=1, + ) + + assert client[secret_key] == "Very secret value" + assert isinstance(kv_setting, SecretReferenceConfigurationSetting) + kv_setting.secret_id = appconfiguration_keyvault_secret_url2 + await appconfig_client.set_configuration_setting(kv_setting) + # Expire the refresh timers to simulate time passing client._refresh_timer._next_refresh_time = 0 client._secret_provider.secret_refresh_timer._next_refresh_time = 0 @@ -119,11 +113,10 @@ async def test_secret_refresh_with_updated_values( await client.refresh() # Verify the value was updated - assert client["secret"] == "Very secret value 2" + assert client[secret_key] == "Very secret value 2" assert mock_callback.call_count >= 1 finally: - kv_setting.secret_id = appconfiguration_keyvault_secret_url - await appconfig_client.set_configuration_setting(kv_setting) + await appconfig_client.delete_configuration_setting(key=secret_key, label="prod") @AppConfigProviderPreparer() @recorded_by_proxy_async diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_refresh.py index 4c95caa94cd9..bdf92df521c2 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_refresh.py @@ -17,8 +17,8 @@ APPCONFIGURATION_KEYVAULT_SECRET_URL, FEATURE_MANAGEMENT_KEY, ) -from azure.appconfiguration import ConfigurationSetting -from azure.appconfiguration.provider import WatchKey +from azure.appconfiguration import ConfigurationSetting, FeatureFlagConfigurationSetting +from azure.appconfiguration.provider import SettingSelector, WatchKey AppConfigProviderPreparer = functools.partial( EnvironmentVariableLoader, @@ -39,71 +39,67 @@ class TestAppConfigurationProvider(AppConfigTestCase, unittest.TestCase): @pytest.mark.asyncio async def test_refresh(self, appconfiguration_endpoint_string, appconfiguration_keyvault_secret_url): mock_callback = Mock() - async with await self.create_client( - endpoint=appconfiguration_endpoint_string, - keyvault_secret_url=appconfiguration_keyvault_secret_url, - refresh_on=[WatchKey("refresh_message")], - refresh_interval=1, - on_refresh_success=mock_callback, - feature_flag_enabled=True, - feature_flag_refresh_enabled=True, - ) as client: - assert client["refresh_message"] == "original value" - assert client["my_json"]["key"] == "value" - assert FEATURE_MANAGEMENT_KEY in client - assert has_feature_flag(client, "Alpha") - - appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) - - setting = await appconfig_client.get_configuration_setting(key="refresh_message") - setting.value = "updated value" - feature_flag = await appconfig_client.get_configuration_setting(key=".appconfig.featureflag/Alpha") - feature_flag.enabled = True - await appconfig_client.set_configuration_setting(setting) - await appconfig_client.set_configuration_setting(feature_flag) - - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - client._feature_flag_refresh_timer._next_refresh_time = 0 - - await client.refresh() - assert client["refresh_message"] == "updated value" - assert has_feature_flag(client, "Alpha", True) - assert mock_callback.call_count == 1 - - setting.value = "original value" - feature_flag.enabled = False - await appconfig_client.set_configuration_setting(setting) - await appconfig_client.set_configuration_setting(feature_flag) - - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - client._feature_flag_refresh_timer._next_refresh_time = 0 - - await client.refresh() - assert client["refresh_message"] == "original value" - assert has_feature_flag(client, "Alpha", False) - assert mock_callback.call_count == 2 - - setting.value = "updated value 2" - feature_flag.enabled = True - await appconfig_client.set_configuration_setting(setting) - await appconfig_client.set_configuration_setting(feature_flag) - - # Not waiting for the refresh interval to pass - await client.refresh() - assert client["refresh_message"] == "original value" - assert has_feature_flag(client, "Alpha", False) - assert mock_callback.call_count == 2 - - setting.value = "original value" - feature_flag.enabled = False - await appconfig_client.set_configuration_setting(setting) - await appconfig_client.set_configuration_setting(feature_flag) - - await client.refresh() - assert client["refresh_message"] == "original value" - assert mock_callback.call_count == 2 + appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) + test_prefix = self.get_resource_name("test") + refresh_key = f"{test_prefix}-refresh-message" + feature_id = f"{test_prefix}-alpha" + setting = ConfigurationSetting(key=refresh_key, value="original value") + feature_flag = FeatureFlagConfigurationSetting(feature_id=feature_id, enabled=False) + await appconfig_client.set_configuration_setting(setting) + await appconfig_client.set_configuration_setting(feature_flag) + + try: + async with await self.create_client( + endpoint=appconfiguration_endpoint_string, + keyvault_secret_url=appconfiguration_keyvault_secret_url, + selects=[SettingSelector(key_filter=refresh_key)], + refresh_on=[WatchKey(refresh_key)], + refresh_interval=1, + on_refresh_success=mock_callback, + feature_flag_enabled=True, + feature_flag_refresh_enabled=True, + feature_flag_selectors=[SettingSelector(key_filter=feature_id)], + ) as client: + assert client[refresh_key] == "original value" + assert FEATURE_MANAGEMENT_KEY in client + assert has_feature_flag(client, feature_id) + + setting.value = "updated value" + feature_flag.enabled = True + await appconfig_client.set_configuration_setting(setting) + await appconfig_client.set_configuration_setting(feature_flag) + + client._refresh_timer._next_refresh_time = 0 + client._feature_flag_refresh_timer._next_refresh_time = 0 + await client.refresh() + assert client[refresh_key] == "updated value" + assert has_feature_flag(client, feature_id, True) + assert mock_callback.call_count == 1 + + setting.value = "original value" + feature_flag.enabled = False + await appconfig_client.set_configuration_setting(setting) + await appconfig_client.set_configuration_setting(feature_flag) + + client._refresh_timer._next_refresh_time = 0 + client._feature_flag_refresh_timer._next_refresh_time = 0 + await client.refresh() + assert client[refresh_key] == "original value" + assert has_feature_flag(client, feature_id, False) + assert mock_callback.call_count == 2 + + setting.value = "updated value 2" + feature_flag.enabled = True + await appconfig_client.set_configuration_setting(setting) + await appconfig_client.set_configuration_setting(feature_flag) + + await client.refresh() + assert client[refresh_key] == "original value" + assert has_feature_flag(client, feature_id, False) + assert mock_callback.call_count == 2 + finally: + await appconfig_client.delete_configuration_setting(key=refresh_key) + await appconfig_client.delete_configuration_setting(key=feature_flag.key) # method: refresh @AppConfigProviderPreparer() @@ -111,57 +107,43 @@ async def test_refresh(self, appconfiguration_endpoint_string, appconfiguration_ @pytest.mark.skipif(sys.version_info < (3, 8), reason="Python 3.7 does not support AsyncMock") @pytest.mark.asyncio async def test_no_refresh(self, appconfiguration_endpoint_string, appconfiguration_keyvault_secret_url): - appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) - - watch_key = ConfigurationSetting(key="watch key", value="0") + test_prefix = self.get_resource_name("test") + refresh_key = f"{test_prefix}-refresh-message" + watch_key_name = f"{test_prefix}-watch-key" + setting = ConfigurationSetting(key=refresh_key, value="original value") + watch_key = ConfigurationSetting(key=watch_key_name, value="0") + await appconfig_client.set_configuration_setting(setting) await appconfig_client.set_configuration_setting(watch_key) mock_callback = Mock() - async with await self.create_client( - endpoint=appconfiguration_endpoint_string, - keyvault_secret_url=appconfiguration_keyvault_secret_url, - refresh_on=[WatchKey("watch key")], - refresh_interval=1, - on_refresh_success=mock_callback, - feature_flag_enabled=True, - feature_flag_refresh_enabled=True, - ) as client: - assert client["refresh_message"] == "original value" - assert client["my_json"]["key"] == "value" - assert FEATURE_MANAGEMENT_KEY in client - assert has_feature_flag(client, "Alpha") - - setting = await appconfig_client.get_configuration_setting(key="refresh_message") - setting.value = "updated value" - await appconfig_client.set_configuration_setting(setting) - - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - client._feature_flag_refresh_timer._next_refresh_time = 0 - - await client.refresh() - # No Change the Watch Key wasn't updated - assert client["refresh_message"] == "original value" - assert has_feature_flag(client, "Alpha", False) - assert mock_callback.call_count == 0 - - watch_key.value = "1" - await appconfig_client.set_configuration_setting(watch_key) - - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - client._feature_flag_refresh_timer._next_refresh_time = 0 - - await client.refresh() - assert client["refresh_message"] == "updated value" - assert has_feature_flag(client, "Alpha", False) - assert mock_callback.call_count == 1 - - # Reset modified settings - setting.value = "original value" - await appconfig_client.set_configuration_setting(setting) - await appconfig_client.delete_configuration_setting(key="watch key") + try: + async with await self.create_client( + endpoint=appconfiguration_endpoint_string, + keyvault_secret_url=appconfiguration_keyvault_secret_url, + selects=[SettingSelector(key_filter=refresh_key)], + refresh_on=[WatchKey(watch_key_name)], + refresh_interval=1, + on_refresh_success=mock_callback, + ) as client: + assert client[refresh_key] == "original value" + + setting.value = "updated value" + await appconfig_client.set_configuration_setting(setting) + client._refresh_timer._next_refresh_time = 0 + await client.refresh() + assert client[refresh_key] == "original value" + assert mock_callback.call_count == 0 + + watch_key.value = "1" + await appconfig_client.set_configuration_setting(watch_key) + client._refresh_timer._next_refresh_time = 0 + await client.refresh() + assert client[refresh_key] == "updated value" + assert mock_callback.call_count == 1 + finally: + await appconfig_client.delete_configuration_setting(key=refresh_key) + await appconfig_client.delete_configuration_setting(key=watch_key_name) @AppConfigProviderPreparer() @recorded_by_proxy_async @@ -169,37 +151,31 @@ async def test_no_refresh(self, appconfiguration_endpoint_string, appconfigurati @pytest.mark.asyncio async def test_refresh_disabled(self, appconfiguration_endpoint_string, appconfiguration_keyvault_secret_url): mock_callback = AsyncMock() - async with await self.create_client( - endpoint=appconfiguration_endpoint_string, - keyvault_secret_url=appconfiguration_keyvault_secret_url, - refresh_on=[WatchKey("refresh_message")], - refresh_interval=1, - on_refresh_success=mock_callback, - feature_flag_enabled=True, - feature_flag_refresh_enabled=True, - refresh_enabled=False, - ) as client: - assert client["refresh_message"] == "original value" - assert client["my_json"]["key"] == "value" - assert FEATURE_MANAGEMENT_KEY in client - assert has_feature_flag(client, "Alpha") - - appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) - - setting = await appconfig_client.get_configuration_setting(key="refresh_message") - setting.value = "updated value" - await appconfig_client.set_configuration_setting(setting) - - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - - await client.refresh() - # Refresh is disabled, so the value should not change - assert client["refresh_message"] == "original value" - assert mock_callback.call_count == 0 - - setting.value = "original value" - await appconfig_client.set_configuration_setting(setting) + appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) + refresh_key = f"{self.get_resource_name('test')}-refresh-message" + setting = ConfigurationSetting(key=refresh_key, value="original value") + await appconfig_client.set_configuration_setting(setting) + + try: + async with await self.create_client( + endpoint=appconfiguration_endpoint_string, + keyvault_secret_url=appconfiguration_keyvault_secret_url, + selects=[SettingSelector(key_filter=refresh_key)], + refresh_on=[WatchKey(refresh_key)], + refresh_interval=1, + on_refresh_success=mock_callback, + refresh_enabled=False, + ) as client: + assert client[refresh_key] == "original value" + + setting.value = "updated value" + await appconfig_client.set_configuration_setting(setting) + client._refresh_timer._next_refresh_time = 0 + await client.refresh() + assert client[refresh_key] == "original value" + assert mock_callback.call_count == 0 + finally: + await appconfig_client.delete_configuration_setting(key=refresh_key) except ImportError: pass diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py index 4934334ce27d..9686c430830e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py @@ -8,7 +8,7 @@ import unittest from unittest.mock import Mock, patch from devtools_testutils import EnvironmentVariableLoader, recorded_by_proxy -from testcase import AppConfigTestCase +from testcase import AppConfigTestCase, create_secret_config_setting from test_constants import ( APPCONFIGURATION_ENDPOINT_STRING, APPCONFIGURATION_KEYVAULT_SECRET_URL, @@ -75,35 +75,28 @@ def test_secret_refresh_with_updated_values( ): """Test that secrets are refreshed with updated values.""" mock_callback = Mock() - - # Create client with the mock secret resolver - client = self.create_client( - endpoint=appconfiguration_endpoint_string, - selects={SettingSelector(key_filter="*", label_filter="prod")}, - keyvault_secret_url=appconfiguration_keyvault_secret_url, - keyvault_secret_url2=appconfiguration_keyvault_secret_url2, - on_refresh_success=mock_callback, - refresh_on=[WatchKey("secret", "prod")], - refresh_interval=1, - secret_refresh_interval=1, # Using a short interval for testing - ) - - # Add a key vault reference to the client (this will use mock resolver) + secret_key = f"{self.get_resource_name('test')}-secret" appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) - - # Get and modify a key vault reference setting - kv_setting = appconfig_client.get_configuration_setting(key="secret", label="prod") - assert kv_setting is not None - - # Verify initial value from mock resolver - assert client["secret"] == "Very secret value" - assert kv_setting is not None - assert isinstance(kv_setting, SecretReferenceConfigurationSetting) - # Update the secret_id (which is the value for SecretReferenceConfigurationSetting) - kv_setting.secret_id = appconfiguration_keyvault_secret_url2 + kv_setting = create_secret_config_setting(secret_key, "prod", appconfiguration_keyvault_secret_url) appconfig_client.set_configuration_setting(kv_setting) try: + client = self.create_client( + endpoint=appconfiguration_endpoint_string, + selects={SettingSelector(key_filter=secret_key, label_filter="prod")}, + keyvault_secret_url=appconfiguration_keyvault_secret_url, + keyvault_secret_url2=appconfiguration_keyvault_secret_url2, + on_refresh_success=mock_callback, + refresh_on=[WatchKey(secret_key, "prod")], + refresh_interval=1, + secret_refresh_interval=1, + ) + + assert client[secret_key] == "Very secret value" + assert isinstance(kv_setting, SecretReferenceConfigurationSetting) + kv_setting.secret_id = appconfiguration_keyvault_secret_url2 + appconfig_client.set_configuration_setting(kv_setting) + # Expire the refresh timers to simulate time passing client._refresh_timer._next_refresh_time = 0 client._secret_provider.secret_refresh_timer._next_refresh_time = 0 @@ -112,11 +105,10 @@ def test_secret_refresh_with_updated_values( client.refresh() # Verify the value was updated - assert client["secret"] == "Very secret value 2" + assert client[secret_key] == "Very secret value 2" assert mock_callback.call_count >= 1 finally: - kv_setting.secret_id = appconfiguration_keyvault_secret_url - appconfig_client.set_configuration_setting(kv_setting) + appconfig_client.delete_configuration_setting(key=secret_key, label="prod") @AppConfigProviderPreparer() @recorded_by_proxy diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py index 79dbd0a768ab..c03957905dd8 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py @@ -13,7 +13,8 @@ APPCONFIGURATION_KEYVAULT_SECRET_URL, FEATURE_MANAGEMENT_KEY, ) -from azure.appconfiguration.provider import WatchKey +from azure.appconfiguration import FeatureFlagConfigurationSetting +from azure.appconfiguration.provider import SettingSelector, WatchKey AppConfigProviderPreparer = functools.partial( EnvironmentVariableLoader, @@ -29,159 +30,135 @@ class TestAppConfigurationProvider(AppConfigTestCase, unittest.TestCase): @recorded_by_proxy def test_refresh(self, appconfiguration_endpoint_string, appconfiguration_keyvault_secret_url): mock_callback = Mock() - client = self.create_client( - endpoint=appconfiguration_endpoint_string, - keyvault_secret_url=appconfiguration_keyvault_secret_url, - refresh_on=[WatchKey("refresh_message")], - refresh_interval=1, - on_refresh_success=mock_callback, - feature_flag_enabled=True, - feature_flag_refresh_enabled=True, - ) - assert client["refresh_message"] == "original value" - assert client["my_json"]["key"] == "value" - assert FEATURE_MANAGEMENT_KEY in client - assert has_feature_flag(client, "Alpha") - appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) - - setting = appconfig_client.get_configuration_setting(key="refresh_message") - setting.value = "updated value" - feature_flag = appconfig_client.get_configuration_setting(key=".appconfig.featureflag/Alpha") - feature_flag.enabled = True + test_prefix = self.get_resource_name("test") + refresh_key = f"{test_prefix}-refresh-message" + feature_id = f"{test_prefix}-alpha" + setting = ConfigurationSetting(key=refresh_key, value="original value") + feature_flag = FeatureFlagConfigurationSetting(feature_id=feature_id, enabled=False) appconfig_client.set_configuration_setting(setting) appconfig_client.set_configuration_setting(feature_flag) - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - client._feature_flag_refresh_timer._next_refresh_time = 0 - - client.refresh() - assert client["refresh_message"] == "updated value" - assert has_feature_flag(client, "Alpha", True) - assert mock_callback.call_count == 1 - - setting.value = "original value" - feature_flag.enabled = False - appconfig_client.set_configuration_setting(setting) - appconfig_client.set_configuration_setting(feature_flag) - - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - client._feature_flag_refresh_timer._next_refresh_time = 0 - - client.refresh() - assert client["refresh_message"] == "original value" - assert has_feature_flag(client, "Alpha", False) - assert mock_callback.call_count == 2 - - setting.value = "updated value 2" - feature_flag.enabled = True - appconfig_client.set_configuration_setting(setting) - appconfig_client.set_configuration_setting(feature_flag) - - # Not waiting for the refresh interval to pass - client.refresh() - assert client["refresh_message"] == "original value" - assert has_feature_flag(client, "Alpha", False) - assert mock_callback.call_count == 2 - - setting.value = "original value" - feature_flag.enabled = False - appconfig_client.set_configuration_setting(setting) - appconfig_client.set_configuration_setting(feature_flag) - - client.refresh() - assert client["refresh_message"] == "original value" - assert mock_callback.call_count == 2 + try: + client = self.create_client( + endpoint=appconfiguration_endpoint_string, + keyvault_secret_url=appconfiguration_keyvault_secret_url, + selects=[SettingSelector(key_filter=refresh_key)], + refresh_on=[WatchKey(refresh_key)], + refresh_interval=1, + on_refresh_success=mock_callback, + feature_flag_enabled=True, + feature_flag_refresh_enabled=True, + feature_flag_selectors=[SettingSelector(key_filter=feature_id)], + ) + assert client[refresh_key] == "original value" + assert FEATURE_MANAGEMENT_KEY in client + assert has_feature_flag(client, feature_id) + + setting.value = "updated value" + feature_flag.enabled = True + appconfig_client.set_configuration_setting(setting) + appconfig_client.set_configuration_setting(feature_flag) + + client._refresh_timer._next_refresh_time = 0 + client._feature_flag_refresh_timer._next_refresh_time = 0 + client.refresh() + assert client[refresh_key] == "updated value" + assert has_feature_flag(client, feature_id, True) + assert mock_callback.call_count == 1 + + setting.value = "original value" + feature_flag.enabled = False + appconfig_client.set_configuration_setting(setting) + appconfig_client.set_configuration_setting(feature_flag) + + client._refresh_timer._next_refresh_time = 0 + client._feature_flag_refresh_timer._next_refresh_time = 0 + client.refresh() + assert client[refresh_key] == "original value" + assert has_feature_flag(client, feature_id, False) + assert mock_callback.call_count == 2 + + setting.value = "updated value 2" + feature_flag.enabled = True + appconfig_client.set_configuration_setting(setting) + appconfig_client.set_configuration_setting(feature_flag) + + client.refresh() + assert client[refresh_key] == "original value" + assert has_feature_flag(client, feature_id, False) + assert mock_callback.call_count == 2 + finally: + appconfig_client.delete_configuration_setting(key=refresh_key) + appconfig_client.delete_configuration_setting(key=feature_flag.key) @AppConfigProviderPreparer() @recorded_by_proxy def test_no_refresh(self, appconfiguration_endpoint_string, appconfiguration_keyvault_secret_url): - appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) - - watch_key = ConfigurationSetting(key="watch key", value="0") - appconfig_client.set_configuration_setting(watch_key) - - mock_callback = Mock() - client = self.create_client( - endpoint=appconfiguration_endpoint_string, - keyvault_secret_url=appconfiguration_keyvault_secret_url, - refresh_on=[WatchKey("watch key")], - refresh_interval=1, - on_refresh_success=mock_callback, - feature_flag_enabled=True, - feature_flag_refresh_enabled=True, - ) - assert client["refresh_message"] == "original value" - assert client["my_json"]["key"] == "value" - assert FEATURE_MANAGEMENT_KEY in client - assert has_feature_flag(client, "Alpha") - - setting = appconfig_client.get_configuration_setting(key="refresh_message") - setting.value = "updated value" + test_prefix = self.get_resource_name("test") + refresh_key = f"{test_prefix}-refresh-message" + watch_key_name = f"{test_prefix}-watch-key" + setting = ConfigurationSetting(key=refresh_key, value="original value") + watch_key = ConfigurationSetting(key=watch_key_name, value="0") appconfig_client.set_configuration_setting(setting) - - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - client._feature_flag_refresh_timer._next_refresh_time = 0 - - client.refresh() - # No Change the Watch Key wasn't updated - assert client["refresh_message"] == "original value" - assert has_feature_flag(client, "Alpha", False) - assert mock_callback.call_count == 0 - - watch_key.value = "1" appconfig_client.set_configuration_setting(watch_key) - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - client._feature_flag_refresh_timer._next_refresh_time = 0 - - client.refresh() - assert client["refresh_message"] == "updated value" - assert has_feature_flag(client, "Alpha", False) - assert mock_callback.call_count == 1 - - # Reset modified settings - setting.value = "original value" - appconfig_client.set_configuration_setting(setting) - appconfig_client.delete_configuration_setting(key="watch key") + mock_callback = Mock() + try: + client = self.create_client( + endpoint=appconfiguration_endpoint_string, + keyvault_secret_url=appconfiguration_keyvault_secret_url, + selects=[SettingSelector(key_filter=refresh_key)], + refresh_on=[WatchKey(watch_key_name)], + refresh_interval=1, + on_refresh_success=mock_callback, + ) + assert client[refresh_key] == "original value" + + setting.value = "updated value" + appconfig_client.set_configuration_setting(setting) + client._refresh_timer._next_refresh_time = 0 + client.refresh() + assert client[refresh_key] == "original value" + assert mock_callback.call_count == 0 + + watch_key.value = "1" + appconfig_client.set_configuration_setting(watch_key) + client._refresh_timer._next_refresh_time = 0 + client.refresh() + assert client[refresh_key] == "updated value" + assert mock_callback.call_count == 1 + finally: + appconfig_client.delete_configuration_setting(key=refresh_key) + appconfig_client.delete_configuration_setting(key=watch_key_name) @AppConfigProviderPreparer() @recorded_by_proxy def test_empty_refresh(self, appconfiguration_endpoint_string, appconfiguration_keyvault_secret_url): mock_callback = Mock() - client = self.create_client( - endpoint=appconfiguration_endpoint_string, - keyvault_secret_url=appconfiguration_keyvault_secret_url, - refresh_on=[WatchKey("refresh_message")], - refresh_interval=1, - on_refresh_success=mock_callback, - feature_flag_enabled=True, - feature_flag_refresh_enabled=True, - refresh_enabled=False, - ) - assert client["refresh_message"] == "original value" - assert client["my_json"]["key"] == "value" - assert FEATURE_MANAGEMENT_KEY in client - assert has_feature_flag(client, "Alpha") - appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) - - setting = appconfig_client.get_configuration_setting(key="refresh_message") - setting.value = "updated value" + refresh_key = f"{self.get_resource_name('test')}-refresh-message" + setting = ConfigurationSetting(key=refresh_key, value="original value") appconfig_client.set_configuration_setting(setting) - # Expire the refresh timers to simulate time passing - client._refresh_timer._next_refresh_time = 0 - - client.refresh() - # Refresh is disabled, so the value should not change - assert client["refresh_message"] == "original value" - assert mock_callback.call_count == 0 - - setting.value = "original value" - appconfig_client.set_configuration_setting(setting) + try: + client = self.create_client( + endpoint=appconfiguration_endpoint_string, + keyvault_secret_url=appconfiguration_keyvault_secret_url, + selects=[SettingSelector(key_filter=refresh_key)], + refresh_on=[WatchKey(refresh_key)], + refresh_interval=1, + on_refresh_success=mock_callback, + refresh_enabled=False, + ) + assert client[refresh_key] == "original value" + + setting.value = "updated value" + appconfig_client.set_configuration_setting(setting) + client._refresh_timer._next_refresh_time = 0 + client.refresh() + assert client[refresh_key] == "original value" + assert mock_callback.call_count == 0 + finally: + appconfig_client.delete_configuration_setting(key=refresh_key) From 94066d910c1a8fdce97bbb761cdd997bbf1dd4e9 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 8 Sep 2026 10:31:00 -0700 Subject: [PATCH 2/6] review changes --- .../assets.json | 2 +- .../key_vault/test_async_secret_refresh.py | 9 ++-- .../tests/aio/test_async_provider_refresh.py | 45 +++++++++++++------ .../tests/key_vault/test_secret_refresh.py | 9 ++-- .../tests/test_provider_refresh.py | 45 +++++++++++++------ 5 files changed, 77 insertions(+), 33 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json index 7335b2f84ff1..17b0fe5fb096 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/appconfiguration/azure-appconfiguration-provider", - "Tag": "python/appconfiguration/azure-appconfiguration-provider_293f160543" + "Tag": "python/appconfiguration/azure-appconfiguration-provider_dae6c7e54b" } diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py index 6836a3f08d0e..fdef46b338fd 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py @@ -86,9 +86,11 @@ async def test_secret_refresh_with_updated_values( secret_key = f"{self.get_resource_name('test')}-secret" appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) kv_setting = create_secret_config_setting(secret_key, "prod", appconfiguration_keyvault_secret_url) - await appconfig_client.set_configuration_setting(kv_setting) - + secret_created = False try: + await appconfig_client.set_configuration_setting(kv_setting) + secret_created = True + client = await self.create_client( endpoint=appconfiguration_endpoint_string, selects={SettingSelector(key_filter=secret_key, label_filter="prod")}, @@ -116,7 +118,8 @@ async def test_secret_refresh_with_updated_values( assert client[secret_key] == "Very secret value 2" assert mock_callback.call_count >= 1 finally: - await appconfig_client.delete_configuration_setting(key=secret_key, label="prod") + if secret_created: + await appconfig_client.delete_configuration_setting(key=secret_key, label="prod") @AppConfigProviderPreparer() @recorded_by_proxy_async diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_refresh.py index bdf92df521c2..5d720ec0f158 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_refresh.py @@ -45,10 +45,14 @@ async def test_refresh(self, appconfiguration_endpoint_string, appconfiguration_ feature_id = f"{test_prefix}-alpha" setting = ConfigurationSetting(key=refresh_key, value="original value") feature_flag = FeatureFlagConfigurationSetting(feature_id=feature_id, enabled=False) - await appconfig_client.set_configuration_setting(setting) - await appconfig_client.set_configuration_setting(feature_flag) - + setting_created = False + feature_flag_created = False try: + await appconfig_client.set_configuration_setting(setting) + setting_created = True + await appconfig_client.set_configuration_setting(feature_flag) + feature_flag_created = True + async with await self.create_client( endpoint=appconfiguration_endpoint_string, keyvault_secret_url=appconfiguration_keyvault_secret_url, @@ -98,8 +102,12 @@ async def test_refresh(self, appconfiguration_endpoint_string, appconfiguration_ assert has_feature_flag(client, feature_id, False) assert mock_callback.call_count == 2 finally: - await appconfig_client.delete_configuration_setting(key=refresh_key) - await appconfig_client.delete_configuration_setting(key=feature_flag.key) + try: + if feature_flag_created: + await appconfig_client.delete_configuration_setting(key=feature_flag.key) + finally: + if setting_created: + await appconfig_client.delete_configuration_setting(key=refresh_key) # method: refresh @AppConfigProviderPreparer() @@ -113,11 +121,15 @@ async def test_no_refresh(self, appconfiguration_endpoint_string, appconfigurati watch_key_name = f"{test_prefix}-watch-key" setting = ConfigurationSetting(key=refresh_key, value="original value") watch_key = ConfigurationSetting(key=watch_key_name, value="0") - await appconfig_client.set_configuration_setting(setting) - await appconfig_client.set_configuration_setting(watch_key) - mock_callback = Mock() + setting_created = False + watch_key_created = False try: + await appconfig_client.set_configuration_setting(setting) + setting_created = True + await appconfig_client.set_configuration_setting(watch_key) + watch_key_created = True + async with await self.create_client( endpoint=appconfiguration_endpoint_string, keyvault_secret_url=appconfiguration_keyvault_secret_url, @@ -142,8 +154,12 @@ async def test_no_refresh(self, appconfiguration_endpoint_string, appconfigurati assert client[refresh_key] == "updated value" assert mock_callback.call_count == 1 finally: - await appconfig_client.delete_configuration_setting(key=refresh_key) - await appconfig_client.delete_configuration_setting(key=watch_key_name) + try: + if watch_key_created: + await appconfig_client.delete_configuration_setting(key=watch_key_name) + finally: + if setting_created: + await appconfig_client.delete_configuration_setting(key=refresh_key) @AppConfigProviderPreparer() @recorded_by_proxy_async @@ -154,9 +170,11 @@ async def test_refresh_disabled(self, appconfiguration_endpoint_string, appconfi appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) refresh_key = f"{self.get_resource_name('test')}-refresh-message" setting = ConfigurationSetting(key=refresh_key, value="original value") - await appconfig_client.set_configuration_setting(setting) - + setting_created = False try: + await appconfig_client.set_configuration_setting(setting) + setting_created = True + async with await self.create_client( endpoint=appconfiguration_endpoint_string, keyvault_secret_url=appconfiguration_keyvault_secret_url, @@ -175,7 +193,8 @@ async def test_refresh_disabled(self, appconfiguration_endpoint_string, appconfi assert client[refresh_key] == "original value" assert mock_callback.call_count == 0 finally: - await appconfig_client.delete_configuration_setting(key=refresh_key) + if setting_created: + await appconfig_client.delete_configuration_setting(key=refresh_key) except ImportError: pass diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py index 9686c430830e..a60a1b48c995 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py @@ -78,9 +78,11 @@ def test_secret_refresh_with_updated_values( secret_key = f"{self.get_resource_name('test')}-secret" appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) kv_setting = create_secret_config_setting(secret_key, "prod", appconfiguration_keyvault_secret_url) - appconfig_client.set_configuration_setting(kv_setting) - + secret_created = False try: + appconfig_client.set_configuration_setting(kv_setting) + secret_created = True + client = self.create_client( endpoint=appconfiguration_endpoint_string, selects={SettingSelector(key_filter=secret_key, label_filter="prod")}, @@ -108,7 +110,8 @@ def test_secret_refresh_with_updated_values( assert client[secret_key] == "Very secret value 2" assert mock_callback.call_count >= 1 finally: - appconfig_client.delete_configuration_setting(key=secret_key, label="prod") + if secret_created: + appconfig_client.delete_configuration_setting(key=secret_key, label="prod") @AppConfigProviderPreparer() @recorded_by_proxy diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py index c03957905dd8..7593b4a4756e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py @@ -36,10 +36,14 @@ def test_refresh(self, appconfiguration_endpoint_string, appconfiguration_keyvau feature_id = f"{test_prefix}-alpha" setting = ConfigurationSetting(key=refresh_key, value="original value") feature_flag = FeatureFlagConfigurationSetting(feature_id=feature_id, enabled=False) - appconfig_client.set_configuration_setting(setting) - appconfig_client.set_configuration_setting(feature_flag) - + setting_created = False + feature_flag_created = False try: + appconfig_client.set_configuration_setting(setting) + setting_created = True + appconfig_client.set_configuration_setting(feature_flag) + feature_flag_created = True + client = self.create_client( endpoint=appconfiguration_endpoint_string, keyvault_secret_url=appconfiguration_keyvault_secret_url, @@ -89,8 +93,12 @@ def test_refresh(self, appconfiguration_endpoint_string, appconfiguration_keyvau assert has_feature_flag(client, feature_id, False) assert mock_callback.call_count == 2 finally: - appconfig_client.delete_configuration_setting(key=refresh_key) - appconfig_client.delete_configuration_setting(key=feature_flag.key) + try: + if feature_flag_created: + appconfig_client.delete_configuration_setting(key=feature_flag.key) + finally: + if setting_created: + appconfig_client.delete_configuration_setting(key=refresh_key) @AppConfigProviderPreparer() @recorded_by_proxy @@ -101,11 +109,15 @@ def test_no_refresh(self, appconfiguration_endpoint_string, appconfiguration_key watch_key_name = f"{test_prefix}-watch-key" setting = ConfigurationSetting(key=refresh_key, value="original value") watch_key = ConfigurationSetting(key=watch_key_name, value="0") - appconfig_client.set_configuration_setting(setting) - appconfig_client.set_configuration_setting(watch_key) - mock_callback = Mock() + setting_created = False + watch_key_created = False try: + appconfig_client.set_configuration_setting(setting) + setting_created = True + appconfig_client.set_configuration_setting(watch_key) + watch_key_created = True + client = self.create_client( endpoint=appconfiguration_endpoint_string, keyvault_secret_url=appconfiguration_keyvault_secret_url, @@ -130,8 +142,12 @@ def test_no_refresh(self, appconfiguration_endpoint_string, appconfiguration_key assert client[refresh_key] == "updated value" assert mock_callback.call_count == 1 finally: - appconfig_client.delete_configuration_setting(key=refresh_key) - appconfig_client.delete_configuration_setting(key=watch_key_name) + try: + if watch_key_created: + appconfig_client.delete_configuration_setting(key=watch_key_name) + finally: + if setting_created: + appconfig_client.delete_configuration_setting(key=refresh_key) @AppConfigProviderPreparer() @recorded_by_proxy @@ -140,9 +156,11 @@ def test_empty_refresh(self, appconfiguration_endpoint_string, appconfiguration_ appconfig_client = self.create_appconfig_client(appconfiguration_endpoint_string) refresh_key = f"{self.get_resource_name('test')}-refresh-message" setting = ConfigurationSetting(key=refresh_key, value="original value") - appconfig_client.set_configuration_setting(setting) - + setting_created = False try: + appconfig_client.set_configuration_setting(setting) + setting_created = True + client = self.create_client( endpoint=appconfiguration_endpoint_string, keyvault_secret_url=appconfiguration_keyvault_secret_url, @@ -161,4 +179,5 @@ def test_empty_refresh(self, appconfiguration_endpoint_string, appconfiguration_ assert client[refresh_key] == "original value" assert mock_callback.call_count == 0 finally: - appconfig_client.delete_configuration_setting(key=refresh_key) + if setting_created: + appconfig_client.delete_configuration_setting(key=refresh_key) From 4dbbbdb20016730cc286d8c5eabeea8ea97f5408 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 8 Sep 2026 11:57:13 -0700 Subject: [PATCH 3/6] Update conftest.py --- .../azure-appconfiguration-provider/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py index 2ee75e620842..2d9689a8552e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -125,12 +125,12 @@ def add_sanitizers(test_proxy): value="sanitized", regex=os.environ.get("APPCONFIGURATION_CONNECTION_STRING", "https://sanitized.azconfig.io"), ) - add_uri_string_sanitizer() for target, value in key_vault_references: target = target.rstrip("/") + "/" value = value.rstrip("/") + "/" add_uri_string_sanitizer(target=target, value=value) add_general_string_sanitizer(target=target, value=value) + add_uri_string_sanitizer() add_remove_header_sanitizer(headers="Correlation-Context") add_general_regex_sanitizer(value="api-version=1970-01-01", regex="api-version=.+") From 50e90f3f2b25b1d2df64e3b310987f171b8af4e2 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 8 Sep 2026 12:36:36 -0700 Subject: [PATCH 4/6] Update assets.json --- .../azure-appconfiguration-provider/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json index 17b0fe5fb096..f28ba8f5265c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/appconfiguration/azure-appconfiguration-provider", - "Tag": "python/appconfiguration/azure-appconfiguration-provider_dae6c7e54b" + "Tag": "python/appconfiguration/azure-appconfiguration-provider_0d3b075abc" } From f11055c4a4c3d59d9b6c08eae9c2a62dd7b26f2a Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 8 Sep 2026 14:01:38 -0700 Subject: [PATCH 5/6] fixing tests --- .../azure-appconfiguration-provider/assets.json | 2 +- .../azure-appconfiguration-provider/tests/conftest.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json index f28ba8f5265c..5e1d0cceed91 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/appconfiguration/azure-appconfiguration-provider", - "Tag": "python/appconfiguration/azure-appconfiguration-provider_0d3b075abc" + "Tag": "python/appconfiguration/azure-appconfiguration-provider_e8f8977626" } diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py index 2d9689a8552e..cd9861c182f0 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -1,6 +1,7 @@ import logging import os import time +from urllib.parse import urlparse from devtools_testutils import ( add_general_regex_sanitizer, @@ -128,7 +129,7 @@ def add_sanitizers(test_proxy): for target, value in key_vault_references: target = target.rstrip("/") + "/" value = value.rstrip("/") + "/" - add_uri_string_sanitizer(target=target, value=value) + add_uri_string_sanitizer(target=urlparse(target).path, value=urlparse(value).path) add_general_string_sanitizer(target=target, value=value) add_uri_string_sanitizer() add_remove_header_sanitizer(headers="Correlation-Context") From 1cf783683cbfcea3e5979e1db62db81f7fc2e44c Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 9 Sep 2026 11:45:14 -0700 Subject: [PATCH 6/6] Fixing Tests --- .../azure-appconfiguration-provider/assets.json | 2 +- .../tests/conftest.py | 13 ++++++------- .../tests/test_constants.py | 4 ++-- sdk/appconfiguration/test-resources.json | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json index 5e1d0cceed91..53b4c344feef 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/assets.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/appconfiguration/azure-appconfiguration-provider", - "Tag": "python/appconfiguration/azure-appconfiguration-provider_e8f8977626" + "Tag": "python/appconfiguration/azure-appconfiguration-provider_e80b715d7c" } diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py index cd9861c182f0..15355bfa5141 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -1,7 +1,6 @@ import logging import os import time -from urllib.parse import urlparse from devtools_testutils import ( add_general_regex_sanitizer, @@ -105,16 +104,16 @@ def add_sanitizers(test_proxy): ( os.environ.get( "APPCONFIGURATION_KEYVAULT_SECRET_URL2", - "https://sanitized.vault.azure.net/secrets/fake-secret2/", + "https://sanitized.vault.azure.net/secrets/SecondSecret/", ), - "https://sanitized.vault.azure.net/secrets/fake-secret2/", + "https://sanitized.vault.azure.net/secrets/SecondSecret/", ), ( os.environ.get( "APPCONFIGURATION_KEYVAULT_SECRET_URL", - "https://sanitized.vault.azure.net/secrets/fake-secret/", + "https://sanitized.vault.azure.net/secrets/TestSecret/", ), - "https://sanitized.vault.azure.net/secrets/fake-secret/", + "https://sanitized.vault.azure.net/secrets/TestSecret/", ), ) @@ -126,12 +125,12 @@ def add_sanitizers(test_proxy): value="sanitized", regex=os.environ.get("APPCONFIGURATION_CONNECTION_STRING", "https://sanitized.azconfig.io"), ) + add_uri_string_sanitizer() for target, value in key_vault_references: target = target.rstrip("/") + "/" value = value.rstrip("/") + "/" - add_uri_string_sanitizer(target=urlparse(target).path, value=urlparse(value).path) + add_uri_string_sanitizer(target=target, value=value) add_general_string_sanitizer(target=target, value=value) - add_uri_string_sanitizer() add_remove_header_sanitizer(headers="Correlation-Context") add_general_regex_sanitizer(value="api-version=1970-01-01", regex="api-version=.+") diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_constants.py index f56583b923e3..e4c29ac19575 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_constants.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_constants.py @@ -6,5 +6,5 @@ "Secret=lamefakesecretlamefakesecretlamefakesecrett=" # cspell: disable-line ) APPCONFIGURATION_ENDPOINT_STRING = "https://sanitized.azconfig.io" -APPCONFIGURATION_KEYVAULT_SECRET_URL = "https://sanitized.vault.azure.net/secrets/fake-secret/" -APPCONFIGURATION_KEYVAULT_SECRET_URL2 = "https://sanitized.vault.azure.net/secrets/fake-secret2/" +APPCONFIGURATION_KEYVAULT_SECRET_URL = "https://sanitized.vault.azure.net/secrets/TestSecret/" +APPCONFIGURATION_KEYVAULT_SECRET_URL2 = "https://sanitized.vault.azure.net/secrets/SecondSecret/" diff --git a/sdk/appconfiguration/test-resources.json b/sdk/appconfiguration/test-resources.json index 529337242ddb..dbbbe0b0f361 100644 --- a/sdk/appconfiguration/test-resources.json +++ b/sdk/appconfiguration/test-resources.json @@ -61,7 +61,7 @@ "endpointValue": "[format('https://{0}-{1}{2}', parameters('baseName'), parameters('azConfigPrefix'), parameters('azConfigEndpointSuffix'))]", "azureKeyVaultUrl": "[format('https://{0}{1}/', parameters('baseName'), parameters('keyVaultEndpointSuffix'))]", "azureKeyVaultSecretUrl": "[format('https://{0}{1}/secrets/TestSecret', parameters('baseName'), parameters('keyVaultEndpointSuffix'))]", - "azureKeyVaultSecretUrl2": "[format('https://{0}{1}/secrets/TestSecret2', parameters('baseName'), parameters('keyVaultEndpointSuffix'))]" + "azureKeyVaultSecretUrl2": "[format('https://{0}{1}/secrets/SecondSecret', parameters('baseName'), parameters('keyVaultEndpointSuffix'))]" }, "resources": [ { @@ -127,7 +127,7 @@ }, { "type": "Microsoft.KeyVault/vaults/secrets", - "name": "[concat(parameters('baseName'), '/TestSecret2')]", + "name": "[concat(parameters('baseName'), '/SecondSecret')]", "apiVersion": "2016-10-01", "location": "[parameters('location')]", "dependsOn": [