Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Tidy tests
  • Loading branch information
jamescrosswell committed Jul 24, 2025
commit f413b79eb49fae6e9cd3abb60fc95ea10b018839
41 changes: 26 additions & 15 deletions test/Sentry.AspNetCore.Tests/Tunnel/IntegrationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public async Task TunnelMiddleware_CanForwardValidEnvelope(string host)
var requestMessage = new HttpRequestMessage(new HttpMethod("POST"), "/tunnel")
{
Content = new StringContent(
@"{""sent_at"":""2021-01-01T00:00:00.000Z"",""sdk"":{""name"":""sentry.javascript.browser"",""version"":""6.8.0""},""dsn"":""https://dns@" + host + @"/1""}
{""type"":""session""}
{""sid"":""fda00e933162466c849962eaea0cfaff""}")
$$"""
{"sent_at":"2021-01-01T00:00:00.000Z","sdk":{"name":"sentry.javascript.browser","version":"6.8.0"},"dsn":"https://dns@{{host}}/1"}
{"type":"session"}
{"sid":"fda00e933162466c849962eaea0cfaff"}
""")
};
await _server.CreateClient().SendAsync(requestMessage);

Expand All @@ -61,9 +63,12 @@ public async Task TunnelMiddleware_DoesNotForwardEnvelopeWithoutDsn()
{
var requestMessage = new HttpRequestMessage(new HttpMethod("POST"), "/tunnel")
{
Content = new StringContent(@"{}
{""type"":""session""}
{""sid"":""fda00e933162466c849962eaea0cfaff""}")
Content = new StringContent(
"""
{}
{"type":"session"}
{"sid":"fda00e933162466c849962eaea0cfaff"}
""")
};
await _server.CreateClient().SendAsync(requestMessage);

Expand All @@ -75,9 +80,11 @@ public async Task TunnelMiddleware_DoesNotForwardEnvelopeToArbitraryHost()
{
var requestMessage = new HttpRequestMessage(new HttpMethod("POST"), "/tunnel");
requestMessage.Content = new StringContent(
@"{""sent_at"":""2021-01-01T00:00:00.000Z"",""sdk"":{""name"":""sentry.javascript.browser"",""version"":""6.8.0""},""dsn"":""https://[email protected]/1""}
{""type"":""session""}
{""sid"":""fda00e933162466c849962eaea0cfaff""}");
"""
{"sent_at":"2021-01-01T00:00:00.000Z","sdk":{"name":"sentry.javascript.browser","version":"6.8.0"},"dsn":"https://[email protected]/1"}
{"type":"session"}
{"sid":"fda00e933162466c849962eaea0cfaff"}
""");
await _server.CreateClient().SendAsync(requestMessage);

Assert.Equal(0, _httpMessageHandler.NumberOfCalls);
Expand All @@ -89,9 +96,11 @@ public async Task TunnelMiddleware_CanForwardEnvelopeToWhiteListedHost()
var requestMessage = new HttpRequestMessage(new HttpMethod("POST"), "/tunnel")
{
Content = new StringContent(
@"{""sent_at"":""2021-01-01T00:00:00.000Z"",""sdk"":{""name"":""sentry.javascript.browser"",""version"":""6.8.0""},""dsn"":""https://[email protected]/1""}
{""type"":""session""}
{""sid"":""fda00e933162466c849962eaea0cfaff""}")
"""
{"sent_at":"2021-01-01T00:00:00.000Z","sdk":{"name":"sentry.javascript.browser","version":"6.8.0"},"dsn":"https://[email protected]/1"}
{"type":"session"}
{"sid":"fda00e933162466c849962eaea0cfaff"}
""")
};
await _server.CreateClient().SendAsync(requestMessage);

Expand All @@ -105,9 +114,11 @@ public async Task TunnelMiddleware_XForwardedFor_RetainsOriginIp()
var requestMessage = new HttpRequestMessage(new HttpMethod("POST"), "/tunnel")
{
Content = new StringContent(
@"{""sent_at"":""2021-01-01T00:00:00.000Z"",""sdk"":{""name"":""sentry.javascript.browser"",""version"":""6.8.0""},""dsn"":""https://[email protected]/1""}
{""type"":""session""}
{""sid"":""fda00e933162466c849962eaea0cfaff""}")
"""
{"sent_at":"2021-01-01T00:00:00.000Z","sdk":{"name":"sentry.javascript.browser","version":"6.8.0"},"dsn":"https://[email protected]/1"}
{"type":"session"}
{"sid":"fda00e933162466c849962eaea0cfaff"}
""")
};
const string originalForwardedFor = "192.168.1.100, 10.0.0.1";
requestMessage.Headers.Add("X-Forwarded-For", originalForwardedFor);
Expand Down