Skip to content

Commit

Permalink
fix(idx): handle unknown selected option in generic remediator valida…
Browse files Browse the repository at this point in the history
…tion (beta)

OKTA-503627
<<<Jenkins Check-In of Tested SHA: e78b223 for [email protected]>>>
Artifact: okta-auth-js
Files changed count: 3
PR Link: #1234
  • Loading branch information
shuowu authored and eng-prod-CI-bot-okta committed Jun 8, 2022
1 parent 4252e9c commit 8b6501b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- [#1231](https://github.com/okta/okta-auth-js/pull/1231) IDX: exposes field level error messages
- [#1234](https://github.com/okta/okta-auth-js/pull/1234) IDX: passes unknown selected option to backend for validation when use GenericRemediator (beta)

## 6.6.1

Expand Down
9 changes: 7 additions & 2 deletions lib/idx/remediators/GenericRemediator/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,17 @@ export function hasValidInputValue(input, values) {
// handle options field
// 1. object type options - check if each object field is required and value can be found from the selectedOption
// 2. primitive options - required field is avaiable from top level
// 3. unknown format - pass to backend for validation
if (options) {
// object type options
if (type === 'object') {
const selectedOption = values[name];
if (!selectedOption?.id) {
return false;
if (!selectedOption) {
return false;
}
if (!selectedOption.id) {
// unknown option format, pass to backend for validation
return true;
}
const optionSchema = options.find((option) => {
const idSchema = option.value.find(({ name }) => name === 'id' );
Expand Down
9 changes: 9 additions & 0 deletions test/spec/idx/remediators/util/hasValidInputValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,15 @@ describe('hasValidInputValue - validate each input with inputValues', () => {
});
});

it('returns true when selected option is in unknown format', () => {
const values = {
authenticator: {
noId: 'fake'
}
};
const res = hasValidInputValue(input, values);
expect(res).toBe(true);
});

it('returns true when selected option has all required values', () => {
// email option - only id is required
Expand Down

0 comments on commit 8b6501b

Please sign in to comment.