V15: Add authorization to saves (#18111)

* Re-add authorization

* Add test plumbing

* Add test helper

* Add happy path test

* Remove usage of negation

* Minor DRYup of test code.

---------

Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
Mole
2025-01-24 13:45:56 +01:00
committed by GitHub
parent 1d9704d8b1
commit c9758edfb1
4 changed files with 236 additions and 39 deletions

View File

@@ -0,0 +1,31 @@
using Umbraco.Cms.Api.Management.ViewModels;
using Umbraco.Cms.Api.Management.ViewModels.Document;
using Umbraco.Cms.Core.Models.ContentEditing;
namespace Umbraco.Cms.Tests.Common.TestHelpers;
public static class DocumentUpdateHelper
{
public static UpdateDocumentRequestModel CreateInvariantDocumentUpdateRequestModel(ContentCreateModel createModel)
{
var updateRequestModel = new UpdateDocumentRequestModel();
updateRequestModel.Template = ReferenceByIdModel.ReferenceOrNull(createModel.TemplateKey);
updateRequestModel.Variants =
[
new DocumentVariantRequestModel
{
Segment = null,
Culture = null,
Name = createModel.InvariantName!,
}
];
updateRequestModel.Values = createModel.InvariantProperties.Select(x => new DocumentValueModel
{
Alias = x.Alias,
Value = x.Value,
});
return updateRequestModel;
}
}