Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed some minor issues based on test results #355

Merged
merged 30 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/flutter_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- run: "flutter upgrade"
- run: "flutter --version"
- run: "flutter pub get"
- run: "flutter build ios -t 'lib/main_netknights.dart' --no-codesign"
- run: "flutter build ios -t 'lib/mains/main_netknights.dart' --debug --flavor netknights --no-codesign"

build_appbundle:
name: (Android)
Expand All @@ -45,17 +45,17 @@ jobs:
api-level: [ 21, 30, 34 ] # [minSdk, most used, newest]
target: [ default ] # [default, google_apis]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17.0.7'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.10.5'
flutter-version: '3.19.0'
- run: "flutter upgrade"
- run: "flutter --version"
- run: "flutter pub get"
- run: 'flutter clean'
- run: "flutter build apk -t 'lib/main_netknights.dart' --debug"

- run: "flutter build apk -t 'lib/mains/main_netknights.dart' --debug --flavor netknights"
8 changes: 4 additions & 4 deletions .github/workflows/flutter_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
timeout-minutes: 40

steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '11'
java-version: '17.0.7'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.16.5'
flutter-version: '3.19.0'
- run: "flutter --version"
- run: flutter pub get
- run: flutter test
10 changes: 5 additions & 5 deletions .github/workflows/test-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
matrix:
api-level: [29]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '11'
java-version: '17.0.7'

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.16.5'
flutter-version: '3.19.0'
channel: 'stable'

# Run integration test
Expand All @@ -29,5 +29,5 @@ jobs:
api-level: ${{ matrix.api-level }}
arch: x86_64
profile: Nexus 6
script: flutter test integration_test
script: flutter test integration_test --flavor netknights

28 changes: 20 additions & 8 deletions integration_test/add_tokens_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import 'package:privacyidea_authenticator/l10n/app_localizations_en.dart';
import 'package:privacyidea_authenticator/mains/main_netknights.dart';
import 'package:privacyidea_authenticator/model/enums/algorithms.dart';
import 'package:privacyidea_authenticator/model/enums/encodings.dart';
import 'package:privacyidea_authenticator/model/enums/introduction.dart';
import 'package:privacyidea_authenticator/model/enums/token_types.dart';
import 'package:privacyidea_authenticator/model/states/introduction_state.dart';
import 'package:privacyidea_authenticator/model/states/settings_state.dart';
import 'package:privacyidea_authenticator/state_notifiers/completed_introduction_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
Expand All @@ -31,6 +34,7 @@ void main() {
late final MockSettingsRepository mockSettingsRepository;
late final MockTokenRepository mockTokenRepository;
late final MockTokenFolderRepository mockTokenFolderRepository;
late final MockIntroductionRepository mockIntroductionRepository;
setUp(() {
mockSettingsRepository = MockSettingsRepository();
when(mockSettingsRepository.loadSettings()).thenAnswer((_) async => SettingsState(useSystemLocale: false, localePreference: const Locale('en')));
Expand All @@ -42,6 +46,9 @@ void main() {
mockTokenFolderRepository = MockTokenFolderRepository();
when(mockTokenFolderRepository.loadFolders()).thenAnswer((_) async => []);
when(mockTokenFolderRepository.saveOrReplaceFolders(any)).thenAnswer((_) async => []);
mockIntroductionRepository = MockIntroductionRepository();
final introductions = {...Introduction.values}..remove(Introduction.introductionScreen);
when(mockIntroductionRepository.loadCompletedIntroductions()).thenAnswer((_) async => IntroductionState(completedIntroductions: introductions));
});
testWidgets(
'Add Tokens Test',
Expand All @@ -51,6 +58,7 @@ void main() {
settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepository)),
tokenProvider.overrideWith((ref) => TokenNotifier(repository: mockTokenRepository)),
tokenFolderProvider.overrideWith((ref) => TokenFolderNotifier(repository: mockTokenFolderRepository)),
introductionProvider.overrideWith((ref) => InrtroductionNotifier(repository: mockIntroductionRepository)),
],
child: PrivacyIDEAAuthenticator(customization: ApplicationCustomization.defaultCustomization),
));
Expand Down Expand Up @@ -82,13 +90,17 @@ void main() {
}

Future<void> _introToMainView(WidgetTester tester) async {
final Finder finder = find.byType(FloatingActionButton);
var finder = find.byType(FloatingActionButton);
await pumpUntilFindNWidgets(tester, finder, 1, const Duration(seconds: 20));
await tester.tap(finder);
await tester.pump(const Duration(milliseconds: 2000));
await tester.tap(finder);
await tester.pump(const Duration(milliseconds: 2000));
await tester.tap(finder);
await tester.pump(const Duration(milliseconds: 2000));
finder = find.text(AppLocalizationsEn().ok);
await pumpUntilFindNWidgets(tester, finder, 1, const Duration(seconds: 10));
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(const Duration(milliseconds: 1000));
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(const Duration(milliseconds: 1000));
await tester.tap(find.byType(FloatingActionButton));
await tester.tap(finder);
await tester.pump(const Duration(milliseconds: 1000));
}

Expand Down Expand Up @@ -160,7 +172,7 @@ Future<void> _createFolder(WidgetTester tester) async {
await tester.pump(const Duration(milliseconds: 1000));
await tester.enterText(find.byType(TextField).first, AppLocalizationsEn().folderName);
await tester.pump();
await tester.tap(find.text(AppLocalizationsEn().save));
await tester.tap(find.text(AppLocalizationsEn().create));
await tester.pump();
}

Expand Down Expand Up @@ -208,7 +220,7 @@ Future<void> _openFolder(WidgetTester tester) async {

void expectMainViewIsEmptyAndCorrect() {
expect(find.byType(FloatingActionButton), findsOneWidget);
expect(find.byType(AppBarItem), findsNWidgets(4));
expect(find.byType(AppBarItem), findsNWidgets(5)); // 4 at BottomNavigationBar and 1 at AppBar
expect(find.byType(TokenWidgetBase), findsNothing);
expect(find.byType(TokenFolderWidget), findsNothing);
expect(find.text(ApplicationCustomization.defaultCustomization.appName), findsOneWidget);
Expand Down
11 changes: 9 additions & 2 deletions integration_test/copy_to_clipboard_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import 'package:integration_test/integration_test.dart';
import 'package:mockito/mockito.dart';
import 'package:privacyidea_authenticator/mains/main_netknights.dart';
import 'package:privacyidea_authenticator/model/enums/algorithms.dart';
import 'package:privacyidea_authenticator/model/enums/introduction.dart';
import 'package:privacyidea_authenticator/model/states/introduction_state.dart';
import 'package:privacyidea_authenticator/model/states/settings_state.dart';
import 'package:privacyidea_authenticator/model/tokens/hotp_token.dart';
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
import 'package:privacyidea_authenticator/utils/version.dart';

import '../test/tests_app_wrapper.dart';
import '../test/tests_app_wrapper.mocks.dart';
Expand All @@ -21,10 +24,11 @@ void main() {
late final MockSettingsRepository mockSettingsRepository;
late final MockTokenRepository mockTokenRepository;
late final MockTokenFolderRepository mockTokenFolderRepository;
late final MockIntroductionRepository mockIntroductionRepository;
setUp(() {
mockSettingsRepository = MockSettingsRepository();
when(mockSettingsRepository.loadSettings())
.thenAnswer((_) async => SettingsState(isFirstRun: false, useSystemLocale: false, localePreference: const Locale('en')));
when(mockSettingsRepository.loadSettings()).thenAnswer((_) async =>
SettingsState(isFirstRun: false, useSystemLocale: false, localePreference: const Locale('en'), latestVersion: Version.parse('999.999.999')));
when(mockSettingsRepository.saveSettings(any)).thenAnswer((_) async => true);
mockTokenRepository = MockTokenRepository();
when(mockTokenRepository.loadTokens()).thenAnswer((_) async => [
Expand All @@ -35,6 +39,9 @@ void main() {
mockTokenFolderRepository = MockTokenFolderRepository();
when(mockTokenFolderRepository.loadFolders()).thenAnswer((_) async => []);
when(mockTokenFolderRepository.saveOrReplaceFolders(any)).thenAnswer((_) async => []);
mockIntroductionRepository = MockIntroductionRepository();
final introductions = {...Introduction.values}..remove(Introduction.introductionScreen);
when(mockIntroductionRepository.loadCompletedIntroductions()).thenAnswer((_) async => IntroductionState(completedIntroductions: introductions));
});
testWidgets('Copy to Clipboard Test', (tester) async {
await tester.pumpWidget(TestsAppWrapper(
Expand Down
11 changes: 9 additions & 2 deletions integration_test/rename_and_delete_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import 'package:mockito/mockito.dart';
import 'package:privacyidea_authenticator/l10n/app_localizations_en.dart';
import 'package:privacyidea_authenticator/mains/main_netknights.dart';
import 'package:privacyidea_authenticator/model/enums/algorithms.dart';
import 'package:privacyidea_authenticator/model/enums/introduction.dart';
import 'package:privacyidea_authenticator/model/states/introduction_state.dart';
import 'package:privacyidea_authenticator/model/states/settings_state.dart';
import 'package:privacyidea_authenticator/model/tokens/hotp_token.dart';
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
import 'package:privacyidea_authenticator/utils/version.dart';
import 'package:privacyidea_authenticator/views/main_view/main_view_widgets/token_widgets/default_token_actions/default_delete_action.dart';
import 'package:privacyidea_authenticator/views/main_view/main_view_widgets/token_widgets/hotp_token_widgets/actions/edit_hotp_token_action.dart';
import 'package:privacyidea_authenticator/views/main_view/main_view_widgets/token_widgets/hotp_token_widgets/hotp_token_widget.dart';
Expand All @@ -24,10 +27,11 @@ void main() {
late final MockSettingsRepository mockSettingsRepository;
late final MockTokenRepository mockTokenRepository;
late final MockTokenFolderRepository mockTokenFolderRepository;
late final MockIntroductionRepository mockIntroductionRepository;
setUp(() {
mockSettingsRepository = MockSettingsRepository();
when(mockSettingsRepository.loadSettings())
.thenAnswer((_) async => SettingsState(isFirstRun: false, useSystemLocale: false, localePreference: const Locale('en')));
when(mockSettingsRepository.loadSettings()).thenAnswer((_) async =>
SettingsState(isFirstRun: false, useSystemLocale: false, localePreference: const Locale('en'), latestVersion: Version.parse('999.999.999')));
when(mockSettingsRepository.saveSettings(any)).thenAnswer((_) async => true);
mockTokenRepository = MockTokenRepository();
when(mockTokenRepository.loadTokens()).thenAnswer((_) async => [
Expand All @@ -38,6 +42,9 @@ void main() {
mockTokenFolderRepository = MockTokenFolderRepository();
when(mockTokenFolderRepository.loadFolders()).thenAnswer((_) async => []);
when(mockTokenFolderRepository.saveOrReplaceFolders(any)).thenAnswer((_) async => []);
mockIntroductionRepository = MockIntroductionRepository();
final introductions = {...Introduction.values}..remove(Introduction.introductionScreen);
when(mockIntroductionRepository.loadCompletedIntroductions()).thenAnswer((_) async => IntroductionState(completedIntroductions: introductions));
});
testWidgets('Rename and Delete Token', (tester) async {
await tester.pumpWidget(TestsAppWrapper(
Expand Down
11 changes: 9 additions & 2 deletions integration_test/two_step_rollout_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import 'package:integration_test/integration_test.dart';
import 'package:mockito/mockito.dart';
import 'package:privacyidea_authenticator/l10n/app_localizations_en.dart';
import 'package:privacyidea_authenticator/mains/main_netknights.dart';
import 'package:privacyidea_authenticator/model/enums/introduction.dart';
import 'package:privacyidea_authenticator/model/states/introduction_state.dart';
import 'package:privacyidea_authenticator/model/states/settings_state.dart';
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/logger.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
import 'package:privacyidea_authenticator/utils/version.dart';
import 'package:privacyidea_authenticator/views/main_view/main_view.dart';
import 'package:privacyidea_authenticator/views/main_view/main_view_widgets/token_widgets/hotp_token_widgets/hotp_token_widget_tile.dart';
import 'package:privacyidea_authenticator/views/main_view/main_view_widgets/token_widgets/totp_token_widgets/totp_token_widget_tile.dart';
Expand Down Expand Up @@ -44,10 +47,11 @@ void main() {
late final MockSettingsRepository mockSettingsRepository;
late final MockTokenRepository mockTokenRepository;
late final MockTokenFolderRepository mockTokenFolderRepository;
late final MockIntroductionRepository mockIntroductionRepository;
setUp(() {
mockSettingsRepository = MockSettingsRepository();
when(mockSettingsRepository.loadSettings())
.thenAnswer((_) async => SettingsState(isFirstRun: false, useSystemLocale: false, localePreference: const Locale('en')));
when(mockSettingsRepository.loadSettings()).thenAnswer((_) async =>
SettingsState(isFirstRun: false, useSystemLocale: false, localePreference: const Locale('en'), latestVersion: Version.parse('999.999.999')));
when(mockSettingsRepository.saveSettings(any)).thenAnswer((_) async => true);
mockTokenRepository = MockTokenRepository();
when(mockTokenRepository.loadTokens()).thenAnswer((_) async => []);
Expand All @@ -56,6 +60,9 @@ void main() {
mockTokenFolderRepository = MockTokenFolderRepository();
when(mockTokenFolderRepository.loadFolders()).thenAnswer((_) async => []);
when(mockTokenFolderRepository.saveOrReplaceFolders(any)).thenAnswer((_) async => []);
mockIntroductionRepository = MockIntroductionRepository();
final introductions = {...Introduction.values}..remove(Introduction.introductionScreen);
when(mockIntroductionRepository.loadCompletedIntroductions()).thenAnswer((_) async => IntroductionState(completedIntroductions: introductions));
});
testWidgets(
'2step rollout test',
Expand Down
13 changes: 10 additions & 3 deletions integration_test/views_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import 'package:mockito/mockito.dart';
import 'package:pointycastle/asymmetric/api.dart';
import 'package:privacyidea_authenticator/l10n/app_localizations_en.dart';
import 'package:privacyidea_authenticator/mains/main_netknights.dart';
import 'package:privacyidea_authenticator/model/enums/introduction.dart';
import 'package:privacyidea_authenticator/model/states/introduction_state.dart';
import 'package:privacyidea_authenticator/model/states/settings_state.dart';
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
import 'package:privacyidea_authenticator/utils/rsa_utils.dart';
import 'package:privacyidea_authenticator/utils/version.dart';
import 'package:privacyidea_authenticator/views/settings_view/settings_view_widgets/settings_groups.dart';

import '../test/tests_app_wrapper.dart';
Expand All @@ -26,10 +29,11 @@ void main() {
late final MockRsaUtils mockRsaUtils;
late final MockFirebaseUtils mockFirebaseUtils;
late final MockPrivacyIdeaIOClient mockIOClient;
late final MockIntroductionRepository mockIntroductionRepository;
setUp(() {
mockSettingsRepository = MockSettingsRepository();
when(mockSettingsRepository.loadSettings())
.thenAnswer((_) async => SettingsState(isFirstRun: false, useSystemLocale: false, localePreference: const Locale('en')));
when(mockSettingsRepository.loadSettings()).thenAnswer((_) async =>
SettingsState(isFirstRun: false, useSystemLocale: false, localePreference: const Locale('en'), latestVersion: Version.parse('999.999.999')));
when(mockSettingsRepository.saveSettings(any)).thenAnswer((_) async => true);
mockTokenRepository = MockTokenRepository();
when(mockTokenRepository.loadTokens()).thenAnswer((_) async => []);
Expand All @@ -51,6 +55,9 @@ void main() {
body: anyNamed('body'),
sslVerify: anyNamed('sslVerify'),
)).thenAnswer((_) => Future.value(Response('{"detail": {"public_key": "publicKey"}}', 200)));
mockIntroductionRepository = MockIntroductionRepository();
final introductions = {...Introduction.values}..remove(Introduction.introductionScreen);
when(mockIntroductionRepository.loadCompletedIntroductions()).thenAnswer((_) async => IntroductionState(completedIntroductions: introductions));
});

testWidgets('Views Test', (tester) async {
Expand Down Expand Up @@ -101,7 +108,7 @@ Future<void> _settingsViewTest(WidgetTester tester) async {
expect(find.text(AppLocalizationsEn().theme), findsOneWidget);
expect(find.text(AppLocalizationsEn().language), findsOneWidget);
expect(find.text(AppLocalizationsEn().errorLogTitle), findsOneWidget);
expect(find.byType(SettingsGroup), findsNWidgets(4));
expect(find.byType(SettingsGroup), findsNWidgets(5));
globalRef!.read(tokenProvider.notifier).handleQrCode(
'otpauth://pipush/label?url=http%3A%2F%2Fwww.example.com&ttl=10&issuer=issuer&enrollment_credential=enrollmentCredentials&v=1&serial=serial&serial=serial&sslverify=0');
await pumpUntilFindNWidgets(tester, find.text(AppLocalizationsEn().pushToken), 1, const Duration(minutes: 5));
Expand Down
34 changes: 34 additions & 0 deletions ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
*.mode1v3
*.mode2v3
*.moved-aside
*.pbxuser
*.perspectivev3
**/*sync/
.sconsign.dblite
.tags*
**/.vagrant/
**/DerivedData/
Icon?
**/Pods/
**/.symlinks/
profile
xcuserdata
**/.generated/
Flutter/App.framework
Flutter/Flutter.framework
Flutter/Flutter.podspec
Flutter/Generated.xcconfig
Flutter/ephemeral/
Flutter/app.flx
Flutter/app.zip
Flutter/flutter_assets/
Flutter/flutter_export_environment.sh
ServiceDefinitions.json
Runner/GeneratedPluginRegistrant.*
**.last_build_id

# Exceptions to above rules.
!default.mode1v3
!default.mode2v3
!default.pbxuser
!default.perspectivev3
Loading
Loading