Skip to content

Instantly share code, notes, and snippets.

@OleksandrKucherenko
Created February 7, 2020 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OleksandrKucherenko/740c191a3f1e95d2e5f20516f101787a to your computer and use it in GitHub Desktop.
Save OleksandrKucherenko/740c191a3f1e95d2e5f20516f101787a to your computer and use it in GitHub Desktop.
@Test
@Config(sdk = Build.VERSION_CODES.M)
public void testFingerprintConfigured_api23() throws Exception {
// GIVEN:
// API23 android version
// Fingerprints are configured
// fingerprint feature is ignored by android os
ReactApplicationContext context = getRNContext();
// set that hardware is available
FingerprintManager fm = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
shadowOf(fm).setIsHardwareDetected(true);
shadowOf(fm).setDefaultFingerprints(5); // 5 fingerprints are available
// WHEN: check availability
final int result = BiometricManager.from(context).canAuthenticate();
final KeychainModule module = new KeychainModule(context);
final boolean isFingerprintWorking = module.isFingerprintAuthAvailable();
// THEN: biometric works
assertThat(result, is(BiometricManager.BIOMETRIC_SUCCESS));
assertThat(isFingerprintWorking, is(true));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment