52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
|
|
using System.Linq.Expressions;
|
||
|
|
using System.Net;
|
||
|
|
using System.Net.Http.Json;
|
||
|
|
using Umbraco.Cms.Api.Management.Controllers.Telemetry;
|
||
|
|
using Umbraco.Cms.Api.Management.ViewModels.Telemetry;
|
||
|
|
using Umbraco.Cms.Core.Models;
|
||
|
|
|
||
|
|
namespace Umbraco.Cms.Tests.Integration.ManagementApi.Telemetry;
|
||
|
|
|
||
|
|
public class SetTelemetryControllerTests : ManagementApiUserGroupTestBase<SetTelemetryController>
|
||
|
|
{
|
||
|
|
protected override Expression<Func<SetTelemetryController, object>> MethodSelector =>
|
||
|
|
x => x.SetConsentLevel(CancellationToken.None, null);
|
||
|
|
|
||
|
|
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.Forbidden
|
||
|
|
};
|
||
|
|
|
||
|
|
protected override UserGroupAssertionModel WriterUserGroupAssertionModel => new()
|
||
|
|
{
|
||
|
|
ExpectedStatusCode = HttpStatusCode.Forbidden
|
||
|
|
};
|
||
|
|
|
||
|
|
protected override UserGroupAssertionModel UnauthorizedUserGroupAssertionModel => new()
|
||
|
|
{
|
||
|
|
ExpectedStatusCode = HttpStatusCode.Unauthorized
|
||
|
|
};
|
||
|
|
|
||
|
|
protected override async Task<HttpResponseMessage> ClientRequest()
|
||
|
|
{
|
||
|
|
TelemetryRequestModel telemetryRequestModel = new() { TelemetryLevel = TelemetryLevel.Minimal };
|
||
|
|
|
||
|
|
return await Client.PostAsync(Url, JsonContent.Create(telemetryRequestModel));
|
||
|
|
}
|
||
|
|
}
|