prep docs and service updates
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
This commit is contained in:
@@ -56,6 +56,10 @@ public class CallgraphIngestionTests : IClassFixture<SignalsTestFactory>
|
||||
Assert.False(string.IsNullOrWhiteSpace(body.CasUri));
|
||||
Assert.False(string.IsNullOrWhiteSpace(body.GraphHash));
|
||||
Assert.False(string.IsNullOrWhiteSpace(body.ManifestCasUri));
|
||||
Assert.False(string.IsNullOrWhiteSpace(body.SchemaVersion));
|
||||
Assert.True(body.NodeCount >= 0);
|
||||
Assert.True(body.EdgeCount >= 0);
|
||||
Assert.True(body.RootCount >= 0);
|
||||
Assert.Equal(body.GraphHash, doc.GraphHash);
|
||||
|
||||
var manifestResponse = await client.GetAsync($"/signals/callgraphs/{body.CallgraphId}/manifest");
|
||||
@@ -63,6 +67,7 @@ public class CallgraphIngestionTests : IClassFixture<SignalsTestFactory>
|
||||
var manifest = await manifestResponse.Content.ReadFromJsonAsync<CallgraphManifest>();
|
||||
Assert.NotNull(manifest);
|
||||
Assert.Equal(body.GraphHash, manifest!.GraphHash);
|
||||
Assert.Equal(body.SchemaVersion, manifest.SchemaVersion);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,112 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using StellaOps.Signals.Tests.TestInfrastructure;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Signals.Tests;
|
||||
|
||||
public class SignalsApiTests : IClassFixture<SignalsTestFactory>
|
||||
{
|
||||
private readonly SignalsTestFactory factory;
|
||||
|
||||
public SignalsApiTests(SignalsTestFactory factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Healthz_ReturnsOk()
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
var response = await client.GetAsync("/healthz");
|
||||
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Readyz_ReturnsOk()
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
var response = await client.GetAsync("/readyz");
|
||||
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
var payload = await response.Content.ReadFromJsonAsync<Dictionary<string, string>>();
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal("ready", payload!["status"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Ping_WithoutScopeHeader_ReturnsUnauthorized()
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
var response = await client.GetAsync("/signals/ping");
|
||||
|
||||
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Ping_WithMissingScope_ReturnsForbidden()
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
client.DefaultRequestHeaders.Add("X-Scopes", "signals:write");
|
||||
var response = await client.GetAsync("/signals/ping");
|
||||
|
||||
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Ping_WithReadScope_ReturnsNoContent()
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
client.DefaultRequestHeaders.Add("X-Scopes", "signals:read");
|
||||
var response = await client.GetAsync("/signals/ping");
|
||||
|
||||
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Ping_WithFallbackDisabled_ReturnsUnauthorized()
|
||||
{
|
||||
using var app = factory.WithWebHostBuilder(builder =>
|
||||
{
|
||||
builder.ConfigureAppConfiguration((_, configuration) =>
|
||||
{
|
||||
configuration.AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["Signals:Authority:AllowAnonymousFallback"] = "false"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
using var client = app.CreateClient();
|
||||
var response = await client.GetAsync("/signals/ping");
|
||||
|
||||
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Status_WithReadScope_ReturnsOk()
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
client.DefaultRequestHeaders.Add("X-Scopes", "signals:read");
|
||||
var response = await client.GetAsync("/signals/status");
|
||||
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
var payload = await response.Content.ReadFromJsonAsync<Dictionary<string, string>>();
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal("signals", payload!["service"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Status_WithMissingScope_ReturnsForbidden()
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
client.DefaultRequestHeaders.Add("X-Scopes", "signals:write");
|
||||
var response = await client.GetAsync("/signals/status");
|
||||
|
||||
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
||||
}
|
||||
}
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using StellaOps.Signals.Models;
|
||||
using StellaOps.Signals.Tests.TestInfrastructure;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Signals.Tests;
|
||||
|
||||
public class SignalsApiTests : IClassFixture<SignalsTestFactory>
|
||||
{
|
||||
private readonly SignalsTestFactory factory;
|
||||
|
||||
public SignalsApiTests(SignalsTestFactory factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Callgraph_Ingest_Response_Includes_Extended_Fields()
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
client.DefaultRequestHeaders.Add("X-Scopes", "signals:write signals:read");
|
||||
|
||||
var req = CallgraphIngestionTests.CreateRequest("java", component: "api-test", version: "1.2.3");
|
||||
var res = await client.PostAsJsonAsync("/signals/callgraphs", req);
|
||||
|
||||
Assert.Equal(HttpStatusCode.Accepted, res.StatusCode);
|
||||
var body = await res.Content.ReadFromJsonAsync<CallgraphIngestResponse>();
|
||||
Assert.NotNull(body);
|
||||
Assert.False(string.IsNullOrWhiteSpace(body!.SchemaVersion));
|
||||
Assert.True(body.NodeCount >= 0);
|
||||
Assert.True(body.EdgeCount >= 0);
|
||||
Assert.True(body.RootCount >= 0);
|
||||
|
||||
// Fetch manifest and ensure schemaVersion matches response
|
||||
var manifestRes = await client.GetAsync($"/signals/callgraphs/{body.CallgraphId}/manifest");
|
||||
Assert.Equal(HttpStatusCode.OK, manifestRes.StatusCode);
|
||||
var manifest = await manifestRes.Content.ReadFromJsonAsync<CallgraphManifest>(new JsonSerializerOptions(JsonSerializerDefaults.Web));
|
||||
Assert.NotNull(manifest);
|
||||
Assert.Equal(body.SchemaVersion, manifest!.SchemaVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,23 @@
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0-rc.2.25502.107" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
|
||||
<PackageReference Include="Mongo2Go" Version="4.1.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0-rc.2.25502.107" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
|
||||
<PackageReference Include="Mongo2Go" Version="4.1.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../Signals/StellaOps.Signals/StellaOps.Signals.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user