feat: complete leave approval MVP
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import 'package:aioa_mobile/core/auth/authenticated_http_client.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/testing.dart';
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'attaches refreshed bearer token only to the configured API origin',
|
||||
() async {
|
||||
final captured = <http.Request>[];
|
||||
final client = AuthenticatedHttpClient(
|
||||
inner: MockClient((request) async {
|
||||
captured.add(request);
|
||||
return http.Response('', 200);
|
||||
}),
|
||||
apiOrigin: 'https://api.example.test',
|
||||
tokenProvider: () async => 'refreshed-token',
|
||||
);
|
||||
|
||||
await client.get(Uri.parse('https://api.example.test/api/v1/me'));
|
||||
await client.put(Uri.parse('https://minio.example.test/upload'));
|
||||
|
||||
expect(captured[0].headers['Authorization'], 'Bearer refreshed-token');
|
||||
expect(captured[1].headers['Authorization'], isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user