Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions lib/src/utils/device_keys_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -485,7 +481,6 @@ class DeviceKeys extends SignableKey {
_verifySignature(
ed25519Key!,
signatures![userId]!['ed25519:$deviceId']!,
isSignatureWithoutLibolmValid: true,
));

@override
Expand Down
38 changes: 29 additions & 9 deletions test/device_keys_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <String, dynamic>{
'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 = <String, dynamic>{
'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...
Comment thread
td-famedly marked this conversation as resolved.
await key.setVerified(false, false);
await key.setBlocked(true);
expect(json.encode(key.toJson()), json.encode(rawJson));
Expand Down
15 changes: 4 additions & 11 deletions test/encryption/bootstrap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -44,6 +43,10 @@ void main() {
client = await getClient();
});

tearDownAll(() async {
await client.dispose();
});

test(
'setup',
() async {
Expand Down Expand Up @@ -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);
});
});
}
4 changes: 3 additions & 1 deletion test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions test/msc_extensions/msc_4075_rtc_notification_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions test/msc_extensions/timeline_export_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Event> mockEvents;

Expand Down
Loading