yubioath-flutter/integration_test/reset_key.dart

114 lines
4.2 KiB
Dart
Raw Normal View History

2022-10-04 13:12:54 +03:00
/*
* Copyright (C) 2022 Yubico.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2022-05-11 15:43:06 +03:00
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:yubico_authenticator/oath/views/oath_screen.dart';
2022-05-12 16:35:14 +03:00
import 'test_util.dart';
2022-05-11 15:43:06 +03:00
void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
2022-09-13 13:32:13 +03:00
group('Reset Key', skip: 'Not reviewed', () {
2022-05-11 15:43:06 +03:00
testWidgets('Reset OATH', (WidgetTester tester) async {
/// this test works if there is an oath credential on the key
/// else it will fail on tap 'Authenticator' widget
2022-09-13 13:32:13 +03:00
await tester.startUp({});
2022-05-11 15:43:06 +03:00
await tester.pump(const Duration(milliseconds: 500));
/// QUESTION: I want to click the DrawerItem named 'WebAuthn' | 'Authenticator'
/// await tester.tap(find.byType(DrawerItem.titleText == 'WebAuthn'));
/// which can be found in main_drawer.dart, how do I make sure I call the right
/// thing here?
await tester.tap(find.text('Authenticator'));
/// get to correct widget
await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.byType(FloatingActionButton));
/// click the Setup Button
await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.text('Reset OATH'));
/// click reset oath
await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.text('Reset'));
/// confirm
await tester.pump(const Duration(milliseconds: 300));
/// I don't know why the expects fail?
/// The following should report 'No accounts' in Authenticator widget.
/// Maybe through find.bySemanticsLabel or byTooltip?
/* expect(find.byType(OathScreen), findsNothing,
reason: 'OATH successfully reset.');*/
await tester.pump(const Duration(seconds: 3));
});
2022-09-13 13:32:13 +03:00
testWidgets('Reset FIDO', skip: true, (WidgetTester tester) async {
2022-05-11 15:43:06 +03:00
/// this test works if there is an oath credential on the key
/// else it will fail on tap 'Authenticator' widget
2022-09-13 13:32:13 +03:00
await tester.startUp({});
2022-05-11 15:43:06 +03:00
await tester.pump(const Duration(milliseconds: 500));
/// QUESTION: I want to click the DrawerItem named 'WebAuthn' | 'Authenticator'
/// await tester.tap(find.byType(DrawerItem.titleText == 'WebAuthn'));
/// which can be found in main_drawer.dart, how do I make sure I call the right
/// thing here?
await tester.tap(find.text('WebAuthn'));
/// get to correct widget
await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.byType(FloatingActionButton));
/// click the Setup Button
await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.text('Reset FIDO'));
/// click reset oath
await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.text('Reset'));
/// confirm
await tester.pump(const Duration(milliseconds: 300));
/// I don't know why the expects fail?
/// The following should report 'No discoverable accounts' in fido widget.
/// Maybe through find.bySemanticsLabel or byTooltip?
///
/// For this reset you require the yubikey-dance, giving user 30s for this
await tester.tap(find.text('Reset'));
await tester.pump(const Duration(milliseconds: 30000));
/// The following should report the success, if there are no accounts.
expect(find.byType(OathScreen), findsNothing, reason: 'FIDO successfully reset.');
2022-05-11 15:43:06 +03:00
await tester.pump(const Duration(seconds: 3));
});
});
}