Add managed server profiles and account login
.NET port / test (macos-latest) (push) Canceled after 0s
.NET port / test (ubuntu-24.04) (push) Canceled after 0s
.NET port / test (windows-latest) (push) Canceled after 0s
.NET port / apple-client (push) Canceled after 0s
.NET port / cpp-conformance (push) Canceled after 0s
.NET port / test (macos-latest) (push) Canceled after 0s
.NET port / test (ubuntu-24.04) (push) Canceled after 0s
.NET port / test (windows-latest) (push) Canceled after 0s
.NET port / apple-client (push) Canceled after 0s
.NET port / cpp-conformance (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using VoiceCat.Core;
|
||||
|
||||
namespace VoiceCat.Tests;
|
||||
|
||||
public sealed class ServerProfileTests
|
||||
{
|
||||
[Fact]
|
||||
public void ProfilesRoundTripWithoutPasswordMaterial()
|
||||
{
|
||||
string directory = Path.Combine(Path.GetTempPath(), "voicecat-profile-" + Guid.NewGuid().ToString("N"));
|
||||
string path = Path.Combine(directory, "servers.json");
|
||||
try
|
||||
{
|
||||
var guest = ServerProfile.Create(" voice.example ", 8384, ServerAuthentication.Guest, nickname: " Cat ");
|
||||
var account = ServerProfile.Create("secure.example", 9443, ServerAuthentication.Account, username: " talon ");
|
||||
var store = new ServerProfileStore(path);
|
||||
store.Save([guest, account]);
|
||||
|
||||
Assert.Equal([guest, account], store.Load());
|
||||
string json = File.ReadAllText(path);
|
||||
Assert.Contains("\"authentication\": \"Account\"", json);
|
||||
Assert.DoesNotContain("password", json, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
finally { if (Directory.Exists(directory)) Directory.Delete(directory, true); }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MissingCorruptAndInvalidProfilesDoNotBreakStartup()
|
||||
{
|
||||
string directory = Path.Combine(Path.GetTempPath(), "voicecat-profile-" + Guid.NewGuid().ToString("N"));
|
||||
string path = Path.Combine(directory, "servers.json");
|
||||
try
|
||||
{
|
||||
var store = new ServerProfileStore(path);
|
||||
Assert.Empty(store.Load());
|
||||
Directory.CreateDirectory(directory);
|
||||
File.WriteAllText(path, "not json");
|
||||
Assert.Empty(store.Load());
|
||||
File.WriteAllText(path, "[{\"id\":\"00000000-0000-0000-0000-000000000000\",\"host\":\"\",\"port\":0,\"authentication\":\"Guest\"}]");
|
||||
Assert.Empty(store.Load());
|
||||
}
|
||||
finally { if (Directory.Exists(directory)) Directory.Delete(directory, true); }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AccountProfilesRequireAUsername()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => ServerProfile.Create("voice.example", 8384, ServerAuthentication.Account));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user