Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
15e6946
begin the refactor. need to update wherever we touch sanitizers to en…
scbedd Apr 12, 2024
1f34c08
just save away the progress so that this can be pulled over to anothe…
scbedd Apr 17, 2024
13d6486
making a sanitizer store its id so that we have a consistent value to…
scbedd Apr 17, 2024
b861e01
getting closer. Need to rationalize registration + removal
scbedd Apr 17, 2024
e2304aa
first passing build. now time to discover all the test failures. gon …
scbedd Apr 18, 2024
45332b9
gotta initialize the Sanitizers concurrentDictionary!
scbedd Apr 18, 2024
c9bde0c
all but 3 tests passing
scbedd Apr 18, 2024
2ece462
simplify _register a bit
scbedd Apr 18, 2024
9a16d3e
rid ourselves of csharp9 call
scbedd Apr 18, 2024
8e2a873
committing progress w/ incomplete new routes
scbedd Apr 18, 2024
b92dec5
reference a specific branch for harsha to explore on
scbedd Apr 18, 2024
a1ae82e
remove some usings
scbedd Apr 18, 2024
053ce5e
we are getting a ton closer
scbedd Apr 18, 2024
95cb685
attempt interlocked increment with the automatic id
scbedd Apr 19, 2024
ef69312
further feedback to avoid ever having a problem
scbedd Apr 19, 2024
c77d722
skin out the tests
scbedd Apr 19, 2024
a3d7d17
repair admin test
scbedd Apr 19, 2024
755d0b2
forgot to set content length woops
scbedd Apr 19, 2024
a40939a
now we're properly writing the responses from Admin
scbedd Apr 19, 2024
2dde663
actually fix the first test
scbedd Apr 19, 2024
518066b
we can actually remove sanitizers now
scbedd Apr 19, 2024
d52c08e
we can remove sanitizers by route now. time to test
scbedd Apr 20, 2024
4cb7012
now it is connected top to bottom. tests only remain
scbedd Apr 20, 2024
f6fb3ce
adding the tests and catching a bug in recording-specific sanitizer r…
scbedd Apr 22, 2024
75fcad2
small correction on returned result
scbedd Apr 22, 2024
02cd858
Update tools/test-proxy/Azure.Sdk.Tools.TestProxy/Properties/launchSe…
scbedd Apr 22, 2024
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
Prev Previous commit
Next Next commit
now it is connected top to bottom. tests only remain
  • Loading branch information
scbedd committed Apr 20, 2024
commit 4cb7012604698c950f674b3862e13f52bc3b3fdd
10 changes: 9 additions & 1 deletion tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task AddTransform()
}

[HttpPost]
public void RemoveSanitizers([FromBody]RemoveSanitizerList sanitizerList)
public async Task RemoveSanitizers([FromBody]RemoveSanitizerList sanitizerList)
{
DebugLogger.LogAdminRequestDetails(_logger, Request);
var recordingId = RecordingHandler.GetHeader(Request, "x-recording-id", allowNulls: true);
Expand All @@ -90,6 +90,14 @@ public void RemoveSanitizers([FromBody]RemoveSanitizerList sanitizerList)
+ string.Join("\n", exceptionsList);
throw new HttpException(HttpStatusCode.BadRequest, varExceptionMessage);
}
else
{
var json = JsonSerializer.Serialize(new { RemovedSanitizers = removedSanitizers });
Response.ContentType = "application/json";
Response.ContentLength = json.Length;

await Response.WriteAsync(json);
}
}

[HttpPost]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public SanitizerDictionary() {
)
};

/// <summary>
/// Used to update the session sanitizers to their default configuration.
/// </summary>
public void ResetSessionSanitizers()
{
var expectedSanitizers = DefaultSanitizerList;
Expand Down Expand Up @@ -86,11 +89,20 @@ public List<RecordedTestSanitizer> GetSanitizers(ModifiableRecordSession session
return GetRegisteredSanitizers(session).Select(x => x.Sanitizer).ToList();
}

/// <summary>
/// Gets a list of sanitizers that should be applied for the session level.
/// </summary>
/// <returns></returns>
public List<RecordedTestSanitizer> GetSanitizers()
{
return GetRegisteredSanitizers().Select(x => x.Sanitizer).ToList();
}

/// <summary>
/// Get the set of registered sanitizers for a specific recording or playback session.
/// </summary>
/// <param name="session"></param>
/// <returns></returns>
public List<RegisteredSanitizer> GetRegisteredSanitizers(ModifiableRecordSession session)
{
var sanitizers = new List<RegisteredSanitizer>();
Expand All @@ -105,6 +117,10 @@ public List<RegisteredSanitizer> GetRegisteredSanitizers(ModifiableRecordSession
return sanitizers;
}

/// <summary>
/// Gets the set of registered sanitizers for the session level.
/// </summary>
/// <returns></returns>
public List<RegisteredSanitizer> GetRegisteredSanitizers()
{
var sanitizers = new List<RegisteredSanitizer>();
Expand Down Expand Up @@ -136,7 +152,7 @@ private bool _register(RecordedTestSanitizer sanitizer, string id)
/// Ensuring that session level sanitizers can be identified internally
/// </summary>
/// <param name="sanitizer"></param>
/// <returns></returns>
/// <returns>The Id of the newly registered sanitizer.</returns>
/// <exception cref="HttpException"></exception>
public string Register(RecordedTestSanitizer sanitizer)
{
Expand All @@ -155,7 +171,7 @@ public string Register(RecordedTestSanitizer sanitizer)
/// </summary>
/// <param name="session"></param>
/// <param name="sanitizer"></param>
/// <returns></returns>
/// <returns>The Id of the newly registered sanitizer.</returns>
/// <exception cref="HttpException"></exception>
public string Register(ModifiableRecordSession session, RecordedTestSanitizer sanitizer)
{
Expand All @@ -171,6 +187,12 @@ public string Register(ModifiableRecordSession session, RecordedTestSanitizer sa
return string.Empty;
}

/// <summary>
/// Removes a sanitizer from the global session set.
/// </summary>
/// <param name="sanitizerId"></param>
/// <returns></returns>
/// <exception cref="HttpException"></exception>
public string Unregister(string sanitizerId)
{
if (SessionSanitizers.Contains(sanitizerId))
Expand All @@ -182,6 +204,13 @@ public string Unregister(string sanitizerId)
throw new HttpException(System.Net.HttpStatusCode.BadRequest, $"The requested sanitizer for removal \"{sanitizerId}\" is not active at the session level.");
}

/// <summary>
/// Removes a sanitizer from a specific recording or playback session.
/// </summary>
/// <param name="sanitizerId"></param>
/// <param name="session"></param>
/// <returns></returns>
/// <exception cref="HttpException"></exception>
public string Unregister(string sanitizerId, ModifiableRecordSession session)
{
if (session.AppliedSanitizers.Contains(sanitizerId))
Expand All @@ -204,13 +233,12 @@ public void Cleanup(ModifiableRecordSession session)
Sanitizers.TryRemove(sanitizerId, out var RemovedSanitizer);
}
}

/// <summary>
/// Not publically available via an API Route, but used to remove all of the active default session sanitizers.
/// </summary>
public void Clear()
{
foreach(var sanitizerId in SessionSanitizers)
{
Sanitizers.TryRemove(sanitizerId.ToString(), out var RemovedSanitizer);
}

SessionSanitizers.Clear();
}
}
Expand Down