From 3d3c03bea017400ba75bf3c75a2eb702ae200596 Mon Sep 17 00:00:00 2001 From: "savage@savage.za.org" Date: Thu, 22 Oct 2026 07:29:47 +0200 Subject: [PATCH] Replace Path.Combine with Path.Join --- src/VectorNNTPD.Common/Acme/AcmePaths.cs | 30 ++--- src/VectorNNTPD.Common/Acme/AtomicFile.cs | 2 +- src/VectorNNTPD.Common/Acme/Dns01Solver.cs | 4 +- .../Acme/AcmeFilesystemIsolationTests.cs | 72 ++++++------ .../Acme/AcmePathJoinTests.cs | 110 ++++++++++++++++++ .../Acme/AcmeTransactionJournalTests.cs | 4 +- .../Parsing/NntpArticleParserTests.cs | 10 +- .../YEnc/YEncArticleValidatorTests.cs | 8 +- .../ApplicationJsonConfigurationTests.cs | 6 +- .../ApplicationLocalPathResolutionTests.cs | 6 +- .../SharedNntpdEnvironmentBindingTests.cs | 4 +- .../Configuration/SharedRabbitMqJsonTests.cs | 16 +-- .../Logging/GzipRollingFileSinkTests.cs | 42 +++---- .../TestDoubles/CommonTestSupport.cs | 2 +- 14 files changed, 213 insertions(+), 103 deletions(-) create mode 100644 tests/VectorNNTPD.Common.Tests/Acme/AcmePathJoinTests.cs diff --git a/src/VectorNNTPD.Common/Acme/AcmePaths.cs b/src/VectorNNTPD.Common/Acme/AcmePaths.cs index 071a2f1f..f22cb549 100644 --- a/src/VectorNNTPD.Common/Acme/AcmePaths.cs +++ b/src/VectorNNTPD.Common/Acme/AcmePaths.cs @@ -83,62 +83,62 @@ internal static void EnsureCertificateIdentityLayout(string stateDir, string fqd /// Account directory path. /// Shared ACME state root. /// The account directory. - private static string AccountDir(string stateDir) => Path.Combine(stateDir, "account"); + private static string AccountDir(string stateDir) => Path.Join(stateDir, "account"); /// Account PKCS#8 DER private key path. /// Shared ACME state root. /// The account private-key path. - internal static string AccountKeyPath(string stateDir) => Path.Combine(AccountDir(stateDir), AccountPrivateKey); + internal static string AccountKeyPath(string stateDir) => Path.Join(AccountDir(stateDir), AccountPrivateKey); /// Account registration metadata JSON path. /// Shared ACME state root. /// The registration metadata path. - internal static string AccountMetaPath(string stateDir) => Path.Combine(AccountDir(stateDir), "registration.json"); + internal static string AccountMetaPath(string stateDir) => Path.Join(AccountDir(stateDir), "registration.json"); /// Pending account key path (crash recovery). /// Shared ACME state root. /// The pending account-key path. internal static string AccountPendingKeyPath(string stateDir) => - Path.Combine(AccountDir(stateDir), AccountPrivateKey + ".pending"); + Path.Join(AccountDir(stateDir), AccountPrivateKey + ".pending"); /// Pending registration metadata path. /// Shared ACME state root. /// The pending registration metadata path. internal static string AccountPendingMetaPath(string stateDir) => - Path.Combine(AccountDir(stateDir), "registration.pending.json"); + Path.Join(AccountDir(stateDir), "registration.pending.json"); /// Common ACME journal root containing one {fqdn}.json file per identity. /// Shared ACME state root. /// The journal directory. - internal static string JournalRoot(string stateDir) => Path.Combine(stateDir, Journal); + internal static string JournalRoot(string stateDir) => Path.Join(stateDir, Journal); /// Persistent ACME transaction journal file for one FQDN. /// Shared ACME state root. /// Certificate FQDN that owns the journal. /// The journal file path journal/{fqdn}.json. internal static string TransactionJournalPath(string stateDir, string fqdn) => - Path.Combine(JournalRoot(stateDir), CertificateIdentities.NormalizeFqdn(fqdn) + ".json"); + Path.Join(JournalRoot(stateDir), CertificateIdentities.NormalizeFqdn(fqdn) + ".json"); /// FQDN-scoped live certificate root. /// Shared ACME state root. /// Certificate FQDN. /// The live directory live/{fqdn}. internal static string LiveDir(string stateDir, string fqdn) => - Path.Combine(stateDir, Live, CertificateIdentities.NormalizeFqdn(fqdn)); + Path.Join(stateDir, Live, CertificateIdentities.NormalizeFqdn(fqdn)); /// FQDN-scoped certificate generations directory. /// Shared ACME state root. /// Certificate FQDN. /// The generations directory live/{fqdn}/gens. internal static string GenerationsDir(string stateDir, string fqdn) => - Path.Combine(LiveDir(stateDir, fqdn), Gens); + Path.Join(LiveDir(stateDir, fqdn), Gens); /// FQDN-scoped current generation pointer file. /// Shared ACME state root. /// Certificate FQDN. /// The current-pointer path live/{fqdn}/current. internal static string CurrentGenerationPointerPath(string stateDir, string fqdn) => - Path.Combine(LiveDir(stateDir, fqdn), Current); + Path.Join(LiveDir(stateDir, fqdn), Current); /// Directory for one generation id under an FQDN. /// Shared ACME state root. @@ -146,7 +146,7 @@ internal static string CurrentGenerationPointerPath(string stateDir, string fqdn /// Generation directory name. /// The generation directory. internal static string GenerationDir(string stateDir, string fqdn, string generationId) => - Path.Combine(GenerationsDir(stateDir, fqdn), generationId); + Path.Join(GenerationsDir(stateDir, fqdn), generationId); /// Paths for a generation's PKCS#12/PFX material. /// Shared ACME state root. @@ -156,7 +156,7 @@ internal static string GenerationDir(string stateDir, string fqdn, string genera internal static CertificatePaths GenerationCertificatePaths(string stateDir, string fqdn, string generationId) { var root = GenerationDir(stateDir, fqdn, generationId); - return new CertificatePaths(Path.Combine(root, CertificatePfx), generationId); + return new CertificatePaths(Path.Join(root, CertificatePfx), generationId); } /// Completion marker for a generation. @@ -165,20 +165,20 @@ internal static CertificatePaths GenerationCertificatePaths(string stateDir, str /// Generation directory name. /// The complete marker path. internal static string GenerationCompleteMarker(string stateDir, string fqdn, string generationId) => - Path.Combine(GenerationDir(stateDir, fqdn, generationId), Complete); + Path.Join(GenerationDir(stateDir, fqdn, generationId), Complete); /// FQDN-scoped transient DNS-01 recovery directory. /// Shared ACME state root. /// Certificate FQDN. /// The recovery directory live/{fqdn}/dns01. internal static string Dns01RecoveryDir(string stateDir, string fqdn) => - Path.Combine(LiveDir(stateDir, fqdn), Dns01); + Path.Join(LiveDir(stateDir, fqdn), Dns01); /// FQDN-scoped issuance lock file path. /// Shared ACME state root. /// Certificate FQDN. /// The lock path live/{fqdn}/.issuance.lock. internal static string IssuanceLockPath(string stateDir, string fqdn) => - Path.Combine(LiveDir(stateDir, fqdn), IssuanceLockFile); + Path.Join(LiveDir(stateDir, fqdn), IssuanceLockFile); } } diff --git a/src/VectorNNTPD.Common/Acme/AtomicFile.cs b/src/VectorNNTPD.Common/Acme/AtomicFile.cs index b1e5725d..3feb33f7 100644 --- a/src/VectorNNTPD.Common/Acme/AtomicFile.cs +++ b/src/VectorNNTPD.Common/Acme/AtomicFile.cs @@ -19,7 +19,7 @@ internal static void WriteBytes(string path, ReadOnlySpan data) Directory.CreateDirectory(directory); } - var tempPath = Path.Combine( + var tempPath = Path.Join( directory ?? ".", $".{Path.GetFileName(path)}.{Guid.NewGuid():N}.tmp"); diff --git a/src/VectorNNTPD.Common/Acme/Dns01Solver.cs b/src/VectorNNTPD.Common/Acme/Dns01Solver.cs index 5d9c8e21..445e828b 100644 --- a/src/VectorNNTPD.Common/Acme/Dns01Solver.cs +++ b/src/VectorNNTPD.Common/Acme/Dns01Solver.cs @@ -519,7 +519,7 @@ private static void WriteJournalEntry(string journalDir, JournalEntry entry) Fqdn = entry.Fqdn, TransactionId = entry.TransactionId, }; - var path = Path.Combine(journalDir, entry.EntryId + ".json"); + var path = Path.Join(journalDir, entry.EntryId + ".json"); AtomicFile.WriteText( path, System.Text.Json.JsonSerializer.Serialize( @@ -532,7 +532,7 @@ private static void WriteJournalEntry(string journalDir, JournalEntry entry) /// FQDN recovery directory. /// Recovery file id. private static void RemoveJournalFile(string journalDir, string entryId) => - AtomicFile.TryDelete(Path.Combine(journalDir, entryId + ".json")); + AtomicFile.TryDelete(Path.Join(journalDir, entryId + ".json")); /// Reads every *.json file in ordinal path order. A missing directory returns an empty list. /// FQDN recovery directory. diff --git a/tests/VectorNNTPD.Common.Tests/Acme/AcmeFilesystemIsolationTests.cs b/tests/VectorNNTPD.Common.Tests/Acme/AcmeFilesystemIsolationTests.cs index a5568c93..d27d564b 100644 --- a/tests/VectorNNTPD.Common.Tests/Acme/AcmeFilesystemIsolationTests.cs +++ b/tests/VectorNNTPD.Common.Tests/Acme/AcmeFilesystemIsolationTests.cs @@ -44,9 +44,9 @@ public void Shared_account_state_is_common_across_identities() Assert.NotNull(loaded); Assert.Equal("https://acme.example/acme/acct/1", loaded.AccountUri); Assert.True(key.AsSpan().SequenceEqual(loaded.PrivateKeyDer)); - Assert.Equal(AcmePaths.AccountKeyPath(dir.Path), Path.Combine(dir.Path, "account", "private_key.der")); - Assert.False(File.Exists(Path.Combine(dir.Path, "account", "nntpd01_private_key.der"))); - Assert.False(File.Exists(Path.Combine(dir.Path, "account", "backfiller01_private_key.der"))); + Assert.Equal(AcmePaths.AccountKeyPath(dir.Path), Path.Join(dir.Path, "account", "private_key.der")); + Assert.False(File.Exists(Path.Join(dir.Path, "account", "nntpd01_private_key.der"))); + Assert.False(File.Exists(Path.Join(dir.Path, "account", "backfiller01_private_key.der"))); } /// @@ -59,33 +59,33 @@ public void Common_paths_are_fqdn_scoped_under_one_certs_root() { using var dir = new TempStateDir(); Assert.Equal( - Path.Combine(dir.Path, "live", NntpdFqdn, "dns01"), + Path.Join(dir.Path, "live", NntpdFqdn, "dns01"), AcmePaths.Dns01RecoveryDir(dir.Path, NntpdFqdn)); Assert.Equal( - Path.Combine(dir.Path, "journal", BackFillerFqdn + ".json"), + Path.Join(dir.Path, "journal", BackFillerFqdn + ".json"), AcmePaths.TransactionJournalPath(dir.Path, BackFillerFqdn)); Assert.Equal( - Path.Combine(dir.Path, "live", NntpdFqdn, "current"), + Path.Join(dir.Path, "live", NntpdFqdn, "current"), AcmePaths.CurrentGenerationPointerPath(dir.Path, NntpdFqdn)); Assert.Equal( - Path.Combine(dir.Path, "live", NntpdFqdn, "gens"), + Path.Join(dir.Path, "live", NntpdFqdn, "gens"), AcmePaths.GenerationsDir(dir.Path, NntpdFqdn)); Assert.Equal( - Path.Combine(dir.Path, "live", BackFillerFqdn, ".issuance.lock"), + Path.Join(dir.Path, "live", BackFillerFqdn, ".issuance.lock"), AcmePaths.IssuanceLockPath(dir.Path, BackFillerFqdn)); Assert.NotEqual( AcmePaths.CurrentGenerationPointerPath(dir.Path, NntpdFqdn), AcmePaths.CurrentGenerationPointerPath(dir.Path, BackFillerFqdn)); Assert.DoesNotContain( - Path.Combine("dns01", "journal"), + Path.Join("dns01", "journal"), AcmePaths.Dns01RecoveryDir(dir.Path, NntpdFqdn), StringComparison.Ordinal); Assert.DoesNotContain( - Path.Combine("journal", "dns01"), + Path.Join("journal", "dns01"), AcmePaths.Dns01RecoveryDir(dir.Path, NntpdFqdn), StringComparison.Ordinal); Assert.DoesNotContain( - Path.Combine("journal", "acme"), + Path.Join("journal", "acme"), AcmePaths.TransactionJournalPath(dir.Path, NntpdFqdn), StringComparison.Ordinal); } @@ -186,10 +186,10 @@ public async Task Dns01_crash_recovery_stays_inside_the_requested_fqdn() var solver = CreateSolver(client, NntpdFqdn, dir.Path); await solver.RecoverAsync(CancellationToken.None); - Assert.False(File.Exists(Path.Combine( + Assert.False(File.Exists(Path.Join( AcmePaths.Dns01RecoveryDir(dir.Path, NntpdFqdn), "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"))); - Assert.True(File.Exists(Path.Combine( + Assert.True(File.Exists(Path.Join( AcmePaths.Dns01RecoveryDir(dir.Path, BackFillerFqdn), "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.json"))); Assert.DoesNotContain(client.Snapshot(), static r => r.Id == "nntpd-rec"); @@ -249,10 +249,10 @@ public async Task Issuance_ledger_records_request_success_expiry_generation_and_ var failed = history.Single(static r => r.Status == AcmeTransactionJournal.StatusFailed); Assert.Contains(failed.Events, static e => e.Type == AcmeTransactionJournal.EventCertificateIssuanceFailed); Assert.Equal( - Path.Combine(dir.Path, "journal", NntpdFqdn + ".json"), + Path.Join(dir.Path, "journal", NntpdFqdn + ".json"), journal.FilePath); Assert.True(File.Exists(journal.FilePath)); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "journal", "acme"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "journal", "acme"))); Assert.Empty(new AcmeTransactionJournal(dir.Path, BackFillerFqdn).LoadHistory()); Assert.False(File.Exists(AcmePaths.TransactionJournalPath(dir.Path, BackFillerFqdn))); } @@ -297,7 +297,7 @@ public async Task Issuance_lock_is_exclusive_per_fqdn_and_independent_across_fqd using var dir = new TempStateDir(); await using var nntpdLock = await AcmeIssuanceLock.AcquireAsync(dir.Path, NntpdFqdn, CancellationToken.None); await using var backfillerLock = await AcmeIssuanceLock.AcquireAsync(dir.Path, BackFillerFqdn, CancellationToken.None); - Assert.Equal(AcmePaths.IssuanceLockPath(dir.Path, NntpdFqdn), Path.Combine(dir.Path, "live", NntpdFqdn, ".issuance.lock")); + Assert.Equal(AcmePaths.IssuanceLockPath(dir.Path, NntpdFqdn), Path.Join(dir.Path, "live", NntpdFqdn, ".issuance.lock")); Assert.NotEqual( AcmePaths.IssuanceLockPath(dir.Path, NntpdFqdn), AcmePaths.IssuanceLockPath(dir.Path, BackFillerFqdn)); @@ -348,10 +348,10 @@ await Task.WhenAll( backfillerManager.EnsureCertificateAsync(CancellationToken.None)); Assert.Equal( - Path.Combine(dir.Path, "live", NntpdFqdn, "current"), + Path.Join(dir.Path, "live", NntpdFqdn, "current"), AcmePaths.CurrentGenerationPointerPath(dir.Path, NntpdFqdn)); Assert.Equal( - Path.Combine(dir.Path, "live", BackFillerFqdn, "current"), + Path.Join(dir.Path, "live", BackFillerFqdn, "current"), AcmePaths.CurrentGenerationPointerPath(dir.Path, BackFillerFqdn)); Assert.NotEqual( File.ReadAllText(AcmePaths.CurrentGenerationPointerPath(dir.Path, NntpdFqdn)), @@ -362,11 +362,11 @@ await Task.WhenAll( Assert.NotEmpty(new AcmeTransactionJournal(dir.Path, BackFillerFqdn).LoadHistory()); Assert.True(File.Exists(AcmePaths.TransactionJournalPath(dir.Path, NntpdFqdn))); Assert.True(File.Exists(AcmePaths.TransactionJournalPath(dir.Path, BackFillerFqdn))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "live", "gens"))); - Assert.False(File.Exists(Path.Combine(dir.Path, "live", "current"))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "journal", "acme"))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "journal", "dns01"))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "dns01"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "live", "gens"))); + Assert.False(File.Exists(Path.Join(dir.Path, "live", "current"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "journal", "acme"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "journal", "dns01"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "dns01"))); using var nntpdCert = nntpdManager.CreateTlsCertificate(); using var backfillerCert = backfillerManager.CreateTlsCertificate(); var nntpdSans = nntpdCert.Extensions.OfType().Single() @@ -376,7 +376,7 @@ await Task.WhenAll( Assert.Contains(NntpdFqdn, nntpdSans); Assert.Contains(CertificateIdentities.NewsHostname, nntpdSans); Assert.Equal([BackFillerFqdn], backfillerSans); - Assert.Equal(AcmePaths.AccountKeyPath(dir.Path), Path.Combine(dir.Path, "account", "private_key.der")); + Assert.Equal(AcmePaths.AccountKeyPath(dir.Path), Path.Join(dir.Path, "account", "private_key.der")); } /// @@ -388,10 +388,10 @@ public void Production_layout_never_creates_global_live_gens_or_current() { using var dir = new TempStateDir(); AcmePaths.EnsureStateLayout(dir.Path); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "live"))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "journal", "acme"))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "journal", "dns01"))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "dns01"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "live"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "journal", "acme"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "journal", "dns01"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "dns01"))); AcmePaths.EnsureCertificateIdentityLayout(dir.Path, NntpdFqdn); var names = CertificateIdentities.ForFqdn(NntpdFqdn); @@ -401,12 +401,12 @@ public void Production_layout_never_creates_global_live_gens_or_current() Assert.True(Directory.Exists(AcmePaths.GenerationsDir(dir.Path, NntpdFqdn))); Assert.True(File.Exists(AcmePaths.CurrentGenerationPointerPath(dir.Path, NntpdFqdn))); Assert.True(Directory.Exists(AcmePaths.Dns01RecoveryDir(dir.Path, NntpdFqdn))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "live", "gens"))); - Assert.False(File.Exists(Path.Combine(dir.Path, "live", "current"))); - Assert.False(File.Exists(Path.Combine(dir.Path, ".issuance.lock"))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "journal", "acme"))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "journal", "dns01"))); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "dns01"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "live", "gens"))); + Assert.False(File.Exists(Path.Join(dir.Path, "live", "current"))); + Assert.False(File.Exists(Path.Join(dir.Path, ".issuance.lock"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "journal", "acme"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "journal", "dns01"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "dns01"))); } /// @@ -441,7 +441,7 @@ public async Task Dns01_history_is_permanent_and_recovery_state_is_transient() Assert.Empty(Directory.GetFiles(AcmePaths.Dns01RecoveryDir(dir.Path, NntpdFqdn), "*.json")); Assert.True(File.Exists(journal.FilePath)); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "journal", "dns01"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "journal", "dns01"))); var transaction = Assert.Single(journal.LoadHistory()); Assert.Contains( transaction.Events, @@ -619,7 +619,7 @@ private static void WriteDns01Journal( .Replace("%CONTENT%", content, StringComparison.Ordinal) .Replace("%RECORD%", recordId, StringComparison.Ordinal) .Replace("%FQDN%", fqdn, StringComparison.Ordinal); - File.WriteAllText(Path.Combine(AcmePaths.Dns01RecoveryDir(stateDir, fqdn), entryId + ".json"), payload); + File.WriteAllText(Path.Join(AcmePaths.Dns01RecoveryDir(stateDir, fqdn), entryId + ".json"), payload); } /// diff --git a/tests/VectorNNTPD.Common.Tests/Acme/AcmePathJoinTests.cs b/tests/VectorNNTPD.Common.Tests/Acme/AcmePathJoinTests.cs new file mode 100644 index 00000000..7a6ae448 --- /dev/null +++ b/tests/VectorNNTPD.Common.Tests/Acme/AcmePathJoinTests.cs @@ -0,0 +1,110 @@ +using System.Runtime.CompilerServices; +using VectorNNTPD.Common.Acme; + +namespace VectorNNTPD.Common.Tests.Acme +{ + /// + /// Locks ACME path construction on Path.Join so rooted later segments cannot + /// silently discard the state-directory prefix (cs/path-combine). + /// + public sealed class AcmePathJoinTests + { + /// + /// Path.Join keeps earlier segments when a later segment is rooted. + /// (Path.Combine would return only the rooted segment; this suite does not call it.) + /// + [Fact] + public void Path_Join_does_not_drop_earlier_segments_for_rooted_later_argument() + { + var baseDir = Path.GetTempPath().TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); + var rooted = Path.GetPathRoot(baseDir)!; + var joined = Path.Join(baseDir, rooted); + var comparison = OperatingSystem.IsWindows() + ? StringComparison.OrdinalIgnoreCase + : StringComparison.Ordinal; + + Assert.StartsWith(baseDir, joined, comparison); + Assert.NotEqual(rooted, joined); + Assert.Contains( + rooted.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), + joined, + comparison); + } + + /// + /// layout helpers stay under the configured state root for normal FQDN input. + /// + [Fact] + public void AcmePaths_layout_stays_under_configured_state_root() + { + var stateDir = Path.Join(Path.GetTempPath(), "vectornntp-acme-join-" + Guid.NewGuid().ToString("N")); + try + { + Directory.CreateDirectory(stateDir); + var fqdn = "backfiller01.usenet.ninja"; + Assert.True(IsUnder(stateDir, AcmePaths.AccountKeyPath(stateDir))); + Assert.True(IsUnder(stateDir, AcmePaths.TransactionJournalPath(stateDir, fqdn))); + Assert.True(IsUnder(stateDir, AcmePaths.LiveDir(stateDir, fqdn))); + Assert.True(IsUnder(stateDir, AcmePaths.Dns01RecoveryDir(stateDir, fqdn))); + Assert.True(IsUnder(stateDir, AcmePaths.IssuanceLockPath(stateDir, fqdn))); + Assert.True(IsUnder(stateDir, AcmePaths.GenerationCertificatePaths(stateDir, fqdn, "gen1").PfxPath)); + } + finally + { + if (Directory.Exists(stateDir)) + { + Directory.Delete(stateDir, recursive: true); + } + } + } + + /// + /// Production ACME path sources must not call Path.Combine. + /// + [Fact] + public void Acme_path_sources_do_not_call_Path_Combine() + { + var repoRoot = FindRepoRoot(); + var files = new[] + { + Path.Join(repoRoot, "src", "VectorNNTPD.Common", "Acme", "AcmePaths.cs"), + Path.Join(repoRoot, "src", "VectorNNTPD.Common", "Acme", "AtomicFile.cs"), + Path.Join(repoRoot, "src", "VectorNNTPD.Common", "Acme", "Dns01Solver.cs"), + }; + + foreach (var file in files) + { + Assert.True(File.Exists(file), file); + var text = File.ReadAllText(file); + Assert.DoesNotContain("Path.Combine(", text, StringComparison.Ordinal); + Assert.Contains("Path.Join(", text, StringComparison.Ordinal); + } + } + + private static bool IsUnder(string root, string candidate) + { + var fullRoot = Path.GetFullPath(root).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) + + Path.DirectorySeparatorChar; + var fullCandidate = Path.GetFullPath(candidate); + return fullCandidate.StartsWith( + fullRoot, + OperatingSystem.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal); + } + + private static string FindRepoRoot([CallerFilePath] string? sourceFile = null) + { + var directory = new DirectoryInfo(Path.GetDirectoryName(sourceFile)!); + while (directory is not null) + { + if (File.Exists(Path.Join(directory.FullName, "VectorNNTPD.slnx"))) + { + return directory.FullName; + } + + directory = directory.Parent; + } + + throw new InvalidOperationException("Could not locate VectorNNTPD.slnx from the test source path."); + } + } +} diff --git a/tests/VectorNNTPD.Common.Tests/Acme/AcmeTransactionJournalTests.cs b/tests/VectorNNTPD.Common.Tests/Acme/AcmeTransactionJournalTests.cs index 8a709c1f..3ab12ff9 100644 --- a/tests/VectorNNTPD.Common.Tests/Acme/AcmeTransactionJournalTests.cs +++ b/tests/VectorNNTPD.Common.Tests/Acme/AcmeTransactionJournalTests.cs @@ -32,7 +32,7 @@ public void One_journal_file_per_fqdn_accumulates_transactions() var second = journal.BeginTransaction([Fqdn, CertificateIdentities.NewsHostname], DirectoryUrl, DateTimeOffset.UtcNow); journal.CompleteFailure(second, "second_failure", "second", DateTimeOffset.UtcNow); - Assert.Equal(Path.Combine(dir.Path, "journal", Fqdn + ".json"), journal.FilePath); + Assert.Equal(Path.Join(dir.Path, "journal", Fqdn + ".json"), journal.FilePath); Assert.True(File.Exists(journal.FilePath)); Assert.Single(Directory.GetFiles(AcmePaths.JournalRoot(dir.Path), "*.json")); @@ -45,7 +45,7 @@ public void One_journal_file_per_fqdn_accumulates_transactions() Assert.Equal("second_failure", reloaded[1].FailureCategory); Assert.Contains(reloaded[0].Events, static e => e.Type == AcmeTransactionJournal.EventCertificateRequestStarted); Assert.Contains(reloaded[0].Events, static e => e.Type == AcmeTransactionJournal.EventCertificateIssuanceFailed); - Assert.False(Directory.Exists(Path.Combine(dir.Path, "journal", "acme"))); + Assert.False(Directory.Exists(Path.Join(dir.Path, "journal", "acme"))); Assert.DoesNotContain( Directory.GetFiles(AcmePaths.JournalRoot(dir.Path), "*.json"), static path => !string.Equals(Path.GetFileName(path), Fqdn + ".json", StringComparison.Ordinal)); diff --git a/tests/VectorNNTPD.Common.Tests/Articles/Parsing/NntpArticleParserTests.cs b/tests/VectorNNTPD.Common.Tests/Articles/Parsing/NntpArticleParserTests.cs index 161f8c07..9659bcb4 100644 --- a/tests/VectorNNTPD.Common.Tests/Articles/Parsing/NntpArticleParserTests.cs +++ b/tests/VectorNNTPD.Common.Tests/Articles/Parsing/NntpArticleParserTests.cs @@ -1010,7 +1010,7 @@ public void Parse_WhenYEncFixtureValid_AcceptsAndClassifiesYEnc() public void Parse_WhenYEncFixtureInvalid_RejectsAsYEncDecodingFailed() { NntpArticleParser parser = new(LocalFqdn); - byte[] fixtureBytes = File.ReadAllBytes(Path.Combine(FixtureRoot, "test_bad_crc_end.yenc")); + byte[] fixtureBytes = File.ReadAllBytes(Path.Join(FixtureRoot, "test_bad_crc_end.yenc")); byte[] body = NormalizeFixtureBodyForParserContract("test_bad_crc_end.yenc", fixtureBytes); byte[] article = BuildArticle( headers: @@ -2221,7 +2221,7 @@ public void Parse_WhenCrOnlyArticleStartsWithContinuation_RejectsMalformedHeader public void Parse_WhenYEncPayloadHasInvalidEscape_RejectsAsYEncDecodingFailed() { NntpArticleParser parser = new(LocalFqdn); - byte[] body = File.ReadAllBytes(Path.Combine(FixtureRoot, "test_invalid_escape.yenc")); + byte[] body = File.ReadAllBytes(Path.Join(FixtureRoot, "test_invalid_escape.yenc")); byte[] article = BuildArticle( headers: [ @@ -2936,7 +2936,7 @@ private static byte[] UnstuffNntpWireDotPrefixedLines(ReadOnlySpan payload /// Thrown when neither candidate directory exists. private static string ResolveFixtureRoot() { - string outputCandidate = Path.Combine(AppContext.BaseDirectory, "Fixtures", "SabctoolsYEnc"); + string outputCandidate = Path.Join(AppContext.BaseDirectory, "Fixtures", "SabctoolsYEnc"); if (Directory.Exists(outputCandidate)) { return outputCandidate; @@ -2946,9 +2946,9 @@ private static string ResolveFixtureRoot() while (!string.IsNullOrWhiteSpace(current)) { - if (File.Exists(Path.Combine(current, "VectorNNTPD.slnx"))) + if (File.Exists(Path.Join(current, "VectorNNTPD.slnx"))) { - string root = Path.Combine(current, "tests", "VectorNNTPD.Common.Tests", "Fixtures", "SabctoolsYEnc"); + string root = Path.Join(current, "tests", "VectorNNTPD.Common.Tests", "Fixtures", "SabctoolsYEnc"); if (Directory.Exists(root)) { return root; diff --git a/tests/VectorNNTPD.Common.Tests/Articles/YEnc/YEncArticleValidatorTests.cs b/tests/VectorNNTPD.Common.Tests/Articles/YEnc/YEncArticleValidatorTests.cs index b8100277..79d60155 100644 --- a/tests/VectorNNTPD.Common.Tests/Articles/YEnc/YEncArticleValidatorTests.cs +++ b/tests/VectorNNTPD.Common.Tests/Articles/YEnc/YEncArticleValidatorTests.cs @@ -947,7 +947,7 @@ public void Validate_WhenArticleBoundaryVariantsAreProvided_ReturnsExpectedStatu /// Raw fixture bytes. private static byte[] LoadFixtureBytes(string fixtureName) { - string path = Path.Combine(FixtureRoot, fixtureName); + string path = Path.Join(FixtureRoot, fixtureName); return File.ReadAllBytes(path); } @@ -1053,7 +1053,7 @@ private static byte[] UnstuffNntpWireDotPrefixedLines(ReadOnlySpan payload /// Thrown when neither the output fixture directory nor the solution-relative directory exists. private static string ResolveFixtureRoot() { - string outputCandidate = Path.Combine(AppContext.BaseDirectory, "Fixtures", "SabctoolsYEnc"); + string outputCandidate = Path.Join(AppContext.BaseDirectory, "Fixtures", "SabctoolsYEnc"); if (Directory.Exists(outputCandidate)) { return outputCandidate; @@ -1063,9 +1063,9 @@ private static string ResolveFixtureRoot() while (!string.IsNullOrWhiteSpace(current)) { - if (File.Exists(Path.Combine(current, "VectorNNTPD.slnx"))) + if (File.Exists(Path.Join(current, "VectorNNTPD.slnx"))) { - string root = Path.Combine(current, "tests", "VectorNNTPD.Common.Tests", "Fixtures", "SabctoolsYEnc"); + string root = Path.Join(current, "tests", "VectorNNTPD.Common.Tests", "Fixtures", "SabctoolsYEnc"); if (Directory.Exists(root)) { return root; diff --git a/tests/VectorNNTPD.Common.Tests/Configuration/ApplicationJsonConfigurationTests.cs b/tests/VectorNNTPD.Common.Tests/Configuration/ApplicationJsonConfigurationTests.cs index 2a510328..b2969f4e 100644 --- a/tests/VectorNNTPD.Common.Tests/Configuration/ApplicationJsonConfigurationTests.cs +++ b/tests/VectorNNTPD.Common.Tests/Configuration/ApplicationJsonConfigurationTests.cs @@ -157,7 +157,7 @@ public void Supplied_rabbitmq_filename_is_exclusive_and_blank_names_are_rejected { Write(root.FullName, "RabbitMq.json", "legacy"); File.WriteAllText( - Path.Combine(root.FullName, "VectorNNTPD.RabbitMQ.json"), + Path.Join(root.FullName, "VectorNNTPD.RabbitMQ.json"), """{"RabbitMQ":{"Port":5672,"Hosts":["198.18.0.4"]}}"""); var builder = new ConfigurationBuilder() .SetBasePath(root.FullName) @@ -209,7 +209,7 @@ public void Missing_required_primary_and_invalid_json_fail_the_build() Assert.Throws(() => required.Build()); File.WriteAllText( - Path.Combine(invalid.FullName, ApplicationJsonConfiguration.PrimaryJsonFileName()), + Path.Join(invalid.FullName, ApplicationJsonConfiguration.PrimaryJsonFileName()), "{"); var malformed = new ConfigurationBuilder() .SetBasePath(invalid.FullName) @@ -242,7 +242,7 @@ private static void Write(string directory, string fileName, string? marker = nu : shared is null ? $$"""{ {{markerLine}} }""" : $$"""{ {{markerLine}}, {{sharedLine}} }"""; - File.WriteAllText(Path.Combine(directory, fileName), body); + File.WriteAllText(Path.Join(directory, fileName), body); } /// diff --git a/tests/VectorNNTPD.Common.Tests/Configuration/ApplicationLocalPathResolutionTests.cs b/tests/VectorNNTPD.Common.Tests/Configuration/ApplicationLocalPathResolutionTests.cs index 4c7eddc6..2170d215 100644 --- a/tests/VectorNNTPD.Common.Tests/Configuration/ApplicationLocalPathResolutionTests.cs +++ b/tests/VectorNNTPD.Common.Tests/Configuration/ApplicationLocalPathResolutionTests.cs @@ -266,9 +266,9 @@ public void Null_or_whitespace_path_is_rejected() public void Relative_path_algorithm_exists_only_in_application_local_path() { var helper = File.ReadAllText(FindRepoFile( - Path.Combine("src", "VectorNNTPD.Common", "Configuration", "ApplicationLocalPath.cs"))); + Path.Join("src", "VectorNNTPD.Common", "Configuration", "ApplicationLocalPath.cs"))); var acmeWrapper = File.ReadAllText(FindRepoFile( - Path.Combine("src", "VectorNNTPD.Common", "Configuration", "AcmeCloudflareOptionsValidator.cs"))); + Path.Join("src", "VectorNNTPD.Common", "Configuration", "AcmeCloudflareOptionsValidator.cs"))); Assert.Contains("Path.GetFullPath(trimmed, fullRoot)", helper, StringComparison.Ordinal); Assert.Contains("A relative path must resolve inside the application base directory.", helper, StringComparison.Ordinal); Assert.Contains("ApplicationLocalPath.ResolveApplicationLocalPath", acmeWrapper, StringComparison.Ordinal); @@ -320,7 +320,7 @@ private static string FindRepoFile(string relativePath) var directory = new DirectoryInfo(AppContext.BaseDirectory); while (directory is not null) { - var candidate = Path.Combine(directory.FullName, relativePath); + var candidate = Path.Join(directory.FullName, relativePath); if (File.Exists(candidate)) { return candidate; diff --git a/tests/VectorNNTPD.Common.Tests/Configuration/SharedNntpdEnvironmentBindingTests.cs b/tests/VectorNNTPD.Common.Tests/Configuration/SharedNntpdEnvironmentBindingTests.cs index 5dd6c51a..1230b2c7 100644 --- a/tests/VectorNNTPD.Common.Tests/Configuration/SharedNntpdEnvironmentBindingTests.cs +++ b/tests/VectorNNTPD.Common.Tests/Configuration/SharedNntpdEnvironmentBindingTests.cs @@ -212,7 +212,7 @@ public void VectorPrefix_StripsToRootConfigurationKeys() [Fact] public void ConfigurationDocumentation_DoesNotPrescribeObsoletePrefixes() { - var docs = FindRepoFile(Path.Combine("docs", "common", "configuration.md")); + var docs = FindRepoFile(Path.Join("docs", "common", "configuration.md")); Assert.True(File.Exists(docs), docs); var text = File.ReadAllText(docs); Assert.Contains("VECTOR__CLOUDFLAREAPIKEY", text, StringComparison.Ordinal); @@ -316,7 +316,7 @@ private static string FindRepoFile(string relativePath) { for (var directory = new DirectoryInfo(AppContext.BaseDirectory); directory is not null; directory = directory.Parent) { - var candidate = Path.Combine(directory.FullName, relativePath); + var candidate = Path.Join(directory.FullName, relativePath); if (File.Exists(candidate)) { return candidate; diff --git a/tests/VectorNNTPD.Common.Tests/Configuration/SharedRabbitMqJsonTests.cs b/tests/VectorNNTPD.Common.Tests/Configuration/SharedRabbitMqJsonTests.cs index 147ff9b2..9b1b37ba 100644 --- a/tests/VectorNNTPD.Common.Tests/Configuration/SharedRabbitMqJsonTests.cs +++ b/tests/VectorNNTPD.Common.Tests/Configuration/SharedRabbitMqJsonTests.cs @@ -21,7 +21,7 @@ public sealed class SharedRabbitMqJsonTests public void Shipped_sample_binds_and_present_host_primary_json_omits_the_section() { var repoRoot = FindRepoRoot(); - var sharedPath = Path.Combine(repoRoot, "src", "VectorNNTPD.Common", "VectorNNTPD.RabbitMQ.json"); + var sharedPath = Path.Join(repoRoot, "src", "VectorNNTPD.Common", "VectorNNTPD.RabbitMQ.json"); Assert.True(File.Exists(sharedPath), sharedPath); var primaryFiles = FindHostPrimaryJsonFiles(repoRoot); @@ -38,9 +38,9 @@ public void Shipped_sample_binds_and_present_host_primary_json_omits_the_section var root = Directory.CreateTempSubdirectory("vnntp-shared-rabbit-"); try { - File.Copy(sharedPath, Path.Combine(root.FullName, "VectorNNTPD.RabbitMQ.json")); + File.Copy(sharedPath, Path.Join(root.FullName, "VectorNNTPD.RabbitMQ.json")); File.WriteAllText( - Path.Combine(root.FullName, ApplicationJsonConfiguration.PrimaryJsonFileName()), + Path.Join(root.FullName, ApplicationJsonConfiguration.PrimaryJsonFileName()), "{}"); var builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings @@ -107,10 +107,10 @@ public void Environment_variable_and_command_line_override_RabbitMq_json() try { File.WriteAllText( - Path.Combine(root.FullName, "VectorNNTPD.RabbitMQ.json"), + Path.Join(root.FullName, "VectorNNTPD.RabbitMQ.json"), """{"RabbitMQ":{"Port":5672,"Hosts":["198.18.0.3"]}}"""); File.WriteAllText( - Path.Combine(root.FullName, ApplicationJsonConfiguration.PrimaryJsonFileName()), + Path.Join(root.FullName, ApplicationJsonConfiguration.PrimaryJsonFileName()), """{"RabbitMQ":{"Port":1}}"""); Environment.SetEnvironmentVariable("RabbitMQ__Port", overriddenPort); @@ -237,7 +237,7 @@ private static string FindRepoRoot() { for (var dir = new DirectoryInfo(AppContext.BaseDirectory); dir is not null; dir = dir.Parent) { - if (File.Exists(Path.Combine(dir.FullName, "VectorNNTPD.slnx"))) + if (File.Exists(Path.Join(dir.FullName, "VectorNNTPD.slnx"))) { return dir.FullName; } @@ -254,7 +254,7 @@ private static string FindRepoRoot() private static List FindHostPrimaryJsonFiles(string repoRoot) { var files = new List(); - var src = Path.Combine(repoRoot, "src"); + var src = Path.Join(repoRoot, "src"); foreach (var project in Directory.EnumerateFiles(src, "*.csproj", SearchOption.AllDirectories)) { if (IsBuildOutputPath(project)) @@ -269,7 +269,7 @@ private static List FindHostPrimaryJsonFiles(string repoRoot) } var assemblyName = ReadAssemblyName(text) ?? Path.GetFileNameWithoutExtension(project); - files.Add(Path.Combine(Path.GetDirectoryName(project)!, assemblyName + ".json")); + files.Add(Path.Join(Path.GetDirectoryName(project)!, assemblyName + ".json")); } return files; diff --git a/tests/VectorNNTPD.Common.Tests/Logging/GzipRollingFileSinkTests.cs b/tests/VectorNNTPD.Common.Tests/Logging/GzipRollingFileSinkTests.cs index b54f5103..73d9161a 100644 --- a/tests/VectorNNTPD.Common.Tests/Logging/GzipRollingFileSinkTests.cs +++ b/tests/VectorNNTPD.Common.Tests/Logging/GzipRollingFileSinkTests.cs @@ -27,8 +27,8 @@ public void DailyRoll_CompressesTheCompletedDay_AndLeavesTheActiveLog() logger.Information("day-two"); } - var dayOne = Path.Combine(dir.Path, "app-20261001.log"); - var dayTwo = Path.Combine(dir.Path, "app-20261002.log"); + var dayOne = Path.Join(dir.Path, "app-20261001.log"); + var dayTwo = Path.Join(dir.Path, "app-20261002.log"); Assert.False(File.Exists(dayOne)); Assert.True(File.Exists(dayOne + ".gz")); Assert.True(File.Exists(dayTwo)); @@ -73,19 +73,19 @@ public void Retention_CountsLogAndGzipDays_IncludingTheActiveFile() public void Restart_RecognizesExistingLogAndGzip_AndAppliesRetention() { using var dir = new TempDir(); - File.WriteAllBytes(Path.Combine(dir.Path, "app-20261001.log.gz"), Gzip("already")); - File.WriteAllText(Path.Combine(dir.Path, "app-20261002.log"), "plain-yesterday"); + File.WriteAllBytes(Path.Join(dir.Path, "app-20261001.log.gz"), Gzip("already")); + File.WriteAllText(Path.Join(dir.Path, "app-20261002.log"), "plain-yesterday"); var time = new ManualTime(new DateTime(2026, 10, 4, 8, 0, 0)); using (var logger = Create(dir.Path, time, retention: 3)) { logger.Information("today"); } - Assert.False(File.Exists(Path.Combine(dir.Path, "app-20261002.log"))); - Assert.Equal("plain-yesterday", Encoding.UTF8.GetString(Inflate(Path.Combine(dir.Path, "app-20261002.log.gz")))); - Assert.True(File.Exists(Path.Combine(dir.Path, "app-20261001.log.gz"))); - Assert.True(File.Exists(Path.Combine(dir.Path, "app-20261004.log"))); - Assert.False(File.Exists(Path.Combine(dir.Path, "app-20261004.log.gz"))); + Assert.False(File.Exists(Path.Join(dir.Path, "app-20261002.log"))); + Assert.Equal("plain-yesterday", Encoding.UTF8.GetString(Inflate(Path.Join(dir.Path, "app-20261002.log.gz")))); + Assert.True(File.Exists(Path.Join(dir.Path, "app-20261001.log.gz"))); + Assert.True(File.Exists(Path.Join(dir.Path, "app-20261004.log"))); + Assert.False(File.Exists(Path.Join(dir.Path, "app-20261004.log.gz"))); time.AdvanceDays(2); using (var logger = Create(dir.Path, time, retention: 3)) @@ -114,12 +114,12 @@ public void CompressionFailure_KeepsTheOriginalLog() logger.Information("next"); } - var failed = Path.Combine(dir.Path, "app-20261001.log"); + var failed = Path.Join(dir.Path, "app-20261001.log"); Assert.True(File.Exists(failed)); Assert.False(File.Exists(failed + ".gz")); Assert.False(File.Exists(failed + GzipLogFileCompressor.PartialSuffix)); Assert.Contains("keep-me", File.ReadAllText(failed), StringComparison.Ordinal); - Assert.True(File.Exists(Path.Combine(dir.Path, "app-20261002.log"))); + Assert.True(File.Exists(Path.Join(dir.Path, "app-20261002.log"))); } /// @@ -136,7 +136,7 @@ public void ActiveFile_IsNotCompressedOrDeleted() logger.Information("only-today"); } - var active = Path.Combine(dir.Path, "app-20261005.log"); + var active = Path.Join(dir.Path, "app-20261005.log"); Assert.True(File.Exists(active)); Assert.False(File.Exists(active + ".gz")); Assert.Null(handed); @@ -157,7 +157,7 @@ public void AsyncFlush_ThenNextDay_CompressesTheCompletedFile() logger.Information("buffered-day"); } - var dayOne = Path.Combine(dir.Path, "app-20261001.log"); + var dayOne = Path.Join(dir.Path, "app-20261001.log"); Assert.True(File.Exists(dayOne)); Assert.Contains("buffered-day", File.ReadAllText(dayOne), StringComparison.Ordinal); Assert.Null(completed); @@ -172,8 +172,8 @@ public void AsyncFlush_ThenNextDay_CompressesTheCompletedFile() Assert.NotNull(completed); Assert.Equal(completed, Inflate(dayOne + ".gz")); Assert.Contains("buffered-day", Encoding.UTF8.GetString(completed), StringComparison.Ordinal); - Assert.Contains("next-buffered-day", File.ReadAllText(Path.Combine(dir.Path, "app-20261002.log")), StringComparison.Ordinal); - Assert.False(File.Exists(Path.Combine(dir.Path, "app-20261002.log.gz"))); + Assert.Contains("next-buffered-day", File.ReadAllText(Path.Join(dir.Path, "app-20261002.log")), StringComparison.Ordinal); + Assert.False(File.Exists(Path.Join(dir.Path, "app-20261002.log.gz"))); } /// @@ -183,7 +183,7 @@ public void AsyncFlush_ThenNextDay_CompressesTheCompletedFile() public void InterruptedGzip_IsDiscarded_AndTheSourceIsCompressedOnRestart() { using var dir = new TempDir(); - var source = Path.Combine(dir.Path, "app-20261001.log"); + var source = Path.Join(dir.Path, "app-20261001.log"); File.WriteAllText(source, "survived-the-crash"); File.WriteAllBytes(source + GzipLogFileCompressor.PartialSuffix, [1, 2, 3, 4]); var time = new ManualTime(new DateTime(2026, 10, 2, 8, 0, 0)); @@ -195,8 +195,8 @@ public void InterruptedGzip_IsDiscarded_AndTheSourceIsCompressedOnRestart() Assert.False(File.Exists(source)); Assert.False(File.Exists(source + GzipLogFileCompressor.PartialSuffix)); Assert.Equal("survived-the-crash", Encoding.UTF8.GetString(Inflate(source + ".gz"))); - Assert.True(File.Exists(Path.Combine(dir.Path, "app-20261002.log"))); - Assert.False(File.Exists(Path.Combine(dir.Path, "app-20261002.log.gz"))); + Assert.True(File.Exists(Path.Join(dir.Path, "app-20261002.log"))); + Assert.False(File.Exists(Path.Join(dir.Path, "app-20261002.log.gz"))); } /// @@ -207,7 +207,7 @@ public void ExistingGzip_IsNotRecompressed_AndLeftoverLogIsRemoved() { using var dir = new TempDir(); var gzip = Gzip("stable"); - var path = Path.Combine(dir.Path, "app-20261001.log"); + var path = Path.Join(dir.Path, "app-20261001.log"); File.WriteAllBytes(path + ".gz", gzip); File.WriteAllText(path, "leftover"); var time = new ManualTime(new DateTime(2026, 10, 2, 8, 0, 0)); @@ -238,7 +238,7 @@ private static Serilog.Core.Logger Create( ILogFileCompressor? compressor = null, Action? onCompleted = null) { - var path = Path.Combine(directory, "app-.log"); + var path = Path.Join(directory, "app-.log"); var configuration = new LoggerConfiguration().MinimumLevel.Debug(); if (async) { @@ -359,7 +359,7 @@ private sealed class TempDir : IDisposable /// public TempDir() { - Path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "vectornntp-gzip-roll-" + Guid.NewGuid().ToString("N")); + Path = System.IO.Path.Join(System.IO.Path.GetTempPath(), "vectornntp-gzip-roll-" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(Path); } diff --git a/tests/VectorNNTPD.Common.Tests/TestDoubles/CommonTestSupport.cs b/tests/VectorNNTPD.Common.Tests/TestDoubles/CommonTestSupport.cs index 7b2eb618..9a1ce177 100644 --- a/tests/VectorNNTPD.Common.Tests/TestDoubles/CommonTestSupport.cs +++ b/tests/VectorNNTPD.Common.Tests/TestDoubles/CommonTestSupport.cs @@ -16,7 +16,7 @@ internal sealed class TempStateDir : IDisposable /// Directory created for one test, under the process temp path and named with a new GUID. /// /// The full path of the directory this instance creates and later deletes. - public string Path { get; } = System.IO.Path.Combine( + public string Path { get; } = System.IO.Path.Join( System.IO.Path.GetTempPath(), "vectornntp-common-" + Guid.NewGuid().ToString("N"));