RealWhorlwind extends Whorlwind { @Override public boolean canStoreSecurely() { return hasPermission() && isHardwareDetected(fingerprintManager) && hasEnrolledFingerprints(fingerprintManager); } RealWhorlwind(Context context, FingerprintManager fingerprintManager, Storage storage,
      String keyAlias, KeyStore keyStore, KeyPairGenerator keyGenerator, KeyFactory keyFactory); @Override boolean canStoreSecurely(); @Override Completable write(@NonNull final String name, @Nullable final ByteString value); @Override Observable<ReadResult> read(@NonNull String name);  }
@Test public void cannotStoreSecurelyWithNoPermission() { shadowContext.denyPermissions(USE_FINGERPRINT); when(fingerprintManager.isHardwareDetected()).thenReturn(true); when(fingerprintManager.hasEnrolledFingerprints()).thenReturn(true); assertThat(whorlwind.canStoreSecurely()).isFalse(); verifyZeroInteractions(storage); }
@Test public void cannotStoreSecurelyWithNoHardware() { shadowContext.grantPermissions(USE_FINGERPRINT); when(fingerprintManager.isHardwareDetected()).thenReturn(false); when(fingerprintManager.hasEnrolledFingerprints()).thenReturn(true); assertThat(whorlwind.canStoreSecurely()).isFalse(); verifyZeroInteractions(storage); }
@Test public void cannotStoreSecurelyWithNoFingerprints() { shadowContext.grantPermissions(USE_FINGERPRINT); when(fingerprintManager.isHardwareDetected()).thenReturn(true); when(fingerprintManager.hasEnrolledFingerprints()).thenReturn(false); assertThat(whorlwind.canStoreSecurely()).isFalse(); verifyZeroInteractions(storage); }
@Test public void canStoreSecurelyWithPermissionAndHardwareAndFingerprints() { shadowContext.grantPermissions(USE_FINGERPRINT); when(fingerprintManager.isHardwareDetected()).thenReturn(true); when(fingerprintManager.hasEnrolledFingerprints()).thenReturn(true); assertThat(whorlwind.canStoreSecurely()).isTrue(); verifyZeroInteractions(storage); }