23 lines
1.1 KiB
C#
23 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using PlotLine.Controllers;
|
|
|
|
internal static class LegacyAcceptanceTests
|
|
{
|
|
public static void RedirectsWithoutReporting()
|
|
{
|
|
if (!System.Attribute.IsDefined(typeof(AcceptanceController), typeof(AuthorizeAttribute)))
|
|
throw new Exception("Legacy bookmarks must still require authentication.");
|
|
var controller = new AcceptanceController();
|
|
foreach (int? projectId in new int?[] { null, 0, -1, 7, int.MaxValue })
|
|
{
|
|
var result = controller.Phase1(projectId) as RedirectToActionResult
|
|
?? throw new Exception("Legacy checklist must redirect rather than query reports.");
|
|
if (result.ControllerName != "Projects" || result.ActionName != (projectId is > 0 ? "Details" : "Index"))
|
|
throw new Exception("Legacy checklist should use the standard project routes and their access controls.");
|
|
if (projectId is > 0 && !Equals(result.RouteValues?["id"], projectId))
|
|
throw new Exception("Legacy bookmark must preserve project identity.");
|
|
}
|
|
}
|
|
}
|