Added mailboxes as local data sources (#1022)
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-10-04 12:26:26 +02:00
1 parent 93be539e50
commit c4400c0ff6
343 files changed
+26051 -3122

No files matched your search

@@ -0,0 +1,99 @@
using AIStudio.Tools.Validation;
using MudBlazor.Interfaces;
namespace AIStudio.Tests.Tools.Validation;
/// <summary>
/// Checks which fields get a fresh verdict when a field they are checked against changes.
/// </summary>
/// <remarks>
/// The data source dialogs check the required confidence level against the embedding provider and
/// the other way around. A form only checks the field which changed, so an error on the other one
/// used to stay on screen after it no longer held.
/// </remarks>
[TestFixture]
public sealed class DependentFieldValidationTests
{
[Test]
public async Task AFieldShowingAnErrorIsValidatedAnew()
{
var changedField = new FakeFormComponent { Touched = true };
var dependentField = new FakeFormComponent { Error = true };
await DependentFieldValidation.RevalidateAsync(changedField, changedField, dependentField);
Assert.That(dependentField.ValidationCount, Is.EqualTo(1), "The stale error is not checked again.");
}
[Test]
public async Task ATouchedFieldIsValidatedAnew()
{
var dependentField = new FakeFormComponent { Touched = true };
await DependentFieldValidation.RevalidateAsync(new FakeFormComponent(), dependentField);
Assert.That(dependentField.ValidationCount, Is.EqualTo(1), "A field the user has filled in keeps its old verdict.");
}
[Test]
public async Task AFieldTheUserHasNotReachedIsLeftAlone()
{
var dependentField = new FakeFormComponent();
await DependentFieldValidation.RevalidateAsync(new FakeFormComponent(), dependentField);
Assert.That(dependentField.ValidationCount, Is.Zero, "A field nobody has filled in yet shows an error.");
}
[Test]
public async Task TheChangedFieldIsLeftToTheForm()
{
var changedField = new FakeFormComponent { Touched = true, Error = true };
await DependentFieldValidation.RevalidateAsync(changedField, changedField);
Assert.That(changedField.ValidationCount, Is.Zero, "The changed field is validated twice.");
}
[Test]
public async Task AChangeOutsideTheFieldsValidatesEveryReachedField()
{
var touchedField = new FakeFormComponent { Touched = true };
var untouchedField = new FakeFormComponent();
await DependentFieldValidation.RevalidateAsync(null, touchedField, untouchedField, null);
Assert.Multiple(() =>
{
Assert.That(touchedField.ValidationCount, Is.EqualTo(1), "The touched field is not checked again.");
Assert.That(untouchedField.ValidationCount, Is.Zero, "The untouched field is checked.");
});
}
private sealed class FakeFormComponent : IFormComponent
{
public int ValidationCount { get; private set; }
public bool Required { get; set; }
public bool Error { get; set; }
public bool HasErrors => this.Error;
public bool Touched { get; init; }
public object? Validation { get; set; }
public bool IsForNull => true;
public List<string> ValidationErrors { get; set; } = [];
public Task Validate()
{
this.ValidationCount++;
return Task.CompletedTask;
}
public Task ResetAsync() => Task.CompletedTask;
public void ResetValidation()
{
}
}
}
@@ -0,0 +1,61 @@
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.Validation;
namespace AIStudio.Tests.Tools.Validation;
/// <summary>
/// Checks what the mailbox dialog accepts before it lets the user test a connection or save.
/// </summary>
[TestFixture]
public sealed class MailboxValidationTests
{
private static readonly DataSourceValidation VALIDATION = new();
[TestCase("imap.example.org", ExpectedResult = true)]
[TestCase(" imap.example.org ", ExpectedResult = true)]
[TestCase("posteo.de", ExpectedResult = true)]
[TestCase("192.168.1.20", ExpectedResult = true)]
[TestCase("::1", ExpectedResult = true)]
[TestCase("", ExpectedResult = false)]
[TestCase(" ", ExpectedResult = false)]
[TestCase("imaps://imap.example.org", ExpectedResult = false)]
[TestCase("imap.example.org:993", ExpectedResult = false)]
[TestCase("imap.example.org/INBOX", ExpectedResult = false)]
public bool TheHostStandsAlone(string host) => DataSourceValidation.ValidateMailboxHost(host) is null;
[Test]
public void AnUnknownEncryptionIsRejectedAndNeverOffered()
{
Assert.Multiple(() =>
{
Assert.That(DataSourceValidation.ValidateMailboxTransportSecurity(MailboxTransportSecurity.UNKNOWN), Is.Not.Null);
Assert.That(ConfigurationSelectDataFactory.GetMailboxTransportSecurityData().Select(option => option.Value), Is.EqualTo(new[] { MailboxTransportSecurity.SSL_ON_CONNECT, MailboxTransportSecurity.STARTTLS }));
});
}
[TestCase(MailboxTransportSecurity.SSL_ON_CONNECT, ExpectedResult = 993)]
[TestCase(MailboxTransportSecurity.STARTTLS, ExpectedResult = 143)]
[TestCase(MailboxTransportSecurity.UNKNOWN, ExpectedResult = null)]
public int? EachEncryptionComesWithItsUsualPort(MailboxTransportSecurity transportSecurity) => transportSecurity.GetUsualPort();
[TestCase(0, ExpectedResult = false)]
[TestCase(DataSourceValidation.MIN_ATTACHMENT_SIZE_MEGABYTES, ExpectedResult = true)]
[TestCase(DataSourceValidation.MAX_ATTACHMENT_SIZE_MEGABYTES, ExpectedResult = true)]
[TestCase(DataSourceValidation.MAX_ATTACHMENT_SIZE_MEGABYTES + 1, ExpectedResult = false)]
public bool TheAttachmentSizeStaysInItsRange(int megabytes) => DataSourceValidation.ValidateMailboxMaxAttachmentSize(megabytes) is null;
[Test]
public void APasswordIsRequiredAndAStorageIssueComesFirst()
{
const string STORAGE_ISSUE = "The keyring is locked.";
var validationWithIssue = new DataSourceValidation { GetSecretStorageIssue = () => STORAGE_ISSUE };
Assert.Multiple(() =>
{
Assert.That(VALIDATION.ValidateMailboxPassword(string.Empty), Is.Not.Null, "An empty password was accepted.");
Assert.That(VALIDATION.ValidateMailboxPassword(" secret with spaces "), Is.Null, "A password was trimmed or rejected for its spaces.");
Assert.That(validationWithIssue.ValidateMailboxPassword("secret"), Is.EqualTo(STORAGE_ISSUE), "The issue of the keyring was not shown.");
});
}
}