Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

fix(arch001): address final review findings — disclose widget-tag fix, strengthen Admin routing test, add popup denial tests

KrzysztofPajak73c02e9db7eb
diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/BasePaymentTransactionControllerTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/BasePaymentTransactionControllerTests.cs
index 5364764e3..4972e54a4 100644
--- a/src/Tests/Grand.Web.Admin.Tests/Controllers/BasePaymentTransactionControllerTests.cs
+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/BasePaymentTransactionControllerTests.cs
@@ -238,6 +238,20 @@ public class BasePaymentTransactionControllerTests
Assert.IsFalse(resultModel.RefreshPage);
}
+ [TestMethod]
+ public async Task PartiallyRefundPopup_Post_DeniedByScope_RedirectsToList()
+ {
+ _paymentTransactionServiceMock.Setup(s => s.GetById("pt-1")).ReturnsAsync(new PaymentTransaction { Id = "pt-1" });
+ _scopeMock.Setup(s => s.HasAccess(It.IsAny<PaymentTransaction>())).ReturnsAsync(false);
+
+ var model = new PaymentTransactionModel { AmountToRefund = 50 };
+ var result = await _controller.PartiallyRefundPopup("pt-1", false, model) as RedirectToActionResult;
+
+ Assert.IsNotNull(result);
+ Assert.AreEqual("List", result.ActionName);
+ _mediatorMock.Verify(m => m.Send(It.IsAny<PartiallyRefundOfflineCommand>(), default), Times.Never);
+ }
+
[TestMethod]
public async Task PartiallyPaidPopup_Post_Success_SetsModelRefreshPage()
{
@@ -253,6 +267,20 @@ public class BasePaymentTransactionControllerTests
Assert.IsTrue(resultModel.RefreshPage);
}
+ [TestMethod]
+ public async Task PartiallyPaidPopup_Post_DeniedByScope_RedirectsToList()
+ {
+ _paymentTransactionServiceMock.Setup(s => s.GetById("pt-1")).ReturnsAsync(new PaymentTransaction { Id = "pt-1" });
+ _scopeMock.Setup(s => s.HasAccess(It.IsAny<PaymentTransaction>())).ReturnsAsync(false);
+
+ var model = new PaymentTransactionModel { AmountToPaid = 50 };
+ var result = await _controller.PartiallyPaidPopup("pt-1", false, model) as RedirectToActionResult;
+
+ Assert.IsNotNull(result);
+ Assert.AreEqual("List", result.ActionName);
+ _mediatorMock.Verify(m => m.Send(It.IsAny<PartiallyPaidOfflineCommand>(), default), Times.Never);
+ }
+
[TestMethod]
public async Task Delete_DeniedByScope_RedirectsToList()
{
diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/PaymentTransactionControllerRoutingTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/PaymentTransactionControllerRoutingTests.cs
index eb8774f5b..d5d972979 100644
--- a/src/Tests/Grand.Web.Admin.Tests/Controllers/PaymentTransactionControllerRoutingTests.cs
+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/PaymentTransactionControllerRoutingTests.cs
@@ -1,5 +1,8 @@
using Grand.Web.Admin.Controllers;
+using Grand.Web.Admin.Extensions;
using Grand.Web.AdminShared.Controllers;
+using Grand.Web.Common.Filters;
+using Microsoft.AspNetCore.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Grand.Web.Admin.Tests.Controllers;
@@ -16,4 +19,17 @@ public class PaymentTransactionControllerRoutingTests
Assert.IsTrue(typeof(PaymentTransactionController)
.GetCustomAttributes(typeof(Microsoft.AspNetCore.Mvc.AutoValidateAntiforgeryTokenAttribute), false)
.Length > 0);
+
+ [TestMethod]
+ public void AdminPaymentTransactionController_HasAreaAttributeWithAdminArea()
+ {
+ var areaAttr = (AreaAttribute)Attribute.GetCustomAttribute(typeof(PaymentTransactionController), typeof(AreaAttribute), false);
+ Assert.IsNotNull(areaAttr, "Missing [Area].");
+ Assert.AreEqual(Constants.AreaAdmin, areaAttr.RouteValue);
+ }
+
+ [TestMethod]
+ public void AdminPaymentTransactionController_HasAuthorizeAdminAttribute() =>
+ Assert.IsTrue(typeof(PaymentTransactionController).IsDefined(typeof(AuthorizeAdminAttribute), false),
+ "Missing [AuthorizeAdmin].");
}
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.DetailsButtons.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.DetailsButtons.cshtml
index c512d49ae..e7a214290 100644
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.DetailsButtons.cshtml
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.DetailsButtons.cshtml
@@ -1,2 +1,5 @@
+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper
+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup
+ was inert and never rendered anything. Fixed during ARCH-001 Phase 7 consolidation. *@
@model PaymentTransactionModel
<vc:store-widget widget-zone="payment_transaction_details_buttons" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.DetailsTop.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.DetailsTop.cshtml
index 5f9095607..918729f01 100644
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.DetailsTop.cshtml
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.DetailsTop.cshtml
@@ -1,2 +1,5 @@
+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper
+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup
+ was inert and never rendered anything. Fixed during ARCH-001 Phase 7 consolidation. *@
@model PaymentTransactionModel
<vc:store-widget widget-zone="payment_transaction_details_top" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.ListButtons.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.ListButtons.cshtml
index be8ad217a..efbdddfb1 100644
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.ListButtons.cshtml
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.ListButtons.cshtml
@@ -1,2 +1,5 @@
+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper
+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup
+ was inert and never rendered anything. Fixed during ARCH-001 Phase 7 consolidation. *@
@model PaymentTransactionListModel
<vc:store-widget widget-zone="payment_transaction_list_buttons" additional-data="null"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.PartiallyPaidButtons.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.PartiallyPaidButtons.cshtml
index f7413df81..c99097c5e 100644
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.PartiallyPaidButtons.cshtml
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.PartiallyPaidButtons.cshtml
@@ -1,2 +1,5 @@
+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper
+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup
+ was inert and never rendered anything. Fixed during ARCH-001 Phase 7 consolidation. *@
@model PaymentTransactionModel
<vc:store-widget widget-zone="payment_transaction_partially_paid_buttons" additional-data="Model"/>
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.PartiallyRefundButtons.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.PartiallyRefundButtons.cshtml
index a6d12018b..9ae13a475 100644
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.PartiallyRefundButtons.cshtml
+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/PaymentTransaction/Partials/WidgetZone.PartiallyRefundButtons.cshtml
@@ -1,2 +1,5 @@
+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper
+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup
+ was inert and never rendered anything. Fixed during ARCH-001 Phase 7 consolidation. *@
@model PaymentTransactionModel
<vc:store-widget widget-zone="payment_transaction_partially_refund_buttons" additional-data="Model"/>