Add missing Account/Delete confirmation page
All checks were successful
Dotnet build and test / build (pull_request) Successful in 18m44s
All checks were successful
Dotnet build and test / build (pull_request) Successful in 18m44s
The POST Delete(UnregisterViewModel) action and the GET Delete() action both existed in AccountController, but Views/Account/Delete.cshtml was missing — so GET /Account/Delete had no page to render. Add the confirmation view (posts back to Delete with the user's UserId, with a "Confirmer la suppression" button and an "Annuler" cancel link). Add a smoke test: an authenticated GET /Account/Delete returns 200 and the confirmation page body. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
709846c58d
commit
2ad7a55e34
3 changed files with 45 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ using System.Net.Http;
|
||||||
using IdentityServer8.Stores;
|
using IdentityServer8.Stores;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Yavsc.Tests.Shared;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Yavsc.Org.Tests.Smoke;
|
namespace Yavsc.Org.Tests.Smoke;
|
||||||
|
|
@ -65,4 +66,26 @@ public class AccountSmokeTests : IClassFixture<TestWebApplicationFactory>
|
||||||
Assert.Equal("/signin", location.AbsolutePath);
|
Assert.Equal("/signin", location.AbsolutePath);
|
||||||
Assert.Contains("ReturnUrl=%2FEstimate", location.Query);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1061,6 +1061,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
||||||
}
|
}
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, Authorize]
|
[HttpPost, Authorize]
|
||||||
public async Task<IActionResult> Delete(UnregisterViewModel model)
|
public async Task<IActionResult> Delete(UnregisterViewModel model)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
21
src/Yavsc.Org/Views/Account/Delete.cshtml
Normal file
21
src/Yavsc.Org/Views/Account/Delete.cshtml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
@model UnregisterViewModel
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Supprimer mon compte";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h2>@ViewBag.Title</h2>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<p>
|
||||||
|
Cette action est <strong>immédiate et irréversible</strong>. Toutes les données
|
||||||
|
associées à votre compte seront supprimées, et vous serez déconnecté.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form asp-controller="Account" asp-action="Delete" method="post" class="form-horizontal" role="form">
|
||||||
|
@Html.Hidden("UserId")
|
||||||
|
<button type="submit" class="btn btn-danger">Confirmer la suppression</button>
|
||||||
|
<a asp-controller="Home" asp-action="Index" class="btn btn-default">Annuler</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Loading…
Reference in a new issue