Skip to content
Merged
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 @@ -79,7 +79,7 @@ public async Task TestReflectionModelWithTargetRecordSession()

await testRecordingHandler.RegisterSanitizer(new UriRegexSanitizer(regex: "ABC123"), recordingId);
await testRecordingHandler.RegisterSanitizer(new BodyRegexSanitizer(regex: ".+?"), recordingId);
testRecordingHandler.SetMatcherForRecording(recordingId, new CustomDefaultMatcher(compareBodies: false, excludedHeaders: "an-excluded-header"));
await testRecordingHandler.SetMatcherForRecording(recordingId, new CustomDefaultMatcher(compareBodies: false, excludedHeaders: "an-excluded-header"));

var model = new ActiveMetadataModel(testRecordingHandler, recordingId);
var descriptions = model.Descriptions.ToList();
Expand Down
13 changes: 11 additions & 2 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,20 @@ public async Task SetMatcher()

if (recordingId != null)
{
_recordingHandler.SetMatcherForRecording(recordingId, m);
await _recordingHandler.SetMatcherForRecording(recordingId, m);
}
else
{
_recordingHandler.Matcher = m;
await _recordingHandler.SanitizerRegistry.SessionSanitizerLock.WaitAsync();

try
{
_recordingHandler.Matcher = m;
}
finally
{
_recordingHandler.SanitizerRegistry.SessionSanitizerLock.Release();
}
}
}

Expand Down
11 changes: 9 additions & 2 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,14 +1093,21 @@ public void AddTransformToRecording(string recordingId, ResponseTransform transf
}


public void SetMatcherForRecording(string recordingId, RecordMatcher matcher)
public async Task SetMatcherForRecording(string recordingId, RecordMatcher matcher)
{
if (!PlaybackSessions.TryGetValue(recordingId, out var session))
{
throw new HttpException(HttpStatusCode.BadRequest, $"{recordingId} is not an active playback session. Check the value being passed and try again.");
}

session.CustomMatcher = matcher;
await session.Session.EntryLock.WaitAsync();
try {
session.CustomMatcher = matcher;
}
finally
{
session.Session.EntryLock.Release();
}
}

public async Task SetDefaultExtensions(string recordingId = null)
Expand Down