feat(mobile): Implement Keycloak WebView authentication with HTTP callback
- Replace flutter_appauth with custom WebView implementation to resolve deep link issues - Add KeycloakWebViewAuthService with integrated WebView for seamless authentication - Configure Android manifest for HTTP cleartext traffic support - Add network security config for development environment (192.168.1.11) - Update Keycloak client to use HTTP callback endpoint (http://192.168.1.11:8080/auth/callback) - Remove obsolete keycloak_auth_service.dart and temporary scripts - Clean up dependencies and regenerate injection configuration - Tested successfully on multiple Android devices (Xiaomi 2201116TG, SM A725F) BREAKING CHANGE: Authentication flow now uses WebView instead of external browser - Users will see Keycloak login page within the app instead of browser redirect - Resolves ERR_CLEARTEXT_NOT_PERMITTED and deep link state management issues - Maintains full OIDC compliance with PKCE flow and secure token storage Technical improvements: - WebView with custom navigation delegate for callback handling - Automatic token extraction and user info parsing from JWT - Proper error handling and user feedback - Consistent authentication state management across app lifecycle
This commit is contained in:
@@ -1,22 +1,92 @@
|
||||
// Test de base pour UnionFlow
|
||||
// Tests pour l'application UnionFlow Mobile
|
||||
//
|
||||
// Tests de base pour vérifier le bon fonctionnement des fonctionnalités principales
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
import 'package:unionflow_mobile_apps/main.dart';
|
||||
import 'package:unionflow_mobile_apps/core/di/injection.dart';
|
||||
import 'package:unionflow_mobile_apps/features/members/presentation/pages/membre_create_page.dart';
|
||||
import 'package:unionflow_mobile_apps/shared/widgets/permission_widget.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('UnionFlow app smoke test', (WidgetTester tester) async {
|
||||
// Test de base pour vérifier que l'app se charge
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: Text('UnionFlow Test'),
|
||||
group('UnionFlow Mobile App Tests', () {
|
||||
setUpAll(() async {
|
||||
// Initialiser les dépendances pour les tests
|
||||
await configureDependencies();
|
||||
});
|
||||
|
||||
tearDownAll(() {
|
||||
// Nettoyer les dépendances après les tests
|
||||
GetIt.instance.reset();
|
||||
});
|
||||
|
||||
testWidgets('App should launch successfully', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const UnionFlowApp());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify that the app launches and shows the main interface
|
||||
expect(find.byType(MaterialApp), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('FloatingActionButton should be present in members list', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const UnionFlowApp());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Navigate to members tab if needed
|
||||
// This test assumes the members page is accessible
|
||||
|
||||
// Look for FloatingActionButton with add icon
|
||||
expect(find.byType(FloatingActionButton), findsWidgets);
|
||||
expect(find.byIcon(Icons.add), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('PermissionFAB should handle permissions correctly', (WidgetTester tester) async {
|
||||
// Test the PermissionFAB widget in isolation
|
||||
bool wasPressed = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
floatingActionButton: PermissionFAB(
|
||||
permission: () => true, // Mock permission granted
|
||||
onPressed: () => wasPressed = true,
|
||||
tooltip: 'Test Button',
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
// Vérifier que le texte est présent
|
||||
expect(find.text('UnionFlow Test'), findsOneWidget);
|
||||
// Find and tap the FAB
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pump();
|
||||
|
||||
// Verify the callback was called
|
||||
expect(wasPressed, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('MembreCreatePage should have required form fields', (WidgetTester tester) async {
|
||||
// Test the member creation page in isolation
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: MembreCreatePage(),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify that essential form fields are present
|
||||
expect(find.byType(TextFormField), findsWidgets);
|
||||
expect(find.byType(AppBar), findsOneWidget);
|
||||
|
||||
// Look for key form elements
|
||||
expect(find.text('Nom'), findsWidgets);
|
||||
expect(find.text('Prénom'), findsWidgets);
|
||||
expect(find.text('Email'), findsWidgets);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user