mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-08 01:20:27 +00:00
feat: move native communication to FFI (#1457)
This commit is contained in:
86 files changed
+4558
-886
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gopeed/api/api.dart' as api;
|
||||
import 'package:gopeed/core/network/gopeed/gopeed_transport.dart';
|
||||
import 'package:gopeed/features/auth/application/web_auth_controller.dart';
|
||||
|
||||
void main() {
|
||||
test('successful login relies on the server cookie and unauthorized requires login', () async {
|
||||
api.setTransportForTesting(_LoginTransport());
|
||||
final controller = WebAuthController();
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
final failure = await controller.login(username: 'gopeed', password: 'secret');
|
||||
|
||||
expect(failure, isNull);
|
||||
controller.requireLogin();
|
||||
expect(controller.loginRequired, isTrue);
|
||||
});
|
||||
}
|
||||
|
||||
class _LoginTransport implements GopeedTransport {
|
||||
@override
|
||||
Future<dynamic> request(
|
||||
String path, {
|
||||
String method = 'GET',
|
||||
dynamic data,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
expect(path, 'api/web/login');
|
||||
expect(method, 'POST');
|
||||
return {'code': 0};
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response<String>> proxyRequest(String uri, {dynamic data, Options? options}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
String join(String path) => path;
|
||||
}
|
||||
Reference in new issue
Block a user