forked from flutter/plugins
-
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.
[local_auth] Avoid user confirmation on face unlock (flutter#2047)
* Define a new parameter for signaling that the transaction is sensitive. * Up the biometric version to beta01. * Handle no device credential error.
- Loading branch information
Showing
6 changed files
with
127 additions
and
13 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
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
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ description: Flutter plugin for Android and iOS device authentication sensors | |
such as Fingerprint Reader and Touch ID. | ||
author: Flutter Team <[email protected]> | ||
homepage: https://github.com/flutter/plugins/tree/master/packages/local_auth | ||
version: 0.5.3 | ||
version: 0.6.0 | ||
|
||
flutter: | ||
plugin: | ||
|
@@ -16,6 +16,11 @@ dependencies: | |
sdk: flutter | ||
meta: ^1.0.5 | ||
intl: ^0.15.1 | ||
platform: ^2.0.0 | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
|
||
environment: | ||
sdk: ">=2.0.0-dev.28.0 <3.0.0" | ||
|
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,90 @@ | ||
// Copyright 2019 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:local_auth/auth_strings.dart'; | ||
import 'package:local_auth/local_auth.dart'; | ||
import 'package:platform/platform.dart'; | ||
|
||
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('LocalAuth', () { | ||
const MethodChannel channel = MethodChannel( | ||
'plugins.flutter.io/local_auth', | ||
); | ||
|
||
final List<MethodCall> log = <MethodCall>[]; | ||
LocalAuthentication localAuthentication; | ||
|
||
setUp(() { | ||
channel.setMockMethodCallHandler((MethodCall methodCall) { | ||
log.add(methodCall); | ||
return Future<dynamic>.value(true); | ||
}); | ||
localAuthentication = LocalAuthentication(); | ||
log.clear(); | ||
}); | ||
|
||
test('authenticate with no args on Android.', () async { | ||
setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); | ||
await localAuthentication.authenticateWithBiometrics( | ||
localizedReason: 'Needs secure'); | ||
expect( | ||
log, | ||
<Matcher>[ | ||
isMethodCall('authenticateWithBiometrics', | ||
arguments: <String, dynamic>{ | ||
'localizedReason': 'Needs secure', | ||
'useErrorDialogs': true, | ||
'stickyAuth': false, | ||
'sensitiveTransaction': true, | ||
}..addAll(const AndroidAuthMessages().args)), | ||
], | ||
); | ||
}); | ||
|
||
test('authenticate with no args on iOS.', () async { | ||
setMockPathProviderPlatform(FakePlatform(operatingSystem: 'ios')); | ||
await localAuthentication.authenticateWithBiometrics( | ||
localizedReason: 'Needs secure'); | ||
expect( | ||
log, | ||
<Matcher>[ | ||
isMethodCall('authenticateWithBiometrics', | ||
arguments: <String, dynamic>{ | ||
'localizedReason': 'Needs secure', | ||
'useErrorDialogs': true, | ||
'stickyAuth': false, | ||
'sensitiveTransaction': true, | ||
}..addAll(const IOSAuthMessages().args)), | ||
], | ||
); | ||
}); | ||
|
||
test('authenticate with no sensitive transaction.', () async { | ||
setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); | ||
await localAuthentication.authenticateWithBiometrics( | ||
localizedReason: 'Insecure', | ||
sensitiveTransaction: false, | ||
useErrorDialogs: false, | ||
); | ||
expect( | ||
log, | ||
<Matcher>[ | ||
isMethodCall('authenticateWithBiometrics', | ||
arguments: <String, dynamic>{ | ||
'localizedReason': 'Insecure', | ||
'useErrorDialogs': false, | ||
'stickyAuth': false, | ||
'sensitiveTransaction': false, | ||
}..addAll(const AndroidAuthMessages().args)), | ||
], | ||
); | ||
}); | ||
}); | ||
} |