feat: lcov and tag olm tests
This commit is contained in:
parent
78e5abc0ae
commit
281510b950
|
|
@ -30,29 +30,6 @@ jobs:
|
|||
scripts/prepare.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:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
|
|
@ -65,10 +42,79 @@ jobs:
|
|||
sdk: ${{ env.dart_version }}
|
||||
- name: Run tests
|
||||
run: |
|
||||
apt-get update && 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
|
||||
sudo apt-get update && sudo apt-get install --no-install-recommends --no-install-suggests -y curl lcov python3 python3-distutils libsqlite3-0 libsqlite3-dev
|
||||
./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:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
tags:
|
||||
olm:
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,33 +2,17 @@
|
|||
|
||||
thread_count=$(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
if which flutter >/dev/null; then
|
||||
flutter pub global activate junitreport
|
||||
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$'
|
||||
if [ -n "$NO_OLM" ]; then
|
||||
tagFlag="-x olm"
|
||||
fi
|
||||
|
||||
# coverage html report
|
||||
genhtml -o coverage coverage/lcov.info || true
|
||||
dart test --concurrency=$thread_count --coverage=coverage_dir $tagFlag
|
||||
TEST_CODE=$?
|
||||
|
||||
# https://github.com/eriwen/lcov-to-cobertura-xml
|
||||
lcov_cobertura.py coverage/lcov.info || true
|
||||
# lets you do more stuff like reporton
|
||||
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
|
||||
|
|
@ -41,7 +41,7 @@ void main() {
|
|||
const fingerprintKey = 'gjL//fyaFHADt9KBADGag8g7F8Up78B/K1zXeiEPLJo';
|
||||
|
||||
/// All Tests related to the Login
|
||||
group('Client', () {
|
||||
group('Client', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
|
||||
/// Check if all Elements get created
|
||||
|
|
@ -50,8 +50,6 @@ void main() {
|
|||
matrix = await getClient();
|
||||
});
|
||||
|
||||
var olmEnabled = true;
|
||||
|
||||
test('Login', () async {
|
||||
matrix = Client(
|
||||
'testclient',
|
||||
|
|
@ -60,15 +58,6 @@ void main() {
|
|||
);
|
||||
final eventUpdateListFuture = matrix.onEvent.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 accountDataCounter = 0;
|
||||
matrix.onPresenceChanged.stream.listen((CachedPresence data) {
|
||||
|
|
@ -112,11 +101,10 @@ void main() {
|
|||
|
||||
expect(loginState, LoginState.loggedIn);
|
||||
expect(matrix.onSync.value != null, true);
|
||||
expect(matrix.encryptionEnabled, olmEnabled);
|
||||
if (olmEnabled) {
|
||||
expect(matrix.identityKey, identityKey);
|
||||
expect(matrix.fingerprintKey, fingerprintKey);
|
||||
}
|
||||
expect(matrix.encryptionEnabled, true);
|
||||
expect(matrix.identityKey, identityKey);
|
||||
expect(matrix.fingerprintKey, fingerprintKey);
|
||||
|
||||
expect(sync.nextBatch == matrix.prevBatch, true);
|
||||
|
||||
expect(matrix.accountData.length, 10);
|
||||
|
|
@ -276,11 +264,8 @@ void main() {
|
|||
expect(deviceeventUpdateList.length, 2);
|
||||
|
||||
expect(deviceeventUpdateList[0].type, 'm.new_device');
|
||||
if (olmEnabled) {
|
||||
expect(deviceeventUpdateList[1].type, 'm.room_key');
|
||||
} else {
|
||||
expect(deviceeventUpdateList[1].type, 'm.room.encrypted');
|
||||
}
|
||||
|
||||
expect(deviceeventUpdateList[1].type, 'm.room_key');
|
||||
});
|
||||
|
||||
test('recentEmoji', () async {
|
||||
|
|
@ -349,15 +334,6 @@ void main() {
|
|||
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);
|
||||
|
||||
try {
|
||||
|
|
@ -392,11 +368,11 @@ void main() {
|
|||
|
||||
expect(loginState, LoginState.loggedIn);
|
||||
expect(matrix.onSync.value != null, true);
|
||||
expect(matrix.encryptionEnabled, olmEnabled);
|
||||
if (olmEnabled) {
|
||||
expect(matrix.identityKey, identityKey);
|
||||
expect(matrix.fingerprintKey, fingerprintKey);
|
||||
}
|
||||
expect(matrix.encryptionEnabled, true);
|
||||
|
||||
expect(matrix.identityKey, identityKey);
|
||||
expect(matrix.fingerprintKey, fingerprintKey);
|
||||
|
||||
expect(sync.nextBatch == matrix.prevBatch, true);
|
||||
});
|
||||
|
||||
|
|
@ -695,9 +671,6 @@ void main() {
|
|||
await client.dispose(closeDatabase: true);
|
||||
});
|
||||
test('sendToDeviceEncrypted', () async {
|
||||
if (!olmEnabled) {
|
||||
return;
|
||||
}
|
||||
FakeMatrixApi.calledEndpoints.clear();
|
||||
|
||||
await matrix.sendToDeviceEncrypted(
|
||||
|
|
@ -714,9 +687,6 @@ void main() {
|
|||
true);
|
||||
});
|
||||
test('sendToDeviceEncryptedChunked', () async {
|
||||
if (!olmEnabled) {
|
||||
return;
|
||||
}
|
||||
FakeMatrixApi.calledEndpoints.clear();
|
||||
await matrix.sendToDeviceEncryptedChunked(
|
||||
matrix.userDeviceKeys['@alice:example.com']!.deviceKeys.values
|
||||
|
|
@ -1199,40 +1169,34 @@ void main() {
|
|||
reason: '!5345234235:example.com not found as archived room');
|
||||
});
|
||||
|
||||
test('Client Init Exception', () async {
|
||||
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');
|
||||
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',
|
||||
test(
|
||||
'Client Init Exception',
|
||||
() async {
|
||||
final customClient = Client(
|
||||
'failclient',
|
||||
databaseBuilder: getMatrixSdkDatabase,
|
||||
);
|
||||
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');
|
||||
}
|
||||
});
|
||||
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?');
|
||||
} 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 {
|
||||
await matrix.dispose(closeDatabase: true);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -27,10 +26,9 @@ import 'fake_client.dart';
|
|||
import 'fake_matrix_api.dart';
|
||||
|
||||
void main() {
|
||||
group('Commands', () {
|
||||
group('Commands', tags: 'olm', () {
|
||||
late Client client;
|
||||
late Room room;
|
||||
var olmEnabled = true;
|
||||
|
||||
Map<String, dynamic> getLastMessagePayload(
|
||||
[String type = 'm.room.message', String? stateKey]) {
|
||||
|
|
@ -43,12 +41,6 @@ void main() {
|
|||
}
|
||||
|
||||
test('setupClient', () async {
|
||||
try {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
} catch (e) {
|
||||
olmEnabled = false;
|
||||
}
|
||||
client = await getClient();
|
||||
room = Room(id: '!1234:fakeServer.notExisting', client: client);
|
||||
room.setState(Event(
|
||||
|
|
@ -398,18 +390,16 @@ void main() {
|
|||
});
|
||||
|
||||
test('discardsession', () async {
|
||||
if (olmEnabled) {
|
||||
await client.encryption?.keyManager.createOutboundGroupSession(room.id);
|
||||
expect(
|
||||
client.encryption?.keyManager.getOutboundGroupSession(room.id) !=
|
||||
null,
|
||||
true);
|
||||
await room.sendTextEvent('/discardsession');
|
||||
expect(
|
||||
client.encryption?.keyManager.getOutboundGroupSession(room.id) !=
|
||||
null,
|
||||
false);
|
||||
}
|
||||
await client.encryption?.keyManager.createOutboundGroupSession(room.id);
|
||||
expect(
|
||||
client.encryption?.keyManager.getOutboundGroupSession(room.id) !=
|
||||
null,
|
||||
true);
|
||||
await room.sendTextEvent('/discardsession');
|
||||
expect(
|
||||
client.encryption?.keyManager.getOutboundGroupSession(room.id) !=
|
||||
null,
|
||||
false);
|
||||
});
|
||||
|
||||
test('markasdm', () async {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import 'dart:async';
|
|||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -44,7 +43,7 @@ void main() {
|
|||
};
|
||||
|
||||
for (final databaseBuilder in databaseBuilders.entries) {
|
||||
group('Test ${databaseBuilder.key}', () {
|
||||
group('Test ${databaseBuilder.key}', tags: 'olm', () {
|
||||
late DatabaseApi database;
|
||||
late int toDeviceQueueIndex;
|
||||
|
||||
|
|
@ -372,7 +371,6 @@ void main() {
|
|||
expect(olm.isEmpty, true);
|
||||
});
|
||||
test('storeOlmSession', () async {
|
||||
if (!(await olmEnabled())) return;
|
||||
await database.storeOlmSession(
|
||||
'identityKey',
|
||||
'sessionId',
|
||||
|
|
@ -393,7 +391,6 @@ void main() {
|
|||
expect(session, null);
|
||||
});
|
||||
test('storeOutboundGroupSession', () async {
|
||||
if (!(await olmEnabled())) return;
|
||||
await database.storeOutboundGroupSession(
|
||||
'!testroom:example.com',
|
||||
'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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -27,29 +26,16 @@ import './fake_matrix_api.dart';
|
|||
|
||||
void main() {
|
||||
/// All Tests related to device keys
|
||||
group('Device keys', () {
|
||||
group('Device keys', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
|
||||
var olmEnabled = true;
|
||||
|
||||
late Client client;
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
test('fromJson', () async {
|
||||
if (!olmEnabled) return;
|
||||
var rawJson = <String, dynamic>{
|
||||
'user_id': '@alice:example.com',
|
||||
'device_id': 'JLAFKJWSCS',
|
||||
|
|
@ -94,7 +80,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('reject devices without self-signature', () async {
|
||||
if (!olmEnabled) return;
|
||||
var key = DeviceKeys.fromJson({
|
||||
'user_id': '@test:fakeServer.notExisting',
|
||||
'device_id': 'BADDEVICE',
|
||||
|
|
@ -131,7 +116,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('set blocked / verified', () async {
|
||||
if (!olmEnabled) return;
|
||||
final key =
|
||||
client.userDeviceKeys[client.userID]!.deviceKeys['OTHERDEVICE']!;
|
||||
client.userDeviceKeys[client.userID]?.deviceKeys['UNSIGNEDDEVICE'] =
|
||||
|
|
@ -212,7 +196,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('verification based on signatures', () async {
|
||||
if (!olmEnabled) return;
|
||||
final user = client.userDeviceKeys[client.userID]!;
|
||||
user.masterKey?.setDirectVerified(true);
|
||||
expect(user.deviceKeys['GHTYAJCE']?.crossVerified, true);
|
||||
|
|
@ -248,7 +231,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('start verification', () async {
|
||||
if (!olmEnabled) return;
|
||||
var req = await client
|
||||
.userDeviceKeys['@alice:example.com']?.deviceKeys['JLAFKJWSCS']
|
||||
?.startVerification();
|
||||
|
|
@ -262,7 +244,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.dispose(closeDatabase: true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,30 +27,20 @@ import 'package:matrix/matrix.dart';
|
|||
import '../fake_client.dart';
|
||||
|
||||
void main() {
|
||||
group('Bootstrap', () {
|
||||
group('Bootstrap', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
late Client client;
|
||||
late Map<String, dynamic> oldSecret;
|
||||
late String origKeyId;
|
||||
|
||||
test('setupClient', () async {
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
client = await getClient();
|
||||
await client.abortSync();
|
||||
});
|
||||
|
||||
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 = client.encryption!.bootstrap(
|
||||
onUpdate: (bootstrap) async {
|
||||
|
|
@ -105,7 +95,6 @@ void main() {
|
|||
}, timeout: Timeout(Duration(minutes: 2)));
|
||||
|
||||
test('change recovery passphrase', () async {
|
||||
if (!olmEnabled) return;
|
||||
Bootstrap? bootstrap;
|
||||
bootstrap = client.encryption!.bootstrap(
|
||||
onUpdate: (bootstrap) async {
|
||||
|
|
@ -153,7 +142,6 @@ void main() {
|
|||
}, timeout: Timeout(Duration(minutes: 2)));
|
||||
|
||||
test('change passphrase with multiple keys', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.setAccountData(client.userID!, 'foxes', oldSecret);
|
||||
await Future.delayed(Duration(milliseconds: 50));
|
||||
|
||||
|
|
@ -206,7 +194,6 @@ void main() {
|
|||
}, timeout: Timeout(Duration(minutes: 2)));
|
||||
|
||||
test('setup new ssss', () async {
|
||||
if (!olmEnabled) return;
|
||||
client.accountData.clear();
|
||||
Bootstrap? bootstrap;
|
||||
bootstrap = client.encryption!.bootstrap(
|
||||
|
|
@ -229,7 +216,6 @@ void main() {
|
|||
}, timeout: Timeout(Duration(minutes: 2)));
|
||||
|
||||
test('bad ssss', () async {
|
||||
if (!olmEnabled) return;
|
||||
client.accountData.clear();
|
||||
await client.setAccountData(client.userID!, 'foxes', oldSecret);
|
||||
await Future.delayed(Duration(milliseconds: 50));
|
||||
|
|
@ -252,7 +238,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.dispose(closeDatabase: true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,33 +26,22 @@ import '../fake_client.dart';
|
|||
import '../fake_matrix_api.dart';
|
||||
|
||||
void main() {
|
||||
group('Cross Signing', () {
|
||||
group('Cross Signing', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
late Client client;
|
||||
|
||||
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;
|
||||
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
client = await getClient();
|
||||
});
|
||||
|
||||
test('basic things', () async {
|
||||
if (!olmEnabled) return;
|
||||
expect(client.encryption?.crossSigning.enabled, true);
|
||||
});
|
||||
|
||||
test('selfSign', () async {
|
||||
if (!olmEnabled) return;
|
||||
final key = client.userDeviceKeys[client.userID]!.masterKey!;
|
||||
key.setDirectVerified(false);
|
||||
FakeMatrixApi.calledEndpoints.clear();
|
||||
|
|
@ -66,7 +55,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('signable', () async {
|
||||
if (!olmEnabled) return;
|
||||
expect(
|
||||
client.encryption!.crossSigning
|
||||
.signable([client.userDeviceKeys[client.userID!]!.masterKey!]),
|
||||
|
|
@ -90,7 +78,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('sign', () async {
|
||||
if (!olmEnabled) return;
|
||||
FakeMatrixApi.calledEndpoints.clear();
|
||||
await client.encryption!.crossSigning.sign([
|
||||
client.userDeviceKeys[client.userID!]!.masterKey!,
|
||||
|
|
@ -114,7 +101,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.dispose(closeDatabase: true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@ import 'package:matrix/matrix.dart';
|
|||
import '../fake_client.dart';
|
||||
|
||||
void main() {
|
||||
group('Encrypt/Decrypt room message', () {
|
||||
group('Encrypt/Decrypt room message', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
late Client client;
|
||||
final roomId = '!726s6s6q:example.com';
|
||||
|
|
@ -33,23 +32,14 @@ void main() {
|
|||
late Map<String, dynamic> payload;
|
||||
final now = DateTime.now();
|
||||
|
||||
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;
|
||||
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
client = await getClient();
|
||||
room = client.getRoomById(roomId)!;
|
||||
});
|
||||
|
||||
test('encrypt payload', () async {
|
||||
if (!olmEnabled) return;
|
||||
payload = await client.encryption!.encryptGroupMessagePayload(roomId, {
|
||||
'msgtype': 'm.text',
|
||||
'text': 'Hello foxies!',
|
||||
|
|
@ -62,7 +52,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('decrypt payload', () async {
|
||||
if (!olmEnabled) return;
|
||||
final encryptedEvent = Event(
|
||||
type: EventTypes.Encrypted,
|
||||
content: payload,
|
||||
|
|
@ -80,7 +69,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('decrypt payload without device_id', () async {
|
||||
if (!olmEnabled) return;
|
||||
payload.remove('device_id');
|
||||
payload.remove('sender_key');
|
||||
final encryptedEvent = Event(
|
||||
|
|
@ -100,7 +88,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('decrypt payload nocache', () async {
|
||||
if (!olmEnabled) return;
|
||||
client.encryption!.keyManager.clearInboundGroupSessions();
|
||||
final encryptedEvent = Event(
|
||||
type: EventTypes.Encrypted,
|
||||
|
|
@ -120,7 +107,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.dispose(closeDatabase: true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -29,9 +29,8 @@ void main() {
|
|||
const otherPickledOlmAccount =
|
||||
'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;
|
||||
var olmEnabled = true;
|
||||
|
||||
late Client client;
|
||||
final otherClient = Client('othertestclient',
|
||||
|
|
@ -39,17 +38,13 @@ void main() {
|
|||
late DeviceKeys device;
|
||||
late Map<String, dynamic> payload;
|
||||
|
||||
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;
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
client = await getClient();
|
||||
});
|
||||
|
||||
test('setupClient', () async {
|
||||
client = await getClient();
|
||||
await client.abortSync();
|
||||
await otherClient.checkHomeserver(
|
||||
|
|
@ -81,13 +76,11 @@ void main() {
|
|||
});
|
||||
|
||||
test('encryptToDeviceMessage', () async {
|
||||
if (!olmEnabled) return;
|
||||
payload = await otherClient.encryption!
|
||||
.encryptToDeviceMessage([device], 'm.to_device', {'hello': 'foxies'});
|
||||
});
|
||||
|
||||
test('decryptToDeviceEvent', () async {
|
||||
if (!olmEnabled) return;
|
||||
final encryptedEvent = ToDeviceEvent(
|
||||
sender: '@othertest:fakeServer.notExisting',
|
||||
type: EventTypes.Encrypted,
|
||||
|
|
@ -100,7 +93,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('decryptToDeviceEvent nocache', () async {
|
||||
if (!olmEnabled) return;
|
||||
client.encryption!.olmManager.olmSessions.clear();
|
||||
payload = await otherClient.encryption!.encryptToDeviceMessage(
|
||||
[device], 'm.to_device', {'hello': 'superfoxies'});
|
||||
|
|
@ -116,7 +108,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.dispose(closeDatabase: true);
|
||||
await otherClient.dispose(closeDatabase: true);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,28 +26,17 @@ import '../fake_client.dart';
|
|||
import '../fake_matrix_api.dart';
|
||||
|
||||
void main() {
|
||||
group('Key Manager', () {
|
||||
group('Key Manager', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
late Client client;
|
||||
|
||||
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;
|
||||
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
client = await getClient();
|
||||
});
|
||||
|
||||
test('handle new m.room_key', () async {
|
||||
if (!olmEnabled) return;
|
||||
final validSessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
|
||||
final validSenderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg';
|
||||
final sessionKey =
|
||||
|
|
@ -95,7 +84,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('outbound group session', () async {
|
||||
if (!olmEnabled) return;
|
||||
final roomId = '!726s6s6q:example.com';
|
||||
expect(
|
||||
client.encryption!.keyManager.getOutboundGroupSession(roomId) != null,
|
||||
|
|
@ -270,7 +258,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('inbound group session', () async {
|
||||
if (!olmEnabled) return;
|
||||
final roomId = '!726s6s6q:example.com';
|
||||
final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
|
||||
final senderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg';
|
||||
|
|
@ -324,7 +311,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('setInboundGroupSession', () async {
|
||||
if (!olmEnabled) return;
|
||||
final session = olm.OutboundGroupSession();
|
||||
session.create();
|
||||
final inbound = olm.InboundGroupSession();
|
||||
|
|
@ -495,7 +481,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('Reused deviceID attack', () async {
|
||||
if (!olmEnabled) return;
|
||||
Logs().level = Level.warning;
|
||||
|
||||
// Ensure the device came from sync
|
||||
|
|
@ -542,7 +527,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.dispose(closeDatabase: false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -39,23 +39,17 @@ Map<String, dynamic> jsonDecode(dynamic payload) {
|
|||
|
||||
void main() {
|
||||
/// All Tests related to device keys
|
||||
group('Key Request', () {
|
||||
group('Key Request', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
});
|
||||
|
||||
final validSessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
|
||||
final validSenderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg';
|
||||
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 requestRoom = matrix.getRoomById('!726s6s6q:example.com')!;
|
||||
await matrix.encryption!.keyManager.request(
|
||||
|
|
@ -82,7 +76,6 @@ void main() {
|
|||
await matrix.dispose(closeDatabase: true);
|
||||
});
|
||||
test('Reply To Request', () async {
|
||||
if (!olmEnabled) return;
|
||||
final matrix = await getClient();
|
||||
matrix.setUserId('@alice:example.com'); // we need to pretend to be alice
|
||||
FakeMatrixApi.calledEndpoints.clear();
|
||||
|
|
@ -277,7 +270,6 @@ void main() {
|
|||
await matrix.dispose(closeDatabase: true);
|
||||
});
|
||||
test('Receive shared keys', () async {
|
||||
if (!olmEnabled) return;
|
||||
final matrix = await getClient();
|
||||
final requestRoom = matrix.getRoomById('!726s6s6q:example.com')!;
|
||||
await matrix.encryption!.keyManager.request(
|
||||
|
|
|
|||
|
|
@ -48,20 +48,8 @@ EventUpdate getLastSentEvent(KeyVerification req) {
|
|||
}
|
||||
|
||||
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
|
||||
group('Key Verification', () {
|
||||
group('Key Verification', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
|
||||
// key @othertest:fakeServer.notExisting
|
||||
|
|
@ -70,6 +58,12 @@ void main() async {
|
|||
|
||||
late Client client1;
|
||||
late Client client2;
|
||||
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
});
|
||||
|
||||
setUp(() async {
|
||||
client1 = await getClient();
|
||||
client2 = Client(
|
||||
|
|
@ -101,7 +95,11 @@ void main() async {
|
|||
KeyVerificationMethod.qrShow,
|
||||
KeyVerificationMethod.reciprocate
|
||||
};
|
||||
|
||||
// get client2 device keys to start verification
|
||||
await client1.updateUserDeviceKeys(additionalUsers: {client2.userID!});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await client1.dispose(closeDatabase: true);
|
||||
await client2.dispose(closeDatabase: true);
|
||||
|
|
@ -810,5 +808,5 @@ void main() async {
|
|||
await client1.encryption!.keyVerificationManager.cleanup();
|
||||
await client2.encryption!.keyVerificationManager.cleanup();
|
||||
});
|
||||
}, skip: skip);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,29 +27,18 @@ import '../fake_client.dart';
|
|||
import '../fake_matrix_api.dart';
|
||||
|
||||
void main() {
|
||||
group('Olm Manager', () {
|
||||
group('Olm Manager', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
late Client client;
|
||||
|
||||
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 Future.value();
|
||||
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
client = await getClient();
|
||||
return Future.value();
|
||||
});
|
||||
|
||||
test('signatures', () async {
|
||||
if (!olmEnabled) return;
|
||||
final payload = <String, dynamic>{
|
||||
'fox': 'floof',
|
||||
};
|
||||
|
|
@ -61,7 +50,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('uploadKeys', () async {
|
||||
if (!olmEnabled) return;
|
||||
FakeMatrixApi.calledEndpoints.clear();
|
||||
final res = await client.encryption!.olmManager
|
||||
.uploadKeys(uploadDeviceKeys: true);
|
||||
|
|
@ -89,8 +77,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('handleDeviceOneTimeKeysCount', () async {
|
||||
if (!olmEnabled) return;
|
||||
|
||||
FakeMatrixApi.calledEndpoints.clear();
|
||||
await client.encryption!.olmManager
|
||||
.handleDeviceOneTimeKeysCount({'signed_curve25519': 20}, null);
|
||||
|
|
@ -127,7 +113,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('restoreOlmSession', () async {
|
||||
if (!olmEnabled) return;
|
||||
client.encryption!.olmManager.olmSessions.clear();
|
||||
await client.encryption!.olmManager
|
||||
.restoreOlmSession(client.userID!, client.identityKey);
|
||||
|
|
@ -145,7 +130,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('startOutgoingOlmSessions', () async {
|
||||
if (!olmEnabled) return;
|
||||
// start an olm session.....with ourself!
|
||||
client.encryption!.olmManager.olmSessions.clear();
|
||||
await client.encryption!.olmManager.startOutgoingOlmSessions([
|
||||
|
|
@ -158,7 +142,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('replay to_device events', () async {
|
||||
if (!olmEnabled) return;
|
||||
final userId = '@alice:example.com';
|
||||
final deviceId = 'JLAFKJWSCS';
|
||||
final senderKey = 'L+4+JCl8MD63dgo8z5Ta+9QAHXiANyOVSfgbHA5d3H8';
|
||||
|
|
@ -261,7 +244,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.dispose(closeDatabase: true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,9 +26,8 @@ import '../fake_client.dart';
|
|||
import '../fake_matrix_api.dart';
|
||||
|
||||
void main() {
|
||||
group('Online Key Backup', () {
|
||||
group('Online Key Backup', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
late Client client;
|
||||
|
||||
|
|
@ -36,22 +35,13 @@ void main() {
|
|||
final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
|
||||
final senderKey = 'JBG7ZaPn54OBC7TuIEiylW3BZ+7WcGQhFBPB9pogbAg';
|
||||
|
||||
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;
|
||||
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
client = await getClient();
|
||||
});
|
||||
|
||||
test('basic things', () async {
|
||||
if (!olmEnabled) return;
|
||||
expect(client.encryption!.keyManager.enabled, true);
|
||||
expect(await client.encryption!.keyManager.isCached(), false);
|
||||
final handle = client.encryption!.ssss.open();
|
||||
|
|
@ -61,7 +51,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('load key', () async {
|
||||
if (!olmEnabled) return;
|
||||
client.encryption!.keyManager.clearInboundGroupSessions();
|
||||
await client.encryption!.keyManager
|
||||
.request(client.getRoomById(roomId)!, sessionId, senderKey);
|
||||
|
|
@ -73,7 +62,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('Load all Room Keys', () async {
|
||||
if (!olmEnabled) return;
|
||||
final keyManager = client.encryption!.keyManager;
|
||||
const roomId = '!getroomkeys726s6s6q:example.com';
|
||||
const sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
|
||||
|
|
@ -86,7 +74,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('Load all Keys', () async {
|
||||
if (!olmEnabled) return;
|
||||
final keyManager = client.encryption!.keyManager;
|
||||
const roomId = '!getallkeys726s6s6q:example.com';
|
||||
const sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
|
||||
|
|
@ -99,7 +86,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('upload key', () async {
|
||||
if (!olmEnabled) return;
|
||||
final session = olm.OutboundGroupSession();
|
||||
session.create();
|
||||
final inbound = olm.InboundGroupSession();
|
||||
|
|
@ -143,7 +129,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.dispose(closeDatabase: false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.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
|
||||
group('Key Verification', () {
|
||||
group('Key Verification', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
|
||||
late Client client1;
|
||||
|
|
@ -532,5 +519,5 @@ void main() async {
|
|||
await client1.encryption!.keyVerificationManager.cleanup();
|
||||
await client2.encryption!.keyVerificationManager.cleanup();
|
||||
});
|
||||
}, skip: skip);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,34 +49,23 @@ class MockSSSS extends SSSS {
|
|||
}
|
||||
|
||||
void main() {
|
||||
group('SSSS', () {
|
||||
group('SSSS', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
late Client client;
|
||||
|
||||
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;
|
||||
|
||||
setUpAll(() async {
|
||||
await olm.init();
|
||||
olm.get_library_version();
|
||||
client = await getClient();
|
||||
});
|
||||
|
||||
test('basic things', () async {
|
||||
if (!olmEnabled) return;
|
||||
expect(client.encryption!.ssss.defaultKeyId,
|
||||
'0FajDWYaM6wQ4O60OZnLvwZfsBNu4Bu3');
|
||||
});
|
||||
|
||||
test('encrypt / decrypt', () async {
|
||||
if (!olmEnabled) return;
|
||||
final key = Uint8List.fromList(secureRandomBytes(32));
|
||||
|
||||
final enc = await SSSS.encryptAes('secret foxies', key, 'name');
|
||||
|
|
@ -85,7 +74,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('store', () async {
|
||||
if (!olmEnabled) return;
|
||||
final handle = client.encryption!.ssss.open();
|
||||
var failed = false;
|
||||
try {
|
||||
|
|
@ -125,7 +113,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('encode / decode recovery key', () async {
|
||||
if (!olmEnabled) return;
|
||||
final key = Uint8List.fromList(secureRandomBytes(32));
|
||||
final encoded = SSSS.encodeRecoveryKey(key);
|
||||
var decoded = SSSS.decodeRecoveryKey(encoded);
|
||||
|
|
@ -140,7 +127,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('cache', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.encryption!.ssss.clearCache();
|
||||
final handle =
|
||||
client.encryption!.ssss.open(EventTypes.CrossSigningSelfSigning);
|
||||
|
|
@ -174,7 +160,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('postUnlock', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.encryption!.ssss.clearCache();
|
||||
client.userDeviceKeys[client.userID!]!.masterKey!
|
||||
.setDirectVerified(false);
|
||||
|
|
@ -200,7 +185,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('make share requests', () async {
|
||||
if (!olmEnabled) return;
|
||||
final key =
|
||||
client.userDeviceKeys[client.userID!]!.deviceKeys['OTHERDEVICE']!;
|
||||
key.setDirectVerified(true);
|
||||
|
|
@ -213,7 +197,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('answer to share requests', () async {
|
||||
if (!olmEnabled) return;
|
||||
var event = ToDeviceEvent(
|
||||
sender: client.userID!,
|
||||
type: 'm.secret.request',
|
||||
|
|
@ -313,7 +296,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('receive share requests', () async {
|
||||
if (!olmEnabled) return;
|
||||
final key =
|
||||
client.userDeviceKeys[client.userID!]!.deviceKeys['OTHERDEVICE']!;
|
||||
key.setDirectVerified(true);
|
||||
|
|
@ -456,7 +438,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('request all', () async {
|
||||
if (!olmEnabled) return;
|
||||
final key =
|
||||
client.userDeviceKeys[client.userID!]!.deviceKeys['OTHERDEVICE']!;
|
||||
key.setDirectVerified(true);
|
||||
|
|
@ -467,7 +448,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('periodicallyRequestMissingCache', () async {
|
||||
if (!olmEnabled) return;
|
||||
client.userDeviceKeys[client.userID!]!.masterKey!.setDirectVerified(true);
|
||||
client.encryption!.ssss = MockSSSS(client.encryption!);
|
||||
(client.encryption!.ssss as MockSSSS).requestedSecrets = false;
|
||||
|
|
@ -480,7 +460,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('createKey', () async {
|
||||
if (!olmEnabled) return;
|
||||
// with passphrase
|
||||
var newKey = await client.encryption!.ssss.createKey('test');
|
||||
expect(client.encryption!.ssss.isKeyValid(newKey.keyId), true);
|
||||
|
|
@ -496,7 +475,6 @@ void main() {
|
|||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
if (!olmEnabled) return;
|
||||
await client.dispose(closeDatabase: true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:matrix/encryption.dart';
|
||||
|
|
@ -30,9 +29,8 @@ import 'fake_matrix_api.dart';
|
|||
|
||||
void main() {
|
||||
/// All Tests related to the Event
|
||||
group('Event', () {
|
||||
group('Event', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
final timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final id = '!4fsdfjisjf:server.abc';
|
||||
|
|
@ -59,17 +57,6 @@ void main() {
|
|||
final event = Event.fromJson(
|
||||
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 {
|
||||
jsonObj.remove('status');
|
||||
jsonObj['content'] = json.decode(contentJson);
|
||||
|
|
@ -1405,109 +1392,117 @@ void main() {
|
|||
getThumbnail: true, downloadCallback: downloadCallback);
|
||||
expect(buffer.bytes, THUMBNAIL_BUFF);
|
||||
});
|
||||
test('encrypted attachments', () async {
|
||||
if (!olmEnabled) return;
|
||||
test(
|
||||
'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 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 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': {
|
||||
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': 'TmF-rZYetZbxpL5yjDPE21UALQJcpEE6X-nvUDD5rA0',
|
||||
'k': '7aPRNIDPeUAUqD6SPR3vVX5W9liyMG98NexVJ9udnCc',
|
||||
'key_ops': ['encrypt', 'decrypt'],
|
||||
'kty': 'oct'
|
||||
},
|
||||
'iv': '41ZqNRZSLFUAAAAAAAAAAA',
|
||||
'iv': 'Wdsf+tnOHIoAAAAAAAAAAA',
|
||||
'hashes': {
|
||||
'sha256': 'zccOwXiOTAYhGXyk0Fra7CRreBF6itjiCKdd+ov8mO4'
|
||||
'sha256': 'WgC7fw2alBC5t+xDx+PFlZxfFJXtIstQCg+j0WDaXxE'
|
||||
},
|
||||
'url': 'mxc://example.com/thumb',
|
||||
'url': 'mxc://example.com/file',
|
||||
'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);
|
||||
'event_id': '\$edit2',
|
||||
'sender': '@alice:example.org',
|
||||
}, room);
|
||||
var buffer = await event.downloadAndDecryptAttachment(
|
||||
downloadCallback: downloadCallback);
|
||||
expect(buffer.bytes, FILE_BUFF_DEC);
|
||||
|
||||
buffer = await event.downloadAndDecryptAttachment(
|
||||
getThumbnail: true, downloadCallback: downloadCallback);
|
||||
expect(buffer.bytes, THUMB_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',
|
||||
'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 {
|
||||
final FILE_BUFF = Uint8List.fromList([0]);
|
||||
var serverHits = 0;
|
||||
|
|
|
|||
|
|
@ -477,8 +477,8 @@ class FakeMatrixApi extends BaseClient {
|
|||
'join': {
|
||||
'!726s6s6q:example.com': {
|
||||
'summary': {
|
||||
'm.heroes': ['@alice:example.com', '@bob:example.com'],
|
||||
'm.joined_member_count': 2,
|
||||
'm.heroes': ['@alice:example.com'],
|
||||
'm.joined_member_count': 1,
|
||||
'm.invited_member_count': 0
|
||||
},
|
||||
'unread_notifications': {
|
||||
|
|
|
|||
|
|
@ -19,14 +19,13 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
void main() {
|
||||
/// All Tests related to device keys
|
||||
group('Matrix File', () {
|
||||
group('Matrix File', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
test('Decrypt', () async {
|
||||
final text = 'hello world';
|
||||
|
|
@ -34,17 +33,9 @@ void main() {
|
|||
name: 'file.txt',
|
||||
bytes: Uint8List.fromList(text.codeUnits),
|
||||
);
|
||||
var olmEnabled = true;
|
||||
try {
|
||||
await olm.init();
|
||||
olm.Account();
|
||||
} catch (_) {
|
||||
olmEnabled = false;
|
||||
}
|
||||
if (olmEnabled) {
|
||||
final encryptedFile = await file.encrypt();
|
||||
expect(encryptedFile.data.isNotEmpty, true);
|
||||
}
|
||||
|
||||
final encryptedFile = await file.encrypt();
|
||||
expect(encryptedFile.data.isNotEmpty, true);
|
||||
});
|
||||
|
||||
test('Shrink', () async {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -28,7 +27,6 @@ void main() {
|
|||
/// All Tests related to the Event
|
||||
group('Event', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
final timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final id = '!4fsdfjisjf:server.abc';
|
||||
|
|
@ -54,14 +52,6 @@ void main() {
|
|||
late Room room;
|
||||
|
||||
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();
|
||||
room = Room(id: '!testroom:example.abc', client: client);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -27,22 +26,12 @@ import 'fake_client.dart';
|
|||
void main() {
|
||||
group('Timeline', () {
|
||||
Logs().level = Level.error;
|
||||
var olmEnabled = true;
|
||||
|
||||
final insertList = <int>[];
|
||||
|
||||
late Client client;
|
||||
|
||||
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.sendMessageTimeoutSeconds = 5;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -27,7 +26,7 @@ import 'fake_client.dart';
|
|||
import 'fake_matrix_api.dart';
|
||||
|
||||
void main() {
|
||||
group('Timeline context', () {
|
||||
group('Timeline context', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
final roomID = '!1234:example.com';
|
||||
var testTimeStamp = 0;
|
||||
|
|
@ -35,7 +34,6 @@ void main() {
|
|||
final insertList = <int>[];
|
||||
final changeList = <int>[];
|
||||
final removeList = <int>[];
|
||||
var olmEnabled = true;
|
||||
|
||||
final countStream = StreamController<int>.broadcast();
|
||||
Future<int> waitForCount(int count) async {
|
||||
|
|
@ -65,14 +63,6 @@ void main() {
|
|||
late Room room;
|
||||
late Timeline timeline;
|
||||
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.sendMessageTimeoutSeconds = 5;
|
||||
|
||||
|
|
@ -318,11 +308,9 @@ void main() {
|
|||
event = await timeline.getEventById('unencrypted_event');
|
||||
expect(event?.body, 'This is an example text message');
|
||||
|
||||
if (olmEnabled) {
|
||||
event = await timeline.getEventById('encrypted_event');
|
||||
// the event is invalid but should have traces of attempting to decrypt
|
||||
expect(event?.messageType, MessageTypes.BadEncrypted);
|
||||
}
|
||||
event = await timeline.getEventById('encrypted_event');
|
||||
// the event is invalid but should have traces of attempting to decrypt
|
||||
expect(event?.messageType, MessageTypes.BadEncrypted);
|
||||
});
|
||||
|
||||
test('Resend message', () async {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -27,7 +26,7 @@ import 'package:matrix/src/models/timeline_chunk.dart';
|
|||
import 'fake_client.dart';
|
||||
|
||||
void main() {
|
||||
group('Timeline', () {
|
||||
group('Timeline', tags: 'olm', () {
|
||||
Logs().level = Level.error;
|
||||
final roomID = '!1234:example.com';
|
||||
var testTimeStamp = 0;
|
||||
|
|
@ -35,7 +34,6 @@ void main() {
|
|||
final insertList = <int>[];
|
||||
final changeList = <int>[];
|
||||
final removeList = <int>[];
|
||||
var olmEnabled = true;
|
||||
var currentPoison = 0;
|
||||
|
||||
final countStream = StreamController<int>.broadcast();
|
||||
|
|
@ -66,14 +64,6 @@ void main() {
|
|||
late Room room;
|
||||
late Timeline timeline;
|
||||
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.sendMessageTimeoutSeconds = 5;
|
||||
|
||||
|
|
@ -550,11 +540,9 @@ void main() {
|
|||
event = await timeline.getEventById('unencrypted_event');
|
||||
expect(event?.body, 'This is an example text message');
|
||||
|
||||
if (olmEnabled) {
|
||||
event = await timeline.getEventById('encrypted_event');
|
||||
// the event is invalid but should have traces of attempting to decrypt
|
||||
expect(event?.messageType, MessageTypes.BadEncrypted);
|
||||
}
|
||||
event = await timeline.getEventById('encrypted_event');
|
||||
// the event is invalid but should have traces of attempting to decrypt
|
||||
expect(event?.messageType, MessageTypes.BadEncrypted);
|
||||
});
|
||||
|
||||
test('Resend message', () async {
|
||||
|
|
|
|||
Loading…
Reference in New Issue