chore: strict inference

This commit is contained in:
Nicolas Werner 2022-08-20 11:53:14 +02:00
parent 7471743be3
commit 5bd934895d
6 changed files with 193 additions and 153 deletions

View File

@ -10,6 +10,10 @@ linter:
avoid_dynamic_calls: true
analyzer:
language:
strict-casts: false
strict-inference: true
strict-raw-types: false
errors:
todo: ignore
exclude:

View File

@ -64,14 +64,14 @@ class FakeMatrixApi extends MockClient {
final method = request.method;
final dynamic data =
method == 'GET' ? request.url.queryParameters : request.body;
dynamic res = {};
dynamic res = <String, dynamic>{};
var statusCode = 200;
//print('\$method request to $action with Data: $data');
// Sync requests with timeout
if (data is Map<String, dynamic> && data['timeout'] is String) {
await Future.delayed(Duration(seconds: 5));
await Future<void>.delayed(Duration(seconds: 5));
}
if (request.url.origin != 'https://fakeserver.notexisting') {
@ -91,7 +91,7 @@ class FakeMatrixApi extends MockClient {
}
} else if (method == 'PUT' &&
action.contains('/client/v3/sendToDevice/')) {
res = {};
res = <String, dynamic>{};
} else if (method == 'GET' &&
action.contains('/client/v3/rooms/') &&
action.contains('/state/m.room.member/')) {
@ -171,7 +171,7 @@ class FakeMatrixApi extends MockClient {
'unsigned': {'age': 1234}
}
],
'state': [],
'state': <Map>[],
};
static Map<String, dynamic> syncResponse = {
@ -393,7 +393,7 @@ class FakeMatrixApi extends MockClient {
'override': [
{
'actions': ['dont_notify'],
'conditions': [],
'conditions': <Map>[],
'default': true,
'enabled': false,
'rule_id': '.m.rule.master'
@ -427,7 +427,7 @@ class FakeMatrixApi extends MockClient {
'rule_id': '!localpart:server.abc'
}
],
'sender': [],
'sender': <Map>[],
'underride': [
{
'actions': [
@ -677,12 +677,12 @@ class FakeMatrixApi extends MockClient {
static Map<String, dynamic> archiveSyncResponse = {
'next_batch': Random().nextDouble().toString(),
'presence': {'events': []},
'account_data': {'events': []},
'to_device': {'events': []},
'presence': {'events': <Map>[]},
'account_data': {'events': <Map>[]},
'to_device': {'events': <Map>[]},
'rooms': {
'join': {},
'invite': {},
'join': <String, Map>{},
'invite': <String, Map>{},
'leave': {
'!5345234234:example.com': {
'timeline': {
@ -727,7 +727,7 @@ class FakeMatrixApi extends MockClient {
},
},
'!5345234235:example.com': {
'timeline': {'events': []},
'timeline': {'events': <Map>[]},
'state': {
'events': [
{
@ -863,7 +863,7 @@ class FakeMatrixApi extends MockClient {
'join_rule': 'public',
'world_readable': true,
'guest_can_join': true,
'children_state': []
'children_state': <Map>[]
},
{
'room_id': '!aZUzMIEZvEwnDquxLf:neko.dev',
@ -876,7 +876,7 @@ class FakeMatrixApi extends MockClient {
'join_rule': 'public',
'world_readable': true,
'guest_can_join': true,
'children_state': []
'children_state': <Map>[]
},
{
'room_id': '!aRzRZBvOAkHMcEjAPS:libera.chat',
@ -888,7 +888,7 @@ class FakeMatrixApi extends MockClient {
'join_rule': 'public',
'world_readable': false,
'guest_can_join': false,
'children_state': []
'children_state': <Map>[]
},
{
'room_id': '!DXsRRxkqqDhDkAyXfL:matrix.org',
@ -901,7 +901,7 @@ class FakeMatrixApi extends MockClient {
'join_rule': 'public',
'world_readable': false,
'guest_can_join': false,
'children_state': []
'children_state': <Map>[]
},
{
'room_id': '!tbCRpmsMiwMBlIThOd:matrix.org',
@ -913,7 +913,7 @@ class FakeMatrixApi extends MockClient {
'join_rule': 'public',
'world_readable': false,
'guest_can_join': false,
'children_state': []
'children_state': <Map>[]
},
{
'room_id': '!LPpmvMsEgDwuSuHSpM:matrix.org',
@ -925,7 +925,7 @@ class FakeMatrixApi extends MockClient {
'join_rule': 'public',
'world_readable': true,
'guest_can_join': true,
'children_state': []
'children_state': <Map>[]
},
{
'room_id': '!prlZxmnmAGuCYHUNSw:neko.dev',
@ -938,7 +938,7 @@ class FakeMatrixApi extends MockClient {
'join_rule': 'public',
'world_readable': true,
'guest_can_join': false,
'children_state': []
'children_state': <Map>[]
},
{
'room_id': '!ooHixUOgoLVUjCSMZC:matrix.org',
@ -950,7 +950,7 @@ class FakeMatrixApi extends MockClient {
'join_rule': 'public',
'world_readable': true,
'guest_can_join': true,
'children_state': []
'children_state': <Map>[]
}
]
};
@ -982,7 +982,7 @@ class FakeMatrixApi extends MockClient {
'tags': {
'm.favourite': {'order': 0.1},
'u.Work': {'order': 0.7},
'u.Customers': {}
'u.Customers': <String, dynamic>{},
}
},
'/client/v3/events?from=1234&timeout=10&room_id=%211234': (var req) => {
@ -1092,7 +1092,7 @@ class FakeMatrixApi extends MockClient {
'network_id': 'gitter',
'desc': 'Gitter',
'icon': 'mxc://example.org/zXyWvUt',
'fields': {}
'fields': <String, dynamic>{}
}
]
}
@ -1610,7 +1610,7 @@ class FakeMatrixApi extends MockClient {
'override': [
{
'actions': ['dont_notify'],
'conditions': [],
'conditions': <Map>[],
'default': true,
'enabled': false,
'rule_id': '.m.rule.master'
@ -1629,8 +1629,8 @@ class FakeMatrixApi extends MockClient {
'rule_id': '.m.rule.suppress_notices'
}
],
'room': [],
'sender': [],
'room': <Map>[],
'sender': <Map>[],
'underride': [
{
'actions': [
@ -1780,7 +1780,7 @@ class FakeMatrixApi extends MockClient {
'algorithm': AlgorithmTypes.megolmBackupV1Curve25519AesSha2,
'auth_data': {
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
'signatures': {},
'signatures': <String, dynamic>{},
},
'count': 0,
'etag': '0',
@ -1839,15 +1839,15 @@ class FakeMatrixApi extends MockClient {
(var req) => spaceHierarchyResponse,
},
'POST': {
'/client/v3/delete_devices': (var req) => {},
'/client/v3/account/3pid/add': (var req) => {},
'/client/v3/account/3pid/bind': (var req) => {},
'/client/v3/delete_devices': (var req) => <String, dynamic>{},
'/client/v3/account/3pid/add': (var req) => <String, dynamic>{},
'/client/v3/account/3pid/bind': (var req) => <String, dynamic>{},
'/client/v3/account/3pid/delete': (var req) =>
{'id_server_unbind_result': 'success'},
'/client/v3/account/3pid/unbind': (var req) =>
{'id_server_unbind_result': 'success'},
'/client/v3/account/password': (var req) => {},
'/client/v3/rooms/1234/report/1234': (var req) => {},
'/client/v3/account/password': (var req) => <String, dynamic>{},
'/client/v3/rooms/1234/report/1234': (var req) => <String, dynamic>{},
'/client/v3/search': (var req) => {
'search_categories': {
'room_events': {
@ -1923,8 +1923,9 @@ class FakeMatrixApi extends MockClient {
'submit_url': 'https://example.org/path/to/submitToken'
},
'/client/v3/rooms/!localpart%3Aexample.com/receipt/m.read/%241234%3Aexample.com':
(var req) => {},
'/client/v3/rooms/!localpart%3Aexample.com/read_markers': (var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/rooms/!localpart%3Aexample.com/read_markers': (var req) =>
<String, dynamic>{},
'/client/v3/user/${Uri.encodeComponent('alice@example.com')}/filter':
(var req) => {'filter_id': '1234'},
'/client/v3/publicRooms?server=example.com': (var req) => {
@ -1950,7 +1951,7 @@ class FakeMatrixApi extends MockClient {
? request["one_time_keys"] as Map<String, dynamic>?
: null;
return {
'failures': {},
'failures': <String, dynamic>{},
'one_time_keys': {
if (keys?['@alice:example.com'] != null)
'@alice:example.com': {
@ -1983,13 +1984,20 @@ class FakeMatrixApi extends MockClient {
}
};
},
'/client/v3/rooms/!localpart%3Aexample.com/invite': (var req) => {},
'/client/v3/rooms/!localpart%3Aexample.com/leave': (var req) => {},
'/client/v3/rooms/!localpart%3Aexample.com/forget': (var req) => {},
'/client/v3/rooms/!localpart%3Aserver.abc/kick': (var req) => {},
'/client/v3/rooms/!localpart%3Aexample.com/kick': (var req) => {},
'/client/v3/rooms/!localpart%3Aexample.com/ban': (var req) => {},
'/client/v3/rooms/!localpart%3Aexample.com/unban': (var req) => {},
'/client/v3/rooms/!localpart%3Aexample.com/invite': (var req) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aexample.com/leave': (var req) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aexample.com/forget': (var req) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/kick': (var req) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aexample.com/kick': (var req) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aexample.com/ban': (var req) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aexample.com/unban': (var req) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aexample.com/join': (var req) =>
{'room_id': '!localpart:example.com'},
'/client/v3/join/!localpart%3Aexample.com?server_name=example.com&server_name=example.abc':
@ -2005,7 +2013,7 @@ class FakeMatrixApi extends MockClient {
}
},
'/client/v3/keys/query': (var req) => {
'failures': {},
'failures': <String, dynamic>{},
'device_keys': {
'@alice:example.com': {
'JLAFKJWSCS': {
@ -2127,7 +2135,7 @@ class FakeMatrixApi extends MockClient {
'ed25519:82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8':
'82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8',
},
'signatures': {},
'signatures': <String, dynamic>{},
},
'@othertest:fakeServer.notExisting': {
'user_id': '@othertest:fakeServer.notExisting',
@ -2135,7 +2143,7 @@ class FakeMatrixApi extends MockClient {
'keys': {
'ed25519:master': 'master',
},
'signatures': {},
'signatures': <String, dynamic>{},
},
},
'self_signing_keys': {
@ -2159,7 +2167,7 @@ class FakeMatrixApi extends MockClient {
'keys': {
'ed25519:self_signing': 'self_signing',
},
'signatures': {},
'signatures': <String, dynamic>{},
},
},
'user_signing_keys': {
@ -2183,7 +2191,7 @@ class FakeMatrixApi extends MockClient {
'keys': {
'ed25519:user_signing': 'user_signing',
},
'signatures': {},
'signatures': <String, dynamic>{},
},
},
},
@ -2223,55 +2231,64 @@ class FakeMatrixApi extends MockClient {
},
'/media/v3/upload?filename=file.jpeg': (var req) =>
{'content_uri': 'mxc://example.com/AQwafuaFswefuhsfAFAgsw'},
'/client/v3/logout': (var reqI) => {},
'/client/v3/pushers/set': (var reqI) => {},
'/client/v3/logout': (var reqI) => <String, dynamic>{},
'/client/v3/pushers/set': (var reqI) => <String, dynamic>{},
'/client/v3/join/1234': (var reqI) => {'room_id': '1234'},
'/client/v3/logout/all': (var reqI) => {},
'/client/v3/logout/all': (var reqI) => <String, dynamic>{},
'/client/v3/createRoom': (var reqI) => {
'room_id': '!1234:fakeServer.notExisting',
},
'/client/v3/rooms/!localpart%3Aserver.abc/read_markers': (var reqI) => {},
'/client/v3/rooms/!localpart:server.abc/kick': (var reqI) => {},
'/client/v3/rooms/!localpart%3Aserver.abc/ban': (var reqI) => {},
'/client/v3/rooms/!localpart%3Aserver.abc/unban': (var reqI) => {},
'/client/v3/rooms/!localpart%3Aserver.abc/invite': (var reqI) => {},
'/client/v3/rooms/!localpart%3Aserver.abc/read_markers': (var reqI) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart:server.abc/kick': (var reqI) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/ban': (var reqI) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/unban': (var reqI) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/invite': (var reqI) =>
<String, dynamic>{},
'/client/v3/keys/device_signing/upload': (var reqI) {
return {};
return <String, dynamic>{};
},
'/client/v3/keys/signatures/upload': (var reqI) => {'failures': {}},
'/client/v3/keys/signatures/upload': (var reqI) =>
{'failures': <String, dynamic>{}},
'/client/v3/room_keys/version': (var reqI) => {'version': '5'},
},
'PUT': {
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.ignored_user_list':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/presence/${Uri.encodeComponent('@alice:example.com')}/status':
(var req) => {},
'/client/v3/pushrules/global/content/nocake/enabled': (var req) => {},
'/client/v3/pushrules/global/content/nocake/actions': (var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/pushrules/global/content/nocake/enabled': (var req) =>
<String, dynamic>{},
'/client/v3/pushrules/global/content/nocake/actions': (var req) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.history_visibility':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.join_rules':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.guest_access':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.call.invite/1234':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.call.answer/1234':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.call.candidates/1234':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.call.hangup/1234':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/rooms/!1234%3Aexample.com/redact/1143273582443PhrSn%3Aexample.org/1234':
(var req) => {'event_id': '1234'},
'/client/v3/pushrules/global/room/!localpart%3Aserver.abc': (var req) =>
{},
<String, dynamic>{},
'/client/v3/pushrules/global/override/.m.rule.master/enabled':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/pushrules/global/content/nocake?before=1&after=2':
(var req) => {},
'/client/v3/devices/QBUAZIFURK': (var req) => {},
'/client/v3/directory/room/%23testalias%3Aexample.com': (var reqI) => {},
(var req) => <String, dynamic>{},
'/client/v3/devices/QBUAZIFURK': (var req) => <String, dynamic>{},
'/client/v3/directory/room/%23testalias%3Aexample.com': (var reqI) =>
<String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.room.message/testtxid':
(var reqI) => {
'event_id': '\$event${FakeMatrixApi.eventCounter++}',
@ -2281,7 +2298,7 @@ class FakeMatrixApi extends MockClient {
'event_id': '\$event${FakeMatrixApi.eventCounter++}',
},
'/client/v3/rooms/!localpart%3Aexample.com/typing/%40alice%3Aexample.com':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/rooms/!1234%3Aexample.com/send/m.room.message/1234':
(var reqI) => {
'event_id': '\$event${FakeMatrixApi.eventCounter++}',
@ -2291,25 +2308,27 @@ class FakeMatrixApi extends MockClient {
'event_id': '\$event${FakeMatrixApi.eventCounter++}',
},
'/client/v3/user/%40test%3AfakeServer.notExisting/rooms/!localpart%3Aserver.abc/tags/m.favourite':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/user/%40alice%3Aexample.com/rooms/!localpart%3Aexample.com/tags/testtag':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/user/%40alice%3Aexample.com/account_data/test.account.data':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/best%20animal':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/user/%40alice%3Aexample.com/rooms/1234/account_data/test.account.data':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/user/%40test%3AfakeServer.notExisting/rooms/!localpart%3Aserver.abc/account_data/com.famedly.marked_unread':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.direct':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/user/%40othertest%3AfakeServer.notExisting/account_data/m.direct':
(var req) => {},
'/client/v3/profile/%40alice%3Aexample.com/displayname': (var reqI) => {},
'/client/v3/profile/%40alice%3Aexample.com/avatar_url': (var reqI) => {},
(var req) => <String, dynamic>{},
'/client/v3/profile/%40alice%3Aexample.com/displayname': (var reqI) =>
<String, dynamic>{},
'/client/v3/profile/%40alice%3Aexample.com/avatar_url': (var reqI) =>
<String, dynamic>{},
'/client/v3/profile/%40test%3AfakeServer.notExisting/avatar_url':
(var reqI) => {},
(var reqI) => <String, dynamic>{},
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.encryption':
(var reqI) => {'event_id': 'YUwRidLecu:example.com'},
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.avatar':
@ -2335,8 +2354,8 @@ class FakeMatrixApi extends MockClient {
'event_id': '42',
},
'/client/v3/directory/list/room/!localpart%3Aexample.com': (var req) =>
{},
'/client/v3/room_keys/version/5': (var req) => {},
<String, dynamic>{},
'/client/v3/room_keys/version/5': (var req) => <String, dynamic>{},
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5':
(var req) => {
'etag': 'asdf',
@ -2354,16 +2373,18 @@ class FakeMatrixApi extends MockClient {
},
'DELETE': {
'/unknown/token': (var req) => {'errcode': 'M_UNKNOWN_TOKEN'},
'/client/v3/devices/QBUAZIFURK': (var req) => {},
'/client/v3/directory/room/%23testalias%3Aexample.com': (var reqI) => {},
'/client/v3/pushrules/global/content/nocake': (var req) => {},
'/client/v3/devices/QBUAZIFURK': (var req) => <String, dynamic>{},
'/client/v3/directory/room/%23testalias%3Aexample.com': (var reqI) =>
<String, dynamic>{},
'/client/v3/pushrules/global/content/nocake': (var req) =>
<String, dynamic>{},
'/client/v3/pushrules/global/override/!localpart%3Aserver.abc':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/user/%40test%3AfakeServer.notExisting/rooms/!localpart%3Aserver.abc/tags/m.favourite':
(var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/user/%40alice%3Aexample.com/rooms/!localpart%3Aexample.com/tags/testtag':
(var req) => {},
'/client/v3/room_keys/version/5': (var req) => {},
(var req) => <String, dynamic>{},
'/client/v3/room_keys/version/5': (var req) => <String, dynamic>{},
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5':
(var req) => {
'etag': 'asdf',

View File

@ -36,8 +36,9 @@ class RoomKeyRequestContent {
String requestId;
RoomKeyRequestContent.fromJson(Map<String, dynamic> json)
: body = ((x) => x != null ? RequestedKeyInfo.fromJson(x) : null)(
json.tryGet('body')),
: body = ((Map<String, dynamic>? x) => x != null
? RequestedKeyInfo.fromJson(x)
: null)(json.tryGet('body')),
action = json.tryGet('action', TryGet.required) ?? '',
requestingDeviceId =
json.tryGet('requesting_device_id', TryGet.required) ?? '',

View File

@ -38,8 +38,9 @@ class SecretStorageKeyContent {
SecretStorageKeyContent();
SecretStorageKeyContent.fromJson(Map<String, dynamic> json)
: passphrase = ((x) => x != null ? PassphraseInfo.fromJson(x) : null)(
json.tryGet('passphrase')),
: passphrase = ((Map<String, dynamic>? x) => x != null
? PassphraseInfo.fromJson(x)
: null)(json.tryGet('passphrase')),
iv = json.tryGet('iv'),
mac = json.tryGet('mac'),
algorithm = json.tryGet('algorithm');

View File

@ -238,7 +238,7 @@ void main() {
'type': 'some type',
'content': {
'images': {
'emote': {},
'emote': <String, dynamic>{},
},
},
};

View File

@ -27,6 +27,8 @@ import 'package:matrix_api_lite/fake_matrix_api.dart';
import 'package:matrix_api_lite/matrix_api_lite.dart';
import 'package:test/test.dart';
const emptyRequest = <String, dynamic>{};
void main() {
/// All Tests related to device keys
group('Matrix API', () {
@ -123,7 +125,7 @@ void main() {
final supportedVersions = await matrixApi.getVersions();
expect(supportedVersions.versions.contains('r0.5.0'), true);
expect(supportedVersions.unstableFeatures!['m.lazy_load_members'], true);
expect(FakeMatrixApi.api['GET']!['/client/versions']!.call({}),
expect(FakeMatrixApi.api['GET']!['/client/versions']!.call(emptyRequest),
supportedVersions.toJson());
matrixApi.homeserver = null;
});
@ -146,7 +148,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final loginTypes = await matrixApi.getLoginFlows();
expect(loginTypes?.first.type, 'm.login.password');
expect(FakeMatrixApi.api['GET']!['/client/v3/login']!.call({}),
expect(FakeMatrixApi.api['GET']!['/client/v3/login']!.call(emptyRequest),
{'flows': loginTypes?.map((x) => x.toJson()).toList()});
matrixApi.homeserver = null;
});
@ -156,7 +158,7 @@ void main() {
LoginType.mLoginPassword,
identifier: AuthenticationUserIdentifier(user: 'username'),
);
expect(FakeMatrixApi.api['POST']!['/client/v3/login']!.call({}),
expect(FakeMatrixApi.api['POST']!['/client/v3/login']!.call(emptyRequest),
loginResponse.toJson());
matrixApi.homeserver = null;
});
@ -178,7 +180,7 @@ void main() {
await matrixApi.register(kind: AccountKind.guest, username: 'test');
expect(
FakeMatrixApi.api['POST']!['/client/v3/register?kind=guest']!
.call({}),
.call(emptyRequest),
registerResponse.toJson());
matrixApi.homeserver = null;
});
@ -195,7 +197,7 @@ void main() {
);
expect(
FakeMatrixApi.api['POST']!['/client/v3/register/email/requestToken']!
.call({}),
.call(emptyRequest),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
});
@ -213,7 +215,7 @@ void main() {
);
expect(
FakeMatrixApi.api['POST']!['/client/v3/register/email/requestToken']!
.call({}),
.call(emptyRequest),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
});
@ -282,7 +284,9 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final response = await matrixApi.getAccount3PIDs();
expect(FakeMatrixApi.api['GET']!['/client/v3/account/3pid']!.call({}),
expect(
FakeMatrixApi.api['GET']!['/client/v3/account/3pid']!
.call(emptyRequest),
{'threepids': response?.map((t) => t.toJson()).toList()});
matrixApi.homeserver = matrixApi.accessToken = null;
});
@ -364,7 +368,9 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final response = await matrixApi.getCapabilities();
expect(FakeMatrixApi.api['GET']!['/client/v3/capabilities']!.call({}),
expect(
FakeMatrixApi.api['GET']!['/client/v3/capabilities']!
.call(emptyRequest),
{'capabilities': response.toJson()});
matrixApi.homeserver = matrixApi.accessToken = null;
});
@ -428,8 +434,8 @@ void main() {
'types': ['type1'],
},
'include_leave': true,
'state': {},
'timeline': {},
'state': <String, dynamic>{},
'timeline': <String, dynamic>{},
},
'presence': {
'limit': 10,
@ -500,7 +506,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/sync?filter=%7B%7D&since=1234&full_state=false&set_presence=unavailable&timeout=15']!
.call({}) as Map?,
.call(emptyRequest) as Map?,
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
});
@ -578,7 +584,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/rooms/!localpart%3Aserver.abc/messages?from=1234&to=1234&dir=b&limit=10&filter=%7B%22lazy_load_members%22%3Atrue%7D']!
.call({}) as Map?,
.call(emptyRequest) as Map?,
timelineHistoryResponse.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -669,7 +675,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/directory/room/%23testalias%3Aexample.com']!
.call({}),
.call(emptyRequest),
roomAliasInformation.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -832,7 +838,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/publicRooms?limit=10&since=1234&server=example.com']!
.call({}),
.call(emptyRequest),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -855,7 +861,7 @@ void main() {
expect(
FakeMatrixApi
.api['POST']!['/client/v3/publicRooms?server=example.com']!
.call({}),
.call(emptyRequest),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -870,7 +876,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v1/rooms/${Uri.encodeComponent('!gPxZhKUssFZKZcoCKY:neko.dev')}/hierarchy']!
.call({}),
.call(emptyRequest),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -886,7 +892,7 @@ void main() {
expect(
FakeMatrixApi.api['POST']!['/client/v3/user_directory/search']!
.call({}),
.call(emptyRequest),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -935,7 +941,7 @@ void main() {
expect(
FakeMatrixApi
.api['GET']!['/client/v3/profile/%40alice%3Aexample.com']!
.call({}),
.call(emptyRequest),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -945,7 +951,9 @@ void main() {
matrixApi.accessToken = '1234';
final response = await matrixApi.getTurnServer();
expect(FakeMatrixApi.api['GET']!['/client/v3/voip/turnServer']!.call({}),
expect(
FakeMatrixApi.api['GET']!['/client/v3/voip/turnServer']!
.call(emptyRequest),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -1010,7 +1018,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/presence/${Uri.encodeComponent('@alice:example.com')}/status']!
.call({}),
.call(emptyRequest),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -1041,7 +1049,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/media/v3/preview_url?url=https%3A%2F%2Fmatrix.org&ts=10']!
.call({}),
.call(emptyRequest),
openGraphData.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -1073,7 +1081,7 @@ void main() {
final devices = await matrixApi.getDevices();
expect(
(FakeMatrixApi.api['GET']!['/client/v3/devices']!.call({})
(FakeMatrixApi.api['GET']!['/client/v3/devices']!.call(emptyRequest)
as Map<String, dynamic>?)?['devices'],
devices?.map((i) => i.toJson()).toList());
@ -1145,7 +1153,7 @@ void main() {
'Alices mobile phone');
expect(
FakeMatrixApi.api['POST']!['/client/v3/keys/query']!
.call({'device_keys': {}}),
.call({'device_keys': emptyRequest}),
response.toJson());
matrixApi.homeserver = matrixApi.accessToken = null;
@ -1189,7 +1197,7 @@ void main() {
'ed25519:82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8':
'82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8',
},
'signatures': {},
'signatures': <String, dynamic>{},
});
final selfSigningKey = MatrixCrossSigningKey.fromJson({
'user_id': '@test:fakeServer.notExisting',
@ -1198,7 +1206,7 @@ void main() {
'ed25519:F9ypFzgbISXCzxQhhSnXMkc1vq12Luna3Nw5rqViOJY':
'F9ypFzgbISXCzxQhhSnXMkc1vq12Luna3Nw5rqViOJY',
},
'signatures': {},
'signatures': <String, dynamic>{},
});
final userSigningKey = MatrixCrossSigningKey.fromJson({
'user_id': '@test:fakeServer.notExisting',
@ -1207,7 +1215,7 @@ void main() {
'ed25519:0PiwulzJ/RU86LlzSSZ8St80HUMN3dqjKa/orIJoA0g':
'0PiwulzJ/RU86LlzSSZ8St80HUMN3dqjKa/orIJoA0g',
},
'signatures': {},
'signatures': <String, dynamic>{},
});
await matrixApi.uploadCrossSigningKeys(
masterKey: masterKey,
@ -1220,7 +1228,8 @@ void main() {
final response = await matrixApi.getPushers();
expect(
FakeMatrixApi.api['GET']!['/client/v3/pushers']!.call({}),
FakeMatrixApi.api['GET']!['/client/v3/pushers']!
.call(<String, dynamic>{}),
{'pushers': response?.map((i) => i.toJson()).toList()},
);
@ -1259,7 +1268,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/notifications?from=1234&limit=10&only=1234']!
.call({}),
.call(<String, dynamic>{}),
response.toJson(),
);
@ -1271,7 +1280,8 @@ void main() {
final response = await matrixApi.getPushRules();
expect(
FakeMatrixApi.api['GET']!['/client/v3/pushrules']!.call({}),
FakeMatrixApi.api['GET']!['/client/v3/pushrules']!
.call(<String, dynamic>{}),
{'global': response.toJson()},
);
@ -1285,7 +1295,7 @@ void main() {
await matrixApi.getPushRule('global', PushRuleKind.content, 'nocake');
expect(
FakeMatrixApi.api['GET']!['/client/v3/pushrules/global/content/nocake']!
.call({}),
.call(<String, dynamic>{}),
response.toJson(),
);
@ -1386,7 +1396,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/events?from=1234&timeout=10&room_id=%211234']!
.call({}),
.call(<String, dynamic>{}),
response.toJson(),
);
@ -1401,7 +1411,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/user/%40alice%3Aexample.com/rooms/!localpart%3Aexample.com/tags']!
.call({}),
.call(<String, dynamic>{}),
{'tags': response?.map((k, v) => MapEntry(k, v.toJson()))},
);
@ -1488,7 +1498,7 @@ void main() {
expect(
FakeMatrixApi
.api['GET']!['/client/v3/admin/whois/%40alice%3Aexample.com']!
.call({}),
.call(emptyRequest),
response.toJson(),
);
@ -1503,7 +1513,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/rooms/1234/context/1234?limit=10&filter=%7B%7D']!
.call({}),
.call(emptyRequest),
response.toJson(),
);
@ -1528,7 +1538,8 @@ void main() {
final response = await matrixApi.getProtocols();
expect(
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/protocols']!.call({}),
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/protocols']!
.call(emptyRequest),
response.map((k, v) => MapEntry(k, v.toJson())),
);
@ -1541,7 +1552,7 @@ void main() {
final response = await matrixApi.getProtocolMetadata('irc');
expect(
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/protocol/irc']!
.call({}),
.call(emptyRequest),
response.toJson(),
);
@ -1554,7 +1565,7 @@ void main() {
final response = await matrixApi.queryLocationByProtocol('irc');
expect(
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/location/irc']!
.call({}),
.call(emptyRequest),
response.map((i) => i.toJson()).toList(),
);
@ -1566,7 +1577,8 @@ void main() {
final response = await matrixApi.queryUserByProtocol('irc');
expect(
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/user/irc']!.call({}),
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/user/irc']!
.call(emptyRequest),
response.map((i) => i.toJson()).toList(),
);
@ -1579,7 +1591,7 @@ void main() {
final response = await matrixApi.queryLocationByAlias('1234');
expect(
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/location?alias=1234']!
.call({}),
.call(emptyRequest),
response.map((i) => i.toJson()).toList(),
);
@ -1592,7 +1604,7 @@ void main() {
final response = await matrixApi.queryUserByID('1234');
expect(
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/user?userid=1234']!
.call({}),
.call(emptyRequest),
response.map((i) => i.toJson()).toList(),
);
@ -1605,7 +1617,7 @@ void main() {
final response = await matrixApi.requestOpenIdToken('1234', {});
expect(
FakeMatrixApi.api['POST']!['/client/v3/user/1234/openid/request_token']!
.call({}),
.call(emptyRequest),
response.toJson(),
);
@ -1626,12 +1638,12 @@ void main() {
final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2;
final authData = <String, dynamic>{
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
'signatures': {},
'signatures': <String, dynamic>{},
};
final ret = await matrixApi.postRoomKeysVersion(algorithm, authData);
expect(
(FakeMatrixApi.api['POST']!['/client/v3/room_keys/version']!.call({})
as Map<String, dynamic>)['version'],
(FakeMatrixApi.api['POST']!['/client/v3/room_keys/version']!
.call(emptyRequest) as Map<String, dynamic>)['version'],
ret);
});
test('getRoomKeysVersionCurrent', () async {
@ -1640,7 +1652,8 @@ void main() {
final ret = await matrixApi.getRoomKeysVersionCurrent();
expect(
FakeMatrixApi.api['GET']!['/client/v3/room_keys/version']!.call({}),
FakeMatrixApi.api['GET']!['/client/v3/room_keys/version']!
.call(emptyRequest),
ret.toJson());
});
test('putRoomKeysVersion', () async {
@ -1650,7 +1663,7 @@ void main() {
final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2;
final authData = <String, dynamic>{
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
'signatures': {},
'signatures': <String, dynamic>{},
};
await matrixApi.putRoomKeysVersion('5', algorithm, authData);
});
@ -1682,7 +1695,7 @@ void main() {
expect(
FakeMatrixApi.api['PUT']![
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']!
.call({}),
.call(emptyRequest),
ret.toJson());
});
test('getRoomKeyBySessionId', () async {
@ -1695,7 +1708,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']!
.call({}),
.call(emptyRequest),
ret.toJson());
});
test('deleteRoomKeyBySessionId', () async {
@ -1709,7 +1722,7 @@ void main() {
expect(
FakeMatrixApi.api['DELETE']![
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']!
.call({}),
.call(emptyRequest),
ret.toJson());
});
test('putRoomKeysByRoomId', () async {
@ -1737,7 +1750,7 @@ void main() {
expect(
FakeMatrixApi.api['PUT']![
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']!
.call({}),
.call(emptyRequest),
ret.toJson());
});
test('getRoomKeysByRoomId', () async {
@ -1749,7 +1762,7 @@ void main() {
expect(
FakeMatrixApi.api['GET']![
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']!
.call({}),
.call(emptyRequest),
ret.toJson());
});
test('deleteRoomKeysByRoomId', () async {
@ -1761,7 +1774,7 @@ void main() {
expect(
FakeMatrixApi.api['DELETE']![
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']!
.call({}),
.call(emptyRequest),
ret.toJson());
});
test('putRoomKeys', () async {
@ -1792,7 +1805,7 @@ void main() {
final ret = await matrixApi.putRoomKeys('5', session);
expect(
FakeMatrixApi.api['PUT']!['/client/v3/room_keys/keys?version=5']!
.call({}),
.call(emptyRequest),
ret.toJson());
});
test('getRoomKeys', () async {
@ -1802,7 +1815,7 @@ void main() {
final ret = await matrixApi.getRoomKeys('5');
expect(
FakeMatrixApi.api['GET']!['/client/v3/room_keys/keys?version=5']!
.call({}),
.call(emptyRequest),
ret.toJson());
});
test('deleteRoomKeys', () async {
@ -1812,7 +1825,7 @@ void main() {
final ret = await matrixApi.deleteRoomKeys('5');
expect(
FakeMatrixApi.api['DELETE']!['/client/v3/room_keys/keys?version=5']!
.call({}),
.call(emptyRequest),
ret.toJson());
});
test('AuthenticationData', () {