New Webserver and WebApp (#942)
* Replace the WCF webserver with an ASP.NET Core webserver (VocaluxeWeb) - New project VocaluxeWeb: ASP.NET Core 2.3 (Kestrel) on .NET Framework 4.8.1, HTTP or HTTPS with a self-signed certificate, REST API (/api/v1) with Swagger, live events (Server-Sent Events) - Access to the game only through IVocaluxeRemote; requests run on the main thread once per frame - Sessions with roles (guest, player, admin) and configurable permissions, PINs hashed with PBKDF2 - Queue as a playlist with requesters and singers, fair order (one song per person and round) - Admin: settings, server status, logged-in devices, activate/deactivate and delete profiles - Profile pictures: own photo or one of the Vocaluxe avatars - Game: WebApp queue screen (song options, playlist group) to start the next song with the chosen singers, return to it after singing, warning when the webserver is off, remote keyboard - Old WCF server, WebserverInitalConfig and URL reservations removed; libraries moved to libs/managed - Unit tests for PIN hashing, settings and permissions, queue order and device names - AppVeyor: Visual Studio 2022 image and Node.js 24 (the build compiles the WebApp) - Documentation in VocaluxeWeb/README.md * New WebApp (Vue 3, TypeScript, Vite) replacing the old jQuery Mobile website - Login with profile and PIN, create profiles - Songs with search, filters, sorting and 30 second previews - Queue: add songs with game mode, audio and singers, edit, reorder, start in the game - Playlists: create, edit, add to the queue - Now playing with live updates, remote control and keyboard - Players: own profile with picture (photo or Vocaluxe avatar), roles for admins - Admin settings: permissions, server status, devices, profiles - Help page, responsive layout for phones, tablets and desktops, light and dark mode - Texts in WebApp/src/locales/en.json, translated with Transifex - Old website and PhoneGap config removed --------- Co-authored-by: Florian Ostertag <flokuep@users.noreply.github.com>
This commit is contained in:
1 parent
e3e9d1d6ae
commit
336d08040e
186 files changed
+14971
-6988
No files matched your search
@@ -85,6 +85,10 @@
|
||||
<Compile Include="VocaluxeLib\Utils\Combinatorics\CCombinationsTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="VocaluxeLib\XML\CXmlSerializerTest.cs" />
|
||||
<Compile Include="VocaluxeWeb\CPinHasherTest.cs" />
|
||||
<Compile Include="VocaluxeWeb\CQueueServiceTest.cs" />
|
||||
<Compile Include="VocaluxeWeb\CUserAgentTest.cs" />
|
||||
<Compile Include="VocaluxeWeb\CWebSettingsTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
@@ -103,6 +107,10 @@
|
||||
<Project>{2a1e0f2d-5392-4bb7-b0a1-a9dfa13e79ff}</Project>
|
||||
<Name>Vocaluxe</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\VocaluxeWeb\VocaluxeWeb.csproj">
|
||||
<Project>{4E2C9A71-6B3D-4F85-9C1E-8A7D5B2F3C60}</Project>
|
||||
<Name>VocaluxeWeb</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="VocaluxeLib\XML\TestFiles\Dictionary`2.xml" />
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using VocaluxeWeb.Services;
|
||||
|
||||
namespace Tests.VocaluxeWeb
|
||||
{
|
||||
[TestFixture]
|
||||
public class CPinHasherTest
|
||||
{
|
||||
[Test]
|
||||
public void TestHashAndVerify()
|
||||
{
|
||||
CPinHasher.Hash("1234", out var hash, out var salt);
|
||||
Assert.That(CPinHasher.Verify("1234", hash, salt), Is.True);
|
||||
Assert.That(CPinHasher.Verify("4321", hash, salt), Is.False);
|
||||
Assert.That(CPinHasher.Verify("", hash, salt), Is.False);
|
||||
Assert.That(CPinHasher.NeedsUpgrade(salt), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSaltIsRandom()
|
||||
{
|
||||
CPinHasher.Hash("1234", out var hash1, out var salt1);
|
||||
CPinHasher.Hash("1234", out var hash2, out var salt2);
|
||||
Assert.That(salt1, Is.Not.EqualTo(salt2));
|
||||
Assert.That(hash1, Is.Not.EqualTo(hash2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMissingValues()
|
||||
{
|
||||
CPinHasher.Hash("1234", out var hash, out var salt);
|
||||
Assert.That(CPinHasher.Verify(null, hash, salt), Is.False);
|
||||
Assert.That(CPinHasher.Verify("1234", null, salt), Is.False);
|
||||
Assert.That(CPinHasher.Verify("1234", hash, null), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLegacyPin()
|
||||
{
|
||||
var salt = new byte[32];
|
||||
new Random(1).NextBytes(salt);
|
||||
var hash = _LegacyHash("0815", salt);
|
||||
|
||||
Assert.That(CPinHasher.NeedsUpgrade(salt), Is.True);
|
||||
Assert.That(CPinHasher.Verify("0815", hash, salt), Is.True);
|
||||
Assert.That(CPinHasher.Verify("0816", hash, salt), Is.False);
|
||||
}
|
||||
|
||||
private static byte[] _LegacyHash(string pin, byte[] salt)
|
||||
{
|
||||
var password = Encoding.UTF8.GetBytes(pin);
|
||||
var data = new byte[password.Length + salt.Length];
|
||||
password.CopyTo(data, 0);
|
||||
salt.CopyTo(data, password.Length);
|
||||
using (var sha = SHA256.Create())
|
||||
{
|
||||
return sha.ComputeHash(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using VocaluxeWeb;
|
||||
using VocaluxeWeb.Contracts;
|
||||
using VocaluxeWeb.Dispatching;
|
||||
using VocaluxeWeb.Remote;
|
||||
using VocaluxeWeb.Services;
|
||||
|
||||
namespace Tests.VocaluxeWeb
|
||||
{
|
||||
[TestFixture]
|
||||
public class CQueueServiceTest
|
||||
{
|
||||
private sealed class CFakeRemote : IVocaluxeRemote
|
||||
{
|
||||
public readonly List<RemotePlaylist> Playlists = new List<RemotePlaylist>();
|
||||
|
||||
public string Version => "test";
|
||||
public bool IsReady => true;
|
||||
public int SongLibraryVersion => 1;
|
||||
|
||||
public RemoteState GetState()
|
||||
{
|
||||
return new RemoteState { Screen = "Main" };
|
||||
}
|
||||
|
||||
public IList<RemoteProfile> GetProfiles()
|
||||
{
|
||||
return new List<RemoteProfile>();
|
||||
}
|
||||
|
||||
public Guid CreateProfile(ProfileChange change)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void UpdateProfile(Guid profileId, ProfileChange change) { }
|
||||
|
||||
public void DeleteProfile(Guid profileId) { }
|
||||
|
||||
public IList<RemoteAvatar> GetAvatars()
|
||||
{
|
||||
return new List<RemoteAvatar>();
|
||||
}
|
||||
|
||||
public IList<RemoteSong> GetSongs()
|
||||
{
|
||||
return Enumerable.Range(0, 20)
|
||||
.Select(i => new RemoteSong
|
||||
{
|
||||
Id = i,
|
||||
Title = "Song " + i,
|
||||
Artist = "Artist",
|
||||
Languages = new string[0],
|
||||
Genres = new string[0],
|
||||
Editions = new string[0],
|
||||
GameModes = new List<int>(),
|
||||
AudioModes = new List<int>()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IList<RemotePlaylist> GetPlaylists()
|
||||
{
|
||||
return Playlists.Select(p => new RemotePlaylist { Id = p.Id, Name = p.Name, Entries = p.Entries.ToList() }).ToList();
|
||||
}
|
||||
|
||||
public int CreatePlaylist(string name)
|
||||
{
|
||||
var playlist = new RemotePlaylist { Id = Playlists.Count + 1, Name = name, Entries = new List<RemotePlaylistEntry>() };
|
||||
Playlists.Add(playlist);
|
||||
return playlist.Id;
|
||||
}
|
||||
|
||||
public void RenamePlaylist(int playlistId, string name) { }
|
||||
|
||||
public void DeletePlaylist(int playlistId) { }
|
||||
|
||||
public void SetPlaylistEntries(int playlistId, IList<RemotePlaylistEntry> entries)
|
||||
{
|
||||
Playlists.First(p => p.Id == playlistId).Entries = entries.ToList();
|
||||
}
|
||||
|
||||
public ERemoteStartResult StartSong(RemoteStartRequest request)
|
||||
{
|
||||
return ERemoteStartResult.Singing;
|
||||
}
|
||||
|
||||
public void SendKey(ERemoteKey key) { }
|
||||
|
||||
public void SendText(string text) { }
|
||||
}
|
||||
|
||||
private readonly CSession _Anna = new CSession { ProfileId = Guid.NewGuid(), ProfileName = "Anna" };
|
||||
private readonly CSession _Ben = new CSession { ProfileId = Guid.NewGuid(), ProfileName = "Ben" };
|
||||
private readonly CSession _Cleo = new CSession { ProfileId = Guid.NewGuid(), ProfileName = "Cleo" };
|
||||
private CFakeRemote _Remote;
|
||||
private CQueueService _Queue;
|
||||
private CancellationTokenSource _Stop;
|
||||
private Task _MainThread;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_Remote = new CFakeRemote();
|
||||
var dispatcher = new CMainThreadDispatcher(TimeSpan.FromSeconds(5));
|
||||
_Queue = new CQueueService(_Remote, dispatcher, new CWebSettingsStore(null), new CSongLibrary(_Remote, dispatcher), new CLiveEvents());
|
||||
_Stop = new CancellationTokenSource();
|
||||
_MainThread = Task.Run(async () =>
|
||||
{
|
||||
while (!_Stop.IsCancellationRequested)
|
||||
{
|
||||
dispatcher.ProcessPending();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
_Stop.Cancel();
|
||||
_MainThread.Wait();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFairOrder()
|
||||
{
|
||||
_Add(1, _Anna);
|
||||
_Add(2, _Anna);
|
||||
_Add(3, _Anna);
|
||||
_Add(4, _Ben);
|
||||
_Add(5, _Ben);
|
||||
var queue = _Add(6, _Cleo);
|
||||
|
||||
Assert.That(_Requesters(queue), Is.EqualTo(new[] { "Anna", "Ben", "Cleo", "Anna", "Ben", "Anna" }));
|
||||
Assert.That(queue.Select(e => e.Song.Id), Is.EqualTo(new[] { 1, 4, 6, 2, 5, 3 }));
|
||||
Assert.That(queue.Select(e => e.Position), Is.EqualTo(Enumerable.Range(0, 6)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddMany()
|
||||
{
|
||||
_Add(1, _Ben);
|
||||
var queue = _Queue.AddManyAsync(new[] { 2, 3, 4 }.Select(id => new RemotePlaylistEntry { SongId = id }).ToList(), _Anna).Result;
|
||||
|
||||
Assert.That(_Requesters(queue), Is.EqualTo(new[] { "Ben", "Anna", "Anna", "Anna" }));
|
||||
Assert.That(_Requesters(_Add(5, _Ben)), Is.EqualTo(new[] { "Ben", "Anna", "Anna", "Ben", "Anna" }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPlaylistIsUpdated()
|
||||
{
|
||||
_Add(7, _Anna);
|
||||
_Add(8, _Ben);
|
||||
|
||||
var playlist = _Remote.Playlists.Single(p => p.Name == "WebApp Queue");
|
||||
Assert.That(playlist.Entries.Select(e => e.SongId), Is.EqualTo(new[] { 7, 8 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSongsAddedInTheGame()
|
||||
{
|
||||
_Add(1, _Anna);
|
||||
_Remote.Playlists[0].Entries.Add(new RemotePlaylistEntry { SongId = 9 });
|
||||
|
||||
var queue = _Add(2, _Anna);
|
||||
Assert.That(queue.Select(e => e.Song.Id), Is.EqualTo(new[] { 1, 9, 2 }));
|
||||
Assert.That(queue[1].RequestedBy, Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnlyOwnerOrManagerMayRemove()
|
||||
{
|
||||
var entry = _Add(1, _Anna)[0];
|
||||
|
||||
Exception error = null;
|
||||
try
|
||||
{
|
||||
_Queue.RemoveAsync(entry.Id, _Ben, false).Wait();
|
||||
}
|
||||
catch (AggregateException e)
|
||||
{
|
||||
error = e.InnerException;
|
||||
}
|
||||
|
||||
Assert.That(error, Is.InstanceOf<CQueueService.CForbiddenException>());
|
||||
Assert.That(_Queue.GetAsync().Result, Has.Count.EqualTo(1));
|
||||
|
||||
Assert.That(_Queue.RemoveAsync(entry.Id, _Ben, true).Result, Is.Empty);
|
||||
_Add(2, _Anna);
|
||||
Assert.That(_Queue.RemoveAsync(_Queue.GetAsync().Result[0].Id, _Anna, false).Result, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMove()
|
||||
{
|
||||
_Add(1, _Anna);
|
||||
_Add(2, _Ben);
|
||||
var queue = _Add(3, _Cleo);
|
||||
|
||||
queue = _Queue.MoveAsync(queue[2].Id, 0).Result;
|
||||
Assert.That(queue.Select(e => e.Song.Id), Is.EqualTo(new[] { 3, 1, 2 }));
|
||||
queue = _Queue.MoveAsync(queue[0].Id, 99).Result;
|
||||
Assert.That(queue.Select(e => e.Song.Id), Is.EqualTo(new[] { 1, 2, 3 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveSung()
|
||||
{
|
||||
_Add(1, _Anna);
|
||||
_Add(2, _Ben);
|
||||
|
||||
var queue = _Queue.RemoveSungAsync(1).Result;
|
||||
Assert.That(queue.Select(e => e.Song.Id), Is.EqualTo(new[] { 2 }));
|
||||
Assert.That(_Queue.RemoveSungAsync(5).Result, Has.Count.EqualTo(1));
|
||||
}
|
||||
|
||||
private IList<QueueEntryDto> _Add(int songId, CSession session)
|
||||
{
|
||||
return _Queue.AddAsync(songId, ESongGameMode.Normal, ESongAudioMode.Normal, null, session).Result;
|
||||
}
|
||||
|
||||
private static IEnumerable<string> _Requesters(IEnumerable<QueueEntryDto> queue)
|
||||
{
|
||||
return queue.Select(e => e.RequestedBy?.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using NUnit.Framework;
|
||||
using VocaluxeWeb.Services;
|
||||
|
||||
namespace Tests.VocaluxeWeb
|
||||
{
|
||||
[TestFixture]
|
||||
public class CUserAgentTest
|
||||
{
|
||||
[TestCase("Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1", "iPhone · Safari")]
|
||||
[TestCase("Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36", "Android phone · Chrome")]
|
||||
[TestCase("Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/26.0 Chrome/122.0.0.0 Safari/537.36", "Android tablet · Samsung Internet")]
|
||||
[TestCase("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0", "Windows · Edge")]
|
||||
[TestCase("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0", "Mac · Firefox")]
|
||||
[TestCase("curl/8.7.1", "curl/8.7.1")]
|
||||
[TestCase("", null)]
|
||||
[TestCase(null, null)]
|
||||
public void TestDescribe(string userAgent, string expected)
|
||||
{
|
||||
Assert.That(CUserAgent.Describe(userAgent), Is.EqualTo(expected));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using VocaluxeWeb.Contracts;
|
||||
using VocaluxeWeb.Remote;
|
||||
using VocaluxeWeb.Services;
|
||||
|
||||
namespace Tests.VocaluxeWeb
|
||||
{
|
||||
[TestFixture]
|
||||
public class CWebSettingsTest
|
||||
{
|
||||
private string _Path;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_Path = Path.Combine(Path.GetTempPath(), "VocaluxeWebTest_" + Guid.NewGuid().ToString("N"), "WebSettings.json");
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
var directory = Path.GetDirectoryName(_Path);
|
||||
if (Directory.Exists(directory))
|
||||
{
|
||||
Directory.Delete(directory, true);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAdminHasAllPermissions()
|
||||
{
|
||||
var settings = new CWebSettings();
|
||||
settings.GuestPermissions.Clear();
|
||||
settings.PlayerPermissions.Clear();
|
||||
var all = Enum.GetValues(typeof(EPermission)).Cast<EPermission>().ToList();
|
||||
|
||||
Assert.That(settings.GetPermissions(ERemoteRole.Admin), Is.EquivalentTo(all));
|
||||
Assert.That(settings.GetPermissions(ERemoteRole.Guest), Is.Empty);
|
||||
Assert.That(settings.GetPermissions(ERemoteRole.Player), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDefaults()
|
||||
{
|
||||
var settings = new CWebSettings();
|
||||
Assert.That(settings.GetPermissions(ERemoteRole.Guest), Is.EquivalentTo(new[] { EPermission.AddToQueue }));
|
||||
Assert.That(settings.GetPermissions(ERemoteRole.Player), Does.Contain(EPermission.AddToQueue));
|
||||
Assert.That(settings.GetPermissions(ERemoteRole.Player), Does.Not.Contain(EPermission.EditAllProfiles));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStoreSavesAndLoads()
|
||||
{
|
||||
var store = new CWebSettingsStore(_Path);
|
||||
store.Update(s =>
|
||||
{
|
||||
s.AllowProfileCreation = false;
|
||||
s.QueuePlaylistName = "Party queue";
|
||||
s.GuestPermissions.Add(EPermission.UseKeyboard);
|
||||
});
|
||||
|
||||
var loaded = new CWebSettingsStore(_Path).Current;
|
||||
Assert.That(loaded.AllowProfileCreation, Is.False);
|
||||
Assert.That(loaded.QueuePlaylistName, Is.EqualTo("Party queue"));
|
||||
Assert.That(loaded.GetPermissions(ERemoteRole.Guest), Does.Contain(EPermission.UseKeyboard));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCurrentIsACopy()
|
||||
{
|
||||
var store = new CWebSettingsStore(_Path);
|
||||
store.Current.GuestPermissions.Add(EPermission.DeletePlaylists);
|
||||
Assert.That(store.Current.GuestPermissions, Does.Not.Contain(EPermission.DeletePlaylists));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBrokenFile()
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_Path));
|
||||
File.WriteAllText(_Path, "{ broken");
|
||||
var store = new CWebSettingsStore(_Path);
|
||||
Assert.That(store.Current.QueuePlaylistName, Is.EqualTo("WebApp Queue"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFileWithRemovedSettings()
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_Path));
|
||||
File.WriteAllText(_Path, "{ \"RequireJoinToken\": true, \"JoinToken\": \"abc\", \"QueuePlaylistName\": \"Party\" }");
|
||||
Assert.That(new CWebSettingsStore(_Path).Current.QueuePlaylistName, Is.EqualTo("Party"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user