diff --git a/secure-messenger/app/lib/oberflaeche/home/chatliste.dart b/secure-messenger/app/lib/oberflaeche/home/chatliste.dart index dbcdab2..b057e4d 100644 --- a/secure-messenger/app/lib/oberflaeche/home/chatliste.dart +++ b/secure-messenger/app/lib/oberflaeche/home/chatliste.dart @@ -463,7 +463,25 @@ extension _Chatliste on _HomeState { padding: const EdgeInsets.all(11), decoration: BoxDecoration(color: p.tint, borderRadius: BorderRadius.circular(8), border: Border.all(color: p.tintLine)), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(shortId(adresseFormatiert(k.id)), style: doto(size: 13, weight: FontWeight.w600, color: p.tintInk, spacing: 0.8)), + // DIE GANZE ADRESSE UND DAS BILD DAZU, nicht nur 4…4 Zeichen. Hier + // entscheidet der Nutzer, wen er annimmt — und acht Zeichen (rund + // 40 Bit) laden zu einer nachgemachten Adresse ein, die vorne und + // hinten gleich aussieht (Sicherheitsbewertung vom 23.11.2026, + // SEC-M7). Das Identicon haengt an der ganzen Adresse; es ist + // dasselbe, das spaeter am Chat steht. + Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Identicon(k.id, 36, avp, 7), + const SizedBox(width: 10), + Expanded( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text(shortId(adresseFormatiert(k.id)), style: doto(size: 13, weight: FontWeight.w600, color: p.tintInk, spacing: 0.8)), + const SizedBox(height: 3), + SelectableText(adresseFormatiert(k.id), + key: ValueKey('anfrage-adresse-${k.id}'), + style: mono(size: 10.5, color: p.tintInk, height: 1.45)), + ]), + ), + ]), const SizedBox(height: 6), Text(t('wantsChat'), style: mono(size: 11.5, color: p.muted)), const SizedBox(height: 8), diff --git a/secure-messenger/app/test/oberflaeche/anfrage_adresse_test.dart b/secure-messenger/app/test/oberflaeche/anfrage_adresse_test.dart new file mode 100644 index 0000000..561efa7 --- /dev/null +++ b/secure-messenger/app/test/oberflaeche/anfrage_adresse_test.dart @@ -0,0 +1,73 @@ +// anfrage_adresse_test.dart — eine Kontaktanfrage zeigt die ganze Adresse +// (Sicherheitsbewertung vom 23.11.2026, SEC-M7). +// +// Bis 23.11.2026 stand an der Anfrage nur "ABCD…WXYZ": acht Zeichen, rund 40 +// Bit. Wer eine Adresse erzeugt, die vorne und hinten gleich aussieht, haette +// sich als jemand Bekanntes ausgeben koennen — genau dort, wo der Nutzer +// entscheidet, wen er annimmt. + +import 'package:bitdm/app_state.dart'; +import 'package:bitdm/core/fake_messenger_core.dart'; +import 'package:bitdm/main.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + late AppState st; + + setUp(() async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler( + const MethodChannel('bitdm/fenster'), (_) async => true); + st = AppState(FakeMessengerCore()); + }); + + tearDown(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(const MethodChannel('bitdm/fenster'), null); + st.dispose(); + }); + + Future warte(WidgetTester tester, [int ms = 400]) async { + for (var i = 0; i < 4; i++) { + await tester.runAsync( + () async => Future.delayed(const Duration(milliseconds: 20))); + await tester.pump(Duration(milliseconds: ms ~/ 2)); + } + } + + testWidgets('DIE ANFRAGE ZEIGT DIE GANZE ADRESSE UND DAS BILD DAZU', + (tester) async { + await tester.runAsync(() async => st.boot()); + await tester.pumpWidget(BitApp(state: st)); + await tester.pump(const Duration(milliseconds: 400)); + await tester.tap(find.text('CREATE IDENTITY')); + await tester.pump(const Duration(milliseconds: 600)); + await warte(tester, 600); + await tester.tap(find.text('I WROTE THEM DOWN')); + await tester.pump(const Duration(milliseconds: 400)); + await tester.tap(find.text('SKIP FOR NOW')); + await tester.pump(const Duration(milliseconds: 400)); + // Auf main gibt es die Rueckfrage noch nicht (fix/ohne-nachweis-ehrlich). + final ohne = find.byKey(const ValueKey('ohne-schutz-weiter')); + if (ohne.evaluate().isNotEmpty) await tester.tap(ohne); + await tester.pump(const Duration(milliseconds: 400)); + await tester.tap(find.text('CHATS').first); + // Der Entwurfskern meldet die Anfrage gut eine Sekunde nach dem Verbinden. + for (var i = 0; i < 4; i++) { + await tester.runAsync( + () async => Future.delayed(const Duration(milliseconds: 600))); + await tester.pump(const Duration(milliseconds: 300)); + } + + expect(st.offeneAnfragen, isNotEmpty, reason: 'keine Anfrage da'); + final id = st.offeneAnfragen.first.id; + final adresse = find.byKey(ValueKey('anfrage-adresse-$id')); + expect(adresse, findsOneWidget, + reason: 'an der Anfrage stehen nur acht Zeichen der Adresse'); + expect(tester.widget(adresse).data, adresseFormatiert(id), + reason: 'nicht die ganze Adresse'); + await tester.pump(const Duration(seconds: 2)); + }); +}