diff --git a/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/bases.py b/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/bases.py index 0cfebcfec1e..5aa84f74295 100644 --- a/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/bases.py +++ b/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/bases.py @@ -19,6 +19,7 @@ AzureResourceProcessor, AzureWorkspaceTriadProcessor, DropProcessor, + EmailProcessor, IndexServiceProcessor, PFSProcessor, RecordingProcessor, @@ -140,6 +141,7 @@ def _get_recording_processors(self) -> List[RecordingProcessor]: AzureResourceProcessor(), AzureWorkspaceTriadProcessor(), DropProcessor(), + EmailProcessor(), IndexServiceProcessor(), PFSProcessor(), StorageProcessor(), diff --git a/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/constants.py b/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/constants.py index 605919d3328..bc3f6153253 100644 --- a/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/constants.py +++ b/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/constants.py @@ -65,6 +65,8 @@ class SanitizedValues: # trick: "unknown_user" is the value when client fails to get username # use this value so that we don't do extra logic when replay USERNAME = "unknown_user" + # MISC + EMAIL_USERNAME = "username" class AzureMLResourceTypes: diff --git a/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/processors.py b/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/processors.py index 4b7597354d2..fd10059e31d 100644 --- a/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/processors.py +++ b/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/processors.py @@ -13,6 +13,7 @@ is_json_payload_request, is_json_payload_response, sanitize_azure_workspace_triad, + sanitize_email, sanitize_experiment_id, sanitize_pfs_body, sanitize_upload_hash, @@ -245,3 +246,11 @@ def process_response(self, response: Dict) -> Dict: body.pop("continuationToken", None) response["body"]["string"] = json.dumps(body) return response + + +class EmailProcessor(RecordingProcessor): + """Sanitize email address in responses.""" + + def process_response(self, response: Dict) -> Dict: + response["body"]["string"] = sanitize_email(response["body"]["string"]) + return response diff --git a/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/utils.py b/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/utils.py index 68686652854..f51376a6559 100644 --- a/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/utils.py +++ b/src/promptflow/tests/sdk_cli_azure_test/recording_utilities/utils.py @@ -201,6 +201,10 @@ def sanitize_pfs_body(body: str) -> str: return json.dumps(body_dict) +def sanitize_email(value: str) -> str: + return re.sub(r"([\w\.-]+)@([\w\.-]+)", r"{}@\2".format(SanitizedValues.EMAIL_USERNAME), value) + + def _is_json_payload(headers: Dict, key: str) -> bool: if not headers: return False diff --git a/src/promptflow/tests/test_configs/recordings/test_arm_connection_operations_TestArmConnectionOperations_test_get_connection.yaml b/src/promptflow/tests/test_configs/recordings/test_arm_connection_operations_TestArmConnectionOperations_test_get_connection.yaml index 4e5baeffc20..7ee0a697274 100644 --- a/src/promptflow/tests/test_configs/recordings/test_arm_connection_operations_TestArmConnectionOperations_test_get_connection.yaml +++ b/src/promptflow/tests/test_configs/recordings/test_arm_connection_operations_TestArmConnectionOperations_test_get_connection.yaml @@ -9,21 +9,21 @@ interactions: Connection: - keep-alive User-Agent: - - promptflow-sdk/0.0.1 azure-ai-ml/1.10.0 azsdk-python-mgmt-machinelearningservices/0.1.0 - Python/3.10.13 (Windows-10-10.0.22621-SP0) + - promptflow-sdk/0.0.1 promptflow/0.0.1 azure-ai-ml/1.12.1 azsdk-python-mgmt-machinelearningservices/0.1.0 + Python/3.10.13 (Windows-10-10.0.22631-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/api-version=2023-06-01-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/api-version=2023-08-01-preview response: body: string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000", "name": "00000", "type": "Microsoft.MachineLearningServices/workspaces", "location": "eastus", "tags": {}, "etag": null, "kind": "Default", "sku": {"name": "Basic", - "tier": "Basic"}}' + "tier": "Basic"}, "properties": {"discoveryUrl": "https://eastus.api.azureml.ms/discovery"}}' headers: cache-control: - no-cache content-length: - - '3519' + - '3630' content-type: - application/json; charset=utf-8 expires: @@ -39,7 +39,7 @@ interactions: x-content-type-options: - nosniff x-request-time: - - '0.022' + - '0.017' status: code: 200 message: OK @@ -53,8 +53,8 @@ interactions: Connection: - keep-alive User-Agent: - - promptflow-sdk/0.0.1 azure-ai-ml/1.10.0 azsdk-python-mgmt-machinelearningservices/0.1.0 - Python/3.10.13 (Windows-10-10.0.22621-SP0) + - promptflow-sdk/0.0.1 promptflow/0.0.1 azure-ai-ml/1.12.1 azsdk-python-mgmt-machinelearningservices/0.1.0 + Python/3.10.13 (Windows-10-10.0.22631-SP0) method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores?api-version=2023-04-01-preview&count=30&isDefault=true&orderByAsc=false response: @@ -91,7 +91,7 @@ interactions: x-content-type-options: - nosniff x-request-time: - - '0.268' + - '0.070' status: code: 200 message: OK @@ -114,19 +114,20 @@ interactions: body: string: '{"tags": null, "location": null, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/connections/azure_open_ai_connection", "name": "azure_open_ai_connection", "type": "Microsoft.MachineLearningServices/workspaces/connections", - "properties": {"authType": "ApiKey", "credentials": {"key": "_"}, "category": - "AzureOpenAI", "expiryTime": null, "target": "_", "createdByWorkspaceArmId": + "properties": {"authType": "ApiKey", "credentials": {"key": "_"}, "group": + "AzureAI", "category": "AzureOpenAI", "expiryTime": null, "target": "_", "createdByWorkspaceArmId": null, "isSharedToAll": false, "sharedUserList": [], "metadata": {"azureml.flow.connection_type": "AzureOpenAI", "azureml.flow.module": "promptflow.connections", "ApiType": - "azure", "ApiVersion": "2023-07-01-preview", "ResourceId": null}}, "systemData": - {"createdAt": "2023-08-22T10:15:34.5762053Z", "createdBy": "yigao@microsoft.com", - "createdByType": "User", "lastModifiedAt": "2023-08-22T10:15:34.5762053Z", - "lastModifiedBy": "yigao@microsoft.com", "lastModifiedByType": "User"}}' + "azure", "ApiVersion": "2023-07-01-preview", "ResourceId": null, "DeploymentApiVersion": + "2023-10-01-preview"}}, "systemData": {"createdAt": "2023-08-22T10:15:34.5762053Z", + "createdBy": "username@microsoft.com", "createdByType": "User", "lastModifiedAt": + "2023-08-22T10:15:34.5762053Z", "lastModifiedBy": "username@microsoft.com", + "lastModifiedByType": "User"}}' headers: cache-control: - no-cache content-length: - - '1170' + - '1246' content-type: - application/json; charset=utf-8 expires: @@ -142,7 +143,7 @@ interactions: x-content-type-options: - nosniff x-request-time: - - '0.197' + - '0.072' status: code: 200 message: OK @@ -165,18 +166,18 @@ interactions: body: string: '{"tags": null, "location": null, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/connections/custom_connection", "name": "custom_connection", "type": "Microsoft.MachineLearningServices/workspaces/connections", - "properties": {"authType": "CustomKeys", "credentials": {"keys": {}}, "category": - "CustomKeys", "expiryTime": null, "target": "_", "createdByWorkspaceArmId": + "properties": {"authType": "CustomKeys", "credentials": {"keys": {}}, "group": + "AzureAI", "category": "CustomKeys", "expiryTime": null, "target": "_", "createdByWorkspaceArmId": null, "isSharedToAll": false, "sharedUserList": [], "metadata": {"azureml.flow.connection_type": "Custom", "azureml.flow.module": "promptflow.connections"}}, "systemData": - {"createdAt": "2023-06-19T20:56:12.0353964Z", "createdBy": "sejuare@microsoft.com", + {"createdAt": "2023-06-19T20:56:12.0353964Z", "createdBy": "username@microsoft.com", "createdByType": "User", "lastModifiedAt": "2023-06-19T20:56:12.0353964Z", - "lastModifiedBy": "sejuare@microsoft.com", "lastModifiedByType": "User"}}' + "lastModifiedBy": "username@microsoft.com", "lastModifiedByType": "User"}}' headers: cache-control: - no-cache content-length: - - '1251' + - '1275' content-type: - application/json; charset=utf-8 expires: @@ -192,7 +193,7 @@ interactions: x-content-type-options: - nosniff x-request-time: - - '0.259' + - '0.075' status: code: 200 message: OK diff --git a/src/promptflow/tests/test_configs/recordings/test_connection_operations_TestConnectionOperations_test_get_connection.yaml b/src/promptflow/tests/test_configs/recordings/test_connection_operations_TestConnectionOperations_test_get_connection.yaml index 35474860fbd..88be482281c 100644 --- a/src/promptflow/tests/test_configs/recordings/test_connection_operations_TestConnectionOperations_test_get_connection.yaml +++ b/src/promptflow/tests/test_configs/recordings/test_connection_operations_TestConnectionOperations_test_get_connection.yaml @@ -9,21 +9,21 @@ interactions: Connection: - keep-alive User-Agent: - - promptflow-sdk/0.0.1 azure-ai-ml/1.10.0 azsdk-python-mgmt-machinelearningservices/0.1.0 - Python/3.10.13 (Windows-10-10.0.22621-SP0) + - promptflow-sdk/0.0.1 promptflow/0.0.1 azure-ai-ml/1.12.1 azsdk-python-mgmt-machinelearningservices/0.1.0 + Python/3.10.13 (Windows-10-10.0.22631-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/api-version=2023-06-01-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/api-version=2023-08-01-preview response: body: string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000", "name": "00000", "type": "Microsoft.MachineLearningServices/workspaces", "location": "eastus", "tags": {}, "etag": null, "kind": "Default", "sku": {"name": "Basic", - "tier": "Basic"}}' + "tier": "Basic"}, "properties": {"discoveryUrl": "https://eastus.api.azureml.ms/discovery"}}' headers: cache-control: - no-cache content-length: - - '3519' + - '3630' content-type: - application/json; charset=utf-8 expires: @@ -39,7 +39,7 @@ interactions: x-content-type-options: - nosniff x-request-time: - - '0.029' + - '0.023' status: code: 200 message: OK @@ -53,8 +53,8 @@ interactions: Connection: - keep-alive User-Agent: - - promptflow-sdk/0.0.1 azure-ai-ml/1.10.0 azsdk-python-mgmt-machinelearningservices/0.1.0 - Python/3.10.13 (Windows-10-10.0.22621-SP0) + - promptflow-sdk/0.0.1 promptflow/0.0.1 azure-ai-ml/1.12.1 azsdk-python-mgmt-machinelearningservices/0.1.0 + Python/3.10.13 (Windows-10-10.0.22631-SP0) method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores?api-version=2023-04-01-preview&count=30&isDefault=true&orderByAsc=false response: @@ -91,7 +91,7 @@ interactions: x-content-type-options: - nosniff x-request-time: - - '0.107' + - '0.058' status: code: 200 message: OK @@ -105,8 +105,8 @@ interactions: Connection: - keep-alive User-Agent: - - promptflow-sdk/0.0.1 azsdk-python-azuremachinelearningdesignerserviceclient/unknown - Python/3.10.13 (Windows-10-10.0.22621-SP0) + - promptflow-sdk/0.0.1 promptflow/0.0.1 azsdk-python-azuremachinelearningdesignerserviceclient/unknown + Python/3.10.13 (Windows-10-10.0.22631-SP0) method: GET uri: https://eastus.api.azureml.ms/flow/api/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/Connections/azure_open_ai_connection response: @@ -114,7 +114,7 @@ interactions: string: '{"connectionName": "azure_open_ai_connection", "connectionType": "AzureOpenAI", "configs": {"api_base": "https://fake.openai.azure.com", "api_key": null, "api_type": "azure", "api_version": "2023-07-01-preview", "resource_id": null}, - "owner": {"userName": "yigao@microsoft.com"}, "createdDate": "2023-08-22T10:15:34.5762053Z", + "owner": {"userName": "username@microsoft.com"}, "createdDate": "2023-08-22T10:15:34.5762053Z", "lastModifiedDate": "2023-08-22T10:15:34.5762053Z"}' headers: connection: @@ -132,7 +132,7 @@ interactions: x-content-type-options: - nosniff x-request-time: - - '0.345' + - '0.382' status: code: 200 message: OK @@ -146,14 +146,14 @@ interactions: Connection: - keep-alive User-Agent: - - promptflow-sdk/0.0.1 azsdk-python-azuremachinelearningdesignerserviceclient/unknown - Python/3.10.13 (Windows-10-10.0.22621-SP0) + - promptflow-sdk/0.0.1 promptflow/0.0.1 azsdk-python-azuremachinelearningdesignerserviceclient/unknown + Python/3.10.13 (Windows-10-10.0.22631-SP0) method: GET uri: https://eastus.api.azureml.ms/flow/api/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/Connections/custom_connection response: body: string: '{"connectionName": "custom_connection", "connectionType": "Custom", - "owner": {"userName": "sejuare@microsoft.com"}, "createdDate": "2023-06-19T20:56:12.0353964Z", + "owner": {"userName": "username@microsoft.com"}, "createdDate": "2023-06-19T20:56:12.0353964Z", "lastModifiedDate": "2023-06-19T20:56:12.0353964Z"}' headers: connection: @@ -167,7 +167,7 @@ interactions: x-content-type-options: - nosniff x-request-time: - - '0.336' + - '0.367' status: code: 200 message: OK