feat: lcov and tag olm tests

This commit is contained in:
td 2024-04-23 15:21:46 +05:30
parent 78e5abc0ae
commit 281510b950
No known key found for this signature in database
GPG Key ID: 62A30523D4D6CE28
26 changed files with 303 additions and 2961 deletions

View File

@ -30,29 +30,6 @@ jobs:
scripts/prepare.sh scripts/prepare.sh
scripts/test_driver.sh" scripts/test_driver.sh"
# coverage is done on the flutter-linux image because we setup olm there
# coverage_without_olm is done on dart images because why not :D
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cat .github/workflows/versions.env >> $GITHUB_ENV
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa
with:
flutter-version: ${{ env.flutter_version }}
cache: true
- name: Run tests
run: |
sed -i 's/#flutter_test/flutter_test/g' pubspec.yaml
rm -r example
./scripts/prepare.sh
./scripts/test.sh
- name: Ensure SDK compiles on web
run: |
pushd web_test
dart pub get
dart run webdev build
coverage_without_olm: coverage_without_olm:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
@ -65,10 +42,79 @@ jobs:
sdk: ${{ env.dart_version }} sdk: ${{ env.dart_version }}
- name: Run tests - name: Run tests
run: | run: |
apt-get update && apt-get install --no-install-recommends --no-install-suggests -y curl lcov python3 python3-distutils libsqlite3-0 libsqlite3-dev sudo apt-get update && sudo apt-get install --no-install-recommends --no-install-suggests -y curl lcov python3 python3-distutils libsqlite3-0 libsqlite3-dev
curl -o /bin/lcov_cobertura.py https://raw.githubusercontent.com/eriwen/lcov-to-cobertura-xml/master/lcov_cobertura/lcov_cobertura.py && sed 's/env python/env python3/' -i /bin/lcov_cobertura.py && chmod +x /bin/lcov_cobertura.py
dart pub get
./scripts/test.sh ./scripts/test.sh
- uses: actions/upload-artifact@v4
if: always()
with:
name: coverage_without_olm
path: coverage_dir/
retention-days: 1
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cat .github/workflows/versions.env >> $GITHUB_ENV
- uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46
with:
sdk: ${{ env.dart_version }}
- name: Run tests
run: |
sudo apt-get update && sudo apt-get install --no-install-recommends --no-install-suggests -y curl lcov python3 python3-distutils libsqlite3-0 libsqlite3-dev libolm3 libssl3
./scripts/test.sh
- uses: actions/upload-artifact@v4
if: always()
with:
name: coverage
path: coverage_dir/
retention-days: 1
merge_converage:
if: always()
runs-on: ubuntu-latest
needs: [coverage, coverage_without_olm]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Merge lcov files
run: |
sudo apt-get -y install lcov
lcov -a coverage/lcov.info -a coverage_without_olm/lcov.info -o merged.info
genhtml merged.info -o merged
echo $(lcov --summary merged.info | grep 'lines......:') >> $GITHUB_STEP_SUMMARY
- uses: actions/upload-artifact@v4
with:
name: merged
path: merged/
retention-days: 1
review_app_coverage:
if: github.event_name == 'pull_request'
needs: [merge_converage]
secrets: inherit
uses: famedly/frontend-ci-templates/.github/workflows/review-app.yml@main
with:
projectname: "matrix-dart-sdk-coverage"
pr: ${{ github.event.pull_request.number }}
environment: "review"
artifact-name: "merged"
dart_web_compatible:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cat .github/workflows/versions.env >> $GITHUB_ENV
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa
with:
flutter-version: ${{ env.flutter_version }}
- name: Ensure SDK compiles on web
run: |
pushd web_test
dart pub get
dart run webdev build
pub-dev-dry-run: pub-dev-dry-run:
runs-on: ubuntu-latest runs-on: ubuntu-latest

2
dart_test.yaml Normal file
View File

@ -0,0 +1,2 @@
tags:
olm:

File diff suppressed because it is too large Load Diff

View File

@ -2,33 +2,17 @@
thread_count=$(getconf _NPROCESSORS_ONLN) thread_count=$(getconf _NPROCESSORS_ONLN)
if which flutter >/dev/null; then if [ -n "$NO_OLM" ]; then
flutter pub global activate junitreport tagFlag="-x olm"
flutter test --concurrency=$thread_count --coverage
TEST_CODE=$?
# coverage
flutter pub global activate remove_from_coverage
flutter pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$'
else
dart test --concurrency=$thread_count --coverage=coverage
TEST_CODE=$?
# coverage -> broken see https://github.com/dart-lang/test/issues/1698
dart pub global activate coverage
#reporton="--report-on=lib/"
if [ -n "$NO_OLM" ]; then reporton="--report-on=lib/src --report-on=lib/msc_extensions"; fi
dart pub global run coverage:format_coverage -i coverage/ --lcov -o coverage/lcov.info $reporton
dart pub global activate remove_from_coverage
dart pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$'
fi fi
# coverage html report dart test --concurrency=$thread_count --coverage=coverage_dir $tagFlag
genhtml -o coverage coverage/lcov.info || true TEST_CODE=$?
# https://github.com/eriwen/lcov-to-cobertura-xml # lets you do more stuff like reporton
lcov_cobertura.py coverage/lcov.info || true dart pub global activate coverage
dart pub global run coverage:format_coverage --lcov -i coverage_dir -o coverage_dir/lcov.info --report-on=lib/
dart pub global activate remove_from_coverage
dart pub global run remove_from_coverage:remove_from_coverage -f coverage_dir/lcov.info -r '\.g\.dart$'
exit $TEST_CODE exit $TEST_CODE

View File

@ -41,7 +41,7 @@ void main() {
const fingerprintKey = 'gjL//fyaFHADt9KBADGag8g7F8Up78B/K1zXeiEPLJo'; const fingerprintKey = 'gjL//fyaFHADt9KBADGag8g7F8Up78B/K1zXeiEPLJo';
/// All Tests related to the Login /// All Tests related to the Login
group('Client', () { group('Client', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
/// Check if all Elements get created /// Check if all Elements get created
@ -50,8 +50,6 @@ void main() {
matrix = await getClient(); matrix = await getClient();
}); });
var olmEnabled = true;
test('Login', () async { test('Login', () async {
matrix = Client( matrix = Client(
'testclient', 'testclient',
@ -60,15 +58,6 @@ void main() {
); );
final eventUpdateListFuture = matrix.onEvent.stream.toList(); final eventUpdateListFuture = matrix.onEvent.stream.toList();
final toDeviceUpdateListFuture = matrix.onToDeviceEvent.stream.toList(); final toDeviceUpdateListFuture = matrix.onToDeviceEvent.stream.toList();
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().w('[LibOlm] Enabled: $olmEnabled');
var presenceCounter = 0; var presenceCounter = 0;
var accountDataCounter = 0; var accountDataCounter = 0;
matrix.onPresenceChanged.stream.listen((CachedPresence data) { matrix.onPresenceChanged.stream.listen((CachedPresence data) {
@ -112,11 +101,10 @@ void main() {
expect(loginState, LoginState.loggedIn); expect(loginState, LoginState.loggedIn);
expect(matrix.onSync.value != null, true); expect(matrix.onSync.value != null, true);
expect(matrix.encryptionEnabled, olmEnabled); expect(matrix.encryptionEnabled, true);
if (olmEnabled) { expect(matrix.identityKey, identityKey);
expect(matrix.identityKey, identityKey); expect(matrix.fingerprintKey, fingerprintKey);
expect(matrix.fingerprintKey, fingerprintKey);
}
expect(sync.nextBatch == matrix.prevBatch, true); expect(sync.nextBatch == matrix.prevBatch, true);
expect(matrix.accountData.length, 10); expect(matrix.accountData.length, 10);
@ -276,11 +264,8 @@ void main() {
expect(deviceeventUpdateList.length, 2); expect(deviceeventUpdateList.length, 2);
expect(deviceeventUpdateList[0].type, 'm.new_device'); expect(deviceeventUpdateList[0].type, 'm.new_device');
if (olmEnabled) {
expect(deviceeventUpdateList[1].type, 'm.room_key'); expect(deviceeventUpdateList[1].type, 'm.room_key');
} else {
expect(deviceeventUpdateList[1].type, 'm.room.encrypted');
}
}); });
test('recentEmoji', () async { test('recentEmoji', () async {
@ -349,15 +334,6 @@ void main() {
databaseBuilder: getDatabase, databaseBuilder: getDatabase,
); );
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().w('[LibOlm] Enabled: $olmEnabled');
expect(matrix.homeserver, null); expect(matrix.homeserver, null);
try { try {
@ -392,11 +368,11 @@ void main() {
expect(loginState, LoginState.loggedIn); expect(loginState, LoginState.loggedIn);
expect(matrix.onSync.value != null, true); expect(matrix.onSync.value != null, true);
expect(matrix.encryptionEnabled, olmEnabled); expect(matrix.encryptionEnabled, true);
if (olmEnabled) {
expect(matrix.identityKey, identityKey); expect(matrix.identityKey, identityKey);
expect(matrix.fingerprintKey, fingerprintKey); expect(matrix.fingerprintKey, fingerprintKey);
}
expect(sync.nextBatch == matrix.prevBatch, true); expect(sync.nextBatch == matrix.prevBatch, true);
}); });
@ -695,9 +671,6 @@ void main() {
await client.dispose(closeDatabase: true); await client.dispose(closeDatabase: true);
}); });
test('sendToDeviceEncrypted', () async { test('sendToDeviceEncrypted', () async {
if (!olmEnabled) {
return;
}
FakeMatrixApi.calledEndpoints.clear(); FakeMatrixApi.calledEndpoints.clear();
await matrix.sendToDeviceEncrypted( await matrix.sendToDeviceEncrypted(
@ -714,9 +687,6 @@ void main() {
true); true);
}); });
test('sendToDeviceEncryptedChunked', () async { test('sendToDeviceEncryptedChunked', () async {
if (!olmEnabled) {
return;
}
FakeMatrixApi.calledEndpoints.clear(); FakeMatrixApi.calledEndpoints.clear();
await matrix.sendToDeviceEncryptedChunked( await matrix.sendToDeviceEncryptedChunked(
matrix.userDeviceKeys['@alice:example.com']!.deviceKeys.values matrix.userDeviceKeys['@alice:example.com']!.deviceKeys.values
@ -1199,40 +1169,34 @@ void main() {
reason: '!5345234235:example.com not found as archived room'); reason: '!5345234235:example.com not found as archived room');
}); });
test('Client Init Exception', () async { test(
try { 'Client Init Exception',
await olm.init(); () async {
olm.get_library_version(); final customClient = Client(
} catch (e) { 'failclient',
olmEnabled = false; databaseBuilder: getMatrixSdkDatabase,
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().w('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
final customClient = Client(
'failclient',
databaseBuilder: getMatrixSdkDatabase,
);
try {
await customClient.init(
newToken: 'testtoken',
newDeviceID: 'testdeviceid',
newDeviceName: 'testdevicename',
newHomeserver: Uri.parse('https://test.server'),
newOlmAccount: 'abcd',
newUserID: '@user:server',
); );
throw Exception('No exception?'); try {
} on ClientInitException catch (error) { await customClient.init(
expect(error.accessToken, 'testtoken'); newToken: 'testtoken',
expect(error.deviceId, 'testdeviceid'); newDeviceID: 'testdeviceid',
expect(error.deviceName, 'testdevicename'); newDeviceName: 'testdevicename',
expect(error.homeserver, Uri.parse('https://test.server')); newHomeserver: Uri.parse('https://test.server'),
expect(error.olmAccount, 'abcd'); newOlmAccount: 'abcd',
expect(error.userId, '@user:server'); newUserID: '@user:server',
expect(error.toString(), 'Exception: BAD_ACCOUNT_KEY'); );
} throw Exception('No exception?');
}); } on ClientInitException catch (error) {
expect(error.accessToken, 'testtoken');
expect(error.deviceId, 'testdeviceid');
expect(error.deviceName, 'testdevicename');
expect(error.homeserver, Uri.parse('https://test.server'));
expect(error.olmAccount, 'abcd');
expect(error.userId, '@user:server');
expect(error.toString(), 'Exception: BAD_ACCOUNT_KEY');
}
},
);
tearDown(() async { tearDown(() async {
await matrix.dispose(closeDatabase: true); await matrix.dispose(closeDatabase: true);

View File

@ -19,7 +19,6 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
@ -27,10 +26,9 @@ import 'fake_client.dart';
import 'fake_matrix_api.dart'; import 'fake_matrix_api.dart';
void main() { void main() {
group('Commands', () { group('Commands', tags: 'olm', () {
late Client client; late Client client;
late Room room; late Room room;
var olmEnabled = true;
Map<String, dynamic> getLastMessagePayload( Map<String, dynamic> getLastMessagePayload(
[String type = 'm.room.message', String? stateKey]) { [String type = 'm.room.message', String? stateKey]) {
@ -43,12 +41,6 @@ void main() {
} }
test('setupClient', () async { test('setupClient', () async {
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
}
client = await getClient(); client = await getClient();
room = Room(id: '!1234:fakeServer.notExisting', client: client); room = Room(id: '!1234:fakeServer.notExisting', client: client);
room.setState(Event( room.setState(Event(
@ -398,18 +390,16 @@ void main() {
}); });
test('discardsession', () async { test('discardsession', () async {
if (olmEnabled) { await client.encryption?.keyManager.createOutboundGroupSession(room.id);
await client.encryption?.keyManager.createOutboundGroupSession(room.id); expect(
expect( client.encryption?.keyManager.getOutboundGroupSession(room.id) !=
client.encryption?.keyManager.getOutboundGroupSession(room.id) != null,
null, true);
true); await room.sendTextEvent('/discardsession');
await room.sendTextEvent('/discardsession'); expect(
expect( client.encryption?.keyManager.getOutboundGroupSession(room.id) !=
client.encryption?.keyManager.getOutboundGroupSession(room.id) != null,
null, false);
false);
}
}); });
test('markasdm', () async { test('markasdm', () async {

View File

@ -20,7 +20,6 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
@ -44,7 +43,7 @@ void main() {
}; };
for (final databaseBuilder in databaseBuilders.entries) { for (final databaseBuilder in databaseBuilders.entries) {
group('Test ${databaseBuilder.key}', () { group('Test ${databaseBuilder.key}', tags: 'olm', () {
late DatabaseApi database; late DatabaseApi database;
late int toDeviceQueueIndex; late int toDeviceQueueIndex;
@ -372,7 +371,6 @@ void main() {
expect(olm.isEmpty, true); expect(olm.isEmpty, true);
}); });
test('storeOlmSession', () async { test('storeOlmSession', () async {
if (!(await olmEnabled())) return;
await database.storeOlmSession( await database.storeOlmSession(
'identityKey', 'identityKey',
'sessionId', 'sessionId',
@ -393,7 +391,6 @@ void main() {
expect(session, null); expect(session, null);
}); });
test('storeOutboundGroupSession', () async { test('storeOutboundGroupSession', () async {
if (!(await olmEnabled())) return;
await database.storeOutboundGroupSession( await database.storeOutboundGroupSession(
'!testroom:example.com', '!testroom:example.com',
'pickle', 'pickle',
@ -531,14 +528,3 @@ void main() {
}); });
} }
} }
Future<bool> olmEnabled() async {
var olmEnabled = true;
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
}
return olmEnabled;
}

View File

@ -18,7 +18,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
@ -27,29 +26,16 @@ import './fake_matrix_api.dart';
void main() { void main() {
/// All Tests related to device keys /// All Tests related to device keys
group('Device keys', () { group('Device keys', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
late Client client; late Client client;
test('setupClient', () async { test('setupClient', () async {
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
client = await getClient(); client = await getClient();
}); });
test('fromJson', () async { test('fromJson', () async {
if (!olmEnabled) return;
var rawJson = <String, dynamic>{ var rawJson = <String, dynamic>{
'user_id': '@alice:example.com', 'user_id': '@alice:example.com',
'device_id': 'JLAFKJWSCS', 'device_id': 'JLAFKJWSCS',
@ -94,7 +80,6 @@ void main() {
}); });
test('reject devices without self-signature', () async { test('reject devices without self-signature', () async {
if (!olmEnabled) return;
var key = DeviceKeys.fromJson({ var key = DeviceKeys.fromJson({
'user_id': '@test:fakeServer.notExisting', 'user_id': '@test:fakeServer.notExisting',
'device_id': 'BADDEVICE', 'device_id': 'BADDEVICE',
@ -131,7 +116,6 @@ void main() {
}); });
test('set blocked / verified', () async { test('set blocked / verified', () async {
if (!olmEnabled) return;
final key = final key =
client.userDeviceKeys[client.userID]!.deviceKeys['OTHERDEVICE']!; client.userDeviceKeys[client.userID]!.deviceKeys['OTHERDEVICE']!;
client.userDeviceKeys[client.userID]?.deviceKeys['UNSIGNEDDEVICE'] = client.userDeviceKeys[client.userID]?.deviceKeys['UNSIGNEDDEVICE'] =
@ -212,7 +196,6 @@ void main() {
}); });
test('verification based on signatures', () async { test('verification based on signatures', () async {
if (!olmEnabled) return;
final user = client.userDeviceKeys[client.userID]!; final user = client.userDeviceKeys[client.userID]!;
user.masterKey?.setDirectVerified(true); user.masterKey?.setDirectVerified(true);
expect(user.deviceKeys['GHTYAJCE']?.crossVerified, true); expect(user.deviceKeys['GHTYAJCE']?.crossVerified, true);
@ -248,7 +231,6 @@ void main() {
}); });
test('start verification', () async { test('start verification', () async {
if (!olmEnabled) return;
var req = await client var req = await client
.userDeviceKeys['@alice:example.com']?.deviceKeys['JLAFKJWSCS'] .userDeviceKeys['@alice:example.com']?.deviceKeys['JLAFKJWSCS']
?.startVerification(); ?.startVerification();
@ -262,7 +244,6 @@ void main() {
}); });
test('dispose client', () async { test('dispose client', () async {
if (!olmEnabled) return;
await client.dispose(closeDatabase: true); await client.dispose(closeDatabase: true);
}); });
}); });

View File

@ -27,30 +27,20 @@ import 'package:matrix/matrix.dart';
import '../fake_client.dart'; import '../fake_client.dart';
void main() { void main() {
group('Bootstrap', () { group('Bootstrap', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
late Client client; late Client client;
late Map<String, dynamic> oldSecret; late Map<String, dynamic> oldSecret;
late String origKeyId; late String origKeyId;
test('setupClient', () async { setUpAll(() async {
await olm.init();
olm.get_library_version();
client = await getClient(); client = await getClient();
await client.abortSync();
}); });
test('setup', () async { test('setup', () async {
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
Bootstrap? bootstrap; Bootstrap? bootstrap;
bootstrap = client.encryption!.bootstrap( bootstrap = client.encryption!.bootstrap(
onUpdate: (bootstrap) async { onUpdate: (bootstrap) async {
@ -105,7 +95,6 @@ void main() {
}, timeout: Timeout(Duration(minutes: 2))); }, timeout: Timeout(Duration(minutes: 2)));
test('change recovery passphrase', () async { test('change recovery passphrase', () async {
if (!olmEnabled) return;
Bootstrap? bootstrap; Bootstrap? bootstrap;
bootstrap = client.encryption!.bootstrap( bootstrap = client.encryption!.bootstrap(
onUpdate: (bootstrap) async { onUpdate: (bootstrap) async {
@ -153,7 +142,6 @@ void main() {
}, timeout: Timeout(Duration(minutes: 2))); }, timeout: Timeout(Duration(minutes: 2)));
test('change passphrase with multiple keys', () async { test('change passphrase with multiple keys', () async {
if (!olmEnabled) return;
await client.setAccountData(client.userID!, 'foxes', oldSecret); await client.setAccountData(client.userID!, 'foxes', oldSecret);
await Future.delayed(Duration(milliseconds: 50)); await Future.delayed(Duration(milliseconds: 50));
@ -206,7 +194,6 @@ void main() {
}, timeout: Timeout(Duration(minutes: 2))); }, timeout: Timeout(Duration(minutes: 2)));
test('setup new ssss', () async { test('setup new ssss', () async {
if (!olmEnabled) return;
client.accountData.clear(); client.accountData.clear();
Bootstrap? bootstrap; Bootstrap? bootstrap;
bootstrap = client.encryption!.bootstrap( bootstrap = client.encryption!.bootstrap(
@ -229,7 +216,6 @@ void main() {
}, timeout: Timeout(Duration(minutes: 2))); }, timeout: Timeout(Duration(minutes: 2)));
test('bad ssss', () async { test('bad ssss', () async {
if (!olmEnabled) return;
client.accountData.clear(); client.accountData.clear();
await client.setAccountData(client.userID!, 'foxes', oldSecret); await client.setAccountData(client.userID!, 'foxes', oldSecret);
await Future.delayed(Duration(milliseconds: 50)); await Future.delayed(Duration(milliseconds: 50));
@ -252,7 +238,6 @@ void main() {
}); });
test('dispose client', () async { test('dispose client', () async {
if (!olmEnabled) return;
await client.dispose(closeDatabase: true); await client.dispose(closeDatabase: true);
}); });
}); });

View File

@ -26,33 +26,22 @@ import '../fake_client.dart';
import '../fake_matrix_api.dart'; import '../fake_matrix_api.dart';
void main() { void main() {
group('Cross Signing', () { group('Cross Signing', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
late Client client; late Client client;
test('setupClient', () async { setUpAll(() async {
try { await olm.init();
await olm.init(); olm.get_library_version();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
client = await getClient(); client = await getClient();
}); });
test('basic things', () async { test('basic things', () async {
if (!olmEnabled) return;
expect(client.encryption?.crossSigning.enabled, true); expect(client.encryption?.crossSigning.enabled, true);
}); });
test('selfSign', () async { test('selfSign', () async {
if (!olmEnabled) return;
final key = client.userDeviceKeys[client.userID]!.masterKey!; final key = client.userDeviceKeys[client.userID]!.masterKey!;
key.setDirectVerified(false); key.setDirectVerified(false);
FakeMatrixApi.calledEndpoints.clear(); FakeMatrixApi.calledEndpoints.clear();
@ -66,7 +55,6 @@ void main() {
}); });
test('signable', () async { test('signable', () async {
if (!olmEnabled) return;
expect( expect(
client.encryption!.crossSigning client.encryption!.crossSigning
.signable([client.userDeviceKeys[client.userID!]!.masterKey!]), .signable([client.userDeviceKeys[client.userID!]!.masterKey!]),
@ -90,7 +78,6 @@ void main() {
}); });
test('sign', () async { test('sign', () async {
if (!olmEnabled) return;
FakeMatrixApi.calledEndpoints.clear(); FakeMatrixApi.calledEndpoints.clear();
await client.encryption!.crossSigning.sign([ await client.encryption!.crossSigning.sign([
client.userDeviceKeys[client.userID!]!.masterKey!, client.userDeviceKeys[client.userID!]!.masterKey!,
@ -114,7 +101,6 @@ void main() {
}); });
test('dispose client', () async { test('dispose client', () async {
if (!olmEnabled) return;
await client.dispose(closeDatabase: true); await client.dispose(closeDatabase: true);
}); });
}); });

View File

@ -23,9 +23,8 @@ import 'package:matrix/matrix.dart';
import '../fake_client.dart'; import '../fake_client.dart';
void main() { void main() {
group('Encrypt/Decrypt room message', () { group('Encrypt/Decrypt room message', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
late Client client; late Client client;
final roomId = '!726s6s6q:example.com'; final roomId = '!726s6s6q:example.com';
@ -33,23 +32,14 @@ void main() {
late Map<String, dynamic> payload; late Map<String, dynamic> payload;
final now = DateTime.now(); final now = DateTime.now();
test('setupClient', () async { setUpAll(() async {
try { await olm.init();
await olm.init(); olm.get_library_version();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
client = await getClient(); client = await getClient();
room = client.getRoomById(roomId)!; room = client.getRoomById(roomId)!;
}); });
test('encrypt payload', () async { test('encrypt payload', () async {
if (!olmEnabled) return;
payload = await client.encryption!.encryptGroupMessagePayload(roomId, { payload = await client.encryption!.encryptGroupMessagePayload(roomId, {
'msgtype': 'm.text', 'msgtype': 'm.text',
'text': 'Hello foxies!', 'text': 'Hello foxies!',
@ -62,7 +52,6 @@ void main() {
}); });
test('decrypt payload', () async { test('decrypt payload', () async {
if (!olmEnabled) return;
final encryptedEvent = Event( final encryptedEvent = Event(
type: EventTypes.Encrypted, type: EventTypes.Encrypted,
content: payload, content: payload,
@ -80,7 +69,6 @@ void main() {
}); });
test('decrypt payload without device_id', () async { test('decrypt payload without device_id', () async {
if (!olmEnabled) return;
payload.remove('device_id'); payload.remove('device_id');
payload.remove('sender_key'); payload.remove('sender_key');
final encryptedEvent = Event( final encryptedEvent = Event(
@ -100,7 +88,6 @@ void main() {
}); });
test('decrypt payload nocache', () async { test('decrypt payload nocache', () async {
if (!olmEnabled) return;
client.encryption!.keyManager.clearInboundGroupSessions(); client.encryption!.keyManager.clearInboundGroupSessions();
final encryptedEvent = Event( final encryptedEvent = Event(
type: EventTypes.Encrypted, type: EventTypes.Encrypted,
@ -120,7 +107,6 @@ void main() {
}); });
test('dispose client', () async { test('dispose client', () async {
if (!olmEnabled) return;
await client.dispose(closeDatabase: true); await client.dispose(closeDatabase: true);
}); });
}); });

View File

@ -29,9 +29,8 @@ void main() {
const otherPickledOlmAccount = const otherPickledOlmAccount =
'VWhVApbkcilKAEGppsPDf9nNVjaK8/IxT3asSR0sYg0S5KgbfE8vXEPwoiKBX2cEvwX3OessOBOkk+ZE7TTbjlrh/KEd31p8Wo+47qj0AP+Ky+pabnhi+/rTBvZy+gfzTqUfCxZrkzfXI9Op4JnP6gYmy7dVX2lMYIIs9WCO1jcmIXiXum5jnfXu1WLfc7PZtO2hH+k9CDKosOFaXRBmsu8k/BGXPSoWqUpvu6WpEG9t5STk4FeAzA'; 'VWhVApbkcilKAEGppsPDf9nNVjaK8/IxT3asSR0sYg0S5KgbfE8vXEPwoiKBX2cEvwX3OessOBOkk+ZE7TTbjlrh/KEd31p8Wo+47qj0AP+Ky+pabnhi+/rTBvZy+gfzTqUfCxZrkzfXI9Op4JnP6gYmy7dVX2lMYIIs9WCO1jcmIXiXum5jnfXu1WLfc7PZtO2hH+k9CDKosOFaXRBmsu8k/BGXPSoWqUpvu6WpEG9t5STk4FeAzA';
group('Encrypt/Decrypt to-device messages', () { group('Encrypt/Decrypt to-device messages', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
late Client client; late Client client;
final otherClient = Client('othertestclient', final otherClient = Client('othertestclient',
@ -39,17 +38,13 @@ void main() {
late DeviceKeys device; late DeviceKeys device;
late Map<String, dynamic> payload; late Map<String, dynamic> payload;
test('setupClient', () async { setUpAll(() async {
try { await olm.init();
await olm.init(); olm.get_library_version();
olm.get_library_version(); client = await getClient();
} catch (e) { });
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
test('setupClient', () async {
client = await getClient(); client = await getClient();
await client.abortSync(); await client.abortSync();
await otherClient.checkHomeserver( await otherClient.checkHomeserver(
@ -81,13 +76,11 @@ void main() {
}); });
test('encryptToDeviceMessage', () async { test('encryptToDeviceMessage', () async {
if (!olmEnabled) return;
payload = await otherClient.encryption! payload = await otherClient.encryption!
.encryptToDeviceMessage([device], 'm.to_device', {'hello': 'foxies'}); .encryptToDeviceMessage([device], 'm.to_device', {'hello': 'foxies'});
}); });
test('decryptToDeviceEvent', () async { test('decryptToDeviceEvent', () async {
if (!olmEnabled) return;
final encryptedEvent = ToDeviceEvent( final encryptedEvent = ToDeviceEvent(
sender: '@othertest:fakeServer.notExisting', sender: '@othertest:fakeServer.notExisting',
type: EventTypes.Encrypted, type: EventTypes.Encrypted,
@ -100,7 +93,6 @@ void main() {
}); });
test('decryptToDeviceEvent nocache', () async { test('decryptToDeviceEvent nocache', () async {
if (!olmEnabled) return;
client.encryption!.olmManager.olmSessions.clear(); client.encryption!.olmManager.olmSessions.clear();
payload = await otherClient.encryption!.encryptToDeviceMessage( payload = await otherClient.encryption!.encryptToDeviceMessage(
[device], 'm.to_device', {'hello': 'superfoxies'}); [device], 'm.to_device', {'hello': 'superfoxies'});
@ -116,7 +108,6 @@ void main() {
}); });
test('dispose client', () async { test('dispose client', () async {
if (!olmEnabled) return;
await client.dispose(closeDatabase: true); await client.dispose(closeDatabase: true);
await otherClient.dispose(closeDatabase: true); await otherClient.dispose(closeDatabase: true);
}); });

View File

@ -26,28 +26,17 @@ import '../fake_client.dart';
import '../fake_matrix_api.dart'; import '../fake_matrix_api.dart';
void main() { void main() {
group('Key Manager', () { group('Key Manager', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
late Client client; late Client client;
test('setupClient', () async { setUpAll(() async {
try { await olm.init();
await olm.init(); olm.get_library_version();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
client = await getClient(); client = await getClient();
}); });
test('handle new m.room_key', () async { test('handle new m.room_key', () async {
if (!olmEnabled) return;
final validSessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; final validSessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
final validSenderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg'; final validSenderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg';
final sessionKey = final sessionKey =
@ -95,7 +84,6 @@ void main() {
}); });
test('outbound group session', () async { test('outbound group session', () async {
if (!olmEnabled) return;
final roomId = '!726s6s6q:example.com'; final roomId = '!726s6s6q:example.com';
expect( expect(
client.encryption!.keyManager.getOutboundGroupSession(roomId) != null, client.encryption!.keyManager.getOutboundGroupSession(roomId) != null,
@ -270,7 +258,6 @@ void main() {
}); });
test('inbound group session', () async { test('inbound group session', () async {
if (!olmEnabled) return;
final roomId = '!726s6s6q:example.com'; final roomId = '!726s6s6q:example.com';
final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
final senderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg'; final senderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg';
@ -324,7 +311,6 @@ void main() {
}); });
test('setInboundGroupSession', () async { test('setInboundGroupSession', () async {
if (!olmEnabled) return;
final session = olm.OutboundGroupSession(); final session = olm.OutboundGroupSession();
session.create(); session.create();
final inbound = olm.InboundGroupSession(); final inbound = olm.InboundGroupSession();
@ -495,7 +481,6 @@ void main() {
}); });
test('Reused deviceID attack', () async { test('Reused deviceID attack', () async {
if (!olmEnabled) return;
Logs().level = Level.warning; Logs().level = Level.warning;
// Ensure the device came from sync // Ensure the device came from sync
@ -542,7 +527,6 @@ void main() {
}); });
test('dispose client', () async { test('dispose client', () async {
if (!olmEnabled) return;
await client.dispose(closeDatabase: false); await client.dispose(closeDatabase: false);
}); });
}); });

View File

@ -39,23 +39,17 @@ Map<String, dynamic> jsonDecode(dynamic payload) {
void main() { void main() {
/// All Tests related to device keys /// All Tests related to device keys
group('Key Request', () { group('Key Request', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
setUpAll(() async {
await olm.init();
olm.get_library_version();
});
final validSessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; final validSessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
final validSenderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg'; final validSenderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg';
test('Create Request', () async { test('Create Request', () async {
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
final matrix = await getClient(); final matrix = await getClient();
final requestRoom = matrix.getRoomById('!726s6s6q:example.com')!; final requestRoom = matrix.getRoomById('!726s6s6q:example.com')!;
await matrix.encryption!.keyManager.request( await matrix.encryption!.keyManager.request(
@ -82,7 +76,6 @@ void main() {
await matrix.dispose(closeDatabase: true); await matrix.dispose(closeDatabase: true);
}); });
test('Reply To Request', () async { test('Reply To Request', () async {
if (!olmEnabled) return;
final matrix = await getClient(); final matrix = await getClient();
matrix.setUserId('@alice:example.com'); // we need to pretend to be alice matrix.setUserId('@alice:example.com'); // we need to pretend to be alice
FakeMatrixApi.calledEndpoints.clear(); FakeMatrixApi.calledEndpoints.clear();
@ -277,7 +270,6 @@ void main() {
await matrix.dispose(closeDatabase: true); await matrix.dispose(closeDatabase: true);
}); });
test('Receive shared keys', () async { test('Receive shared keys', () async {
if (!olmEnabled) return;
final matrix = await getClient(); final matrix = await getClient();
final requestRoom = matrix.getRoomById('!726s6s6q:example.com')!; final requestRoom = matrix.getRoomById('!726s6s6q:example.com')!;
await matrix.encryption!.keyManager.request( await matrix.encryption!.keyManager.request(

View File

@ -48,20 +48,8 @@ EventUpdate getLastSentEvent(KeyVerification req) {
} }
void main() async { void main() async {
var olmEnabled = true;
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
final dynamic skip = olmEnabled ? false : 'olm library not available';
/// All Tests related to the ChatTime /// All Tests related to the ChatTime
group('Key Verification', () { group('Key Verification', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
// key @othertest:fakeServer.notExisting // key @othertest:fakeServer.notExisting
@ -70,6 +58,12 @@ void main() async {
late Client client1; late Client client1;
late Client client2; late Client client2;
setUpAll(() async {
await olm.init();
olm.get_library_version();
});
setUp(() async { setUp(() async {
client1 = await getClient(); client1 = await getClient();
client2 = Client( client2 = Client(
@ -101,7 +95,11 @@ void main() async {
KeyVerificationMethod.qrShow, KeyVerificationMethod.qrShow,
KeyVerificationMethod.reciprocate KeyVerificationMethod.reciprocate
}; };
// get client2 device keys to start verification
await client1.updateUserDeviceKeys(additionalUsers: {client2.userID!});
}); });
tearDown(() async { tearDown(() async {
await client1.dispose(closeDatabase: true); await client1.dispose(closeDatabase: true);
await client2.dispose(closeDatabase: true); await client2.dispose(closeDatabase: true);
@ -810,5 +808,5 @@ void main() async {
await client1.encryption!.keyVerificationManager.cleanup(); await client1.encryption!.keyVerificationManager.cleanup();
await client2.encryption!.keyVerificationManager.cleanup(); await client2.encryption!.keyVerificationManager.cleanup();
}); });
}, skip: skip); });
} }

View File

@ -27,29 +27,18 @@ import '../fake_client.dart';
import '../fake_matrix_api.dart'; import '../fake_matrix_api.dart';
void main() { void main() {
group('Olm Manager', () { group('Olm Manager', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
late Client client; late Client client;
setUp(() async { setUpAll(() async {
try { await olm.init();
await olm.init(); olm.get_library_version();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return Future.value();
client = await getClient(); client = await getClient();
return Future.value();
}); });
test('signatures', () async { test('signatures', () async {
if (!olmEnabled) return;
final payload = <String, dynamic>{ final payload = <String, dynamic>{
'fox': 'floof', 'fox': 'floof',
}; };
@ -61,7 +50,6 @@ void main() {
}); });
test('uploadKeys', () async { test('uploadKeys', () async {
if (!olmEnabled) return;
FakeMatrixApi.calledEndpoints.clear(); FakeMatrixApi.calledEndpoints.clear();
final res = await client.encryption!.olmManager final res = await client.encryption!.olmManager
.uploadKeys(uploadDeviceKeys: true); .uploadKeys(uploadDeviceKeys: true);
@ -89,8 +77,6 @@ void main() {
}); });
test('handleDeviceOneTimeKeysCount', () async { test('handleDeviceOneTimeKeysCount', () async {
if (!olmEnabled) return;
FakeMatrixApi.calledEndpoints.clear(); FakeMatrixApi.calledEndpoints.clear();
await client.encryption!.olmManager await client.encryption!.olmManager
.handleDeviceOneTimeKeysCount({'signed_curve25519': 20}, null); .handleDeviceOneTimeKeysCount({'signed_curve25519': 20}, null);
@ -127,7 +113,6 @@ void main() {
}); });
test('restoreOlmSession', () async { test('restoreOlmSession', () async {
if (!olmEnabled) return;
client.encryption!.olmManager.olmSessions.clear(); client.encryption!.olmManager.olmSessions.clear();
await client.encryption!.olmManager await client.encryption!.olmManager
.restoreOlmSession(client.userID!, client.identityKey); .restoreOlmSession(client.userID!, client.identityKey);
@ -145,7 +130,6 @@ void main() {
}); });
test('startOutgoingOlmSessions', () async { test('startOutgoingOlmSessions', () async {
if (!olmEnabled) return;
// start an olm session.....with ourself! // start an olm session.....with ourself!
client.encryption!.olmManager.olmSessions.clear(); client.encryption!.olmManager.olmSessions.clear();
await client.encryption!.olmManager.startOutgoingOlmSessions([ await client.encryption!.olmManager.startOutgoingOlmSessions([
@ -158,7 +142,6 @@ void main() {
}); });
test('replay to_device events', () async { test('replay to_device events', () async {
if (!olmEnabled) return;
final userId = '@alice:example.com'; final userId = '@alice:example.com';
final deviceId = 'JLAFKJWSCS'; final deviceId = 'JLAFKJWSCS';
final senderKey = 'L+4+JCl8MD63dgo8z5Ta+9QAHXiANyOVSfgbHA5d3H8'; final senderKey = 'L+4+JCl8MD63dgo8z5Ta+9QAHXiANyOVSfgbHA5d3H8';
@ -261,7 +244,6 @@ void main() {
}); });
test('dispose client', () async { test('dispose client', () async {
if (!olmEnabled) return;
await client.dispose(closeDatabase: true); await client.dispose(closeDatabase: true);
}); });
}); });

View File

@ -26,9 +26,8 @@ import '../fake_client.dart';
import '../fake_matrix_api.dart'; import '../fake_matrix_api.dart';
void main() { void main() {
group('Online Key Backup', () { group('Online Key Backup', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
late Client client; late Client client;
@ -36,22 +35,13 @@ void main() {
final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
final senderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg'; final senderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg';
test('setupClient', () async { setUpAll(() async {
try { await olm.init();
await olm.init(); olm.get_library_version();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
client = await getClient(); client = await getClient();
}); });
test('basic things', () async { test('basic things', () async {
if (!olmEnabled) return;
expect(client.encryption!.keyManager.enabled, true); expect(client.encryption!.keyManager.enabled, true);
expect(await client.encryption!.keyManager.isCached(), false); expect(await client.encryption!.keyManager.isCached(), false);
final handle = client.encryption!.ssss.open(); final handle = client.encryption!.ssss.open();
@ -61,7 +51,6 @@ void main() {
}); });
test('load key', () async { test('load key', () async {
if (!olmEnabled) return;
client.encryption!.keyManager.clearInboundGroupSessions(); client.encryption!.keyManager.clearInboundGroupSessions();
await client.encryption!.keyManager await client.encryption!.keyManager
.request(client.getRoomById(roomId)!, sessionId, senderKey); .request(client.getRoomById(roomId)!, sessionId, senderKey);
@ -73,7 +62,6 @@ void main() {
}); });
test('Load all Room Keys', () async { test('Load all Room Keys', () async {
if (!olmEnabled) return;
final keyManager = client.encryption!.keyManager; final keyManager = client.encryption!.keyManager;
const roomId = '!getroomkeys726s6s6q:example.com'; const roomId = '!getroomkeys726s6s6q:example.com';
const sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; const sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
@ -86,7 +74,6 @@ void main() {
}); });
test('Load all Keys', () async { test('Load all Keys', () async {
if (!olmEnabled) return;
final keyManager = client.encryption!.keyManager; final keyManager = client.encryption!.keyManager;
const roomId = '!getallkeys726s6s6q:example.com'; const roomId = '!getallkeys726s6s6q:example.com';
const sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; const sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
@ -99,7 +86,6 @@ void main() {
}); });
test('upload key', () async { test('upload key', () async {
if (!olmEnabled) return;
final session = olm.OutboundGroupSession(); final session = olm.OutboundGroupSession();
session.create(); session.create();
final inbound = olm.InboundGroupSession(); final inbound = olm.InboundGroupSession();
@ -143,7 +129,6 @@ void main() {
}); });
test('dispose client', () async { test('dispose client', () async {
if (!olmEnabled) return;
await client.dispose(closeDatabase: false); await client.dispose(closeDatabase: false);
}); });
}); });

View File

@ -19,7 +19,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/encryption.dart'; import 'package:matrix/encryption.dart';
@ -62,20 +61,8 @@ void main() async {
); );
} }
var olmEnabled = true;
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
final dynamic skip = olmEnabled ? false : 'olm library not available';
/// All Tests related to the ChatTime /// All Tests related to the ChatTime
group('Key Verification', () { group('Key Verification', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
late Client client1; late Client client1;
@ -532,5 +519,5 @@ void main() async {
await client1.encryption!.keyVerificationManager.cleanup(); await client1.encryption!.keyVerificationManager.cleanup();
await client2.encryption!.keyVerificationManager.cleanup(); await client2.encryption!.keyVerificationManager.cleanup();
}); });
}, skip: skip); });
} }

View File

@ -49,34 +49,23 @@ class MockSSSS extends SSSS {
} }
void main() { void main() {
group('SSSS', () { group('SSSS', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
late Client client; late Client client;
test('setupClient', () async { setUpAll(() async {
try { await olm.init();
await olm.init(); olm.get_library_version();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
if (!olmEnabled) return;
client = await getClient(); client = await getClient();
}); });
test('basic things', () async { test('basic things', () async {
if (!olmEnabled) return;
expect(client.encryption!.ssss.defaultKeyId, expect(client.encryption!.ssss.defaultKeyId,
'0FajDWYaM6wQ4O60OZnLvwZfsBNu4Bu3'); '0FajDWYaM6wQ4O60OZnLvwZfsBNu4Bu3');
}); });
test('encrypt / decrypt', () async { test('encrypt / decrypt', () async {
if (!olmEnabled) return;
final key = Uint8List.fromList(secureRandomBytes(32)); final key = Uint8List.fromList(secureRandomBytes(32));
final enc = await SSSS.encryptAes('secret foxies', key, 'name'); final enc = await SSSS.encryptAes('secret foxies', key, 'name');
@ -85,7 +74,6 @@ void main() {
}); });
test('store', () async { test('store', () async {
if (!olmEnabled) return;
final handle = client.encryption!.ssss.open(); final handle = client.encryption!.ssss.open();
var failed = false; var failed = false;
try { try {
@ -125,7 +113,6 @@ void main() {
}); });
test('encode / decode recovery key', () async { test('encode / decode recovery key', () async {
if (!olmEnabled) return;
final key = Uint8List.fromList(secureRandomBytes(32)); final key = Uint8List.fromList(secureRandomBytes(32));
final encoded = SSSS.encodeRecoveryKey(key); final encoded = SSSS.encodeRecoveryKey(key);
var decoded = SSSS.decodeRecoveryKey(encoded); var decoded = SSSS.decodeRecoveryKey(encoded);
@ -140,7 +127,6 @@ void main() {
}); });
test('cache', () async { test('cache', () async {
if (!olmEnabled) return;
await client.encryption!.ssss.clearCache(); await client.encryption!.ssss.clearCache();
final handle = final handle =
client.encryption!.ssss.open(EventTypes.CrossSigningSelfSigning); client.encryption!.ssss.open(EventTypes.CrossSigningSelfSigning);
@ -174,7 +160,6 @@ void main() {
}); });
test('postUnlock', () async { test('postUnlock', () async {
if (!olmEnabled) return;
await client.encryption!.ssss.clearCache(); await client.encryption!.ssss.clearCache();
client.userDeviceKeys[client.userID!]!.masterKey! client.userDeviceKeys[client.userID!]!.masterKey!
.setDirectVerified(false); .setDirectVerified(false);
@ -200,7 +185,6 @@ void main() {
}); });
test('make share requests', () async { test('make share requests', () async {
if (!olmEnabled) return;
final key = final key =
client.userDeviceKeys[client.userID!]!.deviceKeys['OTHERDEVICE']!; client.userDeviceKeys[client.userID!]!.deviceKeys['OTHERDEVICE']!;
key.setDirectVerified(true); key.setDirectVerified(true);
@ -213,7 +197,6 @@ void main() {
}); });
test('answer to share requests', () async { test('answer to share requests', () async {
if (!olmEnabled) return;
var event = ToDeviceEvent( var event = ToDeviceEvent(
sender: client.userID!, sender: client.userID!,
type: 'm.secret.request', type: 'm.secret.request',
@ -313,7 +296,6 @@ void main() {
}); });
test('receive share requests', () async { test('receive share requests', () async {
if (!olmEnabled) return;
final key = final key =
client.userDeviceKeys[client.userID!]!.deviceKeys['OTHERDEVICE']!; client.userDeviceKeys[client.userID!]!.deviceKeys['OTHERDEVICE']!;
key.setDirectVerified(true); key.setDirectVerified(true);
@ -456,7 +438,6 @@ void main() {
}); });
test('request all', () async { test('request all', () async {
if (!olmEnabled) return;
final key = final key =
client.userDeviceKeys[client.userID!]!.deviceKeys['OTHERDEVICE']!; client.userDeviceKeys[client.userID!]!.deviceKeys['OTHERDEVICE']!;
key.setDirectVerified(true); key.setDirectVerified(true);
@ -467,7 +448,6 @@ void main() {
}); });
test('periodicallyRequestMissingCache', () async { test('periodicallyRequestMissingCache', () async {
if (!olmEnabled) return;
client.userDeviceKeys[client.userID!]!.masterKey!.setDirectVerified(true); client.userDeviceKeys[client.userID!]!.masterKey!.setDirectVerified(true);
client.encryption!.ssss = MockSSSS(client.encryption!); client.encryption!.ssss = MockSSSS(client.encryption!);
(client.encryption!.ssss as MockSSSS).requestedSecrets = false; (client.encryption!.ssss as MockSSSS).requestedSecrets = false;
@ -480,7 +460,6 @@ void main() {
}); });
test('createKey', () async { test('createKey', () async {
if (!olmEnabled) return;
// with passphrase // with passphrase
var newKey = await client.encryption!.ssss.createKey('test'); var newKey = await client.encryption!.ssss.createKey('test');
expect(client.encryption!.ssss.isKeyValid(newKey.keyId), true); expect(client.encryption!.ssss.isKeyValid(newKey.keyId), true);
@ -496,7 +475,6 @@ void main() {
}); });
test('dispose client', () async { test('dispose client', () async {
if (!olmEnabled) return;
await client.dispose(closeDatabase: true); await client.dispose(closeDatabase: true);
}); });
}); });

View File

@ -19,7 +19,6 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/encryption.dart'; import 'package:matrix/encryption.dart';
@ -30,9 +29,8 @@ import 'fake_matrix_api.dart';
void main() { void main() {
/// All Tests related to the Event /// All Tests related to the Event
group('Event', () { group('Event', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
final timestamp = DateTime.now().millisecondsSinceEpoch; final timestamp = DateTime.now().millisecondsSinceEpoch;
final id = '!4fsdfjisjf:server.abc'; final id = '!4fsdfjisjf:server.abc';
@ -59,17 +57,6 @@ void main() {
final event = Event.fromJson( final event = Event.fromJson(
jsonObj, Room(id: '!testroom:example.abc', client: client)); jsonObj, Room(id: '!testroom:example.abc', client: client));
test('setup', () async {
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
});
test('Create from json', () async { test('Create from json', () async {
jsonObj.remove('status'); jsonObj.remove('status');
jsonObj['content'] = json.decode(contentJson); jsonObj['content'] = json.decode(contentJson);
@ -1405,109 +1392,117 @@ void main() {
getThumbnail: true, downloadCallback: downloadCallback); getThumbnail: true, downloadCallback: downloadCallback);
expect(buffer.bytes, THUMBNAIL_BUFF); expect(buffer.bytes, THUMBNAIL_BUFF);
}); });
test('encrypted attachments', () async { test(
if (!olmEnabled) return; 'encrypted attachments',
() async {
final FILE_BUFF_ENC =
Uint8List.fromList([0x3B, 0x6B, 0xB2, 0x8C, 0xAF]);
final FILE_BUFF_DEC =
Uint8List.fromList([0x74, 0x65, 0x73, 0x74, 0x0A]);
final THUMB_BUFF_ENC =
Uint8List.fromList([0x55, 0xD7, 0xEB, 0x72, 0x05, 0x13]);
final THUMB_BUFF_DEC =
Uint8List.fromList([0x74, 0x68, 0x75, 0x6D, 0x62, 0x0A]);
Future<Uint8List> downloadCallback(Uri uri) async {
return {
'/_matrix/media/v3/download/example.com/file': FILE_BUFF_ENC,
'/_matrix/media/v3/download/example.com/thumb': THUMB_BUFF_ENC,
}[uri.path]!;
}
final FILE_BUFF_ENC = Uint8List.fromList([0x3B, 0x6B, 0xB2, 0x8C, 0xAF]); final room =
final FILE_BUFF_DEC = Uint8List.fromList([0x74, 0x65, 0x73, 0x74, 0x0A]); Room(id: '!localpart:server.abc', client: await getClient());
final THUMB_BUFF_ENC = var event = Event.fromJson({
Uint8List.fromList([0x55, 0xD7, 0xEB, 0x72, 0x05, 0x13]); 'type': EventTypes.Message,
final THUMB_BUFF_DEC = 'content': {
Uint8List.fromList([0x74, 0x68, 0x75, 0x6D, 0x62, 0x0A]); 'body': 'image',
Future<Uint8List> downloadCallback(Uri uri) async { 'msgtype': 'm.image',
return { 'file': {
'/_matrix/media/v3/download/example.com/file': FILE_BUFF_ENC,
'/_matrix/media/v3/download/example.com/thumb': THUMB_BUFF_ENC,
}[uri.path]!;
}
final room = Room(id: '!localpart:server.abc', client: await getClient());
var event = Event.fromJson({
'type': EventTypes.Message,
'content': {
'body': 'image',
'msgtype': 'm.image',
'file': {
'v': 'v2',
'key': {
'alg': 'A256CTR',
'ext': true,
'k': '7aPRNIDPeUAUqD6SPR3vVX5W9liyMG98NexVJ9udnCc',
'key_ops': ['encrypt', 'decrypt'],
'kty': 'oct'
},
'iv': 'Wdsf+tnOHIoAAAAAAAAAAA',
'hashes': {'sha256': 'WgC7fw2alBC5t+xDx+PFlZxfFJXtIstQCg+j0WDaXxE'},
'url': 'mxc://example.com/file',
'mimetype': 'text/plain'
},
},
'event_id': '\$edit2',
'sender': '@alice:example.org',
}, room);
var buffer = await event.downloadAndDecryptAttachment(
downloadCallback: downloadCallback);
expect(buffer.bytes, FILE_BUFF_DEC);
event = Event.fromJson({
'type': EventTypes.Message,
'content': {
'body': 'image',
'msgtype': 'm.image',
'file': {
'v': 'v2',
'key': {
'alg': 'A256CTR',
'ext': true,
'k': '7aPRNIDPeUAUqD6SPR3vVX5W9liyMG98NexVJ9udnCc',
'key_ops': ['encrypt', 'decrypt'],
'kty': 'oct'
},
'iv': 'Wdsf+tnOHIoAAAAAAAAAAA',
'hashes': {'sha256': 'WgC7fw2alBC5t+xDx+PFlZxfFJXtIstQCg+j0WDaXxE'},
'url': 'mxc://example.com/file',
'mimetype': 'text/plain'
},
'info': {
'thumbnail_file': {
'v': 'v2', 'v': 'v2',
'key': { 'key': {
'alg': 'A256CTR', 'alg': 'A256CTR',
'ext': true, 'ext': true,
'k': 'TmF-rZYetZbxpL5yjDPE21UALQJcpEE6X-nvUDD5rA0', 'k': '7aPRNIDPeUAUqD6SPR3vVX5W9liyMG98NexVJ9udnCc',
'key_ops': ['encrypt', 'decrypt'], 'key_ops': ['encrypt', 'decrypt'],
'kty': 'oct' 'kty': 'oct'
}, },
'iv': '41ZqNRZSLFUAAAAAAAAAAA', 'iv': 'Wdsf+tnOHIoAAAAAAAAAAA',
'hashes': { 'hashes': {
'sha256': 'zccOwXiOTAYhGXyk0Fra7CRreBF6itjiCKdd+ov8mO4' 'sha256': 'WgC7fw2alBC5t+xDx+PFlZxfFJXtIstQCg+j0WDaXxE'
}, },
'url': 'mxc://example.com/thumb', 'url': 'mxc://example.com/file',
'mimetype': 'text/plain' 'mimetype': 'text/plain'
} },
}, },
}, 'event_id': '\$edit2',
'event_id': '\$edit2', 'sender': '@alice:example.org',
'sender': '@alice:example.org', }, room);
}, room); var buffer = await event.downloadAndDecryptAttachment(
expect(event.hasAttachment, true); downloadCallback: downloadCallback);
expect(event.hasThumbnail, true); expect(buffer.bytes, FILE_BUFF_DEC);
expect(event.isAttachmentEncrypted, true);
expect(event.isThumbnailEncrypted, true);
expect(event.attachmentMimetype, 'text/plain');
expect(event.thumbnailMimetype, 'text/plain');
expect(event.attachmentMxcUrl.toString(), 'mxc://example.com/file');
expect(event.thumbnailMxcUrl.toString(), 'mxc://example.com/thumb');
buffer = await event.downloadAndDecryptAttachment(
downloadCallback: downloadCallback);
expect(buffer.bytes, FILE_BUFF_DEC);
buffer = await event.downloadAndDecryptAttachment( event = Event.fromJson({
getThumbnail: true, downloadCallback: downloadCallback); 'type': EventTypes.Message,
expect(buffer.bytes, THUMB_BUFF_DEC); 'content': {
'body': 'image',
'msgtype': 'm.image',
'file': {
'v': 'v2',
'key': {
'alg': 'A256CTR',
'ext': true,
'k': '7aPRNIDPeUAUqD6SPR3vVX5W9liyMG98NexVJ9udnCc',
'key_ops': ['encrypt', 'decrypt'],
'kty': 'oct'
},
'iv': 'Wdsf+tnOHIoAAAAAAAAAAA',
'hashes': {
'sha256': 'WgC7fw2alBC5t+xDx+PFlZxfFJXtIstQCg+j0WDaXxE'
},
'url': 'mxc://example.com/file',
'mimetype': 'text/plain'
},
'info': {
'thumbnail_file': {
'v': 'v2',
'key': {
'alg': 'A256CTR',
'ext': true,
'k': 'TmF-rZYetZbxpL5yjDPE21UALQJcpEE6X-nvUDD5rA0',
'key_ops': ['encrypt', 'decrypt'],
'kty': 'oct'
},
'iv': '41ZqNRZSLFUAAAAAAAAAAA',
'hashes': {
'sha256': 'zccOwXiOTAYhGXyk0Fra7CRreBF6itjiCKdd+ov8mO4'
},
'url': 'mxc://example.com/thumb',
'mimetype': 'text/plain'
}
},
},
'event_id': '\$edit2',
'sender': '@alice:example.org',
}, room);
expect(event.hasAttachment, true);
expect(event.hasThumbnail, true);
expect(event.isAttachmentEncrypted, true);
expect(event.isThumbnailEncrypted, true);
expect(event.attachmentMimetype, 'text/plain');
expect(event.thumbnailMimetype, 'text/plain');
expect(event.attachmentMxcUrl.toString(), 'mxc://example.com/file');
expect(event.thumbnailMxcUrl.toString(), 'mxc://example.com/thumb');
buffer = await event.downloadAndDecryptAttachment(
downloadCallback: downloadCallback);
expect(buffer.bytes, FILE_BUFF_DEC);
await room.client.dispose(closeDatabase: true); buffer = await event.downloadAndDecryptAttachment(
}); getThumbnail: true, downloadCallback: downloadCallback);
expect(buffer.bytes, THUMB_BUFF_DEC);
await room.client.dispose(closeDatabase: true);
},
);
test('downloadAndDecryptAttachment store', () async { test('downloadAndDecryptAttachment store', () async {
final FILE_BUFF = Uint8List.fromList([0]); final FILE_BUFF = Uint8List.fromList([0]);
var serverHits = 0; var serverHits = 0;

View File

@ -477,8 +477,8 @@ class FakeMatrixApi extends BaseClient {
'join': { 'join': {
'!726s6s6q:example.com': { '!726s6s6q:example.com': {
'summary': { 'summary': {
'm.heroes': ['@alice:example.com', '@bob:example.com'], 'm.heroes': ['@alice:example.com'],
'm.joined_member_count': 2, 'm.joined_member_count': 1,
'm.invited_member_count': 0 'm.invited_member_count': 0
}, },
'unread_notifications': { 'unread_notifications': {

View File

@ -19,14 +19,13 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
void main() { void main() {
/// All Tests related to device keys /// All Tests related to device keys
group('Matrix File', () { group('Matrix File', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
test('Decrypt', () async { test('Decrypt', () async {
final text = 'hello world'; final text = 'hello world';
@ -34,17 +33,9 @@ void main() {
name: 'file.txt', name: 'file.txt',
bytes: Uint8List.fromList(text.codeUnits), bytes: Uint8List.fromList(text.codeUnits),
); );
var olmEnabled = true;
try { final encryptedFile = await file.encrypt();
await olm.init(); expect(encryptedFile.data.isNotEmpty, true);
olm.Account();
} catch (_) {
olmEnabled = false;
}
if (olmEnabled) {
final encryptedFile = await file.encrypt();
expect(encryptedFile.data.isNotEmpty, true);
}
}); });
test('Shrink', () async { test('Shrink', () async {

View File

@ -18,7 +18,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
@ -28,7 +27,6 @@ void main() {
/// All Tests related to the Event /// All Tests related to the Event
group('Event', () { group('Event', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
final timestamp = DateTime.now().millisecondsSinceEpoch; final timestamp = DateTime.now().millisecondsSinceEpoch;
final id = '!4fsdfjisjf:server.abc'; final id = '!4fsdfjisjf:server.abc';
@ -54,14 +52,6 @@ void main() {
late Room room; late Room room;
setUpAll(() async { setUpAll(() async {
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
client = await getClient(); client = await getClient();
room = Room(id: '!testroom:example.abc', client: client); room = Room(id: '!testroom:example.abc', client: client);
}); });

View File

@ -18,7 +18,6 @@
import 'dart:async'; import 'dart:async';
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
@ -27,22 +26,12 @@ import 'fake_client.dart';
void main() { void main() {
group('Timeline', () { group('Timeline', () {
Logs().level = Level.error; Logs().level = Level.error;
var olmEnabled = true;
final insertList = <int>[]; final insertList = <int>[];
late Client client; late Client client;
setUp(() async { setUp(() async {
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
client = await getClient(); client = await getClient();
client.sendMessageTimeoutSeconds = 5; client.sendMessageTimeoutSeconds = 5;

View File

@ -18,7 +18,6 @@
import 'dart:async'; import 'dart:async';
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
@ -27,7 +26,7 @@ import 'fake_client.dart';
import 'fake_matrix_api.dart'; import 'fake_matrix_api.dart';
void main() { void main() {
group('Timeline context', () { group('Timeline context', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
final roomID = '!1234:example.com'; final roomID = '!1234:example.com';
var testTimeStamp = 0; var testTimeStamp = 0;
@ -35,7 +34,6 @@ void main() {
final insertList = <int>[]; final insertList = <int>[];
final changeList = <int>[]; final changeList = <int>[];
final removeList = <int>[]; final removeList = <int>[];
var olmEnabled = true;
final countStream = StreamController<int>.broadcast(); final countStream = StreamController<int>.broadcast();
Future<int> waitForCount(int count) async { Future<int> waitForCount(int count) async {
@ -65,14 +63,6 @@ void main() {
late Room room; late Room room;
late Timeline timeline; late Timeline timeline;
setUp(() async { setUp(() async {
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
client = await getClient(); client = await getClient();
client.sendMessageTimeoutSeconds = 5; client.sendMessageTimeoutSeconds = 5;
@ -318,11 +308,9 @@ void main() {
event = await timeline.getEventById('unencrypted_event'); event = await timeline.getEventById('unencrypted_event');
expect(event?.body, 'This is an example text message'); expect(event?.body, 'This is an example text message');
if (olmEnabled) { event = await timeline.getEventById('encrypted_event');
event = await timeline.getEventById('encrypted_event'); // the event is invalid but should have traces of attempting to decrypt
// the event is invalid but should have traces of attempting to decrypt expect(event?.messageType, MessageTypes.BadEncrypted);
expect(event?.messageType, MessageTypes.BadEncrypted);
}
}); });
test('Resend message', () async { test('Resend message', () async {

View File

@ -19,7 +19,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:math'; import 'dart:math';
import 'package:olm/olm.dart' as olm;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
@ -27,7 +26,7 @@ import 'package:matrix/src/models/timeline_chunk.dart';
import 'fake_client.dart'; import 'fake_client.dart';
void main() { void main() {
group('Timeline', () { group('Timeline', tags: 'olm', () {
Logs().level = Level.error; Logs().level = Level.error;
final roomID = '!1234:example.com'; final roomID = '!1234:example.com';
var testTimeStamp = 0; var testTimeStamp = 0;
@ -35,7 +34,6 @@ void main() {
final insertList = <int>[]; final insertList = <int>[];
final changeList = <int>[]; final changeList = <int>[];
final removeList = <int>[]; final removeList = <int>[];
var olmEnabled = true;
var currentPoison = 0; var currentPoison = 0;
final countStream = StreamController<int>.broadcast(); final countStream = StreamController<int>.broadcast();
@ -66,14 +64,6 @@ void main() {
late Room room; late Room room;
late Timeline timeline; late Timeline timeline;
setUp(() async { setUp(() async {
try {
await olm.init();
olm.get_library_version();
} catch (e) {
olmEnabled = false;
Logs().w('[LibOlm] Failed to load LibOlm', e);
}
Logs().i('[LibOlm] Enabled: $olmEnabled');
client = await getClient(); client = await getClient();
client.sendMessageTimeoutSeconds = 5; client.sendMessageTimeoutSeconds = 5;
@ -550,11 +540,9 @@ void main() {
event = await timeline.getEventById('unencrypted_event'); event = await timeline.getEventById('unencrypted_event');
expect(event?.body, 'This is an example text message'); expect(event?.body, 'This is an example text message');
if (olmEnabled) { event = await timeline.getEventById('encrypted_event');
event = await timeline.getEventById('encrypted_event'); // the event is invalid but should have traces of attempting to decrypt
// the event is invalid but should have traces of attempting to decrypt expect(event?.messageType, MessageTypes.BadEncrypted);
expect(event?.messageType, MessageTypes.BadEncrypted);
}
}); });
test('Resend message', () async { test('Resend message', () async {