-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[Microsoft.ClientModel.TestFramework] add options for content disposition filepath normalization and removing default sanitizers #54409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
…g/azure-sdk-for-net into testframework-multipart
sdk/core/Microsoft.ClientModel.TestFramework/src/RecordedTests/TestRecording.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances the test framework with two key features to address cross-platform recording compatibility and performance issues. It adds a ContentDispositionFilePathSanitizer to normalize file paths in Content-Disposition headers (preventing OS-specific recording failures), and introduces a RemoveDefaultSanitizers option to improve performance for large request bodies by allowing selective sanitizer removal while preserving the Authorization header sanitizer.
Key changes:
- Adds
RemoveDefaultSanitizersboolean property andCustomSanitizerslist toRecordedTestBase - Implements logic in
TestRecordingto remove default sanitizers except AZSDK0000 (Authorization) - Introduces
ContentDispositionFilePathSanitizermodel and enum value - Regenerates client code with test-proxy version 1.0.0-dev.20251209.1, including various serialization and infrastructure improvements
Reviewed changes
Copilot reviewed 11 out of 65 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| RecordedTestBase.cs | Adds RemoveDefaultSanitizers property and CustomSanitizers list for test configuration |
| TestRecording.cs | Implements removal of hardcoded list of default sanitizers and applies custom sanitizers |
| RemoveDefaultSanitizersTests.cs | Tests that default sanitizers are removed except Authorization header sanitizer |
| MapsClientTests.cs | Tests default behavior and adds ContentDispositionFilePathSanitizer to CustomSanitizers |
| ContentDispositionFilePathSanitizer.cs | New generated model for the Content-Disposition filepath sanitizer |
| SanitizerType.cs/Serialization.cs | Adds ContentDispositionFilePathSanitizer enum value and serialization |
| SanitizerAddition.cs/Serialization.cs | Updates documentation to include new sanitizer type |
| TestProxyClient*.cs | Regenerated with updated SDK patterns (cancellation token handling, pipeline message creation) |
| TestProxyAdminClient*.cs | Regenerated with consistent patterns for request options |
| Various Serialization files | Updates JsonDocument.Parse calls to use JsonDocumentOptions for consistency |
| TypeFormatters.cs | Refactors to use SerializationFormat enum instead of string format specifiers |
| ClientUriBuilder.cs | Optimizes by consolidating path and query into single StringBuilder |
| SerializationFormat.cs | New enum defining serialization format options |
| CancellationTokenExtensions.cs | New extension method for converting CancellationToken to RequestOptions |
| CodeGen*Attribute.cs | Changes namespace to Microsoft.TypeSpec.Generator.Customizations |
| assets.json | Updates assets tag for new test recordings |
| .config/dotnet-tools.json | Updates test-proxy version to 1.0.0-dev.20251209.1 |
| API surface files (*.cs) | Updates public API surface to expose new properties and sanitizer type |
Some libraries set filepaths as filenames in multipart/form-data Content-Disposition headers, which is okay according to the HTTP spec. This caused issues in the test proxy which does a byte comparison. It will only succeed if the test was recorded and played back on the same OS. I added a sanitizer to normalize this in Azure/azure-sdk-tools#12948
This adds a custom sanitizers list and regenerates to include the new sanitizer. It also adds a boolean to remove default sanitizers except for the Authorization header sanitizer. For OpenAI, the only default sanitizer needed is the Authorization header. All of the unused default sanitizers are causing a huge performance bottleneck when working with large Audio/Image requests