chore: disable dynamic calls
This commit is contained in:
parent
57ec5014d9
commit
7471743be3
|
|
@ -7,6 +7,7 @@ linter:
|
|||
constant_identifier_names: false
|
||||
prefer_final_locals: true
|
||||
prefer_final_in_for_each: true
|
||||
avoid_dynamic_calls: true
|
||||
|
||||
analyzer:
|
||||
errors:
|
||||
|
|
|
|||
|
|
@ -33,12 +33,14 @@ Map<String, dynamic> decodeJson(dynamic data) {
|
|||
if (data is String) {
|
||||
return json.decode(data);
|
||||
}
|
||||
if (data.isEmpty) {
|
||||
if (data is Map && data.isEmpty) {
|
||||
return <String, dynamic>{};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
T? tryCast<T>(dynamic object) => object is T ? object : null;
|
||||
|
||||
/// A mock http client for testing purposes.
|
||||
class FakeMatrixApi extends MockClient {
|
||||
static final calledEndpoints = <String, List<dynamic>>{};
|
||||
|
|
@ -83,7 +85,7 @@ class FakeMatrixApi extends MockClient {
|
|||
}
|
||||
calledEndpoints[action]!.add(data);
|
||||
if (api.containsKey(method) && api[method]!.containsKey(action)) {
|
||||
res = api[method];
|
||||
res = api[method]![action]?.call(data);
|
||||
if (res is Map && res.containsKey('errcode')) {
|
||||
statusCode = 405;
|
||||
}
|
||||
|
|
@ -953,7 +955,7 @@ class FakeMatrixApi extends MockClient {
|
|||
]
|
||||
};
|
||||
|
||||
static final Map<String, Map<String, dynamic>> api = {
|
||||
static final Map<String, Map<String, dynamic Function(dynamic)>> api = {
|
||||
'GET': {
|
||||
'/path/to/auth/error': (var req) => {
|
||||
'errcode': 'M_FORBIDDEN',
|
||||
|
|
@ -1942,42 +1944,45 @@ class FakeMatrixApi extends MockClient {
|
|||
'prev_batch': 'p1902',
|
||||
'total_room_count_estimate': 115
|
||||
},
|
||||
'/client/v3/keys/claim': (var req) => {
|
||||
'failures': {},
|
||||
'one_time_keys': {
|
||||
if (decodeJson(req)['one_time_keys']['@alice:example.com'] !=
|
||||
null)
|
||||
'@alice:example.com': {
|
||||
'JLAFKJWSCS': {
|
||||
'signed_curve25519:AAAAAQ': {
|
||||
'key': 'ikMXajRlkS7Xi9CROrAh3jXnbygk8mLBdSaY9/al0X0',
|
||||
'signatures': {
|
||||
'@alice:example.com': {
|
||||
'ed25519:JLAFKJWSCS':
|
||||
'XdboCa0Ljoh0Y0i/IVnmMqy/+T1hJyu8BA/nRYniJMQ7QWh/pGS5AsWswdARD+MAX+r4u98Qzk0y27HUddZXDA'
|
||||
}
|
||||
'/client/v3/keys/claim': (dynamic req) {
|
||||
final request = decodeJson(req)["one_time_keys"];
|
||||
final keys = (request is Map<String, dynamic>)
|
||||
? request["one_time_keys"] as Map<String, dynamic>?
|
||||
: null;
|
||||
return {
|
||||
'failures': {},
|
||||
'one_time_keys': {
|
||||
if (keys?['@alice:example.com'] != null)
|
||||
'@alice:example.com': {
|
||||
'JLAFKJWSCS': {
|
||||
'signed_curve25519:AAAAAQ': {
|
||||
'key': 'ikMXajRlkS7Xi9CROrAh3jXnbygk8mLBdSaY9/al0X0',
|
||||
'signatures': {
|
||||
'@alice:example.com': {
|
||||
'ed25519:JLAFKJWSCS':
|
||||
'XdboCa0Ljoh0Y0i/IVnmMqy/+T1hJyu8BA/nRYniJMQ7QWh/pGS5AsWswdARD+MAX+r4u98Qzk0y27HUddZXDA'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
if (decodeJson(req)['one_time_keys']
|
||||
['@test:fakeServer.notExisting'] !=
|
||||
null)
|
||||
'@test:fakeServer.notExisting': {
|
||||
'GHTYAJCE': {
|
||||
'signed_curve25519:AAAAAQ': {
|
||||
'key': 'qc72ve94cA28iuE0fXa98QO3uls39DHWdQlYyvvhGh0',
|
||||
'signatures': {
|
||||
'@test:fakeServer.notExisting': {
|
||||
'ed25519:GHTYAJCE':
|
||||
'dFwffr5kTKefO7sjnWLMhTzw7oV31nkPIDRxFy5OQT2OP5++Ao0KRbaBZ6qfuT7lW1owKK0Xk3s7QTBvc/eNDA',
|
||||
},
|
||||
}
|
||||
},
|
||||
if (keys?['@test:fakeServer.notExisting'] != null)
|
||||
'@test:fakeServer.notExisting': {
|
||||
'GHTYAJCE': {
|
||||
'signed_curve25519:AAAAAQ': {
|
||||
'key': 'qc72ve94cA28iuE0fXa98QO3uls39DHWdQlYyvvhGh0',
|
||||
'signatures': {
|
||||
'@test:fakeServer.notExisting': {
|
||||
'ed25519:GHTYAJCE':
|
||||
'dFwffr5kTKefO7sjnWLMhTzw7oV31nkPIDRxFy5OQT2OP5++Ao0KRbaBZ6qfuT7lW1owKK0Xk3s7QTBvc/eNDA',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
},
|
||||
'/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) => {},
|
||||
|
|
@ -1992,8 +1997,11 @@ class FakeMatrixApi extends MockClient {
|
|||
'/client/v3/keys/upload': (var req) => {
|
||||
'one_time_key_counts': {
|
||||
'curve25519': 10,
|
||||
'signed_curve25519':
|
||||
decodeJson(req)['one_time_keys']?.keys?.length ?? 0,
|
||||
'signed_curve25519': tryCast<Map<String, Map<String, dynamic>>>(
|
||||
decodeJson(req))?['one_time_keys']
|
||||
?.keys
|
||||
.length ??
|
||||
0,
|
||||
}
|
||||
},
|
||||
'/client/v3/keys/query': (var req) => {
|
||||
|
|
|
|||
|
|
@ -209,7 +209,10 @@ class MatrixApi extends Api {
|
|||
|
||||
// fix invalid responses from synapse
|
||||
// https://github.com/matrix-org/synapse/pull/10922
|
||||
json['ttl'] = json['ttl'].toInt();
|
||||
final ttl = json['ttl'];
|
||||
if (ttl is double) {
|
||||
json['ttl'] = ttl.toInt();
|
||||
}
|
||||
|
||||
return TurnServerCredentials.fromJson(json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,12 +106,14 @@ class MatrixException implements Exception {
|
|||
/// to authenticate itself. Each flow comprises a series of stages. If this request
|
||||
/// doesn't need additional authentication, then this is null.
|
||||
List<AuthenticationFlow>? get authenticationFlows {
|
||||
if (!raw.containsKey('flows') || raw['flows'] is! List) return null;
|
||||
return (raw['flows'] as List)
|
||||
.map((flow) => flow['stages'])
|
||||
.whereType<List>()
|
||||
.map((stages) => AuthenticationFlow(List<String>.from(stages)))
|
||||
.toList();
|
||||
final flows = raw['flows'];
|
||||
return (flows is List<Map<String, List<String>>>)
|
||||
? flows
|
||||
.map((flow) => flow['stages'])
|
||||
.whereType<List<String>>()
|
||||
.map((stages) => AuthenticationFlow(List<String>.from(stages)))
|
||||
.toList()
|
||||
: null;
|
||||
}
|
||||
|
||||
/// This section contains any information that the client will need to know in order to use a given type
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class MatrixDeviceKeys extends MatrixSignableKey {
|
|||
|
||||
@override
|
||||
MatrixDeviceKeys.fromJson(Map<String, dynamic> json)
|
||||
: algorithms = json['algorithms'].cast<String>(),
|
||||
: algorithms = (json['algorithms'] as List).cast<String>(),
|
||||
deviceId = json['device_id'],
|
||||
super.fromJson(json);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,24 +54,15 @@ class SyncUpdate {
|
|||
: nextBatch = json['next_batch'],
|
||||
rooms =
|
||||
json['rooms'] != null ? RoomsUpdate.fromJson(json['rooms']) : null,
|
||||
presence =
|
||||
(json['presence'] != null && json['presence']['events'] != null)
|
||||
? (json['presence']['events'] as List)
|
||||
.map((i) => Presence.fromJson(i))
|
||||
.toList()
|
||||
: null,
|
||||
accountData = (json['account_data'] != null &&
|
||||
json['account_data']['events'] != null)
|
||||
? (json['account_data']['events'] as List)
|
||||
.map((i) => BasicEvent.fromJson(i))
|
||||
.toList()
|
||||
: null,
|
||||
toDevice =
|
||||
(json['to_device'] != null && json['to_device']['events'] != null)
|
||||
? (json['to_device']['events'] as List)
|
||||
.map((i) => BasicEventWithSender.fromJson(i))
|
||||
.toList()
|
||||
: null,
|
||||
presence = ((json['presence'] as Map?)?['events'] as List?)
|
||||
?.map((i) => Presence.fromJson(i))
|
||||
.toList(),
|
||||
accountData = ((json['account_data'] as Map?)?['events'] as List?)
|
||||
?.map((i) => BasicEvent.fromJson(i))
|
||||
.toList(),
|
||||
toDevice = ((json['to_device'] as Map?)?['events'] as List?)
|
||||
?.map((i) => BasicEventWithSender.fromJson(i))
|
||||
.toList(),
|
||||
deviceLists = json['device_lists'] != null
|
||||
? DeviceListsUpdate.fromJson(json['device_lists'])
|
||||
: null,
|
||||
|
|
@ -183,34 +174,25 @@ class JoinedRoomUpdate extends SyncRoomUpdate {
|
|||
this.unreadNotifications,
|
||||
});
|
||||
|
||||
JoinedRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
summary =
|
||||
json['summary'] != null ? RoomSummary.fromJson(json['summary']) : null;
|
||||
state = (json['state'] != null && json['state']['events'] != null)
|
||||
? (json['state']['events'] as List)
|
||||
.map((i) => MatrixEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
timeline = json['timeline'] != null
|
||||
? TimelineUpdate.fromJson(json['timeline'])
|
||||
: null;
|
||||
|
||||
ephemeral =
|
||||
(json['ephemeral'] != null && json['ephemeral']['events'] != null)
|
||||
? (json['ephemeral']['events'] as List)
|
||||
.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList()
|
||||
JoinedRoomUpdate.fromJson(Map<String, dynamic> json)
|
||||
: summary = json['summary'] != null
|
||||
? RoomSummary.fromJson(json['summary'])
|
||||
: null,
|
||||
state = ((json['state'] as Map?)?['events'] as List?)
|
||||
?.map((i) => MatrixEvent.fromJson(i))
|
||||
.toList(),
|
||||
timeline = json['timeline'] != null
|
||||
? TimelineUpdate.fromJson(json['timeline'])
|
||||
: null,
|
||||
ephemeral = ((json['ephemeral'] as Map?)?['events'] as List?)
|
||||
?.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList(),
|
||||
accountData = ((json['account_data'] as Map?)?['events'] as List?)
|
||||
?.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList(),
|
||||
unreadNotifications = json['unread_notifications'] != null
|
||||
? UnreadNotificationCounts.fromJson(json['unread_notifications'])
|
||||
: null;
|
||||
accountData =
|
||||
(json['account_data'] != null && json['account_data']['events'] != null)
|
||||
? (json['account_data']['events'] as List)
|
||||
.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
unreadNotifications = json['unread_notifications'] != null
|
||||
? UnreadNotificationCounts.fromJson(json['unread_notifications'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
|
|
@ -247,14 +229,10 @@ class InvitedRoomUpdate extends SyncRoomUpdate {
|
|||
|
||||
InvitedRoomUpdate({this.inviteState});
|
||||
|
||||
InvitedRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
inviteState =
|
||||
(json['invite_state'] != null && json['invite_state']['events'] != null)
|
||||
? (json['invite_state']['events'] as List)
|
||||
.map((i) => StrippedStateEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
}
|
||||
InvitedRoomUpdate.fromJson(Map<String, dynamic> json)
|
||||
: inviteState = ((json['invite_state'] as Map?)?['events'] as List?)
|
||||
?.map((i) => StrippedStateEvent.fromJson(i))
|
||||
.toList();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
|
|
@ -278,22 +256,16 @@ class LeftRoomUpdate extends SyncRoomUpdate {
|
|||
this.accountData,
|
||||
});
|
||||
|
||||
LeftRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
state = (json['state'] != null && json['state']['events'] != null)
|
||||
? (json['state']['events'] as List)
|
||||
.map((i) => MatrixEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
timeline = json['timeline'] != null
|
||||
? TimelineUpdate.fromJson(json['timeline'])
|
||||
: null;
|
||||
accountData =
|
||||
(json['account_data'] != null && json['account_data']['events'] != null)
|
||||
? (json['account_data']['events'] as List)
|
||||
.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
}
|
||||
LeftRoomUpdate.fromJson(Map<String, dynamic> json)
|
||||
: state = ((json['state'] as Map?)?['events'] as List?)
|
||||
?.map((i) => MatrixEvent.fromJson(i))
|
||||
.toList(),
|
||||
timeline = json['timeline'] != null
|
||||
? TimelineUpdate.fromJson(json['timeline'])
|
||||
: null,
|
||||
accountData = ((json['account_data'] as Map?)?['events'] as List?)
|
||||
?.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ void main() {
|
|||
},
|
||||
};
|
||||
final copy = original.copy();
|
||||
original['child']['attr'] = 'raccoon';
|
||||
expect(copy['child']['attr'], 'bunny');
|
||||
original['child']['list'].add(3);
|
||||
expect(copy['child']['list'], [1, 2]);
|
||||
(original['child'] as Map<String, dynamic>)['attr'] = 'raccoon';
|
||||
expect((copy['child'] as Map<String, dynamic>)['attr'], 'bunny');
|
||||
((original['child'] as Map<String, dynamic>)['list'] as List<int>).add(3);
|
||||
expect((copy['child'] as Map<String, dynamic>)['list'], [1, 2]);
|
||||
});
|
||||
test('should do arrays', () {
|
||||
final original = <String, dynamic>{
|
||||
|
|
@ -48,10 +48,11 @@ void main() {
|
|||
],
|
||||
};
|
||||
final copy = original.copy();
|
||||
original['arr'][0].add(3);
|
||||
expect(copy['arr'][0], [1, 2]);
|
||||
original['arr'][1]['beep'] = 'blargh';
|
||||
expect(copy['arr'][1]['beep'], 'boop');
|
||||
((original['arr'] as List)[0] as List<int>).add(3);
|
||||
expect((copy['arr'] as List)[0], [1, 2]);
|
||||
((original['arr'] as List)[1] as Map<String, dynamic>)['beep'] = 'blargh';
|
||||
expect(
|
||||
((copy['arr'] as List)[1] as Map<String, dynamic>)['beep'], 'boop');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,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'],
|
||||
expect(FakeMatrixApi.api['GET']!['/client/versions']!.call({}),
|
||||
supportedVersions.toJson());
|
||||
matrixApi.homeserver = null;
|
||||
});
|
||||
|
|
@ -146,7 +146,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'],
|
||||
expect(FakeMatrixApi.api['GET']!['/client/v3/login']!.call({}),
|
||||
{'flows': loginTypes?.map((x) => x.toJson()).toList()});
|
||||
matrixApi.homeserver = null;
|
||||
});
|
||||
|
|
@ -156,7 +156,7 @@ void main() {
|
|||
LoginType.mLoginPassword,
|
||||
identifier: AuthenticationUserIdentifier(user: 'username'),
|
||||
);
|
||||
expect(FakeMatrixApi.api['POST'],
|
||||
expect(FakeMatrixApi.api['POST']!['/client/v3/login']!.call({}),
|
||||
loginResponse.toJson());
|
||||
matrixApi.homeserver = null;
|
||||
});
|
||||
|
|
@ -176,7 +176,9 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
final registerResponse =
|
||||
await matrixApi.register(kind: AccountKind.guest, username: 'test');
|
||||
expect(FakeMatrixApi.api['POST'],
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']!['/client/v3/register?kind=guest']!
|
||||
.call({}),
|
||||
registerResponse.toJson());
|
||||
matrixApi.homeserver = null;
|
||||
});
|
||||
|
|
@ -192,8 +194,8 @@ void main() {
|
|||
idAccessToken: '1234',
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['POST'],
|
||||
FakeMatrixApi.api['POST']!['/client/v3/register/email/requestToken']!
|
||||
.call({}),
|
||||
response.toJson());
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
});
|
||||
|
|
@ -210,8 +212,8 @@ void main() {
|
|||
idAccessToken: '1234',
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['POST'],
|
||||
FakeMatrixApi.api['POST']!['/client/v3/register/email/requestToken']!
|
||||
.call({}),
|
||||
response.toJson());
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
});
|
||||
|
|
@ -280,7 +282,7 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
matrixApi.accessToken = '1234';
|
||||
final response = await matrixApi.getAccount3PIDs();
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
expect(FakeMatrixApi.api['GET']!['/client/v3/account/3pid']!.call({}),
|
||||
{'threepids': response?.map((t) => t.toJson()).toList()});
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
});
|
||||
|
|
@ -362,7 +364,7 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
matrixApi.accessToken = '1234';
|
||||
final response = await matrixApi.getCapabilities();
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
expect(FakeMatrixApi.api['GET']!['/client/v3/capabilities']!.call({}),
|
||||
{'capabilities': response.toJson()});
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
});
|
||||
|
|
@ -497,8 +499,8 @@ void main() {
|
|||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'] as Map?,
|
||||
'/client/v3/sync?filter=%7B%7D&since=1234&full_state=false&set_presence=unavailable&timeout=15']!
|
||||
.call({}) as Map?,
|
||||
response.toJson());
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
});
|
||||
|
|
@ -575,8 +577,8 @@ void main() {
|
|||
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'] as Map?,
|
||||
'/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?,
|
||||
timelineHistoryResponse.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -666,7 +668,8 @@ void main() {
|
|||
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v3/directory/room/%23testalias%3Aexample.com']!
|
||||
.call({}),
|
||||
roomAliasInformation.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -828,7 +831,8 @@ void main() {
|
|||
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v3/publicRooms?limit=10&since=1234&server=example.com']!
|
||||
.call({}),
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -850,7 +854,8 @@ void main() {
|
|||
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['POST'],
|
||||
.api['POST']!['/client/v3/publicRooms?server=example.com']!
|
||||
.call({}),
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -864,7 +869,8 @@ void main() {
|
|||
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v1/rooms/${Uri.encodeComponent('!gPxZhKUssFZKZcoCKY:neko.dev')}/hierarchy']!
|
||||
.call({}),
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -878,7 +884,9 @@ void main() {
|
|||
limit: 10,
|
||||
);
|
||||
|
||||
expect(FakeMatrixApi.api['POST'],
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']!['/client/v3/user_directory/search']!
|
||||
.call({}),
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -926,7 +934,8 @@ void main() {
|
|||
final response = await matrixApi.getUserProfile('@alice:example.com');
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['GET'],
|
||||
.api['GET']!['/client/v3/profile/%40alice%3Aexample.com']!
|
||||
.call({}),
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -936,7 +945,7 @@ void main() {
|
|||
matrixApi.accessToken = '1234';
|
||||
|
||||
final response = await matrixApi.getTurnServer();
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
expect(FakeMatrixApi.api['GET']!['/client/v3/voip/turnServer']!.call({}),
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -1000,7 +1009,8 @@ void main() {
|
|||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v3/presence/${Uri.encodeComponent('@alice:example.com')}/status']!
|
||||
.call({}),
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -1030,7 +1040,8 @@ void main() {
|
|||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/media/v3/preview_url?url=https%3A%2F%2Fmatrix.org&ts=10']!
|
||||
.call({}),
|
||||
openGraphData.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -1061,7 +1072,9 @@ void main() {
|
|||
matrixApi.accessToken = '1234';
|
||||
|
||||
final devices = await matrixApi.getDevices();
|
||||
expect(FakeMatrixApi.api['GET']['devices'],
|
||||
expect(
|
||||
(FakeMatrixApi.api['GET']!['/client/v3/devices']!.call({})
|
||||
as Map<String, dynamic>?)?['devices'],
|
||||
devices?.map((i) => i.toJson()).toList());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -1131,8 +1144,8 @@ void main() {
|
|||
.deviceDisplayName,
|
||||
'Alices mobile phone');
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['POST'],
|
||||
FakeMatrixApi.api['POST']!['/client/v3/keys/query']!
|
||||
.call({'device_keys': {}}),
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -1148,7 +1161,7 @@ void main() {
|
|||
timeout: 10,
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['POST'] {
|
|||
|
||||
final response = await matrixApi.getPushers();
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/pushers']!.call({}),
|
||||
{'pushers': response?.map((i) => i.toJson()).toList()},
|
||||
);
|
||||
|
||||
|
|
@ -1245,7 +1258,8 @@ void main() {
|
|||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v3/notifications?from=1234&limit=10&only=1234']!
|
||||
.call({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1257,7 +1271,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.getPushRules();
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/pushrules']!.call({}),
|
||||
{'global': response.toJson()},
|
||||
);
|
||||
|
||||
|
|
@ -1270,8 +1284,8 @@ void main() {
|
|||
final response =
|
||||
await matrixApi.getPushRule('global', PushRuleKind.content, 'nocake');
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/pushrules/global/content/nocake']!
|
||||
.call({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1371,7 +1385,8 @@ void main() {
|
|||
from: '1234', roomId: '!1234', timeout: 10);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v3/events?from=1234&timeout=10&room_id=%211234']!
|
||||
.call({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1385,7 +1400,8 @@ void main() {
|
|||
'@alice:example.com', '!localpart:example.com');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v3/user/%40alice%3Aexample.com/rooms/!localpart%3Aexample.com/tags']!
|
||||
.call({}),
|
||||
{'tags': response?.map((k, v) => MapEntry(k, v.toJson()))},
|
||||
);
|
||||
|
||||
|
|
@ -1471,7 +1487,8 @@ void main() {
|
|||
final response = await matrixApi.getWhoIs('@alice:example.com');
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['GET'],
|
||||
.api['GET']!['/client/v3/admin/whois/%40alice%3Aexample.com']!
|
||||
.call({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1485,7 +1502,8 @@ void main() {
|
|||
limit: 10, filter: '{}');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v3/rooms/1234/context/1234?limit=10&filter=%7B%7D']!
|
||||
.call({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1510,7 +1528,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.getProtocols();
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/protocols']!.call({}),
|
||||
response.map((k, v) => MapEntry(k, v.toJson())),
|
||||
);
|
||||
|
||||
|
|
@ -1522,7 +1540,8 @@ void main() {
|
|||
|
||||
final response = await matrixApi.getProtocolMetadata('irc');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/protocol/irc']!
|
||||
.call({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1534,7 +1553,8 @@ void main() {
|
|||
|
||||
final response = await matrixApi.queryLocationByProtocol('irc');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/location/irc']!
|
||||
.call({}),
|
||||
response.map((i) => i.toJson()).toList(),
|
||||
);
|
||||
|
||||
|
|
@ -1546,7 +1566,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.queryUserByProtocol('irc');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/user/irc']!.call({}),
|
||||
response.map((i) => i.toJson()).toList(),
|
||||
);
|
||||
|
||||
|
|
@ -1558,8 +1578,8 @@ void main() {
|
|||
|
||||
final response = await matrixApi.queryLocationByAlias('1234');
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/location?alias=1234']!
|
||||
.call({}),
|
||||
response.map((i) => i.toJson()).toList(),
|
||||
);
|
||||
|
||||
|
|
@ -1571,7 +1591,8 @@ void main() {
|
|||
|
||||
final response = await matrixApi.queryUserByID('1234');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/thirdparty/user?userid=1234']!
|
||||
.call({}),
|
||||
response.map((i) => i.toJson()).toList(),
|
||||
);
|
||||
|
||||
|
|
@ -1583,8 +1604,8 @@ void main() {
|
|||
|
||||
final response = await matrixApi.requestOpenIdToken('1234', {});
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['POST'],
|
||||
FakeMatrixApi.api['POST']!['/client/v3/user/1234/openid/request_token']!
|
||||
.call({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1609,8 +1630,8 @@ void main() {
|
|||
};
|
||||
final ret = await matrixApi.postRoomKeysVersion(algorithm, authData);
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['POST']['version'],
|
||||
(FakeMatrixApi.api['POST']!['/client/v3/room_keys/version']!.call({})
|
||||
as Map<String, dynamic>)['version'],
|
||||
ret);
|
||||
});
|
||||
test('getRoomKeysVersionCurrent', () async {
|
||||
|
|
@ -1618,7 +1639,8 @@ void main() {
|
|||
matrixApi.accessToken = '1234';
|
||||
|
||||
final ret = await matrixApi.getRoomKeysVersionCurrent();
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']!['/client/v3/room_keys/version']!.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('putRoomKeysVersion', () async {
|
||||
|
|
@ -1659,7 +1681,8 @@ void main() {
|
|||
roomId, sessionId, '5', session);
|
||||
expect(
|
||||
FakeMatrixApi.api['PUT'],
|
||||
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']!
|
||||
.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('getRoomKeyBySessionId', () async {
|
||||
|
|
@ -1671,7 +1694,8 @@ void main() {
|
|||
final ret = await matrixApi.getRoomKeyBySessionId(roomId, sessionId, '5');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']!
|
||||
.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('deleteRoomKeyBySessionId', () async {
|
||||
|
|
@ -1684,7 +1708,8 @@ void main() {
|
|||
await matrixApi.deleteRoomKeyBySessionId(roomId, sessionId, '5');
|
||||
expect(
|
||||
FakeMatrixApi.api['DELETE'],
|
||||
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']!
|
||||
.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('putRoomKeysByRoomId', () async {
|
||||
|
|
@ -1711,7 +1736,8 @@ void main() {
|
|||
final ret = await matrixApi.putRoomKeysByRoomId(roomId, '5', session);
|
||||
expect(
|
||||
FakeMatrixApi.api['PUT'],
|
||||
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']!
|
||||
.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('getRoomKeysByRoomId', () async {
|
||||
|
|
@ -1722,7 +1748,8 @@ void main() {
|
|||
final ret = await matrixApi.getRoomKeysByRoomId(roomId, '5');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']!
|
||||
.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('deleteRoomKeysByRoomId', () async {
|
||||
|
|
@ -1733,7 +1760,8 @@ void main() {
|
|||
final ret = await matrixApi.deleteRoomKeysByRoomId(roomId, '5');
|
||||
expect(
|
||||
FakeMatrixApi.api['DELETE'],
|
||||
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']!
|
||||
.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('putRoomKeys', () async {
|
||||
|
|
@ -1763,7 +1791,8 @@ void main() {
|
|||
});
|
||||
final ret = await matrixApi.putRoomKeys('5', session);
|
||||
expect(
|
||||
FakeMatrixApi.api['PUT'],
|
||||
FakeMatrixApi.api['PUT']!['/client/v3/room_keys/keys?version=5']!
|
||||
.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('getRoomKeys', () async {
|
||||
|
|
@ -1772,7 +1801,8 @@ void main() {
|
|||
|
||||
final ret = await matrixApi.getRoomKeys('5');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'],
|
||||
FakeMatrixApi.api['GET']!['/client/v3/room_keys/keys?version=5']!
|
||||
.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('deleteRoomKeys', () async {
|
||||
|
|
@ -1781,8 +1811,8 @@ void main() {
|
|||
|
||||
final ret = await matrixApi.deleteRoomKeys('5');
|
||||
expect(
|
||||
FakeMatrixApi
|
||||
.api['DELETE'],
|
||||
FakeMatrixApi.api['DELETE']!['/client/v3/room_keys/keys?version=5']!
|
||||
.call({}),
|
||||
ret.toJson());
|
||||
});
|
||||
test('AuthenticationData', () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue