60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
|
|
using System.Linq.Expressions;
|
||
|
|
using System.Net;
|
||
|
|
using NUnit.Framework;
|
||
|
|
using Umbraco.Cms.Api.Management.Controllers.Dictionary;
|
||
|
|
using Umbraco.Cms.Core;
|
||
|
|
using Umbraco.Cms.Core.Models;
|
||
|
|
using Umbraco.Cms.Core.Services;
|
||
|
|
|
||
|
|
namespace Umbraco.Cms.Tests.Integration.ManagementApi.Dictionary;
|
||
|
|
|
||
|
|
public class DeleteDictionaryControllerTests : ManagementApiUserGroupTestBase<DeleteDictionaryController>
|
||
|
|
{
|
||
|
|
private IDictionaryItemService DictionaryItemService => GetRequiredService<IDictionaryItemService>();
|
||
|
|
|
||
|
|
private Guid _dictionaryKey;
|
||
|
|
|
||
|
|
[SetUp]
|
||
|
|
public async Task Setup()
|
||
|
|
{
|
||
|
|
var dictionaryItem = new DictionaryItem(Constants.System.RootKey, Guid.NewGuid().ToString());
|
||
|
|
_dictionaryKey = dictionaryItem.Key;
|
||
|
|
await DictionaryItemService.CreateAsync(dictionaryItem, Constants.Security.SuperUserKey);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override Expression<Func<DeleteDictionaryController, object>> MethodSelector =>
|
||
|
|
x => x.Delete(CancellationToken.None, _dictionaryKey);
|
||
|
|
|
||
|
|
protected override UserGroupAssertionModel AdminUserGroupAssertionModel => new()
|
||
|
|
{
|
||
|
|
ExpectedStatusCode = HttpStatusCode.OK
|
||
|
|
};
|
||
|
|
|
||
|
|
protected override UserGroupAssertionModel EditorUserGroupAssertionModel => new()
|
||
|
|
{
|
||
|
|
ExpectedStatusCode = HttpStatusCode.Forbidden
|
||
|
|
};
|
||
|
|
|
||
|
|
protected override UserGroupAssertionModel SensitiveDataUserGroupAssertionModel => new()
|
||
|
|
{
|
||
|
|
ExpectedStatusCode = HttpStatusCode.Forbidden
|
||
|
|
};
|
||
|
|
|
||
|
|
protected override UserGroupAssertionModel TranslatorUserGroupAssertionModel => new()
|
||
|
|
{
|
||
|
|
ExpectedStatusCode = HttpStatusCode.OK
|
||
|
|
};
|
||
|
|
|
||
|
|
protected override UserGroupAssertionModel WriterUserGroupAssertionModel => new()
|
||
|
|
{
|
||
|
|
ExpectedStatusCode = HttpStatusCode.Forbidden
|
||
|
|
};
|
||
|
|
|
||
|
|
protected override UserGroupAssertionModel UnauthorizedUserGroupAssertionModel => new()
|
||
|
|
{
|
||
|
|
ExpectedStatusCode = HttpStatusCode.Unauthorized
|
||
|
|
};
|
||
|
|
|
||
|
|
protected override async Task<HttpResponseMessage> ClientRequest() => await Client.DeleteAsync(Url);
|
||
|
|
}
|