mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-25 06:53:49 +00:00
Fixed signing in to mailboxes with characters beyond ASCII in the username or password (#1224)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
f6a4348820
commit
c72a1948b3
27 files changed
+1052
-30
No files matched your search
@@ -3,6 +3,7 @@ using System.Text.Json;
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.Mail;
|
||||
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
@@ -40,6 +41,7 @@ public sealed class MailboxSettingsTests
|
||||
Port = 143,
|
||||
TransportSecurity = MailboxTransportSecurity.STARTTLS,
|
||||
AuthMethod = MailboxAuthMethod.PASSWORD,
|
||||
PasswordEncoding = MailboxPasswordEncoding.FromName("windows-1252"),
|
||||
Username = "someone@example.org",
|
||||
RootFolder = "INBOX/Projects",
|
||||
IncludeSentAndDrafts = false,
|
||||
@@ -137,6 +139,45 @@ public sealed class MailboxSettingsTests
|
||||
Assert.That(mailbox.IncludeSentAndDrafts, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AMailboxStoredBeforeThePasswordEncodingSignsInWithUtf8()
|
||||
{
|
||||
// UTF-8 is what every sign-in used until then:
|
||||
var mailbox = JsonSerializer.Deserialize<DataSourceMailbox>("""{"RootFolder": "INBOX"}""", SettingsManager.JSON_OPTIONS);
|
||||
Assert.That(mailbox.PasswordEncoding, Is.EqualTo(MailboxPasswordEncoding.DEFAULT));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AnEncodingThisVersionDoesNotKnowIsKeptButSignsInNowhere()
|
||||
{
|
||||
// The name stays, so that it is stored as it was; ImapMailboxConnectorTests checks that nothing is sent:
|
||||
var mailbox = JsonSerializer.Deserialize<DataSourceMailbox>("""{"PasswordEncoding": "x-encoding-of-the-future"}""", SettingsManager.JSON_OPTIONS);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(mailbox.PasswordEncoding.Name, Is.EqualTo("x-encoding-of-the-future"));
|
||||
Assert.That(mailbox.PasswordEncoding.IsKnown, Is.False);
|
||||
Assert.That(JsonSerializer.Serialize(mailbox, SettingsManager.JSON_OPTIONS), Does.Contain("\"PasswordEncoding\": \"x-encoding-of-the-future\""));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AnEncodingWhichIsNoNameSignsInNowhereButKeepsTheOtherSettings()
|
||||
{
|
||||
var mailbox = JsonSerializer.Deserialize<DataSourceMailbox>("""{"PasswordEncoding": {"CodePage": 1252}, "RootFolder": "INBOX"}""", SettingsManager.JSON_OPTIONS);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(mailbox.PasswordEncoding.IsKnown, Is.False);
|
||||
Assert.That(mailbox.RootFolder, Is.EqualTo("INBOX"));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AKnownEncodingIsStoredByTheNameDotNetGivesIt()
|
||||
{
|
||||
var mailbox = JsonSerializer.Deserialize<DataSourceMailbox>("""{"PasswordEncoding": " Windows-1254 "}""", SettingsManager.JSON_OPTIONS);
|
||||
Assert.That(JsonSerializer.Serialize(mailbox, SettingsManager.JSON_OPTIONS), Does.Contain("\"PasswordEncoding\": \"windows-1254\""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValuesThisVersionCannotReadFallBackToTheSafeSide()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user