yubioath-flutter/integration_test/otp_test.dart

164 lines
5.5 KiB
Dart
Raw Normal View History

2023-12-14 16:43:49 +03:00
/*
* Copyright (C) 2023 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.
*/
2024-02-08 16:21:05 +03:00
@Tags(['desktop', 'otp'])
2023-12-14 16:43:49 +03:00
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:yubico_authenticator/app/views/keys.dart';
import 'package:yubico_authenticator/otp/keys.dart';
2024-02-08 16:21:05 +03:00
import 'package:yubico_authenticator/otp/models.dart';
2023-12-14 16:43:49 +03:00
2024-02-08 16:21:05 +03:00
import 'utils/otp_test_util.dart';
2023-12-14 16:43:49 +03:00
import 'utils/test_util.dart';
void main() {
var binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
group('OTP UI tests', () {
appTest('Yubico OTP slot 1', (WidgetTester tester) async {
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 1 is empty"
2024-02-08 16:21:05 +03:00
await tester.openSlotMenu(SlotId.one);
await tester.tap(find.byKey(configureYubiOtp).hitTestable());
await tester.shortWait();
// this generates all the fields and saves yubiotp
await tester.tap(find.byKey(useSerial).hitTestable());
await tester.shortWait();
await tester.tap(find.byKey(generatePrivateId).hitTestable());
await tester.shortWait();
await tester.tap(find.byKey(generateSecretKey).hitTestable());
await tester.shortWait();
await tester.tap(find.byKey(saveButton).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 1 is configured"
});
appTest('Challenge-Response slot 1', (WidgetTester tester) async {
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 1 is configured"
2024-02-08 16:21:05 +03:00
await tester.openSlotMenu(SlotId.one);
await tester.tap(find.byKey(configureChalResp).hitTestable());
await tester.shortWait();
// this generates and saves chall-resp
await tester.tap(find.byKey(generateSecretKey).hitTestable());
await tester.shortWait();
await tester.tap(find.byKey(saveButton).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 1 is configured"
});
appTest('Static Password slot 2', (WidgetTester tester) async {
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 2 is empty"
2024-02-08 16:21:05 +03:00
await tester.openSlotMenu(SlotId.two);
2024-02-08 16:21:05 +03:00
await tester.tap(find.byKey(configureStatic).hitTestable());
await tester.shortWait();
// this generates and saves static password
await tester.tap(find.byKey(generateSecretKey).hitTestable());
await tester.shortWait();
await tester.tap(find.byKey(saveButton).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 2 is configured"
});
appTest('OATH-HOTP slot 2', (WidgetTester tester) async {
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 2 is configured"
2024-02-08 16:21:05 +03:00
await tester.openSlotMenu(SlotId.two);
2024-02-08 16:21:05 +03:00
await tester.tap(find.byKey(configureHotp).hitTestable());
await tester.shortWait();
// this writes and saves oath secret
2024-02-06 13:09:10 +03:00
await tester.enterText(find.byKey(secretField), 'asdfasdf');
await tester.shortWait();
await tester.tap(find.byKey(saveButton).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 2 is configured"
});
appTest('Swap slots', (WidgetTester tester) async {
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 1 is configured"
/// TODO: verify "Slot 2 is configured"
// taps swap
2024-02-08 16:21:05 +03:00
await tester.tapSwapSlotsButton();
await tester.tap(find.byKey(swapButton).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 1 is configured"
/// TODO: verify "Slot 2 is configured"
});
2024-02-08 16:21:05 +03:00
appTest('Delete Credentials', (WidgetTester tester) async {
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 1 is configured"
/// TODO: verify "Slot 2 is configured"
2024-02-08 16:21:05 +03:00
await tester.openSlotMenu(SlotId.one);
await tester.tap(find.byKey(deleteAction).hitTestable());
2024-02-08 23:15:42 +03:00
await tester.shortWait();
await tester.tap(find.byKey(deleteButton).hitTestable());
2024-02-08 16:21:05 +03:00
/// TODO: wait for any toasts to be gone
2024-02-08 23:15:42 +03:00
await tester.ultraLongWait();
2024-02-08 16:21:05 +03:00
var closeFinder = find.byKey(closeButton);
if (closeFinder.evaluate().isNotEmpty) {
// close the view
await tester.tap(closeFinder);
await tester.shortWait();
}
// we need to right click on slot 2
2024-02-08 16:21:05 +03:00
await tester.openSlotMenu(SlotId.two);
await tester.tap(find.byKey(deleteAction).hitTestable());
2024-02-08 23:15:42 +03:00
await tester.shortWait();
await tester.tap(find.byKey(deleteButton).hitTestable());
await tester.shortWait();
/// TODO: verify "Slot 1 is empty"
/// TODO: verify "Slot 2 is empty"
2023-12-14 16:43:49 +03:00
});
});
}