fix: personenbezogene Daten aus Companion-Klartextkanal ausschließen
- PlainEventStore.Allowed: Grade/ExamResult entfernt (beide tragen StudentId + Notenwert/-kommentar, PlainSyncEvent.Payload läuft aber als Klartext-JSON über den Server, anders als der AES-256-GCM- verschlüsselte Desktop-Kanal). Nur noch WorkTask/Lesson erlaubt. - Regressionstest PlainEventStoreTests ergänzt. - TODO.md 10.3.3 abgehakt, inkl. deutlichem Warnhinweis: die geplante Mitarbeitsnoten-Erfassung per Companion-App ist damit bewusst blockiert, bis 10.3.1 (Schlüsselaustausch) + eine echte Payload- Verschlüsselung für PlainSyncEvent existieren. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using LehrerApp.Sync.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace LehrerApp.Api.Tests;
|
||||
|
||||
public sealed class PlainEventStoreTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("Grade")]
|
||||
[InlineData("ExamResult")]
|
||||
public void Push_PersonenbezogenerEntityTyp_WirdAbgelehnt(string entityType)
|
||||
{
|
||||
using var temp = new TempEventStore();
|
||||
var evt = new PlainSyncEvent { EntityType = entityType, EntityId = "1", Operation = "Save" };
|
||||
|
||||
var result = temp.Plain.Push("user", [evt]);
|
||||
|
||||
Assert.Contains(evt.EventId, result.RejectedEventIds);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("WorkTask")]
|
||||
[InlineData("Lesson")]
|
||||
public void Push_UnkritischerEntityTyp_WirdAngenommen(string entityType)
|
||||
{
|
||||
using var temp = new TempEventStore();
|
||||
var evt = new PlainSyncEvent { EntityType = entityType, EntityId = "1", Operation = "Save" };
|
||||
|
||||
var result = temp.Plain.Push("user", [evt]);
|
||||
|
||||
Assert.DoesNotContain(evt.EventId, result.RejectedEventIds);
|
||||
}
|
||||
|
||||
private sealed class TempEventStore : IDisposable
|
||||
{
|
||||
private readonly string _directory = Path.Combine(
|
||||
Path.GetTempPath(), $"lehrerapp-api-tests-{Guid.NewGuid():N}");
|
||||
private readonly EventStore _events;
|
||||
public PlainEventStore Plain { get; }
|
||||
|
||||
public TempEventStore()
|
||||
{
|
||||
Directory.CreateDirectory(_directory);
|
||||
_events = new EventStore(_directory);
|
||||
Plain = new PlainEventStore(_events);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_events.Dispose();
|
||||
if (Directory.Exists(_directory)) Directory.Delete(_directory, recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user