Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(idx): handle unknown selected option in generic remediator validation (beta) #1234

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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