V13: Rework attempt pattern to use userkey (#13964)

* Add default super user key to migrations

* Start refactoring all interfaces signatures with ids

* Refactor datatype service to use userKey pattern instead

* Refactor ContentEditingService to use userkeys

* Refactor services to userKey

* Refactor more services to use userkey instead of id

* Refactor RelationService to use userKeys

* Refactor template service to use keys instead of ids

* Refactor fileservice to use keys instead of ids

* Refactor LocalizationService to use keys instead of ids

* Refactor PackagingService to use keys instead of ids

* Refactor TemplateController to use current user keys

* Refactor DataTypeContainerService.cs

* Refactor DataTypeService to use keys instead of ids

* Fix up tests

* Fix up media editing service to use userkey instead of ID

* Update service ctor to avoid ambigious ctors

* refactor DataTypeService

* Refactor DataTypeService to not have a default value for parentKey

* Apply suggestions from code review

Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>

* Update comment

* Add suppression file

* Add backoffice CompatibilitySuppressions

---------

Co-authored-by: Zeegaan <nge@umbraco.dk>
Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
This commit is contained in:
Nikolaj Geisle
2023-03-21 12:41:20 +01:00
committed by GitHub
parent 8a8421c841
commit 93da4371e3
83 changed files with 853 additions and 578 deletions

View File

@@ -170,11 +170,11 @@ public class CreatedPackagesRepositoryTests : UmbracoIntegrationTest
[Test]
public async Task GivenNestedDictionaryItems_WhenPackageExported_ThenTheXmlIsNested()
{
var parent = (await DictionaryItemService.CreateAsync(new DictionaryItem("Parent"))).Result;
var child1 = (await DictionaryItemService.CreateAsync(new DictionaryItem(parent.Key, "Child1"))).Result;
var child2 = (await DictionaryItemService.CreateAsync(new DictionaryItem(child1.Key, "Child2"))).Result;
var child3 = (await DictionaryItemService.CreateAsync(new DictionaryItem(child2.Key, "Child3"))).Result;
var child4 = (await DictionaryItemService.CreateAsync(new DictionaryItem(child3.Key, "Child4"))).Result;
var parent = (await DictionaryItemService.CreateAsync(new DictionaryItem("Parent"), Constants.Security.SuperUserKey)).Result;
var child1 = (await DictionaryItemService.CreateAsync(new DictionaryItem(parent.Key, "Child1"), Constants.Security.SuperUserKey)).Result;
var child2 = (await DictionaryItemService.CreateAsync(new DictionaryItem(child1.Key, "Child2"), Constants.Security.SuperUserKey)).Result;
var child3 = (await DictionaryItemService.CreateAsync(new DictionaryItem(child2.Key, "Child3"), Constants.Security.SuperUserKey)).Result;
var child4 = (await DictionaryItemService.CreateAsync(new DictionaryItem(child3.Key, "Child4"), Constants.Security.SuperUserKey)).Result;
var def = new PackageDefinition
{

View File

@@ -31,7 +31,7 @@ public class RelationServiceTests : UmbracoIntegrationTest
.WithIsDependency(isDependency)
.Build();
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserId);
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserKey);
Assert.Multiple(() =>
{
@@ -56,7 +56,7 @@ public class RelationServiceTests : UmbracoIntegrationTest
.WithParentObjectType(new Guid(parentObjectTypeGuid))
.Build();
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserId);
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserKey);
Assert.Multiple(() =>
{
@@ -78,7 +78,7 @@ public class RelationServiceTests : UmbracoIntegrationTest
.WithParentObjectType(new Guid(parentObjectTypeGuid))
.Build();
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserId);
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserKey);
Assert.Multiple(() =>
{
@@ -97,7 +97,7 @@ public class RelationServiceTests : UmbracoIntegrationTest
.WithKey(new Guid(key))
.Build();
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserId);
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserKey);
Assert.Multiple(() =>
{
@@ -122,7 +122,7 @@ public class RelationServiceTests : UmbracoIntegrationTest
.WithId(id)
.Build();
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserId);
Attempt<IRelationType, RelationTypeOperationStatus> result = await RelationService.CreateAsync(relationType, Constants.Security.SuperUserKey);
Assert.Multiple(() =>
{

View File

@@ -145,9 +145,9 @@ public class TelemetryProviderTests : UmbracoIntegrationTest
var langTwo = _languageBuilder.WithCultureInfo("da-DK").Build();
var langThree = _languageBuilder.WithCultureInfo("sv-SE").Build();
var langTwoResult = await LanguageService.CreateAsync(langTwo);
var langTwoResult = await LanguageService.CreateAsync(langTwo, Constants.Security.SuperUserKey);
Assert.IsTrue(langTwoResult.Success);
var langThreeResult = await LanguageService.CreateAsync(langThree);
var langThreeResult = await LanguageService.CreateAsync(langThree, Constants.Security.SuperUserKey);
Assert.IsTrue(langThreeResult.Success);
IEnumerable<UsageInformation> result = null;

View File

@@ -1,4 +1,5 @@
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Models;
@@ -27,7 +28,7 @@ public class ContentVariantAllowedActionTests : UmbracoTestServerTestBase
public async Task SetUpTestDate()
{
var dk = new Language(DkIso, "Danish");
await LanguageService.CreateAsync(dk);
await LanguageService.CreateAsync(dk, Constants.Security.SuperUserKey);
}
[Test]