Files
Heimdall/tests/Heimdall.IntegrationTests/Controllers/SitesControllerTests.cs
T
arnaud.dartois 636154572b
Heimdall Gitea / Detect CI scope (push) Successful in 6s
Heimdall Gitea / Build and tests (push) Successful in 19m19s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan server image (push) Successful in 6m13s
Heimdall Gitea / Build and scan agent image (push) Successful in 14m44s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 1m48s
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Successful in 19m9s
Heimdall Gitea / CI policy (push) Successful in 10s
Complete remaining Heimdall features and acceptance
Merge pull request #138

Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2026-11-06 11:14:49 +01:00

49 lines
1.8 KiB
C#

using System.Net.Http.Json;
using Heimdall.IntegrationTests.Factories;
using Shouldly;
namespace Heimdall.IntegrationTests.Controllers;
public class SitesControllerTests : PostgresTestBase
{
public SitesControllerTests(PostgreSqlContainerFixture postgres) : base(postgres) { }
[Fact]
public async Task GetSites_WithoutAuth_ReturnsUnauthorized()
{
var client = Factory.CreateClient();
var response = await client.GetAsync("api/sites?page=1&pageSize=10");
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.Unauthorized);
}
[Fact]
public async Task CreateSite_WithAuth_ReturnsOk()
{
var client = await Factory.CreateAdminClientAsync();
var response = await client.PostAsJsonAsync("api/sites", new
{
name = "Site Test",
address = "Paris",
timezone = "Europe/Paris",
ntfyTopic = "site-test-topic"
});
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
var created = await response.Content.ReadFromJsonAsync<Heimdall.Application.DTOs.SiteWithTokenResponse>();
created.ShouldNotBeNull();
var siteResponse = await client.GetAsync($"api/sites/{created.Id}");
siteResponse.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
var site = await siteResponse.Content.ReadFromJsonAsync<Heimdall.Application.DTOs.SiteResponse>();
site.ShouldNotBeNull();
site.NtfyTopic.ShouldBe("site-test-topic");
}
[Fact]
public async Task ListSites_WithAuth_ReturnsOk()
{
var client = await Factory.CreateAdminClientAsync();
var response = await client.GetAsync("api/sites?page=1&pageSize=10");
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
}
}