This file contains hidden or 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
@Test | |
@Config(sdk = Build.VERSION_CODES.KITKAT) | |
public void testExtractFacebookConceal_NoHardware_api19() throws Exception { | |
// GIVEN: | |
// API19, minimal Android version | |
final ReactApplicationContext context = getRNContext(); | |
// WHEN: ask keychain for secured storage | |
final KeychainModule module = new KeychainModule(context); |
This file contains hidden or 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
package com.oblador.keychain; | |
import javax.crypto.KeyGeneratorSpi; | |
import javax.crypto.SecretKey; | |
public abstract class FakeKeyGeneratorSpi extends KeyGeneratorSpi { | |
@Override | |
protected SecretKey engineGenerateKey() { | |
return doEngineGenerateKey(); | |
} |
This file contains hidden or 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
package com.oblador.keychain; | |
import android.security.keystore.KeyInfo; | |
import androidx.annotation.NonNull; | |
import androidx.annotation.Nullable; | |
import org.mockito.MockSettings; | |
import org.mockito.Mockito; |
This file contains hidden or 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
package com.oblador.keychain; | |
import java.security.Provider; | |
import java.util.HashMap; | |
public final class FakeProvider extends Provider { | |
public static final String NAME = "AndroidKeyStore"; | |
public final HashMap<String, HashMap<String, MocksForProvider>> mocks = new HashMap<>(); | |
public final HashMap<String, Object> configuration = new HashMap<>(); |
This file contains hidden or 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
// https://gist.github.com/OleksandrKucherenko/34b5c72445bcf9d5519af6898afcb8fb#file-keychainmoduletests-java-L87-L92 | |
@RunWith(RobolectricTestRunner.class) | |
public class KeychainModuleTests { | |
/** | |
* Security fake provider. | |
*/ | |
private FakeProvider provider = new FakeProvider(); | |
@Before |
This file contains hidden or 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
package com.oblador.keychain; | |
import android.content.Context; | |
import android.content.SharedPreferences; | |
import android.content.pm.PackageManager; | |
import android.hardware.fingerprint.FingerprintManager; | |
import android.os.Build; | |
import androidx.annotation.NonNull; | |
import androidx.biometric.BiometricManager; |
This file contains hidden or 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
val updateLibrarySourcesInExample by tasks.registering(Copy::class) { | |
into("${rootProject.projectDir}/KeychainExample/node_modules/react-native-keychain/") | |
from("${rootProject.projectDir}/android/src/"){ | |
into("android/src") | |
} | |
from("${rootProject.projectDir}/typings/"){ | |
into("typings") | |
} |
This file contains hidden or 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
/** Copyright: 2019-*, Oleksandr Kucherenko ([email protected]) */ | |
apply plugin: 'com.android.library' | |
android { | |
/* ... default android lib OR app configuration ... */ | |
} | |
configurations { | |
repack { transitive = false } | |
compatibility { transitive = false } |
This file contains hidden or 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
// Force Jacoco Agent version upgrade | |
subprojects { | |
configurations.all { | |
resolutionStrategy { | |
eachDependency { details -> | |
if ('org.jacoco' == details.requested.group) { | |
details.useVersion "${jacocoVersion}" | |
} | |
} | |
} |
This file contains hidden or 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
buildscript { | |
ext { | |
jacocoVersion = project.JACOCO_VERSION | |
} | |
dependencies { | |
// To confirm JaCoCo version run: $ ./gradlew buildEnvironment | |
//region classpath "org.jacoco:org.jacoco.core:${jacocoVersion}" | |
// Resolves issue of incorrect version use in one of jacoco/android plugin inner tasks | |
classpath "org.jacoco:org.jacoco.core:${jacocoVersion}" | |
classpath "org.jacoco:org.jacoco.report:${jacocoVersion}" |