chore: expose fake matrix api
This commit is contained in:
parent
5cf1e65838
commit
a2e8830df0
|
|
@ -240,26 +240,28 @@ class FakeMatrixApi extends BaseClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<StreamedResponse> send(BaseRequest baseRequest) async {
|
Future<StreamedResponse> send(BaseRequest request) async {
|
||||||
final bodyStream = baseRequest.finalize();
|
final bodyStream = request.finalize();
|
||||||
final bodyBytes = await bodyStream.toBytes();
|
final bodyBytes = await bodyStream.toBytes();
|
||||||
final request = Request(baseRequest.method, baseRequest.url)
|
final r = Request(request.method, request.url)
|
||||||
..persistentConnection = baseRequest.persistentConnection
|
..persistentConnection = request.persistentConnection
|
||||||
..followRedirects = baseRequest.followRedirects
|
..followRedirects = request.followRedirects
|
||||||
..maxRedirects = baseRequest.maxRedirects
|
..maxRedirects = request.maxRedirects
|
||||||
..headers.addAll(baseRequest.headers)
|
..headers.addAll(request.headers)
|
||||||
..bodyBytes = bodyBytes
|
..bodyBytes = bodyBytes
|
||||||
..finalize();
|
..finalize();
|
||||||
|
|
||||||
final response = await mockIntercept(request);
|
final response = await mockIntercept(r);
|
||||||
return StreamedResponse(
|
return StreamedResponse(
|
||||||
ByteStream.fromBytes(response.bodyBytes), response.statusCode,
|
ByteStream.fromBytes(response.bodyBytes),
|
||||||
contentLength: response.contentLength,
|
response.statusCode,
|
||||||
request: baseRequest,
|
contentLength: response.contentLength,
|
||||||
headers: response.headers,
|
request: request,
|
||||||
isRedirect: response.isRedirect,
|
headers: response.headers,
|
||||||
persistentConnection: response.persistentConnection,
|
isRedirect: response.isRedirect,
|
||||||
reasonPhrase: response.reasonPhrase);
|
persistentConnection: response.persistentConnection,
|
||||||
|
reasonPhrase: response.reasonPhrase,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeMatrixApi() {
|
FakeMatrixApi() {
|
||||||
|
|
@ -21,6 +21,8 @@ library matrix;
|
||||||
|
|
||||||
export 'matrix_api_lite.dart';
|
export 'matrix_api_lite.dart';
|
||||||
|
|
||||||
|
export 'fake_matrix_api.dart' show FakeMatrixApi;
|
||||||
|
|
||||||
export 'src/client.dart';
|
export 'src/client.dart';
|
||||||
export 'src/database/database_api.dart';
|
export 'src/database/database_api.dart';
|
||||||
export 'src/database/hive_database.dart';
|
export 'src/database/hive_database.dart';
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ import 'package:matrix/matrix.dart';
|
||||||
import 'package:matrix/src/utils/client_init_exception.dart';
|
import 'package:matrix/src/utils/client_init_exception.dart';
|
||||||
import 'fake_client.dart';
|
import 'fake_client.dart';
|
||||||
import 'fake_database.dart';
|
import 'fake_database.dart';
|
||||||
import 'fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
late Client matrix;
|
late Client matrix;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'fake_client.dart';
|
import 'fake_client.dart';
|
||||||
import 'fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Commands', tags: 'olm', () {
|
group('Commands', tags: 'olm', () {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import './fake_client.dart';
|
import './fake_client.dart';
|
||||||
import './fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
/// All Tests related to device keys
|
/// All Tests related to device keys
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import '../fake_client.dart';
|
import '../fake_client.dart';
|
||||||
import '../fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Cross Signing', tags: 'olm', () {
|
group('Cross Signing', tags: 'olm', () {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import 'package:test/test.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import '../fake_client.dart';
|
import '../fake_client.dart';
|
||||||
import '../fake_database.dart';
|
import '../fake_database.dart';
|
||||||
import '../fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// key @othertest:fakeServer.notExisting
|
// key @othertest:fakeServer.notExisting
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import '../fake_client.dart';
|
import '../fake_client.dart';
|
||||||
import '../fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Key Manager', tags: 'olm', () {
|
group('Key Manager', tags: 'olm', () {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import '../fake_client.dart';
|
import '../fake_client.dart';
|
||||||
import '../fake_matrix_api.dart';
|
|
||||||
|
|
||||||
Map<String, dynamic> jsonDecode(dynamic payload) {
|
Map<String, dynamic> jsonDecode(dynamic payload) {
|
||||||
if (payload is String) {
|
if (payload is String) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ import 'package:matrix/encryption.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import '../fake_client.dart';
|
import '../fake_client.dart';
|
||||||
import '../fake_database.dart';
|
import '../fake_database.dart';
|
||||||
import '../fake_matrix_api.dart';
|
|
||||||
|
|
||||||
EventUpdate getLastSentEvent(KeyVerification req) {
|
EventUpdate getLastSentEvent(KeyVerification req) {
|
||||||
final entry = FakeMatrixApi.calledEndpoints.entries
|
final entry = FakeMatrixApi.calledEndpoints.entries
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import 'package:test/test.dart';
|
||||||
import 'package:matrix/encryption/utils/json_signature_check_extension.dart';
|
import 'package:matrix/encryption/utils/json_signature_check_extension.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import '../fake_client.dart';
|
import '../fake_client.dart';
|
||||||
import '../fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Olm Manager', tags: 'olm', () {
|
group('Olm Manager', tags: 'olm', () {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import '../fake_client.dart';
|
import '../fake_client.dart';
|
||||||
import '../fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Online Key Backup', tags: 'olm', () {
|
group('Online Key Backup', tags: 'olm', () {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ import 'package:test/test.dart';
|
||||||
import 'package:matrix/encryption.dart';
|
import 'package:matrix/encryption.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import '../fake_client.dart';
|
import '../fake_client.dart';
|
||||||
import '../fake_matrix_api.dart';
|
|
||||||
|
|
||||||
Uint8List secureRandomBytes(int len) {
|
Uint8List secureRandomBytes(int len) {
|
||||||
final rng = Random.secure();
|
final rng = Random.secure();
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import 'package:matrix/encryption.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:matrix/src/models/timeline_chunk.dart';
|
import 'package:matrix/src/models/timeline_chunk.dart';
|
||||||
import 'fake_client.dart';
|
import 'fake_client.dart';
|
||||||
import 'fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
/// All Tests related to the Event
|
/// All Tests related to the Event
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'fake_database.dart';
|
import 'fake_database.dart';
|
||||||
import 'fake_matrix_api.dart';
|
|
||||||
|
|
||||||
const ssssPassphrase = 'nae7ahDiequ7ohniufah3ieS2je1thohX4xeeka7aixohsho9O';
|
const ssssPassphrase = 'nae7ahDiequ7ohniufah3ieS2je1thohX4xeeka7aixohsho9O';
|
||||||
const ssssKey = 'EsT9 RzbW VhPW yqNp cC7j ViiW 5TZB LuY4 ryyv 9guN Ysmr WDPH';
|
const ssssKey = 'EsT9 RzbW VhPW yqNp cC7j ViiW 5TZB LuY4 ryyv 9guN Ysmr WDPH';
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
import 'package:matrix/fake_matrix_api.dart';
|
||||||
import 'package:matrix/msc_extensions/msc_3814_dehydrated_devices/api.dart';
|
import 'package:matrix/msc_extensions/msc_3814_dehydrated_devices/api.dart';
|
||||||
import '../fake_client.dart';
|
import '../fake_client.dart';
|
||||||
import '../fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
/// All Tests related to device keys
|
/// All Tests related to device keys
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
/// All Tests related to the MxContent
|
/// All Tests related to the MxContent
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'fake_client.dart';
|
import 'fake_client.dart';
|
||||||
import 'fake_matrix_api.dart';
|
|
||||||
|
|
||||||
Future<void> updateLastEvent(Event event) {
|
Future<void> updateLastEvent(Event event) {
|
||||||
if (event.room.client.getRoomById(event.room.id) == null) {
|
if (event.room.client.getRoomById(event.room.id) == null) {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import 'package:test/test.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:matrix/src/models/timeline_chunk.dart';
|
import 'package:matrix/src/models/timeline_chunk.dart';
|
||||||
import 'fake_client.dart';
|
import 'fake_client.dart';
|
||||||
import 'fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Timeline context', tags: 'olm', () {
|
group('Timeline context', tags: 'olm', () {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'fake_matrix_api.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
/// All Tests related to the Event
|
/// All Tests related to the Event
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue