43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using System.Net.Http.Json;
|
|
using Heimdall.IntegrationTests.Factories;
|
|
using Shouldly;
|
|
|
|
namespace Heimdall.IntegrationTests.Controllers;
|
|
|
|
public class StatsControllerTests : PostgresTestBase
|
|
{
|
|
public StatsControllerTests(PostgreSqlContainerFixture postgres) : base(postgres) { }
|
|
|
|
[Fact]
|
|
public async Task GetStats_WithoutAuth_ReturnsUnauthorized()
|
|
{
|
|
var client = Factory.CreateClient();
|
|
var response = await client.GetAsync("api/stats");
|
|
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.Unauthorized);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetStats_WithAdminAuth_ReturnsOk()
|
|
{
|
|
var client = await Factory.CreateAdminClientAsync();
|
|
var response = await client.GetAsync("api/stats");
|
|
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetAgentStats_WithoutAuth_ReturnsUnauthorized()
|
|
{
|
|
var client = Factory.CreateClient();
|
|
var response = await client.GetAsync("api/stats/agent-stats");
|
|
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.Unauthorized);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetAgentStats_WithAdminAuth_ReturnsOk()
|
|
{
|
|
var client = await Factory.CreateAdminClientAsync();
|
|
var response = await client.GetAsync("api/stats/agent-stats");
|
|
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
|
|
}
|
|
}
|