test(server): auth, uploads, ranges, sync, jobs, render nodes, events
Covers bootstrap admin, sign-in failure, lockout and rate limit, token revocation and expiry, 401 versus 403, CSRF on cookie sessions, the error shape and API header, chunked upload happy path, resume, hash short-circuit, damaged chunk, quota, Range on originals, thumbnails and exports, path traversal, settings_version conflicts, job state transitions with a fake handler, render node claim, heartbeat timeout and reassignment, output upload, WebSocket progress events, the discovery beacon, the Windows service command line and status rules, and a PostgreSQL run (TITANO_TEST_PG). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
16 files changed
+1646
No files matched your search
@@ -0,0 +1,67 @@
|
||||
using Titano.Data;
|
||||
using Titano.Server.Configuration;
|
||||
using Titano.Server.Hosting;
|
||||
using Titano.Testing;
|
||||
|
||||
namespace Titano.Server.Tests.Hosting;
|
||||
|
||||
[Category("server")]
|
||||
public sealed class StartupTests(TestContext context)
|
||||
{
|
||||
[Test]
|
||||
public void TheServerRefusesToStartWithoutTheArchiveModule()
|
||||
{
|
||||
var root = context.CreateTempDirectory("bare");
|
||||
var options = new ServerOptions
|
||||
{
|
||||
DataPath = Path.Combine(root, "data"),
|
||||
ArchivePath = Path.Combine(root, "archive"),
|
||||
HttpPort = 0,
|
||||
HttpsPort = 0,
|
||||
Database = DatabaseKind.Sqlite,
|
||||
Discovery = false,
|
||||
};
|
||||
var error = Assert.Throws<InvalidOperationException>(() => ServerHost.Build(options, []));
|
||||
Assert.Contains("IArchiveIngest", error.Message);
|
||||
Assert.Contains("IFrameAssetLocator", error.Message);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TitanoDbAcceptsAConnectionString()
|
||||
{
|
||||
var root = context.CreateTempDirectory("env");
|
||||
var options = ServerOptions.Load(new Dictionary<string, string?>
|
||||
{
|
||||
["TITANO_DATA_PATH"] = root,
|
||||
["TITANO_DB"] = "Host=db.lan;Port=6543;Database=archive;Username=titano;Password=secret",
|
||||
});
|
||||
Assert.Equal(DatabaseKind.Postgres, options.Database);
|
||||
var database = options.ToDatabaseOptions();
|
||||
Assert.Equal(Dialect.Postgres, database.Dialect);
|
||||
Assert.Equal(6543, Titano.Data.Postgres.PostgresSettings.Parse(database.ConnectionString).Port);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartsBuildAQuotedPostgresConnectionString()
|
||||
{
|
||||
var options = new ServerOptions { DbHost = "postgres", DbName = "titano", DbUser = "titano", DbPassword = "it's;secret", DbSslMode = "disable" };
|
||||
var settings = Titano.Data.Postgres.PostgresSettings.Parse(options.ToDatabaseOptions().ConnectionString);
|
||||
Assert.Equal(("postgres", "titano", "it's;secret"), (settings.Host, settings.Database, settings.Password));
|
||||
Assert.Equal(Titano.Data.Postgres.SslMode.Disable, settings.SslMode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnvironmentVariablesLockTheirSettings()
|
||||
{
|
||||
var root = context.CreateTempDirectory("locked");
|
||||
var options = ServerOptions.Load(new Dictionary<string, string?>
|
||||
{
|
||||
["TITANO_DATA_PATH"] = root,
|
||||
["TITANO_DB"] = "postgres",
|
||||
["TITANO_HTTP_PORT"] = "9090",
|
||||
["TITANO_DISCOVERY"] = "false",
|
||||
});
|
||||
Assert.SequenceEqual(["Database", "HttpPort", "Discovery"], options.Locked);
|
||||
Assert.Throws<InvalidOperationException>(() => ServerOptions.Load(new Dictionary<string, string?> { ["TITANO_DATA_PATH"] = root, ["TITANO_DB"] = "postgres", ["TITANO_WORKERS"] = "many" }));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user