38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using System.Net.Http.Json;
|
|||
|
|
using System.Text.Json;
|
||
|
|
using Heimdall.IntegrationTests.Factories;
|
||
|
|
using Shouldly;
|
||
|
|
|
||
|
|
namespace Heimdall.IntegrationTests.Controllers;
|
||
|
|
|
||
|
|
public class AuditLogsControllerTests : PostgresTestBase
|
||
|
|
{
|
||
|
|
public AuditLogsControllerTests(PostgreSqlContainerFixture postgres) : base(postgres) { }
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public async Task List_WithoutAuth_ReturnsUnauthorized()
|
||
|
|
{
|
||
|
|
var client = Factory.CreateClient();
|
||
|
|
var response = await client.GetAsync("api/audit-logs?page=1&pageSize=20");
|
||
|
|
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.Unauthorized);
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public async Task List_WithAdminAuth_ReturnsOk()
|
||
|
|
{
|
||
|
|
var client = await Factory.CreateAdminClientAsync();
|
||
|
|
var response = await client.GetAsync("api/audit-logs?page=1&pageSize=20");
|
||
|
|
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
|
||
|
|
|
||
|
|
var content = await response.Content.ReadFromJsonAsync<JsonElement>();
|
||
|
|
content.GetProperty("items").GetArrayLength().ShouldBeGreaterThanOrEqualTo(0);
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public async Task List_WithFilters_ReturnsOk()
|
||
|
|
{
|
||
|
|
var client = await Factory.CreateAdminClientAsync();
|
||
|
|
var response = await client.GetAsync("api/audit-logs?resourceType=Site&action=Create&page=1&pageSize=20");
|
||
|
|
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
|
||
|
|
}
|
||
|
|
}
|