From c5d84bf3c3bfa7c280d52a3bed222e11f46c4217 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 29 Jun 2022 07:28:51 +1000 Subject: [PATCH] Log Warning when secret is detected in DSN (#1749) --- CHANGELOG.md | 1 + src/Sentry/SentrySdk.cs | 10 ++- test/Directory.Build.props | 1 + .../SentryGrpcSdkTestFixture.cs | 2 +- ...reSentryWebHostBuilder.IntegrationTests.cs | 2 +- .../AspNetSentrySdkTestFixture.cs | 2 +- .../IntegrationMockedBackgroundWorker.cs | 2 +- .../MiddlewareLoggerIntegration.cs | 2 +- ...tryHttpMessageHandlerBuilderFilterTests.cs | 2 +- .../SentryTracingMiddlewareTests.cs | 16 ++-- .../SentryWebHostBuilderExtensionsTests.cs | 2 +- .../SqlListenerTests.cs | 4 +- .../ErrorProcessorTests.cs | 2 +- .../SentryMauiAppBuilderExtensionsTests.cs | 24 ++--- test/Sentry.NLog.Tests/SentryTargetTests.cs | 12 ++- .../AspNetSentrySdkTestFixture.cs | 2 +- .../SentrySerilogSinkExtensionsTests.cs | 2 +- test/Sentry.Testing/DsnSamples.cs | 6 +- .../Sentry.Tests/GlobalSessionManagerTests.cs | 2 +- test/Sentry.Tests/HubTests.cs | 88 +++++++++---------- .../DefaultSentryHttpClientFactoryTests.cs | 2 +- .../Sentry.Tests/Internals/DsnLocatorTests.cs | 10 +-- .../Internals/Http/CachingTransportTests.cs | 26 +++--- .../GzipBufferedRequestBodyHandlerTests.cs | 2 +- .../Http/GzipRequestBodyHandlerTests.cs | 2 +- .../Internals/Http/HttpTransportTests.cs | 40 ++++----- test/Sentry.Tests/Protocol/DsnSamples.cs | 17 ---- test/Sentry.Tests/Protocol/DsnTests.cs | 33 ++++--- .../Sentry.Tests/Protocol/TransactionTests.cs | 4 +- test/Sentry.Tests/SentryClientTests.cs | 22 ++--- test/Sentry.Tests/SentrySdkTests.cs | 81 +++++++++-------- 31 files changed, 213 insertions(+), 210 deletions(-) delete mode 100644 test/Sentry.Tests/Protocol/DsnSamples.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index df5b7e347e..35b50eac60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Android Scope Sync ([#1737](https://github.com/getsentry/sentry-dotnet/pull/1737)) - Enable logging in MAUI ([#1738](https://github.com/getsentry/sentry-dotnet/pull/1738)) - Support IntPtr and UIntPtr serialization ([#1746](https://github.com/getsentry/sentry-dotnet/pull/1746)) +- Log Warning when secret is detected in DSN ([#1749](https://github.com/getsentry/sentry-dotnet/pull/1749)) - Catch permission exceptions on Android ([#1750](https://github.com/getsentry/sentry-dotnet/pull/1750)) - Enable offline caching in MAUI ([#1753](https://github.com/getsentry/sentry-dotnet/pull/1753)) diff --git a/src/Sentry/SentrySdk.cs b/src/Sentry/SentrySdk.cs index db07eb0a24..15644825c1 100644 --- a/src/Sentry/SentrySdk.cs +++ b/src/Sentry/SentrySdk.cs @@ -35,18 +35,22 @@ internal static IHub InitHub(SentryOptions options) // If DSN is null (i.e. not explicitly disabled, just unset), then // try to resolve the value from environment. - var dsn = options.Dsn ??= DsnLocator.FindDsnStringOrDisable(); + var dsnString = options.Dsn ??= DsnLocator.FindDsnStringOrDisable(); // If it's either explicitly disabled or we couldn't resolve the DSN // from anywhere else, return a disabled hub. - if (Dsn.IsDisabled(dsn)) + if (Dsn.IsDisabled(dsnString)) { options.LogWarning("Init was called but no DSN was provided nor located. Sentry SDK will be disabled."); return DisabledHub.Instance; } // Validate DSN for an early exception in case it's malformed - _ = Dsn.Parse(dsn); + var dsn = Dsn.Parse(dsnString); + if (dsn.SecretKey != null) + { + options.LogWarning("The provided DSN that contains a secret key. This is not required and will be ignored."); + } return new Hub(options); } diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 8d55a0bfb2..42d3bc5e51 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -35,6 +35,7 @@ + diff --git a/test/Sentry.AspNetCore.Grpc.Tests/SentryGrpcSdkTestFixture.cs b/test/Sentry.AspNetCore.Grpc.Tests/SentryGrpcSdkTestFixture.cs index e1f0094d1b..4a117da283 100644 --- a/test/Sentry.AspNetCore.Grpc.Tests/SentryGrpcSdkTestFixture.cs +++ b/test/Sentry.AspNetCore.Grpc.Tests/SentryGrpcSdkTestFixture.cs @@ -35,7 +35,7 @@ protected override void ConfigureBuilder(WebHostBuilder builder) sentryBuilder.AddGrpc(); sentryBuilder.AddSentryOptions(options => { - options.Dsn = DsnSamples.ValidDsnWithSecret; + options.Dsn = ValidDsn; options.SentryHttpClientFactory = new DelegateHttpClientFactory(_ => sentryHttpClient); Configure?.Invoke(options); diff --git a/test/Sentry.AspNetCore.Tests/AspNetCoreSentryWebHostBuilder.IntegrationTests.cs b/test/Sentry.AspNetCore.Tests/AspNetCoreSentryWebHostBuilder.IntegrationTests.cs index 277ad9340f..8973467146 100644 --- a/test/Sentry.AspNetCore.Tests/AspNetCoreSentryWebHostBuilder.IntegrationTests.cs +++ b/test/Sentry.AspNetCore.Tests/AspNetCoreSentryWebHostBuilder.IntegrationTests.cs @@ -12,7 +12,7 @@ public class SentryWebHostBuilderExtensionsIntegrationTests : AspNetSentrySdkTes [Fact] public void UseSentry_ValidDsnString_EnablesSdk() { - _ = _webHostBuilder.UseSentry(DsnSamples.ValidDsnWithoutSecret) + _ = _webHostBuilder.UseSentry(ValidDsn) .Build(); try diff --git a/test/Sentry.AspNetCore.Tests/AspNetSentrySdkTestFixture.cs b/test/Sentry.AspNetCore.Tests/AspNetSentrySdkTestFixture.cs index ddcc81e8c6..13435f38dc 100644 --- a/test/Sentry.AspNetCore.Tests/AspNetSentrySdkTestFixture.cs +++ b/test/Sentry.AspNetCore.Tests/AspNetSentrySdkTestFixture.cs @@ -17,7 +17,7 @@ protected override void ConfigureBuilder(WebHostBuilder builder) var sentryHttpClient = sentry.CreateClient(); _ = builder.UseSentry(options => { - options.Dsn = DsnSamples.ValidDsnWithSecret; + options.Dsn = ValidDsn; options.SentryHttpClientFactory = new DelegateHttpClientFactory(_ => sentryHttpClient); Configure?.Invoke(options); diff --git a/test/Sentry.AspNetCore.Tests/IntegrationMockedBackgroundWorker.cs b/test/Sentry.AspNetCore.Tests/IntegrationMockedBackgroundWorker.cs index 5850688489..cea002829c 100644 --- a/test/Sentry.AspNetCore.Tests/IntegrationMockedBackgroundWorker.cs +++ b/test/Sentry.AspNetCore.Tests/IntegrationMockedBackgroundWorker.cs @@ -26,7 +26,7 @@ public IntegrationMockedBackgroundWorker() { _ = builder.UseSentry(options => { - options.Dsn = DsnSamples.ValidDsnWithSecret; + options.Dsn = ValidDsn; options.BackgroundWorker = Worker; Configure?.Invoke(options); diff --git a/test/Sentry.AspNetCore.Tests/MiddlewareLoggerIntegration.cs b/test/Sentry.AspNetCore.Tests/MiddlewareLoggerIntegration.cs index ef3ebd93e0..f7e5201119 100644 --- a/test/Sentry.AspNetCore.Tests/MiddlewareLoggerIntegration.cs +++ b/test/Sentry.AspNetCore.Tests/MiddlewareLoggerIntegration.cs @@ -41,7 +41,7 @@ public Fixture() Client.When(client => client.CaptureEvent(Arg.Any(), Arg.Any())) .Do(callback => callback.Arg().Evaluate()); - var hub = new Hub(new SentryOptions { Dsn = DsnSamples.ValidDsnWithSecret }); + var hub = new Hub(new SentryOptions { Dsn = ValidDsn }); hub.BindClient(Client); Hub = hub; var provider = new SentryLoggerProvider(hub, Clock, loggingOptions); diff --git a/test/Sentry.AspNetCore.Tests/SentryHttpMessageHandlerBuilderFilterTests.cs b/test/Sentry.AspNetCore.Tests/SentryHttpMessageHandlerBuilderFilterTests.cs index 66049528e0..153d3ca590 100644 --- a/test/Sentry.AspNetCore.Tests/SentryHttpMessageHandlerBuilderFilterTests.cs +++ b/test/Sentry.AspNetCore.Tests/SentryHttpMessageHandlerBuilderFilterTests.cs @@ -38,7 +38,7 @@ public async Task Generated_client_sends_Sentry_trace_header_automatically() var hub = new Internal.Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret + Dsn = ValidDsn }); var server = new TestServer(new WebHostBuilder() diff --git a/test/Sentry.AspNetCore.Tests/SentryTracingMiddlewareTests.cs b/test/Sentry.AspNetCore.Tests/SentryTracingMiddlewareTests.cs index 88ea116732..d40fe6742c 100644 --- a/test/Sentry.AspNetCore.Tests/SentryTracingMiddlewareTests.cs +++ b/test/Sentry.AspNetCore.Tests/SentryTracingMiddlewareTests.cs @@ -19,7 +19,7 @@ public async Task Transactions_are_grouped_by_route() // Arrange var sentryClient = Substitute.For(); - var hub = new Internal.Hub(new SentryOptions { Dsn = DsnSamples.ValidDsnWithoutSecret, TracesSampleRate = 1 }, sentryClient); + var hub = new Internal.Hub(new SentryOptions { Dsn = ValidDsn, TracesSampleRate = 1 }, sentryClient); var server = new TestServer(new WebHostBuilder() .UseDefaultServiceProvider(di => di.EnableValidation()) @@ -65,7 +65,7 @@ public async Task Transaction_is_bound_on_the_scope_automatically() var sentryClient = Substitute.For(); - var hub = new Internal.Hub(new SentryOptions { Dsn = DsnSamples.ValidDsnWithoutSecret }, sentryClient); + var hub = new Internal.Hub(new SentryOptions { Dsn = ValidDsn }, sentryClient); var server = new TestServer(new WebHostBuilder() .UseDefaultServiceProvider(di => di.EnableValidation()) @@ -108,7 +108,7 @@ public async Task Transaction_is_started_automatically_from_incoming_trace_heade // Arrange var sentryClient = Substitute.For(); - var hub = new Internal.Hub(new SentryOptions { Dsn = DsnSamples.ValidDsnWithoutSecret, TracesSampleRate = 1 }, sentryClient); + var hub = new Internal.Hub(new SentryOptions { Dsn = ValidDsn, TracesSampleRate = 1 }, sentryClient); var server = new TestServer(new WebHostBuilder() .UseDefaultServiceProvider(di => di.EnableValidation()) @@ -152,7 +152,7 @@ public async Task Transaction_is_automatically_populated_with_request_data() var sentryClient = Substitute.For(); - var hub = new Internal.Hub(new SentryOptions { Dsn = DsnSamples.ValidDsnWithoutSecret, TracesSampleRate = 1 }, sentryClient); + var hub = new Internal.Hub(new SentryOptions { Dsn = ValidDsn, TracesSampleRate = 1 }, sentryClient); var server = new TestServer(new WebHostBuilder() .UseDefaultServiceProvider(di => di.EnableValidation()) @@ -204,7 +204,7 @@ public async Task Transaction_sampling_context_contains_HTTP_context_data() var hub = new Internal.Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, TracesSampler = ctx => { samplingContext = ctx; @@ -257,7 +257,7 @@ public async Task Transaction_binds_exception_thrown() var hub = new Internal.Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, TracesSampler = ctx => { samplingContext = ctx; @@ -318,7 +318,7 @@ public async Task Transaction_TransactionNameProviderSetSet_TransactionNameSet() .Do(callback => transaction = callback.Arg()); var options = new SentryAspNetCoreOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, TracesSampleRate = 1 }; @@ -359,7 +359,7 @@ public async Task Transaction_TransactionNameProviderSetUnset_UnknownTransaction .Do(callback => transaction = callback.Arg()); var options = new SentryAspNetCoreOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, TracesSampleRate = 1 }; diff --git a/test/Sentry.AspNetCore.Tests/SentryWebHostBuilderExtensionsTests.cs b/test/Sentry.AspNetCore.Tests/SentryWebHostBuilderExtensionsTests.cs index b31b2da506..28a264e163 100644 --- a/test/Sentry.AspNetCore.Tests/SentryWebHostBuilderExtensionsTests.cs +++ b/test/Sentry.AspNetCore.Tests/SentryWebHostBuilderExtensionsTests.cs @@ -36,7 +36,7 @@ public SentryWebHostBuilderExtensionsTests() [Theory, MemberData(nameof(ExpectedServices))] public void UseSentry_ValidDsnString_ServicesRegistered(Action assert) { - _ = WebHostBuilder.UseSentry(DsnSamples.ValidDsnWithoutSecret); + _ = WebHostBuilder.UseSentry(ValidDsn); assert(Services); } diff --git a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.cs b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.cs index f4ec0fe19b..6f0d1c1229 100644 --- a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.cs +++ b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.cs @@ -21,7 +21,7 @@ public async Task RecordsSql() { TracesSampleRate = 1, Transport = transport, - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLevel = SentryLevel.Debug }; @@ -62,7 +62,7 @@ public async Task RecordsEf() { TracesSampleRate = 1, Transport = transport, - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLevel = SentryLevel.Debug }; diff --git a/test/Sentry.EntityFramework.Tests/ErrorProcessorTests.cs b/test/Sentry.EntityFramework.Tests/ErrorProcessorTests.cs index 7706288d3b..bca84703dc 100644 --- a/test/Sentry.EntityFramework.Tests/ErrorProcessorTests.cs +++ b/test/Sentry.EntityFramework.Tests/ErrorProcessorTests.cs @@ -31,7 +31,7 @@ public Fixture() SentryClient = new SentryClient(new SentryOptions { BeforeSend = _beforeSend, - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, }.AddEntityFramework()); } } diff --git a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs index d5b51c429c..f20bd20ea7 100644 --- a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs +++ b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs @@ -26,7 +26,7 @@ public void CanUseSentry_WithConfigurationOnly() var builder = _fixture.Builder; builder.Services.Configure(options => { - options.Dsn = DsnSamples.ValidDsnWithoutSecret; + options.Dsn = ValidDsn; }); // Act @@ -38,7 +38,7 @@ public void CanUseSentry_WithConfigurationOnly() // Assert Assert.Same(builder, chainedBuilder); Assert.True(SentrySdk.IsEnabled); - Assert.Equal(DsnSamples.ValidDsnWithoutSecret, options.Dsn); + Assert.Equal(ValidDsn, options.Dsn); Assert.False(options.Debug); } @@ -49,7 +49,7 @@ public void CanUseSentry_WithDsnStringOnly() var builder = _fixture.Builder; // Act - var chainedBuilder = builder.UseSentry(DsnSamples.ValidDsnWithoutSecret); + var chainedBuilder = builder.UseSentry(ValidDsn); using var app = builder.Build(); var options = app.Services.GetRequiredService>().Value; @@ -57,7 +57,7 @@ public void CanUseSentry_WithDsnStringOnly() // Assert Assert.Same(builder, chainedBuilder); Assert.True(SentrySdk.IsEnabled); - Assert.Equal(DsnSamples.ValidDsnWithoutSecret, options.Dsn); + Assert.Equal(ValidDsn, options.Dsn); Assert.False(options.Debug); } @@ -70,7 +70,7 @@ public void CanUseSentry_WithOptionsOnly() // Act var chainedBuilder = builder.UseSentry(options => { - options.Dsn = DsnSamples.ValidDsnWithoutSecret; + options.Dsn = ValidDsn; }); using var app = builder.Build(); @@ -79,7 +79,7 @@ public void CanUseSentry_WithOptionsOnly() // Assert Assert.Same(builder, chainedBuilder); Assert.True(SentrySdk.IsEnabled); - Assert.Equal(DsnSamples.ValidDsnWithoutSecret, options.Dsn); + Assert.Equal(ValidDsn, options.Dsn); Assert.False(options.Debug); } @@ -90,7 +90,7 @@ public void CanUseSentry_WithConfigurationAndOptions() var builder = _fixture.Builder; builder.Services.Configure(options => { - options.Dsn = DsnSamples.ValidDsnWithoutSecret; + options.Dsn = ValidDsn; }); // Act @@ -105,7 +105,7 @@ public void CanUseSentry_WithConfigurationAndOptions() // Assert Assert.Same(builder, chainedBuilder); Assert.True(SentrySdk.IsEnabled); - Assert.Equal(DsnSamples.ValidDsnWithoutSecret, options.Dsn); + Assert.Equal(ValidDsn, options.Dsn); Assert.True(options.Debug); } @@ -116,7 +116,7 @@ public void UseSentry_EnablesGlobalMode() var builder = _fixture.Builder; // Act - _ = builder.UseSentry(DsnSamples.ValidDsnWithoutSecret); + _ = builder.UseSentry(ValidDsn); using var app = builder.Build(); var options = app.Services.GetRequiredService>().Value; @@ -133,7 +133,7 @@ public void UseSentry_SetsMauiSdkNameAndVersion() var builder = _fixture.Builder .UseSentry(options => { - options.Dsn = DsnSamples.ValidDsnWithoutSecret; + options.Dsn = ValidDsn; options.BeforeSend = e => { // capture the event @@ -160,7 +160,7 @@ public void UseSentry_EnablesHub() { // Arrange var builder = _fixture.Builder - .UseSentry(DsnSamples.ValidDsnWithoutSecret); + .UseSentry(ValidDsn); // Act using var app = builder.Build(); @@ -179,7 +179,7 @@ public void UseSentry_AppDispose_DisposesHub() // Arrange var builder = _fixture.Builder - .UseSentry(DsnSamples.ValidDsnWithoutSecret); + .UseSentry(ValidDsn); // Act IHub hub; diff --git a/test/Sentry.NLog.Tests/SentryTargetTests.cs b/test/Sentry.NLog.Tests/SentryTargetTests.cs index cadfdc5b5c..969c28c7be 100644 --- a/test/Sentry.NLog.Tests/SentryTargetTests.cs +++ b/test/Sentry.NLog.Tests/SentryTargetTests.cs @@ -8,15 +8,13 @@ namespace Sentry.NLog.Tests; -using static DsnSamples; - public class SentryTargetTests { private const string DefaultMessage = "This is a logged message"; private class Fixture { - public SentryNLogOptions Options { get; set; } = new() { Dsn = ValidDsnWithSecret }; + public SentryNLogOptions Options { get; set; } = new() { Dsn = ValidDsn }; public IHub Hub { get; set; } = Substitute.For(); @@ -86,7 +84,7 @@ public void Can_configure_from_xml_file() - + True @@ -103,7 +101,7 @@ public void Can_configure_from_xml_file() Assert.NotNull(t); if (t.Options.Dsn != null) { - Assert.Equal(ValidDsnWithoutSecret, t.Options.Dsn); + Assert.Equal(ValidDsn, t.Options.Dsn); } Assert.Equal("test", t.Options.Environment); @@ -120,7 +118,7 @@ public void Can_configure_user_from_xml_file() - + @@ -135,7 +133,7 @@ public void Can_configure_user_from_xml_file() var t = logFactory.Configuration.FindTargetByName("sentry") as SentryTarget; Assert.NotNull(t); - Assert.Equal(ValidDsnWithoutSecret, t.Options.Dsn); + Assert.Equal(ValidDsn, t.Options.Dsn); Assert.Equal("'myUser'", t.User.Username.ToString()); Assert.NotEmpty(t.User.Other); Assert.Equal("mood", t.User.Other[0].Name); diff --git a/test/Sentry.Serilog.Tests/AspNetSentrySdkTestFixture.cs b/test/Sentry.Serilog.Tests/AspNetSentrySdkTestFixture.cs index 761f9f8f26..307659dc3b 100644 --- a/test/Sentry.Serilog.Tests/AspNetSentrySdkTestFixture.cs +++ b/test/Sentry.Serilog.Tests/AspNetSentrySdkTestFixture.cs @@ -47,7 +47,7 @@ protected override void ConfigureBuilder(WebHostBuilder builder) var sentryHttpClient = sentry.CreateClient(); _ = builder.UseSentry(options => { - options.Dsn = DsnSamples.ValidDsnWithSecret; + options.Dsn = ValidDsn; options.SentryHttpClientFactory = new DelegateHttpClientFactory(_ => sentryHttpClient); Configure?.Invoke(options); diff --git a/test/Sentry.Serilog.Tests/SentrySerilogSinkExtensionsTests.cs b/test/Sentry.Serilog.Tests/SentrySerilogSinkExtensionsTests.cs index 14f13517e7..f92e148a4e 100644 --- a/test/Sentry.Serilog.Tests/SentrySerilogSinkExtensionsTests.cs +++ b/test/Sentry.Serilog.Tests/SentrySerilogSinkExtensionsTests.cs @@ -21,7 +21,7 @@ private class Fixture public float SampleRate { get; } = 0.4f; public string Release { get; } = nameof(ConfigureSentrySerilogOptions_WithAllParameters_MakesAppropriateChangesToObject); public string Environment { get; } = nameof(ConfigureSentrySerilogOptions_WithAllParameters_MakesAppropriateChangesToObject); - public string Dsn { get; } = DsnSamples.ValidDsnWithSecret; + public string Dsn { get; } = ValidDsn; public int MaxQueueItems { get; } = 17; public TimeSpan ShutdownTimeout { get; } = TimeSpan.FromDays(1.3); public DecompressionMethods DecompressionMethods { get; } = DecompressionMethods.Deflate & DecompressionMethods.GZip; diff --git a/test/Sentry.Testing/DsnSamples.cs b/test/Sentry.Testing/DsnSamples.cs index 0fadc046c4..d23617915b 100644 --- a/test/Sentry.Testing/DsnSamples.cs +++ b/test/Sentry.Testing/DsnSamples.cs @@ -6,11 +6,7 @@ public static class DsnSamples /// /// Sentry has dropped the use of secrets /// - public const string ValidDsnWithoutSecret = "https://d4d82fc1c2c4032a83f3a29aa3a3aff@fake-sentry.io:65535/2147483647"; - /// - /// Legacy includes secret - /// - public const string ValidDsnWithSecret = "https://d4d82fc1c2c4032a83f3a29aa3a3aff:ed0a8589a0bb4d4793ac4c70375f3d65@fake-sentry.io:65535/2147483647"; + public const string ValidDsn = "https://d4d82fc1c2c4032a83f3a29aa3a3aff@fake-sentry.io:65535/2147483647"; /// /// Missing ProjectId /// diff --git a/test/Sentry.Tests/GlobalSessionManagerTests.cs b/test/Sentry.Tests/GlobalSessionManagerTests.cs index 5607e1f083..2ee5eb2a84 100644 --- a/test/Sentry.Tests/GlobalSessionManagerTests.cs +++ b/test/Sentry.Tests/GlobalSessionManagerTests.cs @@ -24,7 +24,7 @@ public Fixture(Action configureOptions = null) Options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, CacheDirectoryPath = _cacheDirectory.Path, Release = "test", Debug = true, diff --git a/test/Sentry.Tests/HubTests.cs b/test/Sentry.Tests/HubTests.cs index 034dad78bd..9d3232ca1b 100644 --- a/test/Sentry.Tests/HubTests.cs +++ b/test/Sentry.Tests/HubTests.cs @@ -17,7 +17,7 @@ public void PushScope_BreadcrumbWithinScope_NotVisibleOutside() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, BackgroundWorker = new FakeBackgroundWorker() }); @@ -37,7 +37,7 @@ public void PushAndLockScope_DoesNotAffectOuterScope() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, BackgroundWorker = new FakeBackgroundWorker() }); @@ -60,7 +60,7 @@ public void CaptureMessage_FailedQueue_LastEventIdSetToEmpty() var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, BackgroundWorker = worker }); @@ -81,7 +81,7 @@ public void CaptureMessage_SuccessQueued_LastEventIdSetToReturnedId() var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, BackgroundWorker = worker }); @@ -101,7 +101,7 @@ public void CaptureException_FinishedSpanBoundToSameExceptionExists_EventIsLinke var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 1 }, client); @@ -129,7 +129,7 @@ public void CaptureException_ActiveSpanExistsOnScope_EventIsLinkedToSpan() var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 1 }, client); @@ -158,7 +158,7 @@ public void CaptureException_ActiveSpanExistsOnScopeButIsSampledOut_EventIsNotLi var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 0 }, client); @@ -187,7 +187,7 @@ public void CaptureException_NoActiveSpanAndNoSpanBoundToSameException_EventIsNo var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 1 }, client); @@ -210,7 +210,7 @@ public void CaptureEvent_SessionActive_NoExceptionDoesNotReportError() var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Release = "release" }, client); @@ -232,7 +232,7 @@ public void CaptureEvent_ExceptionWithOpenSpan_SpanLinkedToEventContext() var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 1 }, client); var scope = new Scope(); @@ -283,7 +283,7 @@ async Task VerifyAsync(HttpRequestMessage message) var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, // To go through a round trip serialization of cached envelope CacheDirectoryPath = tempDirectory?.Path, // So we don't need to deal with gzip'ed payload @@ -344,7 +344,7 @@ public void CaptureEvent_SessionActive_ExceptionReportsError() var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Release = "release" }, client); @@ -366,7 +366,7 @@ public void CaptureEvent_ActiveSession_UnhandledExceptionSessionEndedAsCrashed() var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Release = "release" }; var client = new SentryClient(options, worker); @@ -401,7 +401,7 @@ public void AppDomainUnhandledExceptionIntegration_ActiveSession_UnhandledExcept var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Release = "release" }; var client = new SentryClient(options, worker); @@ -435,7 +435,7 @@ public void StartTransaction_NameOpDescription_Works() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret + Dsn = ValidDsn }); // Act @@ -453,7 +453,7 @@ public void StartTransaction_FromTraceHeader_CopiesContext() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 1 }); @@ -477,7 +477,7 @@ public void StartTransaction_FromTraceHeader_SampledInheritedFromParentRegardles // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 0 }); @@ -499,7 +499,7 @@ public void StartTransaction_FromTraceHeader_CustomSamplerCanSampleOutTransactio // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampler = _ => 0, TracesSampleRate = 1 }); @@ -522,7 +522,7 @@ public void StartTransaction_StaticSampling_SampledIn() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 1 }); @@ -539,7 +539,7 @@ public void StartTransaction_StaticSampling_SampledOut() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 0 }); @@ -559,7 +559,7 @@ public void StartTransaction_StaticSampling_50PercentDistribution() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 0.5 }); @@ -591,7 +591,7 @@ public void StartTransaction_StaticSampling_25PercentDistribution() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 0.25 }); @@ -623,7 +623,7 @@ public void StartTransaction_StaticSampling_75PercentDistribution() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 0.75 }); @@ -652,7 +652,7 @@ public void StartTransaction_DynamicSampling_SampledIn() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampler = ctx => ctx.TransactionContext.Name == "foo" ? 1 : 0 }); @@ -669,7 +669,7 @@ public void StartTransaction_DynamicSampling_SampledOut() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampler = ctx => ctx.TransactionContext.Name == "foo" ? 1 : 0 }); @@ -686,7 +686,7 @@ public void StartTransaction_DynamicSampling_WithCustomContext_SampledIn() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampler = ctx => ctx.CustomSamplingContext.GetValueOrDefault("xxx") as string == "zzz" ? 1 : 0 }); @@ -705,7 +705,7 @@ public void StartTransaction_DynamicSampling_WithCustomContext_SampledOut() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampler = ctx => ctx.CustomSamplingContext.GetValueOrDefault("xxx") as string == "zzz" ? 1 : 0 }); @@ -724,7 +724,7 @@ public void StartTransaction_DynamicSampling_FallbackToStatic_SampledIn() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampler = _ => null, TracesSampleRate = 1 }); @@ -742,7 +742,7 @@ public void StartTransaction_DynamicSampling_FallbackToStatic_SampledOut() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampler = _ => null, TracesSampleRate = 0 }); @@ -760,7 +760,7 @@ public void GetTraceHeader_ReturnsHeaderForActiveSpan() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret + Dsn = ValidDsn }); var transaction = hub.StartTransaction("foo", "bar"); @@ -788,7 +788,7 @@ public void CaptureTransaction_AfterTransactionFinishes_ResetsTransactionOnScope var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret + Dsn = ValidDsn }, client); var transaction = hub.StartTransaction("foo", "bar"); @@ -808,7 +808,7 @@ public void Dispose_IsEnabled_SetToFalse() // Arrange var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret + Dsn = ValidDsn }); hub.IsEnabled.Should().BeTrue(); @@ -826,7 +826,7 @@ public void Dispose_CalledSecondTime_ClientDisposedOnce() var client = Substitute.For(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret + Dsn = ValidDsn }; var hub = new Hub(options, client); @@ -846,7 +846,7 @@ public void StartSession_CapturesUpdate() var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Release = "release" }, client); @@ -871,7 +871,7 @@ public void StartSession_GlobalSessionManager_ExceptionOnCrashLastRun_CapturesUp var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Release = "release" }, client, sessionManager); @@ -891,7 +891,7 @@ public void EndSession_CapturesUpdate() var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Release = "release" }, client); @@ -913,7 +913,7 @@ public void Ctor_AutoSessionTrackingEnabled_StartsSession() // Act _ = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, AutoSessionTracking = true, Release = "release" }, client); @@ -932,7 +932,7 @@ public void Ctor_GlobalModeTrue_DoesNotPushScope() _ = new Hub(new SentryOptions { IsGlobalModeEnabled = true, - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, }, scopeManager: scopeManager); // Assert @@ -949,7 +949,7 @@ public void Ctor_GlobalModeFalse_DoesPushScope() _ = new Hub(new SentryOptions { IsGlobalModeEnabled = false, - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, }, scopeManager: scopeManager); // Assert @@ -964,7 +964,7 @@ public void ResumeSession_WithinAutoTrackingInterval_ContinuesSameSession() var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, AutoSessionTrackingInterval = TimeSpan.FromSeconds(9999) }, client); @@ -987,7 +987,7 @@ public void ResumeSession_BeyondAutoTrackingInterval_EndsPreviousSessionAndStart var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, AutoSessionTrackingInterval = TimeSpan.FromMilliseconds(10), Release = "release" }; @@ -1022,7 +1022,7 @@ public void ResumeSession_NoActiveSession_DoesNothing() var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, AutoSessionTrackingInterval = TimeSpan.FromMilliseconds(10) }; @@ -1053,7 +1053,7 @@ public void ResumeSession_NoPausedSession_DoesNothing() var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, AutoSessionTrackingInterval = TimeSpan.FromMilliseconds(10) }; @@ -1088,7 +1088,7 @@ public void CaptureEvent_MessageOnlyEvent_SpanLinkedToEventContext(SentryLevel l var hub = new Hub(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, TracesSampleRate = 1 }, client); var scope = new Scope(); diff --git a/test/Sentry.Tests/Internals/DefaultSentryHttpClientFactoryTests.cs b/test/Sentry.Tests/Internals/DefaultSentryHttpClientFactoryTests.cs index 760156eb62..60d1aae107 100644 --- a/test/Sentry.Tests/Internals/DefaultSentryHttpClientFactoryTests.cs +++ b/test/Sentry.Tests/Internals/DefaultSentryHttpClientFactoryTests.cs @@ -10,7 +10,7 @@ private class Fixture { public SentryOptions HttpOptions { get; set; } = new() { - Dsn = DsnSamples.ValidDsnWithSecret + Dsn = ValidDsn }; public DefaultSentryHttpClientFactory GetSut() diff --git a/test/Sentry.Tests/Internals/DsnLocatorTests.cs b/test/Sentry.Tests/Internals/DsnLocatorTests.cs index 0ccf059cce..e2f660a2b7 100644 --- a/test/Sentry.Tests/Internals/DsnLocatorTests.cs +++ b/test/Sentry.Tests/Internals/DsnLocatorTests.cs @@ -22,7 +22,7 @@ public void FindDsnOrDisable_NoEnvironmentVariableNorAttribute_ReturnsDisabledDs [Fact] public void FindDsnOrDisable_DsnOnEnvironmentVariable_ReturnsTheDsn() { - const string expected = DsnSamples.ValidDsnWithoutSecret; + const string expected = ValidDsn; EnvironmentVariableGuard.WithVariable( DsnEnvironmentVariable, @@ -36,14 +36,14 @@ public void FindDsnOrDisable_DsnOnEnvironmentVariable_ReturnsTheDsn() [Fact] public void FindDsnOrDisable_DsnOnEnvironmentVariableAndAttribute_ReturnsTheDsnFromEnvironmentVariable() { - const string expected = DsnSamples.ValidDsnWithoutSecret; + const string expected = ValidDsn; EnvironmentVariableGuard.WithVariable( DsnEnvironmentVariable, expected, () => { - var asm = AssemblyCreationHelper.CreateAssemblyWithDsnAttribute(DsnSamples.ValidDsnWithSecret); + var asm = AssemblyCreationHelper.CreateAssemblyWithDsnAttribute(ValidDsn); Assert.Equal(expected, DsnLocator.FindDsnStringOrDisable(asm)); }); } @@ -60,7 +60,7 @@ public void FindDsn_NoDsnInAsm_ReturnsNull() [Fact] public void FindDsn_ValidDsnInAsm_FindsTheDsnString() { - const string expected = DsnSamples.ValidDsnWithoutSecret; + const string expected = ValidDsn; var asm = AssemblyCreationHelper.CreateAssemblyWithDsnAttribute(expected); var actual = DsnLocator.FindDsn(asm); @@ -82,7 +82,7 @@ public void FindDsn_NullDsnInAsm_ReturnsNull() [Fact] public void FindDsn_InvalidDsnInAsm_ReturnsInvalidDsn() { - const string expected = DsnSamples.InvalidDsn; + const string expected = InvalidDsn; var asm = AssemblyCreationHelper.CreateAssemblyWithDsnAttribute(expected); diff --git a/test/Sentry.Tests/Internals/Http/CachingTransportTests.cs b/test/Sentry.Tests/Internals/Http/CachingTransportTests.cs index cc15d5b042..5f0a9c7d63 100644 --- a/test/Sentry.Tests/Internals/Http/CachingTransportTests.cs +++ b/test/Sentry.Tests/Internals/Http/CachingTransportTests.cs @@ -23,7 +23,7 @@ public async Task WithAttachment() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path @@ -74,7 +74,7 @@ public async Task WorksInBackground() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path @@ -107,7 +107,7 @@ public async Task ShouldNotLogOperationCanceledExceptionWhenIsCancellationReques var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, CacheDirectoryPath = cacheDirectory.Path, Debug = true @@ -161,7 +161,7 @@ public async Task ShouldLogOperationCanceledExceptionWhenNotIsCancellationReques var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = logger, CacheDirectoryPath = cacheDirectory.Path, Debug = true @@ -196,7 +196,7 @@ public async Task EnvelopeReachesInnerTransport() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path @@ -223,7 +223,7 @@ public async Task MaintainsLimit() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path, @@ -251,7 +251,7 @@ public async Task AwareOfExistingFiles() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path @@ -290,7 +290,7 @@ public async Task NonTransientExceptionShouldLog() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path @@ -326,7 +326,7 @@ public async Task DoesNotRetryOnNonTransientExceptions() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path @@ -371,7 +371,7 @@ public async Task RecordsDiscardedEventOnNonTransientExceptions() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path, @@ -403,7 +403,7 @@ public async Task RoundtripsClientReports() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path @@ -450,7 +450,7 @@ public async Task RestoresDiscardedEventCounts() using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path @@ -503,7 +503,7 @@ public async Task TestNetworkException(Exception exception) using var cacheDirectory = new TempDirectory(); var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = _logger, Debug = true, CacheDirectoryPath = cacheDirectory.Path diff --git a/test/Sentry.Tests/Internals/Http/GzipBufferedRequestBodyHandlerTests.cs b/test/Sentry.Tests/Internals/Http/GzipBufferedRequestBodyHandlerTests.cs index 8425c17674..6e3103ceb4 100644 --- a/test/Sentry.Tests/Internals/Http/GzipBufferedRequestBodyHandlerTests.cs +++ b/test/Sentry.Tests/Internals/Http/GzipBufferedRequestBodyHandlerTests.cs @@ -18,7 +18,7 @@ private class Fixture public Fixture() { - var uri = Dsn.Parse(DsnSamples.ValidDsnWithSecret).GetStoreEndpointUri(); + var uri = Dsn.Parse(ValidDsn).GetStoreEndpointUri(); Message = new HttpRequestMessage(HttpMethod.Post, uri) { diff --git a/test/Sentry.Tests/Internals/Http/GzipRequestBodyHandlerTests.cs b/test/Sentry.Tests/Internals/Http/GzipRequestBodyHandlerTests.cs index 5a9a2ecf08..1d8dca70cd 100644 --- a/test/Sentry.Tests/Internals/Http/GzipRequestBodyHandlerTests.cs +++ b/test/Sentry.Tests/Internals/Http/GzipRequestBodyHandlerTests.cs @@ -18,7 +18,7 @@ private class Fixture public Fixture() { - var uri = Dsn.Parse(DsnSamples.ValidDsnWithSecret).GetStoreEndpointUri(); + var uri = Dsn.Parse(ValidDsn).GetStoreEndpointUri(); Message = new HttpRequestMessage(HttpMethod.Post, uri) { diff --git a/test/Sentry.Tests/Internals/Http/HttpTransportTests.cs b/test/Sentry.Tests/Internals/Http/HttpTransportTests.cs index 3f0f26cf18..14958594c0 100644 --- a/test/Sentry.Tests/Internals/Http/HttpTransportTests.cs +++ b/test/Sentry.Tests/Internals/Http/HttpTransportTests.cs @@ -31,7 +31,7 @@ public async Task SendEnvelopeAsync_CancellationToken_PassedToClient() .Returns(_ => SentryResponses.GetOkResponse()); var httpTransport = new HttpTransport( - new SentryOptions { Dsn = DsnSamples.ValidDsnWithSecret }, + new SentryOptions { Dsn = ValidDsn }, new HttpClient(httpHandler)); var envelope = Envelope.FromEvent( @@ -69,7 +69,7 @@ public async Task SendEnvelopeAsync_ResponseNotOkWithJsonMessage_LogsError() var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Debug = true, DiagnosticLogger = logger }, @@ -112,7 +112,7 @@ public async Task SendEnvelopeAsync_ResponseRequestEntityTooLargeWithPathDefined var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Debug = true, DiagnosticLogger = logger }, @@ -174,7 +174,7 @@ public async Task SendEnvelopeAsync_ResponseRequestEntityTooLargeWithoutPathDefi var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Debug = true, DiagnosticLogger = logger }, @@ -211,7 +211,7 @@ public async Task SendEnvelopeAsync_ResponseNotOkWithStringMessage_LogsError() var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Debug = true, DiagnosticLogger = logger }, @@ -249,7 +249,7 @@ public async Task SendEnvelopeAsync_ResponseNotOkNoMessage_LogsError() var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, Debug = true, DiagnosticLogger = logger }, @@ -284,7 +284,7 @@ public async Task SendEnvelopeAsync_ItemRateLimit_DropsItem() var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, DiagnosticLogger = _testOutputLogger, SendClientReports = false, Debug = true @@ -351,7 +351,7 @@ public async Task SendEnvelopeAsync_RateLimited_CountsDiscardedEventsCorrectly() var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, DiagnosticLogger = _testOutputLogger, SendClientReports = true, Debug = true @@ -431,7 +431,7 @@ public async Task SendEnvelopeAsync_Fails_RestoresDiscardedEventCounts() var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, DiagnosticLogger = _testOutputLogger, SendClientReports = true, Debug = true @@ -475,7 +475,7 @@ public async Task SendEnvelopeAsync_RateLimited_DoesNotRestoreDiscardedEventCoun var options = new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, DiagnosticLogger = _testOutputLogger, SendClientReports = true, Debug = true @@ -512,7 +512,7 @@ public async Task SendEnvelopeAsync_AttachmentFail_DropsItem() var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, MaxAttachmentSize = 1, DiagnosticLogger = logger, Debug = true @@ -558,7 +558,7 @@ public async Task SendEnvelopeAsync_AttachmentTooLarge_DropsItem() var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, MaxAttachmentSize = 1, DiagnosticLogger = logger, Debug = true @@ -611,7 +611,7 @@ public async Task SendEnvelopeAsync_ItemRateLimit_PromotesNextSessionWithSameId( var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret + Dsn = ValidDsn }, new HttpClient(httpHandler)); @@ -653,7 +653,7 @@ public async Task SendEnvelopeAsync_ItemRateLimit_DoesNotAffectNextSessionWithDi var httpTransport = new HttpTransport( new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret + Dsn = ValidDsn }, new HttpClient(httpHandler)); @@ -689,7 +689,7 @@ public void CreateRequest_AuthHeader_IsSet() { // Arrange var httpTransport = new HttpTransport( - new SentryOptions { Dsn = DsnSamples.ValidDsnWithSecret }, + new SentryOptions { Dsn = ValidDsn }, new HttpClient()); var envelope = Envelope.FromEvent(new SentryEvent()); @@ -707,7 +707,7 @@ public void CreateRequest_AuthHeader_IncludesVersion() { // Arrange var httpTransport = new HttpTransport( - new SentryOptions { Dsn = DsnSamples.ValidDsnWithSecret }, + new SentryOptions { Dsn = ValidDsn }, new HttpClient()); var envelope = Envelope.FromEvent(new SentryEvent()); @@ -726,7 +726,7 @@ public void CreateRequest_RequestMethod_Post() { // Arrange var httpTransport = new HttpTransport( - new SentryOptions { Dsn = DsnSamples.ValidDsnWithSecret }, + new SentryOptions { Dsn = ValidDsn }, new HttpClient()); var envelope = Envelope.FromEvent(new SentryEvent()); @@ -743,12 +743,12 @@ public void CreateRequest_SentryUrl_FromOptions() { // Arrange var httpTransport = new HttpTransport( - new SentryOptions { Dsn = DsnSamples.ValidDsnWithSecret }, + new SentryOptions { Dsn = ValidDsn }, new HttpClient()); var envelope = Envelope.FromEvent(new SentryEvent()); - var uri = Dsn.Parse(DsnSamples.ValidDsnWithSecret).GetEnvelopeEndpointUri(); + var uri = Dsn.Parse(ValidDsn).GetEnvelopeEndpointUri(); // Act var request = httpTransport.CreateRequest(envelope); @@ -762,7 +762,7 @@ public async Task CreateRequest_Content_IncludesEvent() { // Arrange var httpTransport = new HttpTransport( - new SentryOptions { Dsn = DsnSamples.ValidDsnWithSecret }, + new SentryOptions { Dsn = ValidDsn }, new HttpClient()); var envelope = Envelope.FromEvent(new SentryEvent()); diff --git a/test/Sentry.Tests/Protocol/DsnSamples.cs b/test/Sentry.Tests/Protocol/DsnSamples.cs deleted file mode 100644 index 4211ab0c46..0000000000 --- a/test/Sentry.Tests/Protocol/DsnSamples.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Sentry.Tests.Protocol; - -public static class DsnSamples -{ - /// - /// Sentry has dropped the use of secrets - /// - public const string ValidDsnWithoutSecret = "https://d4d82fc1c2c4032a83f3a29aa3a3aff@fake-sentry.io:65535/2147483647"; - /// - /// Legacy includes secret - /// - public const string ValidDsnWithSecret = "https://d4d82fc1c2c4032a83f3a29aa3a3aff:ed0a8589a0bb4d4793ac4c70375f3d65@fake-sentry.io:65535/2147483647"; - /// - /// Missing ProjectId - /// - public const string InvalidDsn = "https://d4d82fc1c2c4032a83f3a29aa3a3aff@fake-sentry.io:65535/"; -} diff --git a/test/Sentry.Tests/Protocol/DsnTests.cs b/test/Sentry.Tests/Protocol/DsnTests.cs index 1bc4ac304d..f4778be13d 100644 --- a/test/Sentry.Tests/Protocol/DsnTests.cs +++ b/test/Sentry.Tests/Protocol/DsnTests.cs @@ -2,6 +2,8 @@ namespace Sentry.Tests.Protocol; public class DsnTests { + private const string ValidDsnWithSecret = "https://d4d82fc1c2c4032a83f3a29aa3a3aff:ed0a8589a0bb4d4793ac4c70375f3d65@fake-sentry.io:65535/2147483647"; + [Fact] public void ToString_SameAsInput() { @@ -11,17 +13,17 @@ public void ToString_SameAsInput() } [Fact] - public void Ctor_SampleValidDsnWithoutSecret_CorrectlyConstructs() + public void Ctor_SampleValidDsn_CorrectlyConstructs() { - var dsn = Dsn.Parse(DsnSamples.ValidDsnWithoutSecret); - Assert.Equal(DsnSamples.ValidDsnWithoutSecret, dsn.ToString()); + var dsn = Dsn.Parse(ValidDsn); + Assert.Equal(ValidDsn, dsn.ToString()); } [Fact] public void Ctor_SampleValidDsnWithSecret_CorrectlyConstructs() { - var dsn = Dsn.Parse(DsnSamples.ValidDsnWithSecret); - Assert.Equal(DsnSamples.ValidDsnWithSecret, dsn.ToString()); + var dsn = Dsn.Parse(ValidDsnWithSecret); + Assert.Equal(ValidDsnWithSecret, dsn.ToString()); } [Fact] @@ -133,21 +135,30 @@ public void Ctor_NullDsn_ThrowsArgumentNull() } [Fact] - public void TryParse_SampleValidDsnWithoutSecret_Succeeds() + public void TryParse_SampleValidDsn_Succeeds() + { + Assert.NotNull(Dsn.TryParse(ValidDsn)); + } + + [Fact] + public void Init_ValidDsnWithSecret_EnablesSdk() { - Assert.NotNull(Dsn.TryParse(DsnSamples.ValidDsnWithoutSecret)); + using (SentrySdk.Init(ValidDsnWithSecret)) + { + Assert.True(SentrySdk.IsEnabled); + } } [Fact] public void TryParse_SampleValidDsnWithSecret_Succeeds() { - Assert.NotNull(Dsn.TryParse(DsnSamples.ValidDsnWithSecret)); + Assert.NotNull(Dsn.TryParse(ValidDsnWithSecret)); } [Fact] public void TryParse_SampleInvalidDsn_Fails() { - Assert.Null(Dsn.TryParse(DsnSamples.InvalidDsn)); + Assert.Null(Dsn.TryParse(InvalidDsn)); } [Fact] @@ -254,10 +265,10 @@ public void TryParse_NullDsn_ThrowsArgumentNull() } [Fact] - public void IsDisabled_ValidDsn_False() => Assert.False(Dsn.IsDisabled(DsnSamples.ValidDsnWithSecret)); + public void IsDisabled_ValidDsn_False() => Assert.False(Dsn.IsDisabled(ValidDsn)); [Fact] - public void IsDisabled_InvalidDsn_False() => Assert.False(Dsn.IsDisabled(DsnSamples.InvalidDsn)); + public void IsDisabled_InvalidDsn_False() => Assert.False(Dsn.IsDisabled(InvalidDsn)); [Fact] public void IsDisabled_NullDsn_False() => Assert.False(Dsn.IsDisabled(null)); diff --git a/test/Sentry.Tests/Protocol/TransactionTests.cs b/test/Sentry.Tests/Protocol/TransactionTests.cs index 615a11d265..dd4b0d5397 100644 --- a/test/Sentry.Tests/Protocol/TransactionTests.cs +++ b/test/Sentry.Tests/Protocol/TransactionTests.cs @@ -261,7 +261,7 @@ public void Finish_CapturesTransaction() { // Arrange var client = Substitute.For(); - var options = new SentryOptions { Dsn = DsnSamples.ValidDsnWithoutSecret }; + var options = new SentryOptions { Dsn = ValidDsn }; var hub = new Hub(options, client); var transaction = new TransactionTracer(hub, "my name", "my op"); @@ -278,7 +278,7 @@ public void Finish_LinksExceptionToEvent() { // Arrange var client = Substitute.For(); - var options = new SentryOptions { Dsn = DsnSamples.ValidDsnWithoutSecret }; + var options = new SentryOptions { Dsn = ValidDsn }; var hub = new Hub(options, client); var exception = new InvalidOperationException(); diff --git a/test/Sentry.Tests/SentryClientTests.cs b/test/Sentry.Tests/SentryClientTests.cs index 04a71b6cfb..286bb957d7 100644 --- a/test/Sentry.Tests/SentryClientTests.cs +++ b/test/Sentry.Tests/SentryClientTests.cs @@ -331,7 +331,7 @@ public void CaptureEvent_Sampling50Percent_EqualDistribution() // Arrange var client = new SentryClient(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, SampleRate = 0.5f, MaxQueueItems = int.MaxValue }); @@ -364,7 +364,7 @@ public void CaptureEvent_Sampling25Percent_AppropriateDistribution() // Arrange var client = new SentryClient(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, SampleRate = 0.25f, MaxQueueItems = int.MaxValue }); @@ -397,7 +397,7 @@ public void CaptureEvent_Sampling75Percent_AppropriateDistribution() // Arrange var client = new SentryClient(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, SampleRate = 0.75f, MaxQueueItems = int.MaxValue }); @@ -504,7 +504,7 @@ public void Dispose_should_only_flush() // Arrange var client = new SentryClient(new SentryOptions { - Dsn = DsnSamples.ValidDsnWithSecret, + Dsn = ValidDsn, }); // Act @@ -702,7 +702,7 @@ public void Ctor_HttpOptionsCallback_InvokedConfigureClient() { var invoked = false; _fixture.BackgroundWorker = null; - _fixture.SentryOptions.Dsn = DsnSamples.ValidDsnWithSecret; + _fixture.SentryOptions.Dsn = ValidDsn; _fixture.SentryOptions.ConfigureClient = _ => invoked = true; using (_fixture.GetSut()) @@ -716,7 +716,7 @@ public void Ctor_CreateHttpClientHandler_InvokedConfigureHandler() { var invoked = false; _fixture.BackgroundWorker = null; - _fixture.SentryOptions.Dsn = DsnSamples.ValidDsnWithSecret; + _fixture.SentryOptions.Dsn = ValidDsn; _fixture.SentryOptions.CreateHttpClientHandler = () => { invoked = true; @@ -732,7 +732,7 @@ public void Ctor_CreateHttpClientHandler_InvokedConfigureHandler() [Fact] public void Ctor_NullBackgroundWorker_ConcreteBackgroundWorker() { - _fixture.SentryOptions.Dsn = DsnSamples.ValidDsnWithSecret; + _fixture.SentryOptions.Dsn = ValidDsn; using var sut = new SentryClient(_fixture.SentryOptions); _ = Assert.IsType(sut.Worker); @@ -741,7 +741,7 @@ public void Ctor_NullBackgroundWorker_ConcreteBackgroundWorker() [Fact] public void Ctor_SetsTransportOnOptions() { - _fixture.SentryOptions.Dsn = DsnSamples.ValidDsnWithSecret; + _fixture.SentryOptions.Dsn = ValidDsn; using var sut = new SentryClient(_fixture.SentryOptions); @@ -751,7 +751,7 @@ public void Ctor_SetsTransportOnOptions() [Fact] public void Ctor_KeepsCustomTransportOnOptions() { - _fixture.SentryOptions.Dsn = DsnSamples.ValidDsnWithSecret; + _fixture.SentryOptions.Dsn = ValidDsn; _fixture.SentryOptions.Transport = new FakeTransport(); using var sut = new SentryClient(_fixture.SentryOptions); @@ -764,7 +764,7 @@ public void Ctor_WrapsCustomTransportWhenCachePathOnOptions() { using var cacheDirectory = new TempDirectory(); _fixture.SentryOptions.CacheDirectoryPath = cacheDirectory.Path; - _fixture.SentryOptions.Dsn = DsnSamples.ValidDsnWithSecret; + _fixture.SentryOptions.Dsn = ValidDsn; _fixture.SentryOptions.Transport = new FakeTransport(); using var sut = new SentryClient(_fixture.SentryOptions); @@ -778,7 +778,7 @@ public async Task SentryClient_WithCachingTransport_RecordsDiscardedEvents() { using var cacheDirectory = new TempDirectory(); _fixture.SentryOptions.CacheDirectoryPath = cacheDirectory.Path; - _fixture.SentryOptions.Dsn = DsnSamples.ValidDsnWithSecret; + _fixture.SentryOptions.Dsn = ValidDsn; var innerTransport = Substitute.For(); var cachingTransport = CachingTransport.Create(innerTransport, _fixture.SentryOptions); diff --git a/test/Sentry.Tests/SentrySdkTests.cs b/test/Sentry.Tests/SentrySdkTests.cs index 8a461965d7..a83480bced 100644 --- a/test/Sentry.Tests/SentrySdkTests.cs +++ b/test/Sentry.Tests/SentrySdkTests.cs @@ -3,7 +3,6 @@ using Sentry.Internal.Http; using Sentry.Internal.ScopeStack; using Sentry.Testing; -using static Sentry.DsnSamples; using static Sentry.Internal.Constants; namespace Sentry.Tests; @@ -35,7 +34,7 @@ public void LastEventId_SetToEventId() { EnvironmentVariableGuard.WithVariable( DsnEnvironmentVariable, - ValidDsnWithSecret, + ValidDsn, () => { using (SentrySdk.Init()) @@ -51,7 +50,7 @@ public void LastEventId_Transaction_DoesNotReset() { EnvironmentVariableGuard.WithVariable( DsnEnvironmentVariable, - ValidDsnWithSecret, + ValidDsn, () => { using (SentrySdk.Init(o => o.TracesSampleRate = 1.0)) @@ -71,18 +70,9 @@ public void Init_BrokenDsn_Throws() } [Fact] - public void Init_ValidDsnWithSecret_EnablesSdk() + public void Init_ValidDsn_EnablesSdk() { - using (SentrySdk.Init(ValidDsnWithSecret)) - { - Assert.True(SentrySdk.IsEnabled); - } - } - - [Fact] - public void Init_ValidDsnWithoutSecret_EnablesSdk() - { - using (SentrySdk.Init(ValidDsnWithoutSecret)) + using (SentrySdk.Init(ValidDsn)) { Assert.True(SentrySdk.IsEnabled); } @@ -93,7 +83,7 @@ public void Init_CallbackWithoutDsn_ValidDsnEnvironmentVariable_LocatesDsnEnviro { EnvironmentVariableGuard.WithVariable( DsnEnvironmentVariable, - ValidDsnWithSecret, + ValidDsn, () => { using (SentrySdk.Init(_ => { })) @@ -125,7 +115,7 @@ public void Init_ValidDsnEnvironmentVariable_EnablesSdk() { EnvironmentVariableGuard.WithVariable( DsnEnvironmentVariable, - ValidDsnWithSecret, + ValidDsn, () => { using (SentrySdk.Init()) @@ -191,6 +181,25 @@ public void Init_EmptyDsn_LogsWarning() } } + [Fact] + public void Init_DsnWithSecret_LogsWarning() + { + var logger = Substitute.For(); + _ = logger.IsEnabled(SentryLevel.Warning).Returns(true); + + var options = new SentryOptions + { + DiagnosticLogger = logger, + Debug = true, + Dsn = "https://d4d82fc1c2c4032a83f3a29aa3a3aff:ed0a8589a0bb4d4793ac4c70375f3d65@fake-sentry.io:65535/2147483647" + }; + + using (SentrySdk.Init(options)) + { + logger.Received(1).Log(SentryLevel.Warning, "The provided DSN that contains a secret key. This is not required and will be ignored."); + } + } + [Fact] public void Init_EmptyDsnDisabledDiagnostics_DoesNotLogWarning() { @@ -212,7 +221,7 @@ public void Init_EmptyDsnDisabledDiagnostics_DoesNotLogWarning() [Fact] public void Init_MultipleCalls_ReplacesHubWithLatest() { - var first = SentrySdk.Init(ValidDsnWithSecret); + var first = SentrySdk.Init(ValidDsn); SentrySdk.AddBreadcrumb("test", "category"); var called = false; SentrySdk.ConfigureScope(p => @@ -223,7 +232,7 @@ public void Init_MultipleCalls_ReplacesHubWithLatest() Assert.True(called); called = false; - var second = SentrySdk.Init(ValidDsnWithSecret); + var second = SentrySdk.Init(ValidDsn); SentrySdk.ConfigureScope(p => { called = true; @@ -250,7 +259,7 @@ public async Task Init_WithCache_BlocksUntilExistingCacheIsFlushed(bool? testDel await using var initialTransport = CachingTransport.Create(initialInnerTransport, new SentryOptions { DiagnosticLogger = _logger, - Dsn = ValidDsnWithoutSecret, + Dsn = ValidDsn, CacheDirectoryPath = cachePath }, startWorker: false); const int numEnvelopes = 5; // Not too many, or this will be slow. Not too few or this will be flaky. @@ -282,7 +291,7 @@ public async Task Init_WithCache_BlocksUntilExistingCacheIsFlushed(bool? testDel using var _ = SentrySdk.Init(o => { - o.Dsn = ValidDsnWithoutSecret; + o.Dsn = ValidDsn; o.DiagnosticLogger = _logger; o.CacheDirectoryPath = cachePath; o.InitCacheFlushTimeout = initFlushTimeout; @@ -334,8 +343,8 @@ public void Disposable_MultipleCalls_NoOp() [Fact] public void Dispose_DisposingFirst_DoesntAffectSecond() { - var first = SentrySdk.Init(ValidDsnWithSecret); - var second = SentrySdk.Init(ValidDsnWithSecret); + var first = SentrySdk.Init(ValidDsn); + var second = SentrySdk.Init(ValidDsn); SentrySdk.AddBreadcrumb("test", "category"); first.Dispose(); var called = false; @@ -401,7 +410,7 @@ public void ConfigureScope_Sync_CallbackNeverInvoked() public async Task ConfigureScope_OnTask_PropagatedToCaller() { const string expected = "test"; - using (SentrySdk.Init(ValidDsnWithoutSecret)) + using (SentrySdk.Init(ValidDsn)) { await ModifyScope(); @@ -431,7 +440,7 @@ public void WithScope_DisabledSdk_CallbackNeverInvoked() [Fact] public void WithScope_InvokedWithNewScope() { - using (SentrySdk.Init(ValidDsnWithoutSecret)) + using (SentrySdk.Init(ValidDsn)) { Scope expected = null; SentrySdk.ConfigureScope(s => expected = s); @@ -454,7 +463,7 @@ public void CaptureEvent_WithConfiguredScope_ScopeAppliesToEvent() using (SentrySdk.Init(o => { - o.Dsn = ValidDsnWithoutSecret; + o.Dsn = ValidDsn; o.BackgroundWorker = worker; })) { @@ -476,7 +485,7 @@ public void CaptureEvent_WithConfiguredScope_ScopeAppliesToEvent() [Fact] public void CaptureEvent_WithConfiguredScope_ScopeOnlyAppliesOnlyOnce() { - using (SentrySdk.Init(ValidDsnWithoutSecret)) + using (SentrySdk.Init(ValidDsn)) { var callbackCounter = 0; SentrySdk.CaptureEvent(new SentryEvent(), _ => callbackCounter++); @@ -493,7 +502,7 @@ public void CaptureEvent_WithConfiguredScopeNull_LogsError() var options = new SentryOptions { - Dsn = ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = logger, Debug = true }; @@ -514,7 +523,7 @@ public void CaptureEvent_WithConfiguredScopeNull_LogsError() public void CaptureEvent_WithConfiguredScope_ScopeCallbackGetsInvoked() { var scopeCallbackWasInvoked = false; - using (SentrySdk.Init(o => o.Dsn = ValidDsnWithoutSecret)) + using (SentrySdk.Init(o => o.Dsn = ValidDsn)) { SentrySdk.CaptureEvent(new SentryEvent(), _ => scopeCallbackWasInvoked = true); @@ -526,7 +535,7 @@ public void CaptureEvent_WithConfiguredScope_ScopeCallbackGetsInvoked() public void CaptureException_WithConfiguredScope_ScopeCallbackGetsInvoked() { var scopeCallbackWasInvoked = false; - using (SentrySdk.Init(o => o.Dsn = ValidDsnWithoutSecret)) + using (SentrySdk.Init(o => o.Dsn = ValidDsn)) { SentrySdk.CaptureException(new Exception(), _ => scopeCallbackWasInvoked = true); @@ -538,7 +547,7 @@ public void CaptureException_WithConfiguredScope_ScopeCallbackGetsInvoked() public void CaptureMessage_WithConfiguredScope_ScopeCallbackGetsInvoked() { var scopeCallbackWasInvoked = false; - using (SentrySdk.Init(o => o.Dsn = ValidDsnWithoutSecret)) + using (SentrySdk.Init(o => o.Dsn = ValidDsn)) { SentrySdk.CaptureMessage("TestMessage", _ => scopeCallbackWasInvoked = true); @@ -577,7 +586,7 @@ public void CaptureMessage_SdkInitialized_IncludesScope() const string expected = "test"; using (SentrySdk.Init(o => { - o.Dsn = ValidDsnWithSecret; + o.Dsn = ValidDsn; o.BackgroundWorker = worker; })) { @@ -654,7 +663,7 @@ public void InitHub_GlobalModeOff_AsyncLocalContainer() // Act var sut = SentrySdk.InitHub(new SentryOptions { - Dsn = ValidDsnWithoutSecret, + Dsn = ValidDsn, IsGlobalModeEnabled = false }); @@ -670,7 +679,7 @@ public void InitHub_GlobalModeOn_GlobalContainer() // Act var sut = SentrySdk.InitHub(new SentryOptions { - Dsn = ValidDsnWithoutSecret, + Dsn = ValidDsn, IsGlobalModeEnabled = true }); @@ -688,7 +697,7 @@ public void InitHub_GlobalModeOn_NoWarningOrErrorLogged() _ = SentrySdk.InitHub(new SentryOptions { - Dsn = ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = logger, IsGlobalModeEnabled = true, Debug = true @@ -715,7 +724,7 @@ public void InitHub_GlobalModeOff_NoWarningOrErrorLogged() _ = SentrySdk.InitHub(new SentryOptions { - Dsn = ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = logger, IsGlobalModeEnabled = false, Debug = true @@ -742,7 +751,7 @@ public void InitHub_DebugEnabled_DebugLogsLogged() _ = SentrySdk.InitHub(new SentryOptions { - Dsn = ValidDsnWithoutSecret, + Dsn = ValidDsn, DiagnosticLogger = logger, IsGlobalModeEnabled = true, Debug = true