blob: 91889cd3e368ddc1194146333bd1f6af4e4ac6a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.0
using System.Net;
namespace Progmasoft.Progmaweb.Api.Tests;
public sealed class SecurityHeaderTests
{
[Fact]
public async Task ApiResponsesSetDefensiveHeaders()
{
await using AccountApiFactory factory = new();
using HttpClient client = factory.CreateAccountClient(handleCookies: false);
HttpResponseMessage response =
await client.GetAsync("/api/v1/status", TestContext.Current.CancellationToken);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal("no-store", Assert.Single(response.Headers.GetValues("Cache-Control")));
Assert.Equal("no-referrer", Assert.Single(response.Headers.GetValues("Referrer-Policy")));
Assert.Equal("nosniff", Assert.Single(response.Headers.GetValues("X-Content-Type-Options")));
Assert.Equal("DENY", Assert.Single(response.Headers.GetValues("X-Frame-Options")));
Assert.Contains("frame-ancestors 'none'",
Assert.Single(response.Headers.GetValues("Content-Security-Policy")), StringComparison.Ordinal);
}
}
|