-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: made evaluationPolicy and authenticationStrategy of LocalAuthe…
…nticationOptions as optional
- Loading branch information
Showing
5 changed files
with
77 additions
and
14 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import LocalAuthenticationLevel from '../../credentials-manager/localAuthenticationLevel'; | ||
import addDefaultLocalAuthOptions from '../addDefaultLocalAuthOptions'; | ||
import LocalAuthenticationStrategy from '../../credentials-manager/localAuthenticationStrategy'; | ||
|
||
describe('addDefaultLocalAuthenticationOptions', () => { | ||
it('should return default options when no options are provided', () => { | ||
const localAuthOptions = { title: 'Please authenticate' }; | ||
const result = addDefaultLocalAuthOptions(localAuthOptions); | ||
expect(result).toEqual({ | ||
title: 'Please authenticate', | ||
authenticationLevel: LocalAuthenticationLevel.strong, | ||
evaluationPolicy: LocalAuthenticationStrategy.deviceOwnerWithBiometrics, | ||
}); | ||
}); | ||
|
||
it('should override default options with provided options', () => { | ||
const localAuthOptions = { | ||
title: 'Please authenticate', | ||
authenticationLevel: LocalAuthenticationLevel.deviceCredential, | ||
evaluationPolicy: LocalAuthenticationStrategy.deviceOwner, | ||
}; | ||
const result = addDefaultLocalAuthOptions(localAuthOptions); | ||
expect(result).toEqual(localAuthOptions); | ||
}); | ||
|
||
it('should merge default options with partially provided options', () => { | ||
const options = { | ||
title: 'Please authenticate', | ||
authenticationLevel: LocalAuthenticationLevel.deviceCredential, | ||
}; | ||
const result = addDefaultLocalAuthOptions(options); | ||
expect(result).toEqual({ | ||
title: 'Please authenticate', | ||
authenticationLevel: LocalAuthenticationLevel.deviceCredential, | ||
evaluationPolicy: LocalAuthenticationStrategy.deviceOwnerWithBiometrics, | ||
}); | ||
}); | ||
}); |
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,19 @@ | ||
import LocalAuthenticationOptions from '../credentials-manager/localAuthenticationOptions'; | ||
import LocalAuthenticationStrategy from '../credentials-manager/localAuthenticationStrategy'; | ||
import LocalAuthenticationLevel from '../credentials-manager/localAuthenticationLevel'; | ||
|
||
const defaultLocalAuthOptions = { | ||
evaluationPolicy: LocalAuthenticationStrategy.deviceOwnerWithBiometrics, | ||
authenticationLevel: LocalAuthenticationLevel.strong, | ||
}; | ||
|
||
function addDefaultLocalAuthOptions( | ||
localAuthenticationOptions: LocalAuthenticationOptions | ||
): LocalAuthenticationOptions { | ||
return { | ||
...defaultLocalAuthOptions, | ||
...localAuthenticationOptions, | ||
}; | ||
} | ||
|
||
export default addDefaultLocalAuthOptions; |