Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Umbraco.Core/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,11 @@ private async Task<Attempt<IEnumerable<NodePermissions>, UserOperationStatus>> G
Dictionary<Guid, int> nodes,
IEnumerable<UmbracoObjectTypes> objectTypes)
{
if (nodes.Count == 0)
{
return Attempt.SucceedWithStatus(UserOperationStatus.Success, Enumerable.Empty<NodePermissions>());
}

IUser? user = await GetAsync(userKey);
if (user is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,33 @@ public async Task AssignUserGroupPermission_Sets_Permission_On_Multiple_Entities
Assert.IsTrue(perms2.Permissions.Contains(ActionBrowse.ActionLetter));
}

[Test]
public async Task GetDocumentPermissionsAsync_Returns_Empty_Permissions_For_Empty_Keys()
{
// Arrange
var userGroup = await CreateTestUserGroup();
var user = UserService.CreateUserWithIdentity("test1", "test1@test.com");
user.AddGroup(userGroup.ToReadOnlyGroup());
UserService.Save(user);

// Create content so the database is non-empty — we want to verify that an an empty key collection
// does not return ALL documents, producing a non-empty result instead of the expected empty one.
var contentType = ContentTypeBuilder.CreateSimpleContentType();
contentType.AllowedTemplates = null;
await ContentTypeService.CreateAsync(contentType, Constants.Security.SuperUserKey);
var content = ContentBuilder.CreateSimpleContent(contentType);
ContentService.Save(content);

// Act
var result = await UserService
.GetDocumentPermissionsAsync(user.Key, Array.Empty<Guid>());

// Assert
Assert.IsTrue(result.Success);
Assert.AreEqual(UserOperationStatus.Success, result.Status);
Assert.IsEmpty(result.Result);
}

[Test]
public async Task AssignUserGroupPermission_Adds_To_Existing_Permissions()
{
Expand Down
Loading