diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppClients.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppClients.cs index a14c9cffe..aab65d1ed 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppClients.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppClients.cs @@ -68,21 +68,6 @@ namespace Squidex.Domain.Apps.Entities.Apps.Guards { e(Not.Valid("role"), nameof(command.Role)); } - - if (client == null) - { - return; - } - - if (!string.IsNullOrWhiteSpace(command.Name) && string.Equals(client.Name, command.Name)) - { - e(Not.New("Client", "name"), nameof(command.Name)); - } - - if (command.Role == client.Role) - { - e(Not.New("Client", "role"), nameof(command.Role)); - } }); } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/Guards/GuardAsset.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/Guards/GuardAsset.cs index 486083010..0a0a7188a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/Guards/GuardAsset.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/Guards/GuardAsset.cs @@ -25,16 +25,6 @@ namespace Squidex.Domain.Apps.Entities.Assets.Guards { e("Either file name, slug or tags must be defined.", nameof(command.FileName), nameof(command.Slug), nameof(command.Tags)); } - - if (!string.IsNullOrWhiteSpace(command.FileName) && string.Equals(command.FileName, oldFileName)) - { - e(Not.New("Asset", "name"), nameof(command.FileName)); - } - - if (!string.IsNullOrWhiteSpace(command.Slug) && string.Equals(command.Slug, oldSlug)) - { - e(Not.New("Asset", "slug"), nameof(command.Slug)); - } }); } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/Guards/GuardRule.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/Guards/GuardRule.cs index 2f8a80964..40023a767 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/Guards/GuardRule.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/Guards/GuardRule.cs @@ -70,11 +70,6 @@ namespace Squidex.Domain.Apps.Entities.Rules.Guards errors.Foreach(x => x.AddTo(e)); } - - if (command.Name != null && string.Equals(rule.Name, command.Name)) - { - e(Not.New("Rule", "name"), nameof(command.Name)); - } }); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppClientsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppClientsTests.cs index 6a27610ce..80bf6162f 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppClientsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppClientsTests.cs @@ -118,25 +118,23 @@ namespace Squidex.Domain.Apps.Entities.Apps.Guards } [Fact] - public void UpdateClient_should_throw_exception_if_client_has_same_name() + public void UpdateClient_should_not_throw_exception_if_client_has_same_name() { var command = new UpdateClient { Id = "ios", Name = "ios" }; var clients_1 = clients_0.Add("ios", "secret"); - ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_1, command, roles), - new ValidationError("Client has already this name.", "Name")); + GuardAppClients.CanUpdate(clients_1, command, roles); } [Fact] - public void UpdateClient_should_throw_exception_if_client_has_same_role() + public void UpdateClient_not_should_throw_exception_if_client_has_same_role() { var command = new UpdateClient { Id = "ios", Role = Role.Editor }; var clients_1 = clients_0.Add("ios", "secret"); - ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_1, command, roles), - new ValidationError("Client has already this role.", "Role")); + GuardAppClients.CanUpdate(clients_1, command, roles); } [Fact] diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetTests.cs index 0462071ba..94e23930a 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetTests.cs @@ -24,25 +24,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Guards } [Fact] - public void CanAnnotate_should_throw_exception_if_names_are_the_same() - { - var command = new AnnotateAsset { FileName = "asset-name" }; - - ValidationAssert.Throws(() => GuardAsset.CanAnnotate(command, "asset-name", "asset-slug"), - new ValidationError("Asset has already this name.", "FileName")); - } - - [Fact] - public void CanAnnotate_should_throw_exception_if_slugs_are_the_same() - { - var command = new AnnotateAsset { Slug = "asset-slug" }; - - ValidationAssert.Throws(() => GuardAsset.CanAnnotate(command, "asset-name", "asset-slug"), - new ValidationError("Asset has already this slug.", "Slug")); - } - - [Fact] - public void CanAnnotate_should_not_throw_exception_if_names_are_different() + public void CanAnnotate_should_not_throw_exception_if_a_value_is_passed() { var command = new AnnotateAsset { FileName = "new-name", Slug = "new-slug" }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Guards/GuardRuleTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Guards/GuardRuleTests.cs index 8883862db..a5df505a9 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Guards/GuardRuleTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Guards/GuardRuleTests.cs @@ -100,15 +100,11 @@ namespace Squidex.Domain.Apps.Entities.Rules.Guards } [Fact] - public async Task CanUpdate_should_throw_exception_if_rule_has_already_this_name() + public async Task CanUpdate_should_not_throw_exception_if_rule_has_already_this_name() { - var command = new UpdateRule - { - Name = "MyName" - }; + var command = new UpdateRule { Name = "MyName" }; - await ValidationAssert.ThrowsAsync(() => GuardRule.CanUpdate(command, appId.Id, appProvider, rule_0), - new ValidationError("Rule has already this name.", "Name")); + await GuardRule.CanUpdate(command, appId.Id, appProvider, rule_0); } [Fact]