diff --git a/lib/src/utils/device_keys_list.dart b/lib/src/utils/device_keys_list.dart index f6d09b607..c9170b2b7 100644 --- a/lib/src/utils/device_keys_list.dart +++ b/lib/src/utils/device_keys_list.dart @@ -235,11 +235,7 @@ abstract class SignableKey extends MatrixSignableKey { return String.fromCharCodes(canonicalJson.encode(data)); } - bool _verifySignature( - String pubKey, - String signature, { - bool isSignatureWithoutLibolmValid = false, - }) { + bool _verifySignature(String pubKey, String signature) { var valid = false; try { vod.Ed25519PublicKey.fromBase64(pubKey).verify( @@ -485,7 +481,6 @@ class DeviceKeys extends SignableKey { _verifySignature( ed25519Key!, signatures![userId]!['ed25519:$deviceId']!, - isSignatureWithoutLibolmValid: true, )); @override diff --git a/test/device_keys_list_test.dart b/test/device_keys_list_test.dart index b00cf0cbd..376d266a1 100644 --- a/test/device_keys_list_test.dart +++ b/test/device_keys_list_test.dart @@ -44,29 +44,49 @@ void main() async { }); test('fromJson', () async { + const userId = '@alice:example.com'; + const deviceId = 'JLAFKJWSCS'; + final account = vod.Account(); + final identityKeys = account.identityKeys; + final curve25519Key = identityKeys.curve25519.toBase64(); + final ed25519Key = identityKeys.ed25519.toBase64(); + + final signingData = { + 'algorithms': [ + AlgorithmTypes.olmV1Curve25519AesSha2, + AlgorithmTypes.megolmV1AesSha2, + ], + 'device_id': deviceId, + 'keys': { + 'curve25519:$deviceId': curve25519Key, + 'ed25519:$deviceId': ed25519Key, + }, + 'user_id': userId, + }; + final signingContent = + String.fromCharCodes(json.encode(signingData).codeUnits); + final signature = account.sign(signingContent).toBase64(); + var rawJson = { - 'user_id': '@alice:example.com', - 'device_id': 'JLAFKJWSCS', + 'user_id': userId, + 'device_id': deviceId, 'algorithms': [ AlgorithmTypes.olmV1Curve25519AesSha2, AlgorithmTypes.megolmV1AesSha2, ], 'keys': { - 'curve25519:JLAFKJWSCS': - '3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI', - 'ed25519:JLAFKJWSCS': 'lEuiRJBit0IG6nUf5pUzWTUEsRVVe/HJkoKuEww9ULI', + 'curve25519:$deviceId': curve25519Key, + 'ed25519:$deviceId': ed25519Key, }, 'signatures': { - '@alice:example.com': { - 'ed25519:JLAFKJWSCS': - 'dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA', + userId: { + 'ed25519:$deviceId': signature, }, }, 'unsigned': {'device_display_name': "Alice's mobile phone"}, }; final key = DeviceKeys.fromJson(rawJson, client); - // NOTE(Nico): this actually doesn't do anything, because the device signature is invalid... await key.setVerified(false, false); await key.setBlocked(true); expect(json.encode(key.toJson()), json.encode(rawJson)); diff --git a/test/encryption/bootstrap_test.dart b/test/encryption/bootstrap_test.dart index cd1005f56..982a3260c 100644 --- a/test/encryption/bootstrap_test.dart +++ b/test/encryption/bootstrap_test.dart @@ -18,7 +18,6 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; import 'package:test/test.dart'; import 'package:vodozemac/vodozemac.dart' as vod; @@ -44,6 +43,10 @@ void main() { client = await getClient(); }); + tearDownAll(() async { + await client.dispose(); + }); + test( 'setup', () async { @@ -252,15 +255,5 @@ void main() { } expect(askedBadSsss, true); }); - - test('dispose client', () async { - await client.dispose(closeDatabase: true); - }); - - tearDownAll(() async { - // Force process exit to prevent hanging in CI - // Some FFI resources from vodozemac may keep background threads alive - exit(0); - }); }); } diff --git a/test/event_test.dart b/test/event_test.dart index 95b46df96..006edb8ae 100644 --- a/test/event_test.dart +++ b/test/event_test.dart @@ -981,7 +981,9 @@ void main() async { ); expect( await event.calcLocalizedBody(MatrixDefaultLocalizations()), - 'Example activated end to end encryption. Need pantalaimon', + client.encryptionEnabled + ? 'Example activated end to end encryption' + : 'Example activated end to end encryption. Need pantalaimon', ); expect(event.isEventTypeKnown, true); diff --git a/test/msc_extensions/msc_4075_rtc_notification_test.dart b/test/msc_extensions/msc_4075_rtc_notification_test.dart index fcbdcba0e..e5ff7eda5 100644 --- a/test/msc_extensions/msc_4075_rtc_notification_test.dart +++ b/test/msc_extensions/msc_4075_rtc_notification_test.dart @@ -14,6 +14,10 @@ void main() { room = Room(id: '!1234:fakeServer.notExisting', client: client); }); + tearDownAll(() async { + await client.dispose(); + }); + group('RtcNotificationType', () { test('fromValue returns correct type', () { expect(RtcNotificationType.fromValue('ring'), RtcNotificationType.ring); diff --git a/test/msc_extensions/timeline_export_test.dart b/test/msc_extensions/timeline_export_test.dart index b3acb9f06..2209016a3 100644 --- a/test/msc_extensions/timeline_export_test.dart +++ b/test/msc_extensions/timeline_export_test.dart @@ -125,6 +125,10 @@ void main() { timeline = Timeline(room: room, chunk: TimelineChunk(events: [])); }); + tearDown(() async { + await client.dispose(closeDatabase: false); + }); + group('basic export functionality', () { late List mockEvents;