diff --git a/integration_test/passkey_test.dart b/integration_test/passkey_test.dart index 4f598604..c55e5c04 100644 --- a/integration_test/passkey_test.dart +++ b/integration_test/passkey_test.dart @@ -31,58 +31,136 @@ void main() { const simplePin = '1111'; const fidoPin1 = '9473'; const fidoPin2 = '4781'; - appTest('Reset Key', (WidgetTester tester) async { - // await tester.configurePasskey(); + + /// Sadly these tests are built on each other to save reset-dance + + appTest('Reset Fido2 1/3', (WidgetTester tester) async { await tester.resetFido2(); }); - appTest('Set SimplePin', (WidgetTester tester) async { - await tester.configurePasskey(); + group('Set/change pin and pin complexity', (){ + appTest('Set simplePin', (WidgetTester tester) async { + /// OBS: This will not work if there is pin complexity requirements + await tester.configurePasskey(); - await tester.tap(find.byKey(managePinAction)); - await tester.shortWait(); + await tester.tap(find.byKey(managePinAction).hitTestable()); + await tester.shortWait(); - await tester.enterText(find.byKey(newPin), simplePin); - await tester.shortWait(); - await tester.enterText(find.byKey(newPin), simplePin); - await tester.shortWait(); + await tester.enterText(find.byKey(newPin), simplePin); + await tester.shortWait(); + await tester.enterText(find.byKey(confirmPin), simplePin); + await tester.shortWait(); - await tester.tap(find.byKey(saveButton)); - await tester.shortWait(); + await tester.tap(find.byKey(saveButton).hitTestable()); + await tester.shortWait(); + }); + appTest('Change to fidoPin1', (WidgetTester tester) async { + await tester.configurePasskey(); + + await tester.tap(find.byKey(managePinAction).hitTestable()); + await tester.shortWait(); + + await tester.enterText(find.byKey(currentPin), simplePin); + await tester.shortWait(); + await tester.enterText(find.byKey(newPin), fidoPin1); + await tester.shortWait(); + await tester.enterText(find.byKey(confirmPin), fidoPin1); + await tester.shortWait(); + + await tester.tap(find.byKey(saveButton).hitTestable()); + await tester.shortWait(); + }); + appTest('Change to fidoPin2', (WidgetTester tester) async { + await tester.configurePasskey(); + + await tester.tap(find.byKey(managePinAction)); + await tester.shortWait(); + + await tester.enterText(find.byKey(currentPin), fidoPin1); + await tester.shortWait(); + await tester.enterText(find.byKey(newPin), fidoPin2); + await tester.shortWait(); + await tester.enterText(find.byKey(confirmPin), fidoPin2); + await tester.shortWait(); + + await tester.tap(find.byKey(saveButton).hitTestable()); + await tester.shortWait(); + }); }); - appTest('Change to FidoPin1', (WidgetTester tester) async { - await tester.configurePasskey(); - - await tester.tap(find.byKey(managePinAction)); - await tester.shortWait(); - - await tester.enterText(find.byKey(currentPin), simplePin); - await tester.shortWait(); - await tester.enterText(find.byKey(newPin), fidoPin1); - await tester.shortWait(); - await tester.enterText(find.byKey(newPin), fidoPin1); - await tester.shortWait(); - - await tester.tap(find.byKey(saveButton)); - await tester.shortWait(); + appTest('Reset Fido2 2/3', (WidgetTester tester) async { + await tester.resetFido2(); }); - appTest('Change to FidoPin2', (WidgetTester tester) async { - await tester.configurePasskey(); + group('Pin use, pin lock', () { + appTest('Set fidoPin1', (WidgetTester tester) async { + await tester.configurePasskey(); - await tester.tap(find.byKey(managePinAction)); - await tester.shortWait(); + await tester.tap(find.byKey(managePinAction).hitTestable()); + await tester.shortWait(); - await tester.enterText(find.byKey(currentPin), fidoPin1); - await tester.shortWait(); - await tester.enterText(find.byKey(newPin), fidoPin2); - await tester.shortWait(); - await tester.enterText(find.byKey(newPin), fidoPin2); - await tester.shortWait(); + await tester.enterText(find.byKey(newPin), fidoPin1); + await tester.shortWait(); + await tester.enterText(find.byKey(confirmPin), fidoPin1); + await tester.shortWait(); - await tester.tap(find.byKey(saveButton)); - await tester.shortWait(); + await tester.tap(find.byKey(saveButton).hitTestable()); + await tester.shortWait(); + }); + appTest('Wrong pin 1/3', (WidgetTester tester) async { + await tester.tap(find.byKey(fidoPasskeysAppDrawer).hitTestable()); + await tester.shortWait(); + + await tester.enterText(find.byKey(pinEntry), simplePin); + await tester.shortWait(); + await tester.tap(find.byKey(unlockFido2WithPin).hitTestable()); + await tester.shortWait(); + await tester.enterText(find.byKey(pinEntry), simplePin); + await tester.shortWait(); + await tester.tap(find.byKey(unlockFido2WithPin).hitTestable()); + await tester.shortWait(); + await tester.enterText(find.byKey(pinEntry), simplePin); + await tester.shortWait(); + await tester.tap(find.byKey(unlockFido2WithPin).hitTestable()); + await tester.shortWait(); + + /// TODO verify that l_pin_soft_locked is seen. + }); + appTest('Wrong pin 2/3', (WidgetTester tester) async { + await tester.tap(find.byKey(fidoPasskeysAppDrawer).hitTestable()); + await tester.shortWait(); + + await tester.enterText(find.byKey(pinEntry), simplePin); + await tester.shortWait(); + await tester.tap(find.byKey(unlockFido2WithPin).hitTestable()); + await tester.shortWait(); + await tester.enterText(find.byKey(pinEntry), simplePin); + await tester.shortWait(); + await tester.tap(find.byKey(unlockFido2WithPin).hitTestable()); + await tester.shortWait(); + await tester.enterText(find.byKey(pinEntry), simplePin); + await tester.shortWait(); + await tester.tap(find.byKey(unlockFido2WithPin).hitTestable()); + await tester.shortWait(); + + /// TODO verify that l_pin_soft_locked is seen. + }); + appTest('Wrong pin 3/3', (WidgetTester tester) async { + await tester.tap(find.byKey(fidoPasskeysAppDrawer).hitTestable()); + await tester.shortWait(); + + await tester.enterText(find.byKey(pinEntry), simplePin); + await tester.shortWait(); + await tester.tap(find.byKey(unlockFido2WithPin).hitTestable()); + await tester.shortWait(); + await tester.enterText(find.byKey(pinEntry), simplePin); + await tester.shortWait(); + await tester.tap(find.byKey(unlockFido2WithPin).hitTestable()); + await tester.shortWait(); + await tester.enterText(find.byKey(pinEntry), simplePin); + await tester.shortWait(); + + /// TODO verify that l_pin_blocked_reset_locked is seen. + }); }); - appTest('Reset Key', (WidgetTester tester) async { - await tester.configurePasskey(); + appTest('Reset Fido2 3/3', (WidgetTester tester) async { await tester.resetFido2(); }); }); diff --git a/integration_test/utils/passkey_test_util.dart b/integration_test/utils/passkey_test_util.dart index 8e26d9b7..f23a838e 100644 --- a/integration_test/utils/passkey_test_util.dart +++ b/integration_test/utils/passkey_test_util.dart @@ -30,8 +30,7 @@ extension Fido2Functions on WidgetTester { /// Open the PIV Configuration Future configurePasskey() async { // 1. open PIV view - var pivDrawerButton = find.byKey(fidoPasskeysAppDrawer).hitTestable(); - await tap(pivDrawerButton); + await tap(find.byKey(fidoPasskeysAppDrawer).hitTestable()); await shortWait(); await tap(find.byKey(actionsIconButtonKey).hitTestable()); await shortWait(); @@ -59,7 +58,11 @@ extension Fido2Functions on WidgetTester { await tap(find.byKey(factoryResetReset)); await fido2DanceWait(); - /// TODO 5. Verify Resetedness + /// 5. Click the 'Close' button + await tap(find.text('Close').hitTestable()); + await shortWait(); + + /// TODO 6. Verify Resetedness } } diff --git a/lib/fido/keys.dart b/lib/fido/keys.dart index 035291ac..594a87a6 100644 --- a/lib/fido/keys.dart +++ b/lib/fido/keys.dart @@ -28,6 +28,11 @@ const newPin = Key('$_keyAction.new_pin'); const confirmPin = Key('$_keyAction.confirm_pin'); const currentPin = Key('$_keyAction.current_pin'); +// pin entry +const pinEntry = Key('$_keyAction.pin_entry'); +const unlockFido2WithPin = Key('$_keyAction.unlock_fido2_with_pin'); + + // Credential actions const editCredentialAction = Key('$_credentialAction.edit'); const deleteCredentialAction = Key('$_credentialAction.delete'); diff --git a/lib/fido/views/pin_dialog.dart b/lib/fido/views/pin_dialog.dart index 8613d54d..f6852a78 100755 --- a/lib/fido/views/pin_dialog.dart +++ b/lib/fido/views/pin_dialog.dart @@ -69,6 +69,7 @@ class _FidoPinDialogState extends ConsumerState { TextButton( onPressed: isValid ? _submit : null, child: Text(l10n.s_save), + key: saveButton, ), ], child: Padding( diff --git a/lib/fido/views/pin_entry_form.dart b/lib/fido/views/pin_entry_form.dart index 53cc3bc9..310f0734 100644 --- a/lib/fido/views/pin_entry_form.dart +++ b/lib/fido/views/pin_entry_form.dart @@ -21,6 +21,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../app/models.dart'; import '../../widgets/app_input_decoration.dart'; import '../../widgets/app_text_field.dart'; +import '../keys.dart'; import '../models.dart'; import '../state.dart'; @@ -85,6 +86,7 @@ class _PinEntryFormState extends ConsumerState { Padding( padding: const EdgeInsets.only(top: 16.0, bottom: 4.0), child: AppTextField( + key: pinEntry, autofocus: true, obscureText: _isObscure, autofillHints: const [AutofillHints.password],