work work ... haaaard work
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using StellaOps.SbomService.Models;
|
||||
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public class EntrypointEndpointsTests : IClassFixture<SbomServiceWebApplicationFactory>
|
||||
{
|
||||
private readonly SbomServiceWebApplicationFactory _factory;
|
||||
|
||||
public EntrypointEndpointsTests(SbomServiceWebApplicationFactory factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_entrypoints_requires_tenant()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
var response = await client.GetAsync("/entrypoints");
|
||||
response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_entrypoints_returns_seeded_list()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
var response = await client.GetAsync("/entrypoints?tenant=tenant-a");
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var payload = await response.Content.ReadFromJsonAsync<EntrypointListResponse>();
|
||||
payload.Should().NotBeNull();
|
||||
payload!.Tenant.Should().Be("tenant-a");
|
||||
payload.Items.Should().NotBeEmpty();
|
||||
payload.Items.Select(e => e.Artifact).Should().Contain("ghcr.io/stellaops/sample-api");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Post_entrypoints_upserts_and_returns_ordered_list()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
var upsert = new EntrypointUpsertRequest(
|
||||
Tenant: "tenant-a",
|
||||
Artifact: "ghcr.io/stellaops/sample-api",
|
||||
Service: "web",
|
||||
Path: "/api/v2",
|
||||
Scope: "runtime",
|
||||
RuntimeFlag: true);
|
||||
|
||||
var post = await client.PostAsJsonAsync("/entrypoints", upsert);
|
||||
post.EnsureSuccessStatusCode();
|
||||
|
||||
var payload = await post.Content.ReadFromJsonAsync<EntrypointListResponse>();
|
||||
payload.Should().NotBeNull();
|
||||
payload!.Items.First(e => e.Service == "web").Path.Should().Be("/api/v2");
|
||||
payload.Items.Should().BeInAscendingOrder(e => e.Artifact);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user