82 lines
2.6 KiB
Dart
82 lines
2.6 KiB
Dart
import 'package:baron_safe_app/src/features/bridge/baron_safe_bridge_command.dart';
|
|
import 'package:baron_safe_app/src/features/bridge/baron_safe_bridge_models.dart';
|
|
import 'package:baron_safe_app/src/features/bridge/baron_safe_bridge_service.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('BaronSafeBridgeCommand', () {
|
|
test('parses allowed command names', () {
|
|
expect(
|
|
BaronSafeBridgeCommand.tryParse('getDeviceInfo'),
|
|
BaronSafeBridgeCommand.getDeviceInfo,
|
|
);
|
|
expect(
|
|
BaronSafeBridgeCommand.tryParse('openBiometricPrompt'),
|
|
BaronSafeBridgeCommand.openBiometricPrompt,
|
|
);
|
|
});
|
|
|
|
test('returns null for unknown command names', () {
|
|
expect(BaronSafeBridgeCommand.tryParse('unknownCommand'), isNull);
|
|
});
|
|
});
|
|
|
|
group('PlaceholderBaronSafeBridgeService', () {
|
|
test('returns placeholder device info', () async {
|
|
const service = PlaceholderBaronSafeBridgeService();
|
|
|
|
final response = await service.handle(
|
|
const BaronSafeBridgeRequest(
|
|
command: BaronSafeBridgeCommand.getDeviceInfo,
|
|
),
|
|
);
|
|
|
|
expect(response.isSuccess, isTrue);
|
|
expect(response.data['deviceId'], 'placeholder-device');
|
|
expect(response.data['platform'], 'flutter');
|
|
});
|
|
|
|
test('returns placeholder biometric result', () async {
|
|
const service = PlaceholderBaronSafeBridgeService();
|
|
|
|
final response = await service.handle(
|
|
const BaronSafeBridgeRequest(
|
|
command: BaronSafeBridgeCommand.openBiometricPrompt,
|
|
payload: {'reason': 'Confirm session block'},
|
|
),
|
|
);
|
|
|
|
expect(response.isSuccess, isTrue);
|
|
expect(response.data['verified'], isFalse);
|
|
expect(response.data['reason'], contains('Confirm session block'));
|
|
});
|
|
|
|
test('registers placeholder push token', () async {
|
|
const service = PlaceholderBaronSafeBridgeService();
|
|
|
|
final response = await service.handle(
|
|
const BaronSafeBridgeRequest(
|
|
command: BaronSafeBridgeCommand.registerPushToken,
|
|
),
|
|
);
|
|
|
|
expect(response.isSuccess, isTrue);
|
|
expect(response.data['registered'], isTrue);
|
|
expect(response.data['token'], isA<Map<String, Object?>>());
|
|
});
|
|
|
|
test('marks sensitive backend commands as not implemented', () async {
|
|
const service = PlaceholderBaronSafeBridgeService();
|
|
|
|
final response = await service.handle(
|
|
const BaronSafeBridgeRequest(
|
|
command: BaronSafeBridgeCommand.blockSession,
|
|
),
|
|
);
|
|
|
|
expect(response.isSuccess, isFalse);
|
|
expect(response.error?.code, 'not_implemented');
|
|
});
|
|
});
|
|
}
|