Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Feb 20, 2024
1 parent ff7fd44 commit c99af33
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(SolutionRoot)\build\elasticapmsample.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<None Remove="Views\Home\Cookies.cshtml" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Antlr3.Runtime" Version="3.5.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class HomeController : ControllerBase
internal const string GenNSpansPageRelativePath = HomePageRelativePath + "/" + nameof(GenNSpans);
internal const string GetDotNetRuntimeDescriptionPageRelativePath = HomePageRelativePath + "/" + nameof(GetDotNetRuntimeDescription);
internal const string HomePageRelativePath = "Home";
internal const string CookiesPageRelativePath = "Cookies";
internal const string CookiesPageRelativePath = HomePageRelativePath + "/" + nameof(Cookies);
internal const string LabelsTestRelativePath = HomePageRelativePath + "/" + nameof(LabelsTest);
internal const string NotFoundPageRelativePath = HomePageRelativePath + "/" + nameof(NotFound);

Expand Down
5 changes: 3 additions & 2 deletions test/iis/AspNetFullFrameworkSampleApp/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
<add key="ElasticApm:CaptureBodyContentTypes" value="application/x-www-form-urlencoded*, multipart/form-data, text/*, application/json*, application/xml*" />
<add key="ElasticApm:MaxQueueEventCount" value="9128"/>
<add key="ElasticApm:CloudProvider" value="none"/>
<add key="ElasticApm:SanitizeFieldNames" value="password, passwd, pwd, secret, *key, *token*, *session*, *credit*, *card*, *auth*, set-cookie, *principal*, mysecurecookie"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1"/>
<httpRuntime targetFramework="4.6.1"/>
<compilation debug="true" targetFramework="4.6.2"/>
<httpRuntime targetFramework="4.6.2"/>
</system.web>
<system.webServer>
<modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task SanitizesCookieHeaders()
{
var pathData = SampleAppUrlPaths.CookiesPage;

await SendGetRequestToSampleAppAndVerifyResponse(pathData.Uri, pathData.StatusCode);
await SendGetRequestToSampleAppAndVerifyResponse(pathData.Uri, pathData.StatusCode, false);
await WaitAndCustomVerifyReceivedData(receivedData =>
{
receivedData.Transactions.Count.Should().Be(1);
Expand All @@ -31,9 +31,11 @@ await WaitAndCustomVerifyReceivedData(receivedData =>
receivedData.Transactions[0].Context.Request.Should().NotBeNull();

receivedData.Transactions[0].Context.Response.Headers["Set-Cookie"].Should().Be(Apm.Consts.Redacted);
});
}, false);

await SendGetRequestToSampleAppAndVerifyResponse(pathData.Uri, pathData.StatusCode);
ClearState();

await SendGetRequestToSampleAppAndVerifyResponse(pathData.Uri, pathData.StatusCode, false);
await WaitAndCustomVerifyReceivedData(receivedData =>
{
receivedData.Transactions.Count.Should().Be(1);
Expand All @@ -45,8 +47,8 @@ await WaitAndCustomVerifyReceivedData(receivedData =>

receivedData.Transactions[0].Context.Request.Headers["Cookie"].Should().Be(Apm.Consts.Redacted);
receivedData.Transactions[0].Context.Request.Cookies["MySecureCookie"].Should().Be(Apm.Consts.Redacted);
receivedData.Transactions[0].Context.Request.Cookies["SafeCookie"].Should().Be("123");
});
receivedData.Transactions[0].Context.Request.Cookies["SafeCookie"].Should().Be("This is safe to record and should not be redacted.");
}, false);
}
}
}

0 comments on commit c99af33

Please sign in to comment.