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>
This commit is contained in:
github-actions[bot] 2026-05-03 12:47:40 +00:00 committed by GitHub
parent 871b959ed9
commit 1bcd36ca76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -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");

View File

@ -0,0 +1,19 @@
using Xunit;
namespace OpenClaw.Tray.Tests;
/// <summary>
/// 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.
/// </summary>
public sealed class WindowsFactAttribute : FactAttribute
{
public WindowsFactAttribute()
{
if (!OperatingSystem.IsWindows())
{
Skip = "Windows-only: requires a Windows platform API.";
}
}
}