From 1bcd36ca763e8fcab136a5ea3cf9dd1766d39b9f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 3 May 2026 12:47:40 +0000 Subject: [PATCH] test(tray): add WindowsFactAttribute; skip DPAPI test on non-Windows SettingsManager_ProtectsElevenLabsApiKeyForStorage calls ProtectSettingSecret, which intentionally throws PlatformNotSupportedException on non-Windows (DPAPI is Windows-only). The test had no platform guard, so it produced a spurious failure on every Linux CI run. Adds WindowsFactAttribute following the same pattern as IntegrationFactAttribute: a custom FactAttribute subclass that sets Skip automatically when the test runs on a non-Windows platform. Applies it to the one DPAPI test. The test continues to run and assert fully on Windows CI (windows-latest). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../SettingsRoundTripTests.cs | 2 +- .../WindowsFactAttribute.cs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/OpenClaw.Tray.Tests/WindowsFactAttribute.cs diff --git a/tests/OpenClaw.Tray.Tests/SettingsRoundTripTests.cs b/tests/OpenClaw.Tray.Tests/SettingsRoundTripTests.cs index 6181bb3..f1996b3 100644 --- a/tests/OpenClaw.Tray.Tests/SettingsRoundTripTests.cs +++ b/tests/OpenClaw.Tray.Tests/SettingsRoundTripTests.cs @@ -215,7 +215,7 @@ public class SettingsRoundTripTests Assert.Null(SettingsData.FromJson("not json at all")); } - [Fact] + [WindowsFact] public void SettingsManager_ProtectsElevenLabsApiKeyForStorage() { var protectedValue = SettingsManager.ProtectSettingSecret("elevenlabs-key"); diff --git a/tests/OpenClaw.Tray.Tests/WindowsFactAttribute.cs b/tests/OpenClaw.Tray.Tests/WindowsFactAttribute.cs new file mode 100644 index 0000000..7b76149 --- /dev/null +++ b/tests/OpenClaw.Tray.Tests/WindowsFactAttribute.cs @@ -0,0 +1,19 @@ +using Xunit; + +namespace OpenClaw.Tray.Tests; + +/// +/// Marks a test that can only run on Windows (e.g. tests that exercise +/// Windows Data Protection API, NTFS reparse points, or other Win32 surfaces). +/// The test is automatically skipped on non-Windows platforms. +/// +public sealed class WindowsFactAttribute : FactAttribute +{ + public WindowsFactAttribute() + { + if (!OperatingSystem.IsWindows()) + { + Skip = "Windows-only: requires a Windows platform API."; + } + } +}