work
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled

This commit is contained in:
StellaOps Bot
2025-11-25 08:01:23 +02:00
parent d92973d6fd
commit 6bee1fdcf5
207 changed files with 12816 additions and 2295 deletions

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8"/>
<PackageReference Include="xunit" Version="2.9.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\\..\\src\\VulnExplorer\\StellaOps.VulnExplorer.Api\\StellaOps.VulnExplorer.Api.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,54 @@
using System.Net;
using System.Net.Http.Json;
using Microsoft.AspNetCore.Mvc.Testing;
using StellaOps.VulnExplorer.Api.Models;
namespace StellaOps.VulnExplorer.Api.Tests;
public class VulnApiTests : IClassFixture<WebApplicationFactory<Program>>
{
private readonly WebApplicationFactory<Program> factory;
public VulnApiTests(WebApplicationFactory<Program> factory)
{
this.factory = factory.WithWebHostBuilder(_ => { });
}
[Fact]
public async Task List_ReturnsDeterministicOrder()
{
var client = factory.CreateClient();
client.DefaultRequestHeaders.Add("x-stella-tenant", "tenant-a");
var response = await client.GetAsync("/v1/vulns");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var payload = await response.Content.ReadFromJsonAsync<VulnListResponse>();
Assert.NotNull(payload);
Assert.Equal(new[] { "vuln-0001", "vuln-0002" }, payload!.Items.Select(v => v.Id));
}
[Fact]
public async Task List_FiltersByCve()
{
var client = factory.CreateClient();
client.DefaultRequestHeaders.Add("x-stella-tenant", "tenant-a");
var response = await client.GetAsync("/v1/vulns?cve=CVE-2024-2222");
response.EnsureSuccessStatusCode();
var payload = await response.Content.ReadFromJsonAsync<VulnListResponse>();
Assert.Single(payload!.Items);
Assert.Equal("vuln-0002", payload.Items[0].Id);
}
[Fact]
public async Task Detail_ReturnsNotFoundWhenMissing()
{
var client = factory.CreateClient();
client.DefaultRequestHeaders.Add("x-stella-tenant", "tenant-a");
var response = await client.GetAsync("/v1/vulns/missing");
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
}