-
-
Notifications
You must be signed in to change notification settings - Fork 521
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
24a0fd7
commit f846420
Showing
14 changed files
with
445 additions
and
237 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { device } from 'detox'; | ||
|
||
beforeAll(async () => { | ||
if (device.getPlatform() === 'ios') { | ||
await device.setBiometricEnrollment(true); | ||
} | ||
}); | ||
|
||
afterAll(async () => { | ||
await device.uninstallApp(); | ||
await device.installApp(); | ||
}); |
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,154 @@ | ||
import { by, device, element, expect } from 'detox'; | ||
import { matchLoadInfo } from '../utils/matchLoadInfo'; | ||
import cp from 'child_process'; | ||
|
||
describe('Access Control', () => { | ||
beforeEach(async () => { | ||
await device.launchApp({ newInstance: true }); | ||
}); | ||
['genericPassword', 'internetCredentials'].forEach((type) => { | ||
it( | ||
' should save and retrieve username and password with biometrics - ' + | ||
type, | ||
async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
await element(by.id('usernameInput')).typeText( | ||
'testUsernameBiometrics' | ||
); | ||
await element(by.id('passwordInput')).typeText( | ||
'testPasswordBiometrics' | ||
); | ||
// 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 matchLoadInfo('testUsernameBiometrics', 'testPasswordBiometrics'); | ||
} | ||
); | ||
|
||
it( | ||
'should retrieve username and password after app launch with biometrics - ' + | ||
type, | ||
async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
await expect( | ||
element(by.text('hasGenericPassword: true')) | ||
).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 matchLoadInfo('testUsernameBiometrics', 'testPasswordBiometrics'); | ||
} | ||
); | ||
|
||
it( | ||
':android:should save and retrieve username and password with biometrics for hardware security level - ' + | ||
type, | ||
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 matchLoadInfo('testUsernameHardware', 'testPasswordHardware'); | ||
} | ||
); | ||
|
||
it( | ||
':android:should save and retrieve username and password with biometrics for software security level - ' + | ||
type, | ||
async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
await element(by.id('usernameInput')).typeText('testUsernameSoftware'); | ||
await element(by.id('passwordInput')).typeText('testPasswordSoftware'); | ||
// Hide keyboard | ||
await element(by.text('Keychain Example')).tap(); | ||
await element(by.text('Fingerprint')).tap(); | ||
await element(by.text('Software')).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 matchLoadInfo('testUsernameSoftware', 'testPasswordSoftware'); | ||
} | ||
); | ||
|
||
it( | ||
'should save and retrieve username and password without biometrics' + | ||
type, | ||
async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
await element(by.id('usernameInput')).typeText('testUsernameAny'); | ||
await element(by.id('passwordInput')).typeText('testPasswordAny'); | ||
// Hide keyboard | ||
await element(by.text('Keychain Example')).tap(); | ||
await element(by.text('None')).tap(); | ||
|
||
if (device.getPlatform() === 'android') { | ||
await element(by.text('Software')).tap(); | ||
} | ||
|
||
await expect(element(by.text('Save'))).toBeVisible(); | ||
await element(by.text('Save')).tap(); | ||
await expect(element(by.text(/^Credentials saved! .*$/))).toBeVisible(); | ||
await element(by.text('Load')).tap(); | ||
await matchLoadInfo('testUsernameAny', 'testPasswordAny'); | ||
} | ||
); | ||
|
||
it('should retrieve username and password after app launch without biometrics', async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
await expect(element(by.text('hasGenericPassword: true'))).toBeVisible(); | ||
await element(by.text('Load')).tap(); | ||
await matchLoadInfo('testUsernameAny', 'testPasswordAny'); | ||
}); | ||
}); | ||
|
||
it('should reset all credentials', async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
// Hide keyboard | ||
|
||
await element(by.text('Reset')).tap(); | ||
await expect(element(by.text(/^Credentials Reset!$/))).toBeVisible(); | ||
}); | ||
}); |
77 changes: 0 additions & 77 deletions
77
KeychainExample/e2e/testCases/biometricsAccessControlTest.spec.js
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
KeychainExample/e2e/testCases/noneAccessControTest.spec.js
This file was deleted.
Oops, something went wrong.
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,92 @@ | ||
import { by, device, element, expect } from 'detox'; | ||
import { matchLoadInfo } from '../utils/matchLoadInfo'; | ||
|
||
describe(':android:Security Level', () => { | ||
beforeEach(async () => { | ||
await device.launchApp({ newInstance: true }); | ||
}); | ||
['genericPassword', 'internetCredentials'].forEach((type) => { | ||
it(':android:should save with Any security level - ' + type, async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
await element(by.id('usernameInput')).typeText('testUsernameAny'); | ||
await element(by.id('passwordInput')).typeText('testPasswordAny'); | ||
// Hide keyboard | ||
await element(by.text('Keychain Example')).tap(); | ||
|
||
await element(by.text(type)).tap(); | ||
await element(by.text('None')).tap(); | ||
await element(by.text('Any')).tap(); | ||
|
||
await expect(element(by.text('Save'))).toBeVisible(); | ||
await element(by.text('Save')).tap(); | ||
await expect(element(by.text(/^Credentials saved! .*$/))).toBeVisible(); | ||
await element(by.text('Load')).tap(); | ||
await matchLoadInfo( | ||
'testUsernameAny', | ||
'testPasswordAny', | ||
undefined, | ||
type === 'internetCredentials' ? 'https://example.com' : undefined | ||
); | ||
}); | ||
|
||
it( | ||
':android:should save with Software security level - ' + type, | ||
async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
await element(by.id('usernameInput')).typeText('testUsernameSoftware'); | ||
await element(by.id('passwordInput')).typeText('testPasswordSoftware'); | ||
// Hide keyboard | ||
await element(by.text('Keychain Example')).tap(); | ||
|
||
await element(by.text(type)).tap(); | ||
await element(by.text('None')).tap(); | ||
await element(by.text('Software')).tap(); | ||
|
||
await expect(element(by.text('Save'))).toBeVisible(); | ||
await element(by.text('Save')).tap(); | ||
await expect(element(by.text(/^Credentials saved! .*$/))).toBeVisible(); | ||
await element(by.text('Load')).tap(); | ||
await matchLoadInfo( | ||
'testUsernameSoftware', | ||
'testPasswordSoftware', | ||
undefined, | ||
type === 'internetCredentials' ? 'https://example.com' : undefined | ||
); | ||
} | ||
); | ||
|
||
it( | ||
':android:should save with Hardware security level - ' + type, | ||
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(type)).tap(); | ||
await element(by.text('None')).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(); | ||
await element(by.text('Load')).tap(); | ||
await matchLoadInfo( | ||
'testUsernameHardware', | ||
'testPasswordHardware', | ||
undefined, | ||
type === 'internetCredentials' ? 'https://example.com' : undefined | ||
); | ||
} | ||
); | ||
}); | ||
|
||
it(':android:should reset all credentials', async () => { | ||
await expect(element(by.text('Keychain Example'))).toExist(); | ||
// Hide keyboard | ||
|
||
await element(by.text('Reset')).tap(); | ||
await expect(element(by.text(/^Credentials Reset!$/))).toBeVisible(); | ||
}); | ||
}); |
Oops, something went wrong.