Merge branch 'fix/tests-ci': serial culture tests, screenshot diff, playback, installer and PostgreSQL CI
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
39 files changed
+1825
-218
No files matched your search
@@ -29,6 +29,11 @@ internal static class PgTestServer
|
||||
public static string Optional(string variable) =>
|
||||
Environment.GetEnvironmentVariable(variable) is { Length: > 0 } cs ? cs : throw new SkipException($"{variable} not set");
|
||||
|
||||
/// <summary>Set to 1 where the server was set up with TLS (CI): a server that refuses TLS then fails the TLS tests.</summary>
|
||||
public const string TlsVariable = "TITANO_TEST_PG_TLS";
|
||||
|
||||
public static bool TlsExpected => Environment.GetEnvironmentVariable(TlsVariable) is "1" or "true";
|
||||
|
||||
public static async Task<string> CreateSchemaAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var name = "titano_t_" + Guid.NewGuid().ToString("N")[..16];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Security.Authentication;
|
||||
using Titano.Data.Postgres;
|
||||
using Titano.Data.Tests.Infrastructure;
|
||||
@@ -6,7 +7,11 @@ using Titano.Testing;
|
||||
|
||||
namespace Titano.Data.Tests.Postgres;
|
||||
|
||||
/// <summary>Protocol-level tests against a live server (TITANO_TEST_PG; optional TITANO_TEST_PG_MD5/_CLEARTEXT/_TRUST).</summary>
|
||||
/// <summary>
|
||||
/// Protocol-level tests against a live server (TITANO_TEST_PG). Optional: TITANO_TEST_PG_MD5/_CLEARTEXT/_TRUST (roles
|
||||
/// of the other authentication methods), TITANO_TEST_PG_TLS=1 (the server offers TLS) and TITANO_TEST_PG_ROOT_CERT (the
|
||||
/// PEM its certificate chains to). CI sets them all up (.github/scripts/postgres-ci-setup.sh).
|
||||
/// </summary>
|
||||
[RequiresEnvironment(PgTestServer.Variable)]
|
||||
public sealed class PgWireTests(TestContext context) : DatabaseTest(context)
|
||||
{
|
||||
@@ -15,6 +20,14 @@ public sealed class PgWireTests(TestContext context) : DatabaseTest(context)
|
||||
private async Task<PostgresDatabase> OpenAsync(string? extra = null) =>
|
||||
(PostgresDatabase)Own(DatabaseFactory.Open(await NewOptionsAsync(extraPostgres: extra)));
|
||||
|
||||
/// <summary>A server without TLS skips the TLS tests, unless it was set up with TLS (<see cref="PgTestServer.TlsVariable"/>).</summary>
|
||||
[DoesNotReturn]
|
||||
private static void WithoutTls(DatabaseConnectionException refusal)
|
||||
{
|
||||
if (PgTestServer.TlsExpected) Assert.Fail($"{PgTestServer.TlsVariable} says the server offers TLS, but it refused: {refusal.Message}");
|
||||
TestContext.Skip("server has no TLS");
|
||||
}
|
||||
|
||||
private async Task<string> AuthenticateAsync(string connectionString)
|
||||
{
|
||||
var database = Own(new PostgresDatabase(PostgresSettings.Parse(connectionString)));
|
||||
@@ -61,7 +74,7 @@ public sealed class PgWireTests(TestContext context) : DatabaseTest(context)
|
||||
}
|
||||
catch (DatabaseConnectionException ex) when (ex.Message.Contains("does not support TLS", StringComparison.Ordinal))
|
||||
{
|
||||
TestContext.Skip("server has no TLS");
|
||||
WithoutTls(ex);
|
||||
return;
|
||||
}
|
||||
await using var session = await database.OpenAsync(Ct);
|
||||
@@ -83,13 +96,22 @@ public sealed class PgWireTests(TestContext context) : DatabaseTest(context)
|
||||
}
|
||||
catch (DatabaseConnectionException ex) when (ex.Message.Contains("does not support TLS", StringComparison.Ordinal))
|
||||
{
|
||||
TestContext.Skip("server has no TLS");
|
||||
WithoutTls(ex);
|
||||
}
|
||||
catch (AuthenticationException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task VerifyFullAcceptsACertificateThatChainsToTheConfiguredRoot()
|
||||
{
|
||||
var root = PgTestServer.Optional("TITANO_TEST_PG_ROOT_CERT");
|
||||
var database = await OpenAsync($"SslMode=VerifyFull;Root Certificate={root}");
|
||||
await using var session = await database.OpenAsync(Ct);
|
||||
Assert.True(await session.ScalarAsync<bool>("SELECT ssl FROM pg_stat_ssl WHERE pid = pg_backend_pid()", [], Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task DecodesEveryMappedResultType()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user