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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Tags(['android', 'desktop', 'oath'])
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:integration_test/integration_test.dart';
|
|
|
|
import 'package:yubico_authenticator/app/views/keys.dart';
|
2024-02-06 12:42:14 +03:00
|
|
|
import 'package:yubico_authenticator/otp/keys.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('OTP menu items exist', (WidgetTester tester) async {
|
|
|
|
await tester.tap(find.byKey(otpAppDrawer));
|
|
|
|
await tester.shortWait();
|
2024-02-06 12:42:14 +03:00
|
|
|
|
|
|
|
await tester.tap(find.byKey(configureYubiOtp).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
});
|
|
|
|
|
|
|
|
appTest('Yubico OTP slot 1', (WidgetTester tester) async {
|
|
|
|
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
//verify "Slot 1 is empty"
|
|
|
|
|
|
|
|
// we are missing the right click on top of the correct slot
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
//verify "Slot 1 is configured"
|
|
|
|
});
|
|
|
|
|
|
|
|
appTest('Challenge-Response slot 1', (WidgetTester tester) async {
|
|
|
|
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
// verify "Slot 1 is configured"
|
|
|
|
|
|
|
|
// we are missing the right click on top of the correct slot
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
// verify "Slot 1 is configured"
|
|
|
|
});
|
|
|
|
|
|
|
|
appTest('Static Password slot 2', (WidgetTester tester) async {
|
|
|
|
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
// verify "Slot 2 is empty"
|
|
|
|
|
|
|
|
// we are missing the right click on top of the correct slot
|
|
|
|
|
|
|
|
await tester.tap(find.byKey(configureYubiOtp).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();
|
|
|
|
|
|
|
|
// verify "Slot 2 is configured"
|
|
|
|
});
|
|
|
|
|
|
|
|
appTest('OATH-HOTP slot 2', (WidgetTester tester) async {
|
|
|
|
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
// verify "Slot 2 is configured"
|
|
|
|
|
|
|
|
// we are missing the right click on top of the correct slot
|
|
|
|
|
|
|
|
await tester.tap(find.byKey(configureYubiOtp).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');
|
2024-02-06 12:42:14 +03:00
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(saveButton).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
// verify "Slot 2 is configured"
|
|
|
|
});
|
|
|
|
|
|
|
|
appTest('Swap slots', (WidgetTester tester) async {
|
|
|
|
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
// verify "Slot 1 is configured"
|
|
|
|
// verify "Slot 2 is configured"
|
|
|
|
|
|
|
|
// taps swap
|
|
|
|
await tester.tap(find.byKey(actionsIconButtonKey).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(swapSlots).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(swap).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
// verify "Slot 1 is configured"
|
|
|
|
// verify "Slot 2 is configured"
|
|
|
|
|
|
|
|
});
|
|
|
|
appTest('Delete Credentials', (WidgetTester tester) async {
|
|
|
|
await tester.tap(find.byKey(otpAppDrawer).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
// verify "Slot 1 is configured"
|
|
|
|
// verify "Slot 2 is configured"
|
|
|
|
|
|
|
|
// we need to right click on slot 1
|
|
|
|
await tester.tap(find.byKey(deleteAction).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(deleteButton).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
// we need to right click on slot 2
|
|
|
|
await tester.tap(find.byKey(deleteAction).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(deleteButton).hitTestable());
|
|
|
|
await tester.shortWait();
|
|
|
|
|
|
|
|
// verify "Slot 1 is empty"
|
|
|
|
// verify "Slot 2 is empty"
|
2023-12-14 16:43:49 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|