Add Baron Safe app features through session block skeleton
ci / flutter-check (push) Successful in 4s
ci / flutter-check (push) Successful in 4s
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
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:baron_safe_app/src/features/session/baron_safe_session_block_service.dart';
|
||||
import 'package:baron_safe_app/src/features/session/baron_safe_session_models.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
@@ -77,5 +79,55 @@ void main() {
|
||||
expect(response.isSuccess, isFalse);
|
||||
expect(response.error?.code, 'not_implemented');
|
||||
});
|
||||
|
||||
test('rejects blockSession when sessionId is missing', () async {
|
||||
const service = PlaceholderBaronSafeBridgeService(
|
||||
sessionBlockService: _FakeSessionBlockService(),
|
||||
);
|
||||
|
||||
final response = await service.handle(
|
||||
const BaronSafeBridgeRequest(
|
||||
command: BaronSafeBridgeCommand.blockSession,
|
||||
),
|
||||
);
|
||||
|
||||
expect(response.isSuccess, isFalse);
|
||||
expect(response.error?.code, 'invalid_payload');
|
||||
});
|
||||
|
||||
test('runs injected session block service', () async {
|
||||
const service = PlaceholderBaronSafeBridgeService(
|
||||
sessionBlockService: _FakeSessionBlockService(),
|
||||
);
|
||||
|
||||
final response = await service.handle(
|
||||
const BaronSafeBridgeRequest(
|
||||
command: BaronSafeBridgeCommand.blockSession,
|
||||
payload: {'sessionId': 'session-1', 'reason': 'Suspicious login'},
|
||||
),
|
||||
);
|
||||
|
||||
expect(response.isSuccess, isTrue);
|
||||
expect(response.data['sessionId'], 'session-1');
|
||||
expect(response.data['blocked'], isTrue);
|
||||
expect(response.data['biometricVerified'], isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class _FakeSessionBlockService implements BaronSafeSessionBlockService {
|
||||
const _FakeSessionBlockService();
|
||||
|
||||
@override
|
||||
Future<BaronSafeSessionBlockResult> blockSession({
|
||||
required String sessionId,
|
||||
required String reason,
|
||||
}) async {
|
||||
return BaronSafeSessionBlockResult(
|
||||
sessionId: sessionId,
|
||||
blocked: true,
|
||||
biometricVerified: true,
|
||||
message: reason,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user