Skip to content

Commit

Permalink
Fix SanitizeFieldNamesTests (#1299)
Browse files Browse the repository at this point in the history
* Update SanitizeFieldNamesTests.cs

* Fix failing sanitize tests
  • Loading branch information
gregkalapos authored May 26, 2021
1 parent b6b679c commit 4591f02
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Elastic.Apm/Filters/ErrorContextSanitizerFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public IError Filter(IError error)
{
if (realError.Context.Request?.Headers != null && realError.ConfigSnapshot != null)
{
foreach (var key in realError.Context?.Request?.Headers?.Keys)
foreach (var key in realError.Context?.Request?.Headers?.Keys.ToList())
{
if (WildcardMatcher.IsAnyMatch(realError.ConfigSnapshot.SanitizeFieldNames, key))
realError.Context.Request.Headers[key] = Consts.Redacted;
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Apm/Filters/HeaderDictionarySanitizerFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ITransaction Filter(ITransaction transaction)
{
if (realTransaction.IsContextCreated && realTransaction.Context.Request?.Headers != null)
{
foreach (var key in realTransaction.Context?.Request?.Headers?.Keys)
foreach (var key in realTransaction.Context?.Request?.Headers?.Keys.ToList())
{
if (WildcardMatcher.IsAnyMatch(realTransaction.ConfigSnapshot.SanitizeFieldNames, key))
realTransaction.Context.Request.Headers[key] = Consts.Redacted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public async Task SanitizeHeadersOnError(string headerName, bool useOnlyDiagnost
_capturedPayload.FirstTransaction.Context.Request.Headers[headerName].Should().Be("[REDACTED]");

_capturedPayload.WaitForErrors();
_capturedPayload.Errors.Should().ContainSingle();
_capturedPayload.Errors.Should().NotBeEmpty();
_capturedPayload.FirstError.Context.Should().NotBeNull();
_capturedPayload.FirstError.Context.Request.Should().NotBeNull();
_capturedPayload.FirstError.Context.Request.Headers.Should().NotBeNull();
Expand Down

0 comments on commit 4591f02

Please sign in to comment.