Everything almost works, to fix:

-pin entry when locking key is damn hard!
This commit is contained in:
Joakim Troëng 2024-02-09 20:56:07 +01:00
parent 813904e878
commit 461d0de317
5 changed files with 133 additions and 44 deletions

View File

@ -31,41 +31,45 @@ void main() {
const simplePin = '1111'; const simplePin = '1111';
const fidoPin1 = '9473'; const fidoPin1 = '9473';
const fidoPin2 = '4781'; 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(); await tester.resetFido2();
}); });
appTest('Set SimplePin', (WidgetTester tester) async { 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.configurePasskey();
await tester.tap(find.byKey(managePinAction)); await tester.tap(find.byKey(managePinAction).hitTestable());
await tester.shortWait(); await tester.shortWait();
await tester.enterText(find.byKey(newPin), simplePin); await tester.enterText(find.byKey(newPin), simplePin);
await tester.shortWait(); await tester.shortWait();
await tester.enterText(find.byKey(newPin), simplePin); await tester.enterText(find.byKey(confirmPin), simplePin);
await tester.shortWait(); await tester.shortWait();
await tester.tap(find.byKey(saveButton)); await tester.tap(find.byKey(saveButton).hitTestable());
await tester.shortWait(); await tester.shortWait();
}); });
appTest('Change to FidoPin1', (WidgetTester tester) async { appTest('Change to fidoPin1', (WidgetTester tester) async {
await tester.configurePasskey(); await tester.configurePasskey();
await tester.tap(find.byKey(managePinAction)); await tester.tap(find.byKey(managePinAction).hitTestable());
await tester.shortWait(); await tester.shortWait();
await tester.enterText(find.byKey(currentPin), simplePin); await tester.enterText(find.byKey(currentPin), simplePin);
await tester.shortWait(); await tester.shortWait();
await tester.enterText(find.byKey(newPin), fidoPin1); await tester.enterText(find.byKey(newPin), fidoPin1);
await tester.shortWait(); await tester.shortWait();
await tester.enterText(find.byKey(newPin), fidoPin1); await tester.enterText(find.byKey(confirmPin), fidoPin1);
await tester.shortWait(); await tester.shortWait();
await tester.tap(find.byKey(saveButton)); await tester.tap(find.byKey(saveButton).hitTestable());
await tester.shortWait(); await tester.shortWait();
}); });
appTest('Change to FidoPin2', (WidgetTester tester) async { appTest('Change to fidoPin2', (WidgetTester tester) async {
await tester.configurePasskey(); await tester.configurePasskey();
await tester.tap(find.byKey(managePinAction)); await tester.tap(find.byKey(managePinAction));
@ -75,14 +79,88 @@ void main() {
await tester.shortWait(); await tester.shortWait();
await tester.enterText(find.byKey(newPin), fidoPin2); await tester.enterText(find.byKey(newPin), fidoPin2);
await tester.shortWait(); await tester.shortWait();
await tester.enterText(find.byKey(newPin), fidoPin2); await tester.enterText(find.byKey(confirmPin), fidoPin2);
await tester.shortWait(); await tester.shortWait();
await tester.tap(find.byKey(saveButton)); await tester.tap(find.byKey(saveButton).hitTestable());
await tester.shortWait(); await tester.shortWait();
}); });
appTest('Reset Key', (WidgetTester tester) async { });
appTest('Reset Fido2 2/3', (WidgetTester tester) async {
await tester.resetFido2();
});
group('Pin use, pin lock', () {
appTest('Set fidoPin1', (WidgetTester tester) async {
await tester.configurePasskey(); await tester.configurePasskey();
await tester.tap(find.byKey(managePinAction).hitTestable());
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('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 Fido2 3/3', (WidgetTester tester) async {
await tester.resetFido2(); await tester.resetFido2();
}); });
}); });

View File

@ -30,8 +30,7 @@ extension Fido2Functions on WidgetTester {
/// Open the PIV Configuration /// Open the PIV Configuration
Future<void> configurePasskey() async { Future<void> configurePasskey() async {
// 1. open PIV view // 1. open PIV view
var pivDrawerButton = find.byKey(fidoPasskeysAppDrawer).hitTestable(); await tap(find.byKey(fidoPasskeysAppDrawer).hitTestable());
await tap(pivDrawerButton);
await shortWait(); await shortWait();
await tap(find.byKey(actionsIconButtonKey).hitTestable()); await tap(find.byKey(actionsIconButtonKey).hitTestable());
await shortWait(); await shortWait();
@ -59,7 +58,11 @@ extension Fido2Functions on WidgetTester {
await tap(find.byKey(factoryResetReset)); await tap(find.byKey(factoryResetReset));
await fido2DanceWait(); await fido2DanceWait();
/// TODO 5. Verify Resetedness /// 5. Click the 'Close' button
await tap(find.text('Close').hitTestable());
await shortWait();
/// TODO 6. Verify Resetedness
} }
} }

View File

@ -28,6 +28,11 @@ const newPin = Key('$_keyAction.new_pin');
const confirmPin = Key('$_keyAction.confirm_pin'); const confirmPin = Key('$_keyAction.confirm_pin');
const currentPin = Key('$_keyAction.current_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 // Credential actions
const editCredentialAction = Key('$_credentialAction.edit'); const editCredentialAction = Key('$_credentialAction.edit');
const deleteCredentialAction = Key('$_credentialAction.delete'); const deleteCredentialAction = Key('$_credentialAction.delete');

View File

@ -69,6 +69,7 @@ class _FidoPinDialogState extends ConsumerState<FidoPinDialog> {
TextButton( TextButton(
onPressed: isValid ? _submit : null, onPressed: isValid ? _submit : null,
child: Text(l10n.s_save), child: Text(l10n.s_save),
key: saveButton,
), ),
], ],
child: Padding( child: Padding(

View File

@ -21,6 +21,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../app/models.dart'; import '../../app/models.dart';
import '../../widgets/app_input_decoration.dart'; import '../../widgets/app_input_decoration.dart';
import '../../widgets/app_text_field.dart'; import '../../widgets/app_text_field.dart';
import '../keys.dart';
import '../models.dart'; import '../models.dart';
import '../state.dart'; import '../state.dart';
@ -85,6 +86,7 @@ class _PinEntryFormState extends ConsumerState<PinEntryForm> {
Padding( Padding(
padding: const EdgeInsets.only(top: 16.0, bottom: 4.0), padding: const EdgeInsets.only(top: 16.0, bottom: 4.0),
child: AppTextField( child: AppTextField(
key: pinEntry,
autofocus: true, autofocus: true,
obscureText: _isObscure, obscureText: _isObscure,
autofillHints: const [AutofillHints.password], autofillHints: const [AutofillHints.password],