audit notes work completed, test fixes work (95% done), new sprints, new data sources setup and configuration

This commit is contained in:
master
2026-01-14 10:48:00 +02:00
parent d7be6ba34b
commit 95d5898650
379 changed files with 40695 additions and 19041 deletions

View File

@@ -0,0 +1,18 @@
# Integrations Plugin Tests - AGENTS.md
## Module Overview
Test project for Integration connector plugins including InMemory and Harbor connectors.
## Test Coverage
- `InMemoryConnectorPluginTests` - Tests for the InMemory connector plugin (test/dev purposes)
- Additional tests for Harbor connector plugin to be added
## Working Agreements
1. Use deterministic TimeProvider injection for time-dependent tests
2. Mock HTTP connections for external service tests
3. Verify cancellation token propagation
## Running Tests
```bash
dotnet test src/Integrations/__Tests/StellaOps.Integrations.Plugin.Tests/StellaOps.Integrations.Plugin.Tests.csproj
```

View File

@@ -0,0 +1,136 @@
using StellaOps.Integrations.Core;
using StellaOps.Integrations.Plugin.InMemory;
using Xunit;
namespace StellaOps.Integrations.Plugin.Tests;
/// <summary>
/// Tests for InMemoryConnectorPlugin.
/// </summary>
public sealed class InMemoryConnectorPluginTests
{
private static readonly DateTimeOffset FixedTime = new(2026, 1, 13, 10, 0, 0, TimeSpan.Zero);
[Fact]
public void Name_ReturnsInMemory()
{
var plugin = new InMemoryConnectorPlugin();
Assert.Equal("inmemory", plugin.Name);
}
[Fact]
public void Type_ReturnsRegistry()
{
var plugin = new InMemoryConnectorPlugin();
Assert.Equal(IntegrationType.Registry, plugin.Type);
}
[Fact]
public void Provider_ReturnsInMemory()
{
var plugin = new InMemoryConnectorPlugin();
Assert.Equal(IntegrationProvider.InMemory, plugin.Provider);
}
[Fact]
public void IsAvailable_ReturnsTrue()
{
var plugin = new InMemoryConnectorPlugin();
Assert.True(plugin.IsAvailable(null!));
}
[Fact]
public async Task TestConnectionAsync_ReturnsSuccess()
{
var fakeTime = new FixedTimeProvider(FixedTime);
var plugin = new InMemoryConnectorPlugin(fakeTime);
var config = CreateTestConfig();
var result = await plugin.TestConnectionAsync(config);
Assert.True(result.Success);
Assert.Contains("successful", result.Message, StringComparison.OrdinalIgnoreCase);
Assert.NotNull(result.Details);
Assert.Equal("true", result.Details["simulated"]);
}
[Fact]
public async Task TestConnectionAsync_IncludesEndpointInDetails()
{
var fakeTime = new FixedTimeProvider(FixedTime);
var plugin = new InMemoryConnectorPlugin(fakeTime);
var config = CreateTestConfig("https://test.example.com");
var result = await plugin.TestConnectionAsync(config);
Assert.NotNull(result.Details);
Assert.Equal("https://test.example.com", result.Details["endpoint"]);
}
[Fact]
public async Task CheckHealthAsync_ReturnsHealthy()
{
var fakeTime = new FixedTimeProvider(FixedTime);
var plugin = new InMemoryConnectorPlugin(fakeTime);
var config = CreateTestConfig();
var result = await plugin.CheckHealthAsync(config);
Assert.Equal(HealthStatus.Healthy, result.Status);
Assert.Contains("healthy", result.Message, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public async Task CheckHealthAsync_UsesInjectedTimeProvider()
{
var fakeTime = new FixedTimeProvider(FixedTime);
var plugin = new InMemoryConnectorPlugin(fakeTime);
var config = CreateTestConfig();
var result = await plugin.CheckHealthAsync(config);
// CheckedAt should be based on the fake time (plus ~50ms simulated delay)
Assert.True(result.CheckedAt >= FixedTime);
}
[Fact]
public async Task TestConnectionAsync_RespectsCanellation()
{
var plugin = new InMemoryConnectorPlugin();
var config = CreateTestConfig();
using var cts = new CancellationTokenSource();
cts.Cancel();
await Assert.ThrowsAsync<TaskCanceledException>(
() => plugin.TestConnectionAsync(config, cts.Token));
}
private static IntegrationConfig CreateTestConfig(string endpoint = "https://example.com")
{
return new IntegrationConfig(
IntegrationId: Guid.NewGuid(),
Type: IntegrationType.Registry,
Provider: IntegrationProvider.InMemory,
Endpoint: endpoint,
ResolvedSecret: null,
OrganizationId: null,
ExtendedConfig: null);
}
/// <summary>
/// Simple fixed-time provider for deterministic tests.
/// </summary>
private sealed class FixedTimeProvider : TimeProvider
{
private readonly DateTimeOffset _fixedTime;
public FixedTimeProvider(DateTimeOffset fixedTime) => _fixedTime = fixedTime;
public override DateTimeOffset GetUtcNow() => _fixedTime;
}
}

View File

@@ -0,0 +1,32 @@
<?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>
<OutputType>Exe</OutputType>
<UseXunitV3>true</UseXunitV3>
</PropertyGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Moq" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\__Plugins\StellaOps.Integrations.Plugin.InMemory\StellaOps.Integrations.Plugin.InMemory.csproj" />
<ProjectReference Include="..\..\__Plugins\StellaOps.Integrations.Plugin.Harbor\StellaOps.Integrations.Plugin.Harbor.csproj" />
<ProjectReference Include="..\..\__Libraries\StellaOps.Integrations.Persistence\StellaOps.Integrations.Persistence.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,7 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"diagnosticMessages": true,
"parallelizeAssembly": true,
"parallelizeTestCollections": true,
"maxParallelThreads": -1
}