fix Reset OATH test when 1 key is connected

This commit is contained in:
Adam Velebil 2024-02-07 09:19:13 +01:00
parent c0a9d2b8f8
commit 539f4fb89c
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10
4 changed files with 15 additions and 19 deletions

View File

@ -303,26 +303,14 @@ extension OathFunctions on WidgetTester {
/// Factory reset OATH application
Future<void> resetOATH() async {
// TODO: Implement this using new Reset Dialog
/// 1. instead of tapping actioniconbutton, first click navigation
/// 1. open drawer if needed
await openDrawer();
await shortWait();
// await tapActionIconButton();
// Future<void> tapActionIconButton() async {
// await tap(findActionIconButton());
// await pump(const Duration(milliseconds: 500));
// }
/// 2. then click the meatball button+'Factory reset' for correct S/N
// stealing some of startUp to get serialnumber check:
await collectYubiKeyInformation();
final approvedSerialNumbers = await getApprovedSerialNumbers();
if (approvedSerialNumbers.contains(yubiKeySerialNumber)) {
// this does not work, yubikeyPopupMenuButton probably wrong!?
await tap(find.byKey(yubikeyPopupMenuButton).hitTestable());
await shortWait();
await tap(find.byKey(yubikeyFactoryResetMenuButton).hitTestable());

View File

@ -178,6 +178,7 @@ class _DeviceMenuButton extends ConsumerWidget {
child: Opacity(
opacity: menuItems.isNotEmpty ? opacity : 0.0,
child: PopupMenuButton(
key: yubikeyPopupMenuButton,
enabled: menuItems.isNotEmpty,
icon: const Icon(Icons.more_horiz_outlined),
tooltip: '',
@ -348,7 +349,6 @@ class _DeviceRowState extends ConsumerState<_DeviceRow> {
if (serial != null)
PopupMenuItem(
enabled: true,
key: yubikeyPopupMenuButton,
onTap: () async {
await ref.read(withContextProvider)((context) async {
await _showKeyCustomizationDialog(

View File

@ -37,9 +37,12 @@ const openpgpAppDrawer = Key('$_prefix.drawer.openpgp');
// drawer yubikey more items
const yubikeyPopupMenuButton = Key('$_prefix.yubikey_popup_menu_button');
const yubikeyLabelColorMenuButton = Key('$_prefix.yubikey_label_color_menu_button');
const yubikeyApplicationToggleMenuButton = Key('$_prefix.yubikey_application_toggle_menu_button');
const yubikeyFactoryResetMenuButton = Key('$_prefix.yubikey_factory_reset_menu_button');
const yubikeyLabelColorMenuButton =
Key('$_prefix.yubikey_label_color_menu_button');
const yubikeyApplicationToggleMenuButton =
Key('$_prefix.yubikey_application_toggle_menu_button');
const yubikeyFactoryResetMenuButton =
Key('$_prefix.yubikey_factory_reset_menu_button');
// factory reset dialog
const factoryResetPickResetOath = Key('$_prefix.yubikey_factory_reset_oath');
@ -48,7 +51,6 @@ const factoryResetPickResetPiv = Key('$_prefix.yubikey_factory_reset_piv');
const factoryResetCancel = Key('$_prefix.yubikey_factory_reset_cancel');
const factoryResetReset = Key('$_prefix.yubikey_factory_reset_reset');
// settings page
const settingDrawerIcon = Key('$_prefix.settings_drawer_icon');
const helpDrawerIcon = Key('$_prefix.setting_drawer_icon');

View File

@ -156,8 +156,8 @@ class _ResetDialogState extends ConsumerState<ResetDialog> {
null => null,
_ => throw UnsupportedError('Application cannot be reset'),
},
child: Text(l10n.s_reset),
key: factoryResetReset,
child: Text(l10n.s_reset),
)
],
child: Padding(
@ -177,6 +177,12 @@ class _ResetDialogState extends ConsumerState<ResetDialog> {
value: c,
icon: const Icon(null),
label: Padding(
key: switch (c) {
Capability.oath => factoryResetPickResetOath,
Capability.fido2 => factoryResetPickResetFido2,
Capability.piv => factoryResetPickResetPiv,
_ => const Key('_invalid') // no reset
},
padding: const EdgeInsets.only(right: 22),
child: Text(c.getDisplayName(l10n)),
),