This replaces the blocked history in PR #3 with one properly attributed, signed/DCO commit. The owner personally reviewed and approved PR #3 in the release session. **No file changes from the approved candidate:** bothbaee14f492ande605df62c4have exact Git treea85912cbad. Original PR #3 and its commits are preserved for review history. Historical commits were locally signed but GitHub reported no_user; protected merge checks those introduced commits even for squash merging. This commit resolves attribution without bypassing or weakening signature rules. The reader, Settings, themes, source highlighting/split, live reload, file associations, Print/PDF, About credits, toolbar/footer/editor fixes, user-first README/screenshots and developer guides are exactly the approved implementation. Stable/dev separation and protected Azure signing caller are unchanged. Evidence: - Approved treebaee14f/ CI38285775463 passes all checks. Downloaded focused29/29, published111/111, stable110/110 and dev110/110 TRXs have zero failures/skips. Core coverage100% lines/98.86% branches; actual update/restart/coexistence/default-preservation receipts verify. - New single-commit hooks, online workflow security, signing and DCO pass. GitHub must rerun all required checks on this commit; results are not copied across SHAs. - Live repository setup validates18 Actions-bound checks, with only fuzzing added and all prior protections preserved. - OpenSSF project15417 is now owner-reviewed and saved at70% under owner-confirmed CDLA-Permissive2.0. This is an in-progress assessment, not a passing badge. - Production CI OIDC and signed1.0/dev publication remain required; local representative signing is not CI proof. Substantial AI assistance: Codex (GPT-6). Supersedes PR #3. Release work remains tracked in #33. Closes #4, #6, #7, #8, #9, #10, #11, #12, #13, #14, #15, #16, #17, #18, #19, #20, #21, #22, #23, #24, #25, #26, #27, #28, #29, #32, #34. Refs #1, #5, #30, #31, #33. Signed-off-by: James Maes <james@kof22.com> Co-authored-by: Codex GPT-6 <noreply@openai.com>
68 lines
2.5 KiB
C#
68 lines
2.5 KiB
C#
/*
|
|
* Copyright (c) 2026 James Maes
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
using MarkdownViewr.Windows.Core.Documents;
|
|
|
|
|
|
namespace MarkdownViewr.Windows.Core.Tests;
|
|
|
|
/// <summary>History is private, bounded and tolerant of corrupt settings without probing the filesystem.</summary>
|
|
public sealed class RecentDocumentsTests
|
|
{
|
|
/// <summary>Invalid persisted entries cannot become relative file activations or unbounded menu text.</summary>
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
[InlineData("notes.md")]
|
|
[InlineData("https://example.com/notes.md")]
|
|
[InlineData("C:\\notes\u0000.md")]
|
|
[InlineData("C:\\notes\n.md")]
|
|
public void Sanitize_InvalidPath_RemovesEntry(string? path)
|
|
=> Assert.Empty(RecentDocuments.Sanitize([path]));
|
|
|
|
|
|
|
|
/// <summary>The history retains Windows path order, drops duplicate casing and imposes the fixed limit.</summary>
|
|
[Fact]
|
|
public void Sanitize_MixedHistory_PreservesUniqueBoundedPaths()
|
|
{
|
|
string first = Path.Combine(Path.GetTempPath(), "notes & café.md");
|
|
string[] paths = [first, first.ToUpperInvariant(), .. Enumerable.Range(0, 25).Select(index => Path.Combine(Path.GetTempPath(), index + ".md"))];
|
|
string[] history = RecentDocuments.Sanitize(paths);
|
|
Assert.Equal(20, history.Length);
|
|
Assert.Equal(first, history[0]);
|
|
Assert.EndsWith("18.md", history[^1], StringComparison.Ordinal);
|
|
Assert.Empty(RecentDocuments.Sanitize([Path.GetTempPath() + new string('x', 32768)]));
|
|
}
|
|
|
|
|
|
|
|
/// <summary>Recording a successful open promotes a duplicate and accepts a fresh history without touching files.</summary>
|
|
[Fact]
|
|
public void Record_SuccessfulPath_PromotesOnlyThatEntry()
|
|
{
|
|
string first = Path.Combine(Path.GetTempPath(), "one.md");
|
|
string second = Path.Combine(Path.GetTempPath(), "two.md");
|
|
Assert.Equal([second, first], RecentDocuments.Record([first, second], second));
|
|
Assert.Equal([first], RecentDocuments.Record(null, first));
|
|
Assert.Empty(RecentDocuments.Sanitize(null));
|
|
}
|
|
|
|
|
|
|
|
/// <summary>Old or malformed settings load an empty repaired history and use the same bounds as the menu.</summary>
|
|
[Fact]
|
|
public void Sanitize_Settings_RepairsHistory()
|
|
{
|
|
var settings = new AppSettings { RecentFiles = null! };
|
|
settings.Sanitize();
|
|
Assert.Empty(settings.RecentFiles);
|
|
settings.RecentFiles = ["relative.md", Path.Combine(Path.GetTempPath(), "existing.md")];
|
|
settings.Sanitize();
|
|
Assert.Single(settings.RecentFiles);
|
|
}
|
|
}
|