Skip to content
Open
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 @@ -6,6 +6,7 @@
import json
import os

from azure.cli.testsdk import ResourceGroupPreparer
from azure.cli.testsdk.scenario_tests import RecordingProcessor
from azure.cli.testsdk.scenario_tests.utilities import is_json_payload
from azure.cli.core.util import shell_safe_json_parse
Expand All @@ -28,12 +29,24 @@ def get_resource_name_prefix(prefix):
resource_prefix = _get_local_test_resource_prefix()
return prefix if resource_prefix is None else resource_prefix + prefix

def get_test_resource_group():
# Data-plane tests use Microsoft Entra ID (--auth-mode login) against a store whose local auth
# is disabled. The recording principal must already hold "App Configuration Data Owner" at a
# scope covering the store, so tests target a fixed resource group with that standing role
# instead of an ephemeral @ResourceGroupPreparer group. Override via AZURE_CLI_APPCONFIG_TEST_RG.
return os.environ.get("AZURE_CLI_APPCONFIG_TEST_RG", "mametcal-python")
# Value the reused live test resource group (AZURE_CLI_TEST_DEV_RESOURCE_GROUP_NAME) is rewritten to
# in recordings by ResourceGroupNameReplacer. Matches the default ResourceGroupPreparer() moniker.
SANITIZED_TEST_RESOURCE_GROUP = "clitest.rg000001"


class AppConfigResourceGroupPreparer(ResourceGroupPreparer):
""" ResourceGroupPreparer that keeps moniker numbering aligned when reusing a dev resource group.

In dev-setting mode the base preparer returns early without calling live_only_execute, so it never
advances test_resources_count during recording the way it does in playback. That would desync
create_random_name numbering (e.g. store000001 vs store000002) between recording and playback, so
touch the moniker here to consume the same counter slot in both modes.
"""

def create_resource(self, name, **kwargs):
if self.dev_setting_name:
_ = self.moniker
return super().create_resource(name, **kwargs)


def _case_insensitive_query_matcher(r1, r2):
Expand Down Expand Up @@ -86,9 +99,43 @@ def process_response(self, response):
return response


class ResourceGroupNameReplacer(RecordingProcessor):
""" Scrub the reused live test resource group name from recordings.

Data-plane tests reuse a pre-provisioned resource group (AZURE_CLI_TEST_DEV_RESOURCE_GROUP_NAME)
that holds a standing "App Configuration Data Owner" role. ResourceGroupPreparer does not sanitize
a dev-setting resource group, so rewrite it to the moniker ResourceGroupPreparer uses in playback.
"""

def __init__(self):
self._real_rg = os.environ.get("AZURE_CLI_TEST_DEV_RESOURCE_GROUP_NAME")

def _scrub(self, value):
if self._real_rg and value:
return value.replace(self._real_rg, SANITIZED_TEST_RESOURCE_GROUP)
return value

def process_request(self, request):
request.uri = self._scrub(request.uri)
if isinstance(request.body, bytes):
try:
request.body = self._scrub(request.body.decode('utf-8')).encode('utf-8')
except UnicodeDecodeError:
pass
elif request.body:
request.body = self._scrub(request.body)
return request

def process_response(self, response):
if response.get('body', {}).get('string'):
response['body']['string'] = self._scrub(response['body']['string'])
return response


def register_appconfig_recording_processors(test):
""" Register App Configuration-specific recording processors on the test. """
test.recording_processors.append(OperationLocationSanitizer(test.name_replacer))
test.recording_processors.append(ResourceGroupNameReplacer())

class CredentialResponseSanitizer(RecordingProcessor):
def process_response(self, response):
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interactions:
User-Agent:
- AZURECLI/2.88.0 azsdk-python-core/1.39.0 Python/3.14.3 (Windows-11-10.0.26200-SP0)
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mametcal-python/providers/Microsoft.AppConfiguration/configurationStores/featurenamespacetest000001?api-version=2025-08-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppConfiguration/configurationStores/featurenamespacetest000002?api-version=2025-08-01-preview
response:
body:
string: '{"type": "Microsoft.AppConfiguration/configurationStores", "location":
Expand All @@ -30,8 +30,8 @@ interactions:
"privateEndpointConnections": null, "disableLocalAuth": null, "softDeleteRetentionInDays":
null, "defaultKeyValueRevisionRetentionPeriodInSeconds": null, "enablePurgeProtection":
null, "dataPlaneProxy": null, "telemetry": null, "azureFrontDoor": null},
"sku": {"name": "Standard"}, "systemData": null, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mametcal-python/providers/Microsoft.AppConfiguration/configurationStores/featurenamespacetest000001",
"name": "featurenamespacetest000001", "tags": {}}'
"sku": {"name": "Standard"}, "systemData": null, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppConfiguration/configurationStores/featurenamespacetest000002",
"name": "featurenamespacetest000002", "tags": {}}'
headers:
azure-asyncoperation:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AppConfiguration/locations/eastus/operationsStatus/Y29uZmlndXJhdGlvblN0b3Jlcw.cJ5BjhSPKSmVDT5-_QMzwrtr7aRT15UwzxrWV83BNyE?api-version=2025-08-01-preview&t=639186261997872239&c=MIIHlDCCBnygAwIBAgIQAcfN_Jd6ViGd1-EkFH97aDANBgkqhkiG9w0BAQsFADA2MTQwMgYDVQQDEytDQ01FIEcxIFRMUyBSU0EgMjA0OCBTSEEyNTYgMjA0OSBFVVMyIENBIDAxMB4XDTI2MDQwOTA0MzUxMFoXDTI2MTAwNDEwMzUxMFowQDE-MDwGA1UEAxM1YXN5bmNvcGVyYXRpb25zaWduaW5nY2VydGlmaWNhdGUubWFuYWdlbWVudC5henVyZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9nzXnnnT0V5cDY5fHgY6fvt0f5K67TLY5rf3kXsgNDiGJL9Ub1_cJuWgTTjGYmxaPP6HFz_YOLdMBGPkVhZavejw0qLifjw8nEBivhzrnSlLVzv8ThjIxvzYq7Pixu564lZgpE4tktNQwXrbdQ8_M_ltt8Ia4jO8Wc47QJt-BIUGY10RRyuDzAEGrQRCDbQB1Kyo6IjF95ihEDSUcGthqOIsbqMERKgZokdpO3a8ikGNKVtOb3zrePXR71iCDdkdamGIsPVfGxaBtUDO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EUC0K6-E9BW4iWrae0Je8S9UfwUU6GnoIRIZzQPqo8Tjx3ZY_bD5jgTr_Uio4_koydZxehQUVNZkX4rGdwMyDsIi45iBGam8Nm6OpjLXeoQq5pyi2vsg1OvaNg0hbcRZtqoIw__tiaC7dDZyDUkMmGPA9S6f2pvd7UVh67ICpI-pHeGGUHlssiP04JvdIRwGWw&h=0p20phmjahMMOgDHY2kcGdycxtEJPe9gKVocFj7orgs
Expand Down Expand Up @@ -288,21 +288,21 @@ interactions:
User-Agent:
- AZURECLI/2.88.0 azsdk-python-core/1.39.0 Python/3.14.3 (Windows-11-10.0.26200-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mametcal-python/providers/Microsoft.AppConfiguration/configurationStores/featurenamespacetest000001?api-version=2025-08-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppConfiguration/configurationStores/featurenamespacetest000002?api-version=2025-08-01-preview
response:
body:
string: '{"type": "Microsoft.AppConfiguration/configurationStores", "location":
"eastus", "properties": {"provisioningState": "Succeeded", "creationDate":
"2026-07-02T21:56:39+00:00", "endpoint": "https://featurenamespacetest000001.azconfig.io",
"2026-07-02T21:56:39+00:00", "endpoint": "https://featurenamespacetest000002.azconfig.io",
"encryption": {"keyVaultProperties": null}, "privateEndpointConnections":
null, "disableLocalAuth": true, "softDeleteRetentionInDays": 1, "defaultKeyValueRevisionRetentionPeriodInSeconds":
2592000, "enablePurgeProtection": false, "dataPlaneProxy": {"authenticationMode":
"Local", "privateLinkDelegation": "Disabled"}, "telemetry": {"resourceId":
null}, "azureFrontDoor": {"resourceId": null}}, "sku": {"name": "standard"},
"systemData": {"createdBy": "test@example.com", "createdByType": "User", "createdAt":
"2026-07-02T21:56:39+00:00", "lastModifiedBy": "test@example.com", "lastModifiedByType":
"User", "lastModifiedAt": "2026-07-02T21:56:39+00:00"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mametcal-python/providers/Microsoft.AppConfiguration/configurationStores/featurenamespacetest000001",
"name": "featurenamespacetest000001", "tags": {}}'
"User", "lastModifiedAt": "2026-07-02T21:56:39+00:00"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppConfiguration/configurationStores/featurenamespacetest000002",
"name": "featurenamespacetest000002", "tags": {}}'
headers:
cache-control:
- no-cache
Expand Down Expand Up @@ -344,7 +344,7 @@ interactions:
- AZURECLI.APPCONFIG/2.88.0 azsdk-python-appconfiguration/1.8.0 Python/3.14.3
(Windows-11-10.0.26200-SP0)
method: GET
uri: https://featurenamespacetest000001.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3ABeta?api-version=2023-11-01&label=v1
uri: https://featurenamespacetest000002.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3ABeta?api-version=2023-11-01&label=v1
response:
body:
string: ''
Expand Down Expand Up @@ -390,7 +390,7 @@ interactions:
- AZURECLI.APPCONFIG/2.88.0 azsdk-python-appconfiguration/1.8.0 Python/3.14.3
(Windows-11-10.0.26200-SP0)
method: PUT
uri: https://featurenamespacetest000001.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3ABeta?api-version=2023-11-01&label=v1
uri: https://featurenamespacetest000002.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3ABeta?api-version=2023-11-01&label=v1
response:
body:
string: '{"etag":"ND9fxz4tD1dql7R_z9joI_mE60z0GqGZnwL9RSRtFsU","key":".appconfig.featureflag/MyApp:Beta","label":"v1","content_type":"application/vnd.microsoft.appconfig.ff+json;charset=utf-8","value":"{\"id\":
Expand Down Expand Up @@ -433,7 +433,7 @@ interactions:
- AZURECLI.APPCONFIG/2.88.0 azsdk-python-appconfiguration/1.8.0 Python/3.14.3
(Windows-11-10.0.26200-SP0)
method: GET
uri: https://featurenamespacetest000001.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3ABeta?api-version=2023-11-01&label=v1
uri: https://featurenamespacetest000002.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3ABeta?api-version=2023-11-01&label=v1
response:
body:
string: '{"etag":"ND9fxz4tD1dql7R_z9joI_mE60z0GqGZnwL9RSRtFsU","key":".appconfig.featureflag/MyApp:Beta","label":"v1","content_type":"application/vnd.microsoft.appconfig.ff+json;charset=utf-8","value":"{\"id\":
Expand Down Expand Up @@ -488,7 +488,7 @@ interactions:
- AZURECLI.APPCONFIG/2.88.0 azsdk-python-appconfiguration/1.8.0 Python/3.14.3
(Windows-11-10.0.26200-SP0)
method: PUT
uri: https://featurenamespacetest000001.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3ABeta?api-version=2023-11-01&label=v1
uri: https://featurenamespacetest000002.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3ABeta?api-version=2023-11-01&label=v1
response:
body:
string: '{"etag":"ocTV-H7Gvwa8X16FdsKYivH5oxPz4CJntwmM4qE_50M","key":".appconfig.featureflag/MyApp:Beta","label":"v1","content_type":"application/vnd.microsoft.appconfig.ff+json;charset=utf-8","value":"{\"id\":
Expand Down Expand Up @@ -531,7 +531,7 @@ interactions:
- AZURECLI.APPCONFIG/2.88.0 azsdk-python-appconfiguration/1.8.0 Python/3.14.3
(Windows-11-10.0.26200-SP0)
method: GET
uri: https://featurenamespacetest000001.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3AGlobalFeature?api-version=2023-11-01&label=v1
uri: https://featurenamespacetest000002.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3AGlobalFeature?api-version=2023-11-01&label=v1
response:
body:
string: ''
Expand Down Expand Up @@ -577,7 +577,7 @@ interactions:
- AZURECLI.APPCONFIG/2.88.0 azsdk-python-appconfiguration/1.8.0 Python/3.14.3
(Windows-11-10.0.26200-SP0)
method: PUT
uri: https://featurenamespacetest000001.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3AGlobalFeature?api-version=2023-11-01&label=v1
uri: https://featurenamespacetest000002.azconfig.io/kv/.appconfig.featureflag%2FMyApp%3AGlobalFeature?api-version=2023-11-01&label=v1
response:
body:
string: '{"etag":"t76tJYws7j9Ur6XmJZprJ9QgH4yNJLM2rxIBMeAAReI","key":".appconfig.featureflag/MyApp:GlobalFeature","label":"v1","content_type":"application/vnd.microsoft.appconfig.ff+json;charset=utf-8","value":"{\"id\":
Expand Down Expand Up @@ -620,7 +620,7 @@ interactions:
- AZURECLI.APPCONFIG/2.88.0 azsdk-python-appconfiguration/1.8.0 Python/3.14.3
(Windows-11-10.0.26200-SP0)
method: GET
uri: https://featurenamespacetest000001.azconfig.io/kv?api-version=2023-11-01&key=.appconfig.featureflag%2FMyApp%3A%2A&label=%2A
uri: https://featurenamespacetest000002.azconfig.io/kv?api-version=2023-11-01&key=.appconfig.featureflag%2FMyApp%3A%2A&label=%2A
response:
body:
string: '{"etag":"nQfoiAa6UapCYyfs6W_EIpQpugkuIHktFCW2KMaVLpw","items":[{"etag":"ocTV-H7Gvwa8X16FdsKYivH5oxPz4CJntwmM4qE_50M","key":".appconfig.featureflag/MyApp:Beta","label":"v1","content_type":"application/vnd.microsoft.appconfig.ff+json;charset=utf-8","value":"{\"id\":
Expand Down
Loading
Loading