Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/apps/api-tests
diff options
context:
space:
mode:
authorLeitwolf112026-10-15 18:30:31 +0300
committerLeitwolf112026-10-15 18:30:31 +0300
commitbd83e9e0fba03a4436e4fcfdde33c1e04d1a9c8f (patch)
treed6390125eb9045ab3496f6cee7544f26a183c4ba /apps/api-tests
parenta7604e755e5bb77729a309daea75b14522d22afe (diff)
downloadprogmaweb-bd83e9e0fba03a4436e4fcfdde33c1e04d1a9c8f.tar.gz
Treat progmasoft.com as an HSTS-preloaded domain
.com has no HSTS requirement of its own, but progmasoft.com is served as if it had one: - Every HTTPS server block of progmasoft.com, www, account and viget sends max-age=63072000; includeSubDomains; preload. The www redirect sent none before. - Plain HTTP only answers the ACME challenge and otherwise redirects to HTTPS, now with a permanent 308 instead of 301. - The API's own HSTS policy, which it adds to HTTPS responses outside development, carries the same values, so a proxied response never shows two different policies. A test checks the header.
Diffstat (limited to 'apps/api-tests')
-rw-r--r--apps/api-tests/SecurityHeaderTests.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/apps/api-tests/SecurityHeaderTests.cs b/apps/api-tests/SecurityHeaderTests.cs
index 2d53ecf..e355035 100644
--- a/apps/api-tests/SecurityHeaderTests.cs
+++ b/apps/api-tests/SecurityHeaderTests.cs
@@ -4,6 +4,7 @@
using System.Net;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.HttpOverrides;
+using Microsoft.AspNetCore.Mvc.Testing;
using Progmasoft.Progmaweb.Api.Security;
namespace Progmasoft.Progmaweb.Api.Tests;
@@ -41,4 +42,21 @@ public sealed class SecurityHeaderTests
Assert.Contains("frame-ancestors 'none'",
Assert.Single(response.Headers.GetValues("Content-Security-Policy")), StringComparison.Ordinal);
}
+
+ [Fact]
+ public async Task HttpsResponsesCarryThePreloadPolicyNginxSends()
+ {
+ await using AccountApiFactory factory = new();
+ using HttpClient client = factory.CreateClient(new WebApplicationFactoryClientOptions
+ {
+ AllowAutoRedirect = false,
+ BaseAddress = new Uri("https://account.progmasoft.com"),
+ });
+
+ HttpResponseMessage response =
+ await client.GetAsync("/api/v1/status", TestContext.Current.CancellationToken);
+
+ Assert.Equal("max-age=63072000; includeSubDomains; preload",
+ Assert.Single(response.Headers.GetValues("Strict-Transport-Security")));
+ }
}