diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/PlaybackTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/PlaybackTests.cs index 5022d3f6f4b..1b8fdd66406 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/PlaybackTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/PlaybackTests.cs @@ -37,7 +37,9 @@ public async void TestStartPlaybackSimple() await controller.Start(); var value = httpContext.Response.Headers["x-recording-id"].ToString(); - Assert.NotNull(value); + var recordLocation = httpContext.Response.Headers["x-recording-file-location"].ToString(); + Assert.False(String.IsNullOrEmpty(value)); + Assert.False(String.IsNullOrEmpty(recordLocation)); Assert.True(testRecordingHandler.PlaybackSessions.ContainsKey(value)); } @@ -74,7 +76,9 @@ public async void TestStartPlaybackInMemory() await playbackController.Start(); var value = playbackContext.Response.Headers["x-recording-id"].ToString(); - Assert.NotNull(value); + var recordLocation = playbackContext.Response.Headers["x-recording-file-location"].ToString(); + Assert.False(String.IsNullOrEmpty(value)); + Assert.True(String.IsNullOrEmpty(recordLocation)); Assert.True(testRecordingHandler.PlaybackSessions.ContainsKey(value)); Assert.True(testRecordingHandler.InMemorySessions.Count() == 1); } @@ -206,7 +210,7 @@ public async Task TestPlaybackSetsRetryAfterToZero() await controller.Start(); var recordingId = httpContext.Response.Headers["x-recording-id"].ToString(); - Assert.NotNull(recordingId); + Assert.False(String.IsNullOrEmpty(recordingId)); Assert.True(testRecordingHandler.PlaybackSessions.ContainsKey(recordingId)); var entry = testRecordingHandler.PlaybackSessions[recordingId].Session.Entries[0]; HttpRequest request = TestHelpers.CreateRequestFromEntry(entry); @@ -241,7 +245,7 @@ public async Task TestPlaybackWithGZippedContentPlayback() await controller.Start(); var recordingId = httpContext.Response.Headers["x-recording-id"].ToString(); - Assert.NotNull(recordingId); + Assert.False(String.IsNullOrEmpty(recordingId)); Assert.True(testRecordingHandler.PlaybackSessions.ContainsKey(recordingId)); var entry = testRecordingHandler.PlaybackSessions[recordingId].Session.Entries[0]; HttpRequest request = TestHelpers.CreateRequestFromEntry(entry); diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs index 5e08673fa99..82fdb96b679 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs @@ -35,7 +35,7 @@ public async Task TestStartRecordSimple() }; await controller.Start(); var recordingId = httpContext.Response.Headers["x-recording-id"].ToString(); - Assert.NotNull(recordingId); + Assert.False(string.IsNullOrEmpty(recordingId)); Assert.True(testRecordingHandler.RecordingSessions.ContainsKey(recordingId)); } @@ -62,9 +62,9 @@ public async Task TestStartRecordInMemory() [Theory] [InlineData("recordings/TestStartRecordSimple_nosave.json", "request-response")] - [InlineData("recordings/TestStartRecordSimpl�_nosave.json", "request-response")] + [InlineData("recordings/TestStartRecordSimplé_nosave.json", "request-response")] [InlineData("recordings/TestStartRecordSimple.json", "")] - [InlineData("recordings/TestStartRecordSimpl�.json", "")] + [InlineData("recordings/TestStartRecordSimplé.json", "")] public async Task TestStopRecordingSimple(string targetFile, string additionalEntryModeHeader) { RecordingHandler testRecordingHandler = new RecordingHandler(Directory.GetCurrentDirectory()); diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md index 307e0bd97fb..f77a1124a90 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md @@ -351,6 +351,8 @@ To start an individual test recording or playback, users will POST to a route on You will receive a recordingId in the reponse under header `x-recording-id`. This value should be included under header `x-recording-id` in all further requests. +For playback, you will receive the location of the recording file (if it is on disk) in the header `x-recording-file-location`. + ### Run your tests The implicit assumption about this proxy is that you as a dev have _some way_ to reroute your existing requests (with some header additions) to the test-proxy. diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs index af8a23ca1c2..6c9f71d2ef5 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs @@ -372,7 +372,7 @@ public async Task StartPlaybackAsync(string sessionId, HttpResponse outgoingResp { await RestoreAssetsJson(assetsPath, true); var path = await GetRecordingPath(sessionId, assetsPath); - + outgoingResponse.Headers.Add("x-recording-file-location", path); if (!File.Exists(path)) { throw new TestRecordingMismatchException($"Recording file path {path} does not exist.");