GET System/capabilities blijft bereikbaar als het CMS uit staat of in onderhoud is

De actie krijgt [PublicSiteEndpoint] (en [AllowAnonymous]), zodat een gast op de loginpagina geen 503 meer krijgt; de lijst van publieke acties in de route-table-test en een pipelinetest (CMS in onderhoud) zijn bijgewerkt. Besluit van Bryan: de beschikbaarheidsstatussen blokkeren alleen het CMS, nooit de publieke site.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 13:25:57 +01:00
co-authored by Claude Sonnet 5.5
parent 99066f7ed6
commit b39fc5b6ea
3 changed files with 19 additions and 0 deletions
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using SlpModularCms.Core.Availability;
using SlpModularCms.Core.Email;
namespace SlpModularCms.Core.Hosting;
@@ -25,6 +27,8 @@ public class SystemController : ControllerBase
}
[HttpGet("capabilities")]
[AllowAnonymous]
[PublicSiteEndpoint]
public IActionResult GetCapabilities()
{
// EmailEnabled tells the UI whether mail actions exist on this site; DefaultLanguage is the
@@ -161,6 +161,7 @@ public class PublicSiteEndpointGateTests
$"{nameof(OfferingsController)}.{nameof(OfferingsController.GetOfferings)}",
$"{nameof(ContactMessagesController)}.{nameof(ContactMessagesController.GetToken)}",
$"{nameof(ContactMessagesController)}.{nameof(ContactMessagesController.Submit)}",
$"{nameof(SystemController)}.{nameof(SystemController.GetCapabilities)}",
];
private static IReadOnlyList<MethodInfo> AllActions() =>
@@ -315,4 +315,18 @@ public class ContactPipelineGateTests(EnabledContactHostFactory factory) : IClas
post.StatusCode.Should().Be(HttpStatusCode.Accepted);
(await factory.WithDb(db => db.ContactMessages.CountAsync(m => m.Name == "Pipeline Gate"))).Should().Be(1);
}
[Fact]
public async Task TheLoginPageRoutes_NeverAnswer503_WhileTheCmsIsDisabled()
{
await factory.WithDb(db => db.Database.ExecuteSqlRawAsync(
"INSERT INTO AvailabilityState (Id, Status, Message, LastUpdatedAt, UpdatedBy) VALUES (UUID(), 2, 'maintenance pipeline test', NOW(), 'pipeline test')"));
var client = factory.CreateClient();
// A guest on a disabled or maintenance CMS must still be able to read what the login page needs.
(await client.GetAsync("/api/v1/System/capabilities")).StatusCode.Should().Be(HttpStatusCode.OK);
(await client.GetAsync("/api/v1/Availability/status")).StatusCode.Should().Be(HttpStatusCode.OK);
(await client.GetAsync("/api/v1/offerings")).StatusCode.Should().Be(HttpStatusCode.OK);
(await client.GetAsync("/api/v1/contact-messages")).StatusCode.Should().Be(HttpStatusCode.ServiceUnavailable, "the management routes stay behind the gate");
}
}