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:
2026-08-13 13:07:36 +02:00
co-authored by Claude Sonnet 5
parent db1afff7e4
commit 48d07a2b99
25 changed files with 1228 additions and 21 deletions
@@ -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); }
}
}