Skip to content

Instantly share code, notes, and snippets.

View OleksandrKucherenko's full-sized avatar

Oleksandr OleksandrKucherenko

View GitHub Profile
package com.oblador.keychain;
import javax.crypto.KeyGeneratorSpi;
import javax.crypto.SecretKey;
public abstract class FakeKeyGeneratorSpi extends KeyGeneratorSpi {
@Override
protected SecretKey engineGenerateKey() {
return doEngineGenerateKey();
}
@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);
@Test
@Config(sdk = Build.VERSION_CODES.LOLLIPOP)
public void testFingerprintNoHardware_api21() throws Exception {
// GIVEN: API21 android version
ReactApplicationContext context = getRNContext();
KeychainModule module = new KeychainModule(context);
// WHEN: verify availability
final int result = BiometricManager.from(context).canAuthenticate();
final boolean isFingerprintAvailable = module.isFingerprintAuthAvailable();
@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
@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();
@Test
@Config(sdk = Build.VERSION_CODES.P)
public void testFingerprintConfigured_api28() throws Exception {
// GIVEN:
// API28 android version
// for api24+ system feature should be enabled
// fingerprints are configured
ReactApplicationContext context = getRNContext();
shadowOf(context.getPackageManager()).setSystemFeature(PackageManager.FEATURE_FINGERPRINT, true);
@OleksandrKucherenko
OleksandrKucherenko / git-cheats.sh
Last active March 27, 2023 09:37
GIT useful commands
#!/bin/bash
# Get root folder path of the project under git
# Output: /Users/oleksandr.kucherenko/projects/klarna-app
git rev-parse --show-toplevel
# Get latest commit hash
# Output: 1b03718dabad03aaef917eff3ea8bb15e4fa1c46
git rev-parse @
@OleksandrKucherenko
OleksandrKucherenko / configureMyMac.sh
Last active March 19, 2025 10:14
Pre-configure My mac
#!/usr/bin/env bash
set -x # uncomment to debug
# required for Homebrew
xcode-select —-install
sudo xcodebuild -license accept
# install https://brew.sh/
which brew || (/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" )
@OleksandrKucherenko
OleksandrKucherenko / logger.sh
Created August 17, 2022 08:06
BASH logger that listen to DEBUG environment variable
#!/usr/bin/env bash
# shellcheck disable=SC2155,SC2034,SC2059
# get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
#
# Register debug logger functions that are controlled by DEBUG= environment variable
# Examples:
# DEBUG=* - print all logs
@OleksandrKucherenko
OleksandrKucherenko / dependencies.sh
Created August 17, 2022 08:13
How to verify BASH script dependencies
#!/usr/bin/env bash
# shellcheck disable=SC2034
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1090 source=commons.sh
source "$SCRIPT_DIR/commons.sh"
logger dependencies "$@" # register own debug tag & logger functions
#set -x # Uncomment to DEBUG