1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-19 12:08:11 -05:00

Configure logging only once

This commit is contained in:
Justin Baur 2025-04-06 10:29:57 -04:00
parent 2c27c8447d
commit a94e7047e7
No known key found for this signature in database

View File

@ -1,4 +1,4 @@
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using Bit.Core.Models.Mail; using Bit.Core.Models.Mail;
using Bit.Core.Platform.X509ChainCustomization; using Bit.Core.Platform.X509ChainCustomization;
@ -16,6 +16,7 @@ namespace Bit.Core.IntegrationTest;
public class MailKitSmtpMailDeliveryServiceTests public class MailKitSmtpMailDeliveryServiceTests
{ {
private static int _loggingConfigured;
private readonly X509Certificate2 _selfSignedCert; private readonly X509Certificate2 _selfSignedCert;
public MailKitSmtpMailDeliveryServiceTests(ITestOutputHelper testOutputHelper) public MailKitSmtpMailDeliveryServiceTests(ITestOutputHelper testOutputHelper)
@ -34,6 +35,12 @@ public class MailKitSmtpMailDeliveryServiceTests
private static void ConfigureSmtpServerLogging(ITestOutputHelper testOutputHelper) private static void ConfigureSmtpServerLogging(ITestOutputHelper testOutputHelper)
{ {
// The logging in SmtpServer is configured statically so if we add it for each test it duplicates
// but we cant add the logger statically either because we need ITestOutputHelper
if (Interlocked.CompareExchange(ref _loggingConfigured, 1, 0) == 0)
{
return;
}
// Unfortunately this package doesn't public expose its logging infrastructure // Unfortunately this package doesn't public expose its logging infrastructure
// so we use private reflection to try and access it. // so we use private reflection to try and access it.
try try