forked from Yubico/yubioath-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Yubico#1389 from Yubico/test/passkey-tests
Test/passkey tests
- Loading branch information
Showing
6 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,8 @@ tags: | |
|
||
# Management tests | ||
management: | ||
timeout: none | ||
|
||
# Passkey tests | ||
passkey: | ||
timeout: none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* 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(['desktop', 'passkey']) | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:yubico_authenticator/fido/keys.dart'; | ||
|
||
import 'utils/passkey_test_util.dart'; | ||
import 'utils/test_util.dart'; | ||
|
||
void main() { | ||
var binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive; | ||
|
||
group('Passkey PIN tests', () { | ||
const simplePin = '1111'; | ||
const fidoPin1 = '947344'; | ||
const fidoPin2 = '478178'; | ||
|
||
/// Sadly these tests are built on each other to save reset-dance | ||
appTest('Reset Fido2 1/2', (WidgetTester tester) async { | ||
await tester.resetFido2(); | ||
}); | ||
group('Set/change pin', () { | ||
appTest('Set simplePin', (WidgetTester tester) async { | ||
// OBS: This will not work if there is pin complexity requirements | ||
await tester.configurePasskey(); | ||
|
||
await tester.tap(find.byKey(managePinAction).hitTestable()); | ||
await tester.shortWait(); | ||
|
||
await tester.enterText(find.byKey(newPin), simplePin); | ||
await tester.shortWait(); | ||
await tester.enterText(find.byKey(confirmPin), simplePin); | ||
await tester.shortWait(); | ||
|
||
await tester.tap(find.byKey(saveButton).hitTestable()); | ||
await tester.shortWait(); | ||
|
||
/// TODO: deal with error messages from fips keys | ||
/// TODO: make sure that the outcome of this test is a set state, right now it differs between FIPS and non-FIPS keys. | ||
}); | ||
appTest('Change to fidoPin1', (WidgetTester tester) async { | ||
await tester.configurePasskey(); | ||
|
||
await tester.tap(find.byKey(managePinAction).hitTestable()); | ||
await tester.shortWait(); | ||
|
||
await tester.enterText(find.byKey(currentPin), simplePin); | ||
await tester.shortWait(); | ||
await tester.enterText(find.byKey(newPin), fidoPin1); | ||
await tester.shortWait(); | ||
await tester.enterText(find.byKey(confirmPin), fidoPin1); | ||
await tester.shortWait(); | ||
|
||
await tester.tap(find.byKey(saveButton).hitTestable()); | ||
await tester.shortWait(); | ||
}); | ||
appTest('Change to fidoPin2', (WidgetTester tester) async { | ||
await tester.configurePasskey(); | ||
|
||
await tester.tap(find.byKey(managePinAction)); | ||
await tester.shortWait(); | ||
|
||
await tester.enterText(find.byKey(currentPin), fidoPin1); | ||
await tester.shortWait(); | ||
await tester.enterText(find.byKey(newPin), fidoPin2); | ||
await tester.shortWait(); | ||
await tester.enterText(find.byKey(confirmPin), fidoPin2); | ||
await tester.shortWait(); | ||
|
||
await tester.tap(find.byKey(saveButton).hitTestable()); | ||
await tester.shortWait(); | ||
}); | ||
}); | ||
appTest('Reset Fido2 2/2', (WidgetTester tester) async { | ||
await tester.resetFido2(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:yubico_authenticator/app/views/keys.dart'; | ||
|
||
import 'test_util.dart'; | ||
|
||
const fido2DanceLongWaitMs = 15000; | ||
|
||
extension Fido2Functions on WidgetTester { | ||
Future<void> fido2DanceWait() async { | ||
await pump(const Duration(milliseconds: fido2DanceLongWaitMs)); | ||
} | ||
|
||
/// Open the PIV Configuration | ||
Future<void> configurePasskey() async { | ||
// 1. open PIV view | ||
await tap(find.byKey(fidoPasskeysAppDrawer).hitTestable()); | ||
await shortWait(); | ||
await tap(find.byKey(actionsIconButtonKey).hitTestable()); | ||
await shortWait(); | ||
} | ||
|
||
/// Factory reset Fido2 application | ||
Future<void> resetFido2() async { | ||
final targetKey = approvedKeys[0]; // only reset approved keys! | ||
|
||
/// 1. make sure we are using approved key | ||
await switchToKey(targetKey); | ||
await shortWait(); | ||
|
||
/// 2. open the key menu | ||
await tapPopupMenu(targetKey); | ||
await shortWait(); | ||
await tap(find.byKey(yubikeyFactoryResetMenuButton).hitTestable()); | ||
await longWait(); | ||
|
||
/// 3. then toggle 'Fido2' in the 'Factory reset' reset_dialog.dart | ||
await tap(find.byKey(factoryResetPickResetFido2)); | ||
await longWait(); | ||
|
||
/// 4. Click reset TextButton: done | ||
await tap(find.byKey(factoryResetReset)); | ||
await fido2DanceWait(); | ||
|
||
/// 5. Click the 'Close' button | ||
await tap(find.text('Close').hitTestable()); | ||
await shortWait(); | ||
|
||
/// TODO 6. Verify Resetedness | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters