Datensicherheit: Backup, Verschlüsselung, App-Sperre (Kapitel 13.3)
Automatisches rollierendes Backup der Datenbank beim Start mit Wiederherstellung über die Einstellungen, versionierte Schema-Migration, optionale Passwort-Verschlüsselung der LiteDB-Datei und eine App-Sperre nach Inaktivität mit eigenem Passwort. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using LehrerApp.Core.Services;
|
||||
using LehrerApp.Desktop.ViewModels;
|
||||
using Xunit;
|
||||
|
||||
namespace LehrerApp.Desktop.Tests;
|
||||
|
||||
public sealed class AppLockViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
public void Unlock_KorrektesPasswort_HebtDieSperreAuf()
|
||||
{
|
||||
using var temp = new TempAppData();
|
||||
var appLock = new AppLockService(temp.Path);
|
||||
appLock.SetPassword("geheim123");
|
||||
var vm = new AppLockViewModel(appLock) { IsLocked = true, PasswordAttempt = "geheim123" };
|
||||
|
||||
vm.UnlockCommand.Execute(null);
|
||||
|
||||
Assert.False(vm.IsLocked);
|
||||
Assert.Equal("", vm.UnlockError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Unlock_FalschesPasswort_BleibtGesperrtUndZeigtFehler()
|
||||
{
|
||||
using var temp = new TempAppData();
|
||||
var appLock = new AppLockService(temp.Path);
|
||||
appLock.SetPassword("geheim123");
|
||||
var vm = new AppLockViewModel(appLock) { IsLocked = true, PasswordAttempt = "falsch" };
|
||||
|
||||
vm.UnlockCommand.Execute(null);
|
||||
|
||||
Assert.True(vm.IsLocked);
|
||||
Assert.NotEqual("", vm.UnlockError);
|
||||
Assert.Equal("", vm.PasswordAttempt);
|
||||
}
|
||||
|
||||
private sealed class TempAppData : IDisposable
|
||||
{
|
||||
public string Path { get; } = System.IO.Path.Combine(
|
||||
System.IO.Path.GetTempPath(), $"lehrerapp-applockvm-tests-{Guid.NewGuid():N}");
|
||||
|
||||
public TempAppData() => Directory.CreateDirectory(Path);
|
||||
public void Dispose() { if (Directory.Exists(Path)) Directory.Delete(Path, recursive: true); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user