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

324-ios-platformexceptionnotavailable-authentication-canceled-comapplelocalauthentication-null #325

Closed
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
6 changes: 3 additions & 3 deletions .github/workflows/flutter_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- run: "flutter upgrade"
- run: "flutter --version"
- run: "flutter pub get"
- run: "flutter build ios --no-codesign"
- run: "flutter build ios -t 'lib/main_netknights.dart' --no-codesign"

build_appbundle:
name: (Android)
Expand All @@ -41,7 +41,7 @@ jobs:
# matrix job fails.
fail-fast: false
matrix:
api-level: [ 21,31 ] # [minSdk, most used, newest (30 is not working :(] 19 would be minSDK but does not support x86_64
api-level: [ 21, 30, 34 ] # [minSdk, most used, newest]
target: [ default ] # [default, google_apis]
steps:
- uses: actions/checkout@v2
Expand All @@ -56,5 +56,5 @@ jobs:
- run: "flutter --version"
- run: "flutter pub get"
- run: 'flutter clean'
- run: "flutter build apk --debug"
- run: "flutter build apk -t 'lib/main_netknights.dart' --debug"

5 changes: 5 additions & 0 deletions .github/workflows/test-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ jobs:
target: [playstore]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- uses: subosito/flutter-action@v1
with:
flutter-version: '3.13.2'
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/lock_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ Future<bool> lockAuth({required BuildContext context, required String localizedR
authenticationInProgress = false;
}
} on PlatformException catch (e, s) {
Logger.error('Error: ${e.code}', name: 'token_widgets.dart#lockAuth', error: e, stackTrace: s);
authenticationInProgress = false;
Logger.info("Authentication failed", error: e, stackTrace: s);
}
return didAuthenticate;
}
5 changes: 3 additions & 2 deletions lib/utils/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
import 'dart:math';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -131,9 +132,9 @@ class Logger {
static void error(String? message, {required dynamic error, required dynamic stackTrace, String? name}) {
final errorString = instance._convertLogToSingleString(message, error: error, stackTrace: stackTrace, name: name, logLevel: LogLevel.ERROR);
if (message != null) {
instance._lastError = message.substring(0, 100);
instance._lastError = message.substring(0, min(message.length, 100));
} else if (error != null) {
instance._lastError = error.toString().substring(0, 100);
instance._lastError = error.toString().substring(0, min(error.toString().length, 100));
}
instance._logToFile(errorString);
instance._showSnackbar();
Expand Down
66 changes: 66 additions & 0 deletions test/unit_test/model/states_test/settings_state_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:privacyidea_authenticator/model/states/settings_state.dart';

void main() {
_testSettingsState();
}

void _testSettingsState() {
group('SettingsState', () {
final state = SettingsState(
isFirstRun: true,
showGuideOnStart: true,
hideOpts: true,
enablePolling: true,
crashReportRecipients: {'test'},
localePreference: const Locale('en'),
useSystemLocale: true,
verboseLogging: true,
);
test('constructor', () {
expect(state.isFirstRun, true);
expect(state.showGuideOnStart, true);
expect(state.hideOpts, true);
expect(state.enablePolling, true);
expect(state.crashReportRecipients, {'test'});
expect(state.localePreference.toLanguageTag(), const Locale('en').toLanguageTag());
expect(state.useSystemLocale, true);
expect(state.verboseLogging, true);
});
test('copyWith', () {
final newState = state.copyWith(
isFirstRun: false,
showGuideOnStart: false,
hideOpts: false,
enablePolling: false,
crashReportRecipients: {'test2'},
localePreference: const Locale('de'),
useSystemLocale: false,
verboseLogging: false,
);
expect(state.isFirstRun, true);
expect(state.showGuideOnStart, true);
expect(state.hideOpts, true);
expect(state.enablePolling, true);
expect(state.crashReportRecipients, {'test'});
expect(state.localePreference.toLanguageTag(), const Locale('en').toLanguageTag());
expect(state.useSystemLocale, true);
expect(state.verboseLogging, true);
expect(newState.isFirstRun, false);
expect(newState.showGuideOnStart, false);
expect(newState.hideOpts, false);
expect(newState.enablePolling, false);
expect(newState.crashReportRecipients, {'test2'});
expect(newState.localePreference.toLanguageTag(), const Locale('de').toLanguageTag());
expect(newState.useSystemLocale, false);
expect(newState.verboseLogging, false);
});
test('encodeLocale/decodeLocale', () {
const locale = Locale('en');
final encodedLocale = SettingsState.encodeLocale(locale);
final decodedLocale = SettingsState.decodeLocale(encodedLocale);
expect(locale.toLanguageTag(), decodedLocale.toLanguageTag());
});
});
}
22 changes: 12 additions & 10 deletions test/unit_test/state_notifiers/push_request_notifier_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer';

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart';
Expand All @@ -23,6 +25,7 @@ class _MockPushProvider extends Mock implements PushProvider {
}

void simulatePush(PushRequest pushRequest) {
log(pushSubscriber.toString());
pushSubscriber?.newRequest(pushRequest);
}
}
Expand All @@ -38,16 +41,14 @@ void _testPushRequestNotifier() {
final container = ProviderContainer();
final mockPushProvider = _MockPushProvider();
final mockFirebaseUtils = MockFirebaseUtils();
final testProvider = StateNotifierProvider<PushRequestNotifier, PushRequest?>((ref) {
final notifier = PushRequestNotifier(
pushProvider: mockPushProvider,
firebaseUtils: mockFirebaseUtils,
ioClient: MockPrivacyIdeaIOClient(),
rsaUtils: MockRsaUtils(),
);
mockPushProvider.initialize(pushSubscriber: notifier, firebaseUtils: mockFirebaseUtils);
return notifier;
});
final notifier = PushRequestNotifier(
pushProvider: mockPushProvider,
firebaseUtils: mockFirebaseUtils,
ioClient: MockPrivacyIdeaIOClient(),
rsaUtils: MockRsaUtils(),
);
final testProvider = StateNotifierProvider<PushRequestNotifier, PushRequest?>((ref) => notifier);
await mockPushProvider.initialize(pushSubscriber: notifier, firebaseUtils: mockFirebaseUtils);
final pr = PushRequest(
title: 'title',
question: 'question',
Expand All @@ -57,6 +58,7 @@ void _testPushRequestNotifier() {
id: 1,
expirationDate: DateTime.now().add(const Duration(minutes: 10)),
);
log('1');
mockPushProvider.simulatePush(pr);
expect(container.read(testProvider), pr);
});
Expand Down
Loading