-
-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6cc5e4
commit b3d0ed9
Showing
15 changed files
with
256 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,4 +133,4 @@ RUBY VERSION | |
ruby 3.3.0p0 | ||
|
||
BUNDLED WITH | ||
2.5.4 | ||
2.5.17 |
104 changes: 104 additions & 0 deletions
104
KeychainExample/e2e/testCases/biometricsAccessControlTest.spec.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { by, device, element, expect } from 'detox'; | ||
import path from 'path'; | ||
import cp from 'child_process'; | ||
|
||
const enrollBiometric = async () => { | ||
if (device.getPlatform() === 'android') { | ||
const script = path.resolve( | ||
__dirname, | ||
'../utils/enrollFingerprintAndroid.sh' | ||
); | ||
const result = cp.spawnSync('sh', [script], { | ||
stdio: 'inherit', | ||
}); | ||
|
||
// Check for errors | ||
if (result.error) { | ||
console.error('Error executing script:', result.error); | ||
} | ||
} else { | ||
await device.setBiometricEnrollment(true); | ||
} | ||
}; | ||
|
||
describe('Biometrics Access Control', () => { | ||
beforeAll(async () => { | ||
await enrollBiometric(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await device.launchApp({ newInstance: true }); | ||
}); | ||
|
||
it('should save and retrieve username and password', async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
await element(by.id('usernameInput')).typeText('testUsername'); | ||
await element(by.id('passwordInput')).typeText('testPassword'); | ||
// Hide keyboard | ||
await element(by.text('Keychain Example')).tap(); | ||
|
||
if (device.getPlatform() === 'android') { | ||
await element(by.text('Fingerprint')).tap(); | ||
await element(by.text('Software')).tap(); | ||
} else { | ||
await element(by.text('FaceID')).tap(); | ||
} | ||
|
||
await expect(element(by.text('Save'))).toBeVisible(); | ||
await element(by.text('Save')).tap(); | ||
await expect(element(by.text(/^Credentials saved! .*$/))).toBeVisible(); | ||
// Biometric prompt is not available in the IOS simulator | ||
// https://github.com/oblador/react-native-keychain/issues/340 | ||
if (device.getPlatform() === 'android') { | ||
setTimeout(() => { | ||
cp.spawnSync('adb', ['-e', 'emu', 'finger', 'touch', '1']); | ||
}, 1000); | ||
} | ||
await element(by.text('Load')).tap(); | ||
await expect(element(by.text('Credentials loaded!'))).toBeVisible(); | ||
await expect(element(by.id('usernameInput'))).toHaveText('testUsername'); | ||
await expect(element(by.id('passwordInput'))).toHaveText('testPassword'); | ||
}); | ||
|
||
it('should retrieve username and password after app launch', async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
// Biometric prompt is not available in the IOS simulator | ||
// https://github.com/oblador/react-native-keychain/issues/340 | ||
if (device.getPlatform() === 'android') { | ||
setTimeout(() => { | ||
cp.spawnSync('adb', ['-e', 'emu', 'finger', 'touch', '1']); | ||
}, 1000); | ||
} | ||
await element(by.text('Load')).tap(); | ||
await expect(element(by.text('Credentials loaded!'))).toBeVisible(); | ||
await expect(element(by.id('usernameInput'))).toHaveText('testUsername'); | ||
await expect(element(by.id('passwordInput'))).toHaveText('testPassword'); | ||
}); | ||
|
||
it(':android:should save and retrieve username and password for hardware security level', async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
await element(by.id('usernameInput')).typeText('testUsernameHardware'); | ||
await element(by.id('passwordInput')).typeText('testPasswordHardware'); | ||
// Hide keyboard | ||
await element(by.text('Keychain Example')).tap(); | ||
await element(by.text('Fingerprint')).tap(); | ||
await element(by.text('Hardware')).tap(); | ||
|
||
await expect(element(by.text('Save'))).toBeVisible(); | ||
await element(by.text('Save')).tap(); | ||
await expect(element(by.text(/^Credentials saved! .*$/))).toBeVisible(); | ||
|
||
setTimeout(() => { | ||
cp.spawnSync('adb', ['-e', 'emu', 'finger', 'touch', '1']); | ||
}, 1000); | ||
|
||
await element(by.text('Load')).tap(); | ||
await expect(element(by.text('Credentials loaded!'))).toBeVisible(); | ||
await expect(element(by.id('usernameInput'))).toHaveText( | ||
'testUsernameHardware' | ||
); | ||
await expect(element(by.id('passwordInput'))).toHaveText( | ||
'testPasswordHardware' | ||
); | ||
}); | ||
}); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
DELAY=10 | ||
adb shell locksettings set-pin 1111 | ||
adb shell am start -a android.settings.SECURITY_SETTINGS | ||
sleep $DELAY | ||
adb shell input tap 274 2300 | ||
sleep $DELAY | ||
adb shell input text 1111 | ||
adb shell input keyevent 66 | ||
sleep $DELAY | ||
adb shell input tap 1100 2700 | ||
sleep $DELAY | ||
adb shell input tap 1100 2700 | ||
sleep $DELAY | ||
adb -e emu finger touch 1 | ||
sleep $DELAY | ||
adb -e emu finger touch 1 | ||
sleep $DELAY | ||
adb -e emu finger touch 1 | ||
sleep $DELAY | ||
adb shell input keyevent 4 | ||
sleep $DELAY | ||
adb shell input keyevent 4 | ||
sleep $DELAY | ||
adb shell input keyevent 4 | ||
sleep $DELAY | ||
adb shell input keyevent 4 | ||
sleep $DELAY | ||
adb shell input keyevent 4 | ||
sleep $DELAY | ||
adb shell input keyevent 4 |
8 changes: 8 additions & 0 deletions
8
KeychainExample/ios/KeychainExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.