2022-10-04 13:12:54 +03:00
|
|
|
/*
|
2023-12-04 17:28:07 +03:00
|
|
|
* Copyright (C) 2023 Yubico.
|
2022-10-04 13:12:54 +03:00
|
|
|
*
|
|
|
|
* 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', 'management'])
|
2024-07-03 13:44:20 +03:00
|
|
|
library;
|
|
|
|
|
2023-06-30 16:32:10 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2023-11-27 13:41:05 +03:00
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
2022-10-03 16:34:06 +03:00
|
|
|
import 'package:integration_test/integration_test.dart';
|
|
|
|
import 'package:yubico_authenticator/app/views/keys.dart' as app_keys;
|
|
|
|
import 'package:yubico_authenticator/management/views/keys.dart'
|
|
|
|
as management_keys;
|
|
|
|
|
2023-06-30 16:32:10 +03:00
|
|
|
import 'utils/test_util.dart';
|
2022-10-03 16:34:06 +03:00
|
|
|
|
|
|
|
Key _getCapabilityWidgetKey(bool isUsb, String name) =>
|
|
|
|
Key('management.keys.capability.${isUsb ? 'usb' : 'nfc'}.$name');
|
|
|
|
|
|
|
|
Future<FilterChip?> _getCapabilityWidget(Key key) async {
|
|
|
|
return find.byKey(key).hitTestable().evaluate().single.widget as FilterChip;
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
var binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
|
|
|
|
|
|
|
group('Management UI tests', () {
|
|
|
|
appTest('Drawer items exist', (WidgetTester tester) async {
|
|
|
|
await tester.openDrawer();
|
2023-07-03 12:27:25 +03:00
|
|
|
expect(find.byKey(app_keys.managementAppDrawer).hitTestable(),
|
|
|
|
findsOneWidget);
|
2022-10-03 16:34:06 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-11-22 17:25:01 +03:00
|
|
|
group('Toggle Applications on key', () {
|
|
|
|
appTest('Toggle OTP', (WidgetTester tester) async {
|
2022-10-03 16:34:06 +03:00
|
|
|
await tester.openManagementScreen();
|
|
|
|
|
|
|
|
// find USB OTP capability
|
|
|
|
var usbOtpKey = _getCapabilityWidgetKey(true, 'OTP');
|
|
|
|
var otpChip = await _getCapabilityWidget(usbOtpKey);
|
|
|
|
if (otpChip != null) {
|
|
|
|
// we expect OTP to be enabled on the Key for this test
|
|
|
|
expect(otpChip.selected, equals(true));
|
|
|
|
await tester.tap(find.byKey(usbOtpKey));
|
2023-11-22 17:25:01 +03:00
|
|
|
await tester.shortWait();
|
2022-10-03 16:34:06 +03:00
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
2023-11-22 17:25:01 +03:00
|
|
|
await tester.ultraLongWait();
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.shortWait();
|
|
|
|
}
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
if (otpChip != null) {
|
|
|
|
await tester.tap(find.byKey(usbOtpKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
|
|
|
|
// no management screen visible now
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.longWait();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
appTest('Toggle PIV', (WidgetTester tester) async {
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
var usbPivKey = _getCapabilityWidgetKey(true, 'PIV');
|
|
|
|
var pivChip = await _getCapabilityWidget(usbPivKey);
|
|
|
|
|
2023-12-04 17:28:07 +03:00
|
|
|
// find USB PIV capability
|
2023-11-22 17:25:01 +03:00
|
|
|
if (pivChip != null) {
|
|
|
|
expect(pivChip.selected, equals(true));
|
|
|
|
await tester.tap(find.byKey(usbPivKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.shortWait();
|
|
|
|
}
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
if (pivChip != null) {
|
2023-12-04 17:28:07 +03:00
|
|
|
// we expect PIV to be enabled on the Key for this test
|
2023-11-22 17:25:01 +03:00
|
|
|
await tester.tap(find.byKey(usbPivKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
2022-10-03 16:34:06 +03:00
|
|
|
|
|
|
|
// no management screen visible now
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.longWait();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-11-22 17:25:01 +03:00
|
|
|
appTest('Toggle OATH', (WidgetTester tester) async {
|
2022-10-03 16:34:06 +03:00
|
|
|
await tester.openManagementScreen();
|
|
|
|
|
2023-12-04 17:28:07 +03:00
|
|
|
// find USB OATH capability
|
2023-11-22 17:25:01 +03:00
|
|
|
var usbOathKey = _getCapabilityWidgetKey(true, 'OATH');
|
|
|
|
var oathChip = await _getCapabilityWidget(usbOathKey);
|
|
|
|
if (oathChip != null) {
|
2023-12-04 17:28:07 +03:00
|
|
|
// we expect OATH to be enabled on the Key for this test
|
2023-11-22 17:25:01 +03:00
|
|
|
expect(oathChip.selected, equals(true));
|
|
|
|
await tester.tap(find.byKey(usbOathKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.shortWait();
|
|
|
|
}
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
if (oathChip != null) {
|
|
|
|
await tester.tap(find.byKey(usbOathKey));
|
|
|
|
await tester.shortWait();
|
2022-10-03 16:34:06 +03:00
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
2023-11-22 17:25:01 +03:00
|
|
|
await tester.ultraLongWait();
|
2022-10-03 16:34:06 +03:00
|
|
|
|
|
|
|
// no management screen visible now
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.longWait();
|
|
|
|
}
|
|
|
|
});
|
2023-11-22 17:25:01 +03:00
|
|
|
appTest('Toggle OpenPGP', (WidgetTester tester) async {
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
|
2023-12-04 17:28:07 +03:00
|
|
|
// find USB OPENPGP capability
|
2023-11-22 17:25:01 +03:00
|
|
|
var usbPgpKey = _getCapabilityWidgetKey(true, 'OpenPGP');
|
|
|
|
var pgpChip = await _getCapabilityWidget(usbPgpKey);
|
|
|
|
if (pgpChip != null) {
|
2023-12-04 17:28:07 +03:00
|
|
|
// we expect OPENPGP to be enabled on the Key for this test
|
2023-11-22 17:25:01 +03:00
|
|
|
expect(pgpChip.selected, equals(true));
|
|
|
|
await tester.tap(find.byKey(usbPgpKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.shortWait();
|
|
|
|
}
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
if (pgpChip != null) {
|
|
|
|
await tester.tap(find.byKey(usbPgpKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
|
|
|
|
// no management screen visible now
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.longWait();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
appTest('Toggle YubiHSM Auth', (WidgetTester tester) async {
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
|
2023-12-04 17:28:07 +03:00
|
|
|
// find USB YubiHSM Auth capability
|
2023-11-22 17:25:01 +03:00
|
|
|
var usbHsmKey = _getCapabilityWidgetKey(true, 'YubiHSM Auth');
|
|
|
|
var hsmChip = await _getCapabilityWidget(usbHsmKey);
|
|
|
|
if (hsmChip != null) {
|
2023-12-04 17:28:07 +03:00
|
|
|
// we expect YubiHSM Auth to be enabled on the Key for this test
|
2023-11-22 17:25:01 +03:00
|
|
|
expect(hsmChip.selected, equals(true));
|
|
|
|
await tester.tap(find.byKey(usbHsmKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.shortWait();
|
|
|
|
}
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
if (hsmChip != null) {
|
|
|
|
await tester.tap(find.byKey(usbHsmKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
|
|
|
|
// no management screen visible now
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.longWait();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
appTest('Toggle FIDO U2F', (WidgetTester tester) async {
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
|
2023-12-04 17:28:07 +03:00
|
|
|
// find USB FIDO U2F capability
|
2023-11-22 17:25:01 +03:00
|
|
|
var usbU2fKey = _getCapabilityWidgetKey(true, 'FIDO U2F');
|
|
|
|
var u2fChip = await _getCapabilityWidget(usbU2fKey);
|
|
|
|
if (u2fChip != null) {
|
2023-12-04 17:28:07 +03:00
|
|
|
// we expect FIDO U2F to be enabled on the Key for this test
|
2023-11-22 17:25:01 +03:00
|
|
|
expect(u2fChip.selected, equals(true));
|
|
|
|
await tester.tap(find.byKey(usbU2fKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.shortWait();
|
|
|
|
}
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
if (u2fChip != null) {
|
|
|
|
await tester.tap(find.byKey(usbU2fKey));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
|
|
|
|
// no management screen visible now
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.longWait();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
appTest('Toggle FIDO2', (WidgetTester tester) async {
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
|
2023-12-04 17:28:07 +03:00
|
|
|
// find USB FIDO2 capability
|
2023-11-22 17:25:01 +03:00
|
|
|
var usbFido2Key = _getCapabilityWidgetKey(true, 'FIDO2');
|
|
|
|
var fido2Chip = await _getCapabilityWidget(usbFido2Key);
|
|
|
|
if (fido2Chip != null) {
|
2023-12-04 17:28:07 +03:00
|
|
|
// we expect FIDO2 to be enabled on the Key for this test
|
2023-11-22 17:25:01 +03:00
|
|
|
expect(fido2Chip.selected, equals(true));
|
|
|
|
await tester.tap(find.byKey(usbFido2Key));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.shortWait();
|
|
|
|
}
|
|
|
|
await tester.openManagementScreen();
|
|
|
|
if (fido2Chip != null) {
|
|
|
|
await tester.tap(find.byKey(usbFido2Key));
|
|
|
|
await tester.shortWait();
|
|
|
|
await tester.tap(find.byKey(management_keys.saveButtonKey));
|
|
|
|
// long wait
|
|
|
|
await tester.ultraLongWait();
|
|
|
|
|
|
|
|
// no management screen visible now
|
|
|
|
expect(find.byKey(management_keys.screenKey), findsNothing);
|
|
|
|
await tester.longWait();
|
|
|
|
}
|
2022-10-03 16:34:06 +03:00
|
|
|
});
|
|
|
|
}
|