Skip to content

Instantly share code, notes, and snippets.

@OleksandrKucherenko
Created February 7, 2020 13:56
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/029f45aad15f02e1d1c7ab25ebe1d077 to your computer and use it in GitHub Desktop.
Save OleksandrKucherenko/029f45aad15f02e1d1c7ab25ebe1d077 to your computer and use it in GitHub Desktop.
@Test
@Config(sdk = Build.VERSION_CODES.M)
public void testFingerprintAvailableButNotConfigured_api23() throws Exception {
// GIVEN:
// fingerprint api available but not configured properly
// API23 android version
ReactApplicationContext context = getRNContext();
KeychainModule module = new KeychainModule(context);
// set that hardware is available
FingerprintManager fm = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
shadowOf(fm).setIsHardwareDetected(true);
// WHEN: check availability
final int result = BiometricManager.from(context).canAuthenticate();
final boolean isFingerprintWorking = module.isFingerprintAuthAvailable();
// THEN: another status from biometric api, fingerprint is still unavailable
assertThat(result, is(BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED));
assertThat(isFingerprintWorking, is(false));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment