diff --git a/src/Yavsc.Org.Tests/Smoke/AccountSmokeTests.cs b/src/Yavsc.Org.Tests/Smoke/AccountSmokeTests.cs index 5e7ab7776..4a7600596 100644 --- a/src/Yavsc.Org.Tests/Smoke/AccountSmokeTests.cs +++ b/src/Yavsc.Org.Tests/Smoke/AccountSmokeTests.cs @@ -3,6 +3,7 @@ using System.Net.Http; using IdentityServer8.Stores; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Yavsc.Tests.Shared; using Xunit; namespace Yavsc.Org.Tests.Smoke; @@ -65,4 +66,26 @@ public class AccountSmokeTests : IClassFixture Assert.Equal("/signin", location.AbsolutePath); Assert.Contains("ReturnUrl=%2FEstimate", location.Query); } + + // Regression: the POST Delete action existed, but neither the GET + // Delete view nor a rendered confirmation page was reachable — + // Views/Account/Delete.cshtml was missing. An authenticated GET + // must now return the confirmation page (200). + [Fact] + public async Task Authenticated_get_account_delete_returns_confirmation_page() + { + var client = _factory.CreateClient(new WebApplicationFactoryClientOptions + { + AllowAutoRedirect = false, + }); + client.DefaultRequestHeaders.Add( + TestAuthPolicyProvider.HeaderName, TestAuthPolicyProvider.AdminRole); + + var response = await client.GetAsync("/Account/Delete", TestContext.Current.CancellationToken); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + var body = await response.Content.ReadAsStringAsync( + TestContext.Current.CancellationToken); + Assert.Contains("Supprimer mon compte", body); + } } diff --git a/src/Yavsc.Org/Controllers/Accounting/AccountController.cs b/src/Yavsc.Org/Controllers/Accounting/AccountController.cs index 04f60aa1d..f8fa7f0d2 100644 --- a/src/Yavsc.Org/Controllers/Accounting/AccountController.cs +++ b/src/Yavsc.Org/Controllers/Accounting/AccountController.cs @@ -1061,6 +1061,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory, } return View(); } + [HttpPost, Authorize] public async Task Delete(UnregisterViewModel model) { diff --git a/src/Yavsc.Org/Views/Account/Delete.cshtml b/src/Yavsc.Org/Views/Account/Delete.cshtml new file mode 100644 index 000000000..7443d3d2a --- /dev/null +++ b/src/Yavsc.Org/Views/Account/Delete.cshtml @@ -0,0 +1,21 @@ +@model UnregisterViewModel +@{ + ViewBag.Title = "Supprimer mon compte"; +} + +

@ViewBag.Title

+ +
+
+

+ Cette action est immédiate et irréversible. Toutes les données + associées à votre compte seront supprimées, et vous serez déconnecté. +

+ +
+ @Html.Hidden("UserId") + + Annuler +
+
+
\ No newline at end of file