Files
Chronos/tests/Chronos.App.Tests/Windows/DiagnosticsBundleTests.cs
T
Alby96andClaude Opus 5.5 5f27a86406
CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
refactor!: rename Titano to Chronos and move CI and releases to Gitea
The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout. The release cross-compiles the Windows programs, checks their
  icon, version and DPI manifest, packs installers and zips, publishes the
  Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only
  tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow) and
  pe-check.

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 11:34:48 +02:00

98 lines
4.5 KiB
C#

using System.IO;
using System.IO.Compression;
using Chronos.App.Infrastructure;
using Chronos.App.Settings;
using Chronos.Core.Video;
using Chronos.Testing;
namespace Chronos.App.Tests.Windows;
/// <summary>The desktop diagnostics bundle: every entry present, the saved server token and passwords never inside.</summary>
[WindowsOnly]
public sealed class DiagnosticsBundleTests(TestContext context)
{
private const string Token = "AQAAANCMnd8BFdERjHoAwE-saved-token";
[Test]
public async Task TheBundleCarriesReportsAndLogsButNoSecrets()
{
var environment = AppEnvironment.ForCapture();
try
{
var settings = new AppSettings { Language = "en", ServerUrl = "https://nas.local:8443", ServerUsername = "alice", ProtectedToken = Token };
var services = new AppServices(environment, settings, () => { }, new NoDialogs()) { Encoders = new OneEncoder() };
await File.WriteAllTextAsync(Path.Combine(environment.LogDirectory, "chronos-20261002.log"), $"signed in with password={Token}\n");
var path = await DiagnosticsBundle.CreateAsync(services, context.CreateTempDirectory(), ["Self-test H.264 Test: passed"]);
using var zip = ZipFile.OpenRead(path);
var texts = zip.Entries.ToDictionary(e => e.FullName, e =>
{
using var reader = new StreamReader(e.Open());
return reader.ReadToEnd();
});
Assert.SequenceEqual(new[] { "codecs.txt", "environment.txt", "jobs-failed.json", "logs/chronos-20261002.log", "settings.json" },
texts.Keys.Order(StringComparer.Ordinal));
foreach (var (name, text) in texts) Assert.False(text.Contains(Token, StringComparison.Ordinal), $"{name} leaks the token");
Assert.Contains("Self-test H.264 Test: passed", texts["environment.txt"]);
Assert.Contains("Test encoder", texts["codecs.txt"]);
Assert.Contains("\"ServerUsername\": \"alice\"", texts["settings.json"]);
Assert.Contains("\"ProtectedToken\": \"[removed]\"", texts["settings.json"]);
}
finally
{
environment.DeleteCaptureData();
}
}
[Test]
public async Task BundlesNeverOverwriteEachOtherAndAFailedOneLeavesNothing()
{
var environment = AppEnvironment.ForCapture();
try
{
var services = new AppServices(environment, new AppSettings { Language = "en" }, () => { }, new NoDialogs()) { Encoders = new OneEncoder() };
await File.WriteAllTextAsync(Path.Combine(environment.LogDirectory, "chronos-20261002.log"), "started\n");
var folder = context.CreateTempDirectory();
var first = await DiagnosticsBundle.CreateAsync(services, folder);
var second = await DiagnosticsBundle.CreateAsync(services, folder);
Assert.NotEqual(first, second);
Assert.SequenceEqual(new[] { first, second }.Order(StringComparer.Ordinal), Directory.GetFiles(folder).Order(StringComparer.Ordinal));
// The encoder inventory runs after the job query and before the zip is written: cancelling there fails the
// bundle half-way, once its temporary file exists.
using var cts = new CancellationTokenSource();
services.Encoders = new OneEncoder(cts.Cancel);
var empty = context.CreateTempDirectory();
await Assert.ThrowsAsync<OperationCanceledException>(() => DiagnosticsBundle.CreateAsync(services, empty, ct: cts.Token));
Assert.Empty(Directory.GetFiles(empty));
}
finally
{
environment.DeleteCaptureData();
}
}
private sealed class OneEncoder(Action? onDetect = null) : IEncoderInventory
{
public string? Adapter() => "Test adapter";
public IReadOnlyList<EncoderRow> Detect()
{
onDetect?.Invoke();
return [new EncoderRow("H.264", "Test encoder", null, EncoderSource.MediaFoundation, true, false, 4096, 2304, VideoCodec.H264)];
}
public Task<SelfTestResult> SelfTestAsync(EncoderRow row, CancellationToken ct) => Task.FromResult(new SelfTestResult(true, 100, null));
}
private sealed class NoDialogs : IAppDialogs
{
public string? PickFolder(string title, string? initialFolder = null) => null;
public string? PickJsonFile(string title) => null;
public bool Confirm(ConfirmRequest request) => false;
public bool SignIn(string server, string? username, Func<string, string, Task<string?>> signIn) => false;
}
}