From c8c5128995726283bcf0013fd99e7c9015a63380 Mon Sep 17 00:00:00 2001 From: yv01p Date: Wed, 24 Dec 2025 14:59:25 +0000 Subject: [PATCH] test(integration): add Phase 6 ContentPermissionManager DI tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../ContentServiceRefactoringTests.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs index 8044c6dc57..930a3f8c55 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs @@ -888,6 +888,49 @@ internal sealed class ContentServiceRefactoringTests : UmbracoIntegrationTestWit #endregion + #region Phase 6 - Permission Manager Tests + + /// + /// Phase 6 Test: Verifies ContentPermissionManager is registered and resolvable from DI. + /// + [Test] + public void ContentPermissionManager_CanBeResolvedFromDI() + { + // Act + var permissionManager = GetRequiredService(); + + // Assert + Assert.That(permissionManager, Is.Not.Null); + Assert.That(permissionManager, Is.InstanceOf()); + } + + /// + /// Phase 6 Test: Verifies permission operations work via ContentService after delegation. + /// + [Test] + public async Task SetPermission_ViaContentService_DelegatesToPermissionManager() + { + // Arrange + var content = ContentBuilder.CreateSimpleContent(ContentType, "PermissionDelegationTest", -1); + ContentService.Save(content); + + var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupAlias); + Assert.That(adminGroup, Is.Not.Null, "Admin group should exist"); + + // Act - This should delegate to ContentPermissionManager + ContentService.SetPermission(content, "F", new[] { adminGroup!.Id }); + + // Assert - Verify it worked (via GetPermissions which also delegates) + var permissions = ContentService.GetPermissions(content); + var adminPermissions = permissions.FirstOrDefault(p => p.UserGroupId == adminGroup.Id); + + Assert.That(adminPermissions, Is.Not.Null, "Should have permissions for admin group"); + Assert.That(adminPermissions!.AssignedPermissions, Does.Contain("F"), + "Admin group should have Browse permission"); + } + + #endregion + /// /// Notification handler that tracks the order of notifications for test verification. ///