diff --git a/lib/OktaAuth.ts b/lib/OktaAuth.ts
index c6baac62f6..1b8682ca39 100644
--- a/lib/OktaAuth.ts
+++ b/lib/OktaAuth.ts
@@ -124,7 +124,6 @@ import {
parseEmailVerifyCallback,
isEmailVerifyCallbackError
} from './idx';
-import { createGlobalRequestInterceptor, setGlobalRequestInterceptor } from './idx/headers';
import { OktaUserAgent } from './OktaUserAgent';
import { parseOAuthResponseFromUrl } from './oidc/parseFromUrl';
import {
@@ -336,8 +335,6 @@ class OktaAuth implements OktaAuthInterface, SigninAPI, SignoutAPI {
unlockAccount: unlockAccount.bind(null, this),
};
- setGlobalRequestInterceptor(createGlobalRequestInterceptor(this)); // to pass custom headers to IDX endpoints
-
// HTTP
this.http = {
setRequestHeader: setRequestHeader.bind(null, this)
diff --git a/lib/idx/headers.ts b/lib/idx/headers.ts
deleted file mode 100644
index 8db0c210b0..0000000000
--- a/lib/idx/headers.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-/*!
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- *
- */
-
-// BETA - SUBJECT TO CHANGE
-// Currently we must modify request headers using the single instance of `idx.client.interceptors` exported from IDX-JS
-// This means that multiple instances of OktaAuth will see the same header modifications
-// TODO: use AuthJS http agent for IDX API requests. OKTA-417473
-import { OktaAuthInterface } from '../types';
-import idx from './idx-js';
-export function setGlobalRequestInterceptor(fn) {
- idx.client.interceptors.request.use(fn);
-}
-
-export function clearGlobalRequestInterceptor() {
- idx.client.interceptors.request.clear();
-}
-
-// A factory which returns a function that can be passed to `setGlobalRequestInterceptor`
-export function createGlobalRequestInterceptor(sdk: OktaAuthInterface) {
- return function (requestConfig) {
- // Set user-agent and any other custom headers set in the options
- var oktaUserAgentHeader = sdk._oktaUserAgent.getHttpHeader();
- const headers = Object.assign({
- ...oktaUserAgentHeader
- }, sdk.options.headers);
- Object.keys(headers).forEach(name => {
- // X-Device-Token may only be specified if the /interact request includes a `client_secret`
- // which indicates a trusted client which is allowed to present this information on behalf of the end user.
- // https://oktainc.atlassian.net/browse/OKTA-441021
- if (!sdk.options.clientSecret && name === 'X-Device-Token') {
- return;
- }
- requestConfig.headers[name] = headers[name];
- });
- };
-}
diff --git a/lib/idx/idx-js/client.ts b/lib/idx/idx-js/client.ts
deleted file mode 100644
index df591b0cac..0000000000
--- a/lib/idx/idx-js/client.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-// @ts-nocheck
-import fetch from 'cross-fetch';
-
-/**
- * Reusable interceptor interface
- */
-export class Interceptor {
- handlers = [];
-
- // Adds a new interceptor to our HttpClient
- use(before) {
- this.handlers.push({
- before,
- });
- }
-
- // Clears all interceptors
- clear() {
- this.handlers = [];
- }
-}
-
-/**
- * Singleton instance of the IdX HTTP Client
- *
- * Invoke the `use` method to add a new interceptor:
- * - client.interceptors.request.use((requestConfig) => { some logic });
- */
-export const HttpClient = {
- interceptors: {
- request: new Interceptor(),
- },
-};
-
-export const request = async (
- target,
- {
- method = 'POST',
- headers = {},
- credentials = 'include',
- body
- }
-) => {
- const requestOptions = {
- url: target,
- method,
- headers: {
- ...headers,
- },
- credentials,
- body,
- };
-
- if (HttpClient.interceptors) {
- HttpClient.interceptors.request.handlers.forEach( interceptor => {
- interceptor.before(requestOptions);
- });
- }
-
- // Extract the URL to adhere to the fetch API
- const { url } = requestOptions;
- delete requestOptions.url;
-
- return fetch( url, requestOptions );
-};
diff --git a/lib/idx/idx-js/index.ts b/lib/idx/idx-js/index.ts
deleted file mode 100644
index da885b3411..0000000000
--- a/lib/idx/idx-js/index.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-// @ts-nocheck
-import introspect from './introspect';
-import interact from './interact';
-import parsersForVersion from './parsers';
-import { HttpClient } from './client';
-
-const LATEST_SUPPORTED_IDX_API_VERSION = '1.0.0';
-
-const { makeIdxState } = parsersForVersion(LATEST_SUPPORTED_IDX_API_VERSION);
-
-export default {
- introspect,
- interact,
- makeIdxState,
- client: HttpClient,
- LATEST_SUPPORTED_IDX_API_VERSION,
-};
diff --git a/lib/idx/idx-js/interact.ts b/lib/idx/idx-js/interact.ts
deleted file mode 100644
index 41352f2336..0000000000
--- a/lib/idx/idx-js/interact.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-/* eslint-disable camelcase */
-// @ts-nocheck
-import { request } from './client';
-
-const parseAndReject = response => response.json().then( err => Promise.reject(err) );
-
-const interact = async function interact({
- withCredentials,
- clientId,
- baseUrl,
- scopes = ['openid', 'email'],
- redirectUri,
- codeChallenge,
- codeChallengeMethod,
- state,
- activationToken,
- recoveryToken,
- clientSecret,
-}) {
-
- const target = `${baseUrl}/v1/interact`;
- const params = {
- client_id: clientId,
- scope: scopes.join(' '),
- redirect_uri: redirectUri,
- code_challenge: codeChallenge,
- code_challenge_method: codeChallengeMethod,
- state,
- };
- if (activationToken) {
- params.activation_token = activationToken;
- }
- if (recoveryToken) {
- params.recovery_token = recoveryToken;
- }
- if (clientSecret) {
- params.client_secret = clientSecret;
- }
- const body = Object.entries(params)
- .map( ([param, value]) => `${param}=${encodeURIComponent(value)}` )
- .join('&');
- const headers = {
- 'content-type': 'application/x-www-form-urlencoded',
- };
- const credentials = withCredentials === false ? 'omit' : 'include';
- return request(target, { credentials, headers, body })
- .then( response => response.ok ? response.json() : parseAndReject( response ) )
- .then( data => data.interaction_handle);
-};
-
-export default interact;
diff --git a/lib/idx/idx-js/introspect.ts b/lib/idx/idx-js/introspect.ts
deleted file mode 100644
index e7cc53e920..0000000000
--- a/lib/idx/idx-js/introspect.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-import { request } from './client';
-import { validateVersionConfig } from './util';
-
-export interface IntrospectOptions {
- domain: string;
- withCredentials?: boolean;
- interactionHandle?: string;
- stateHandle?: string;
- version?: string;
-}
-
-const introspect = async function introspect({
- withCredentials,
- domain,
- interactionHandle,
- stateHandle,
- version,
-}: IntrospectOptions) {
- validateVersionConfig(version);
- const target = `${domain}/idp/idx/introspect`;
- const body = stateHandle ? { stateToken: stateHandle } : { interactionHandle };
- const headers = {
- 'content-type': `application/ion+json; okta-version=${version}`, // Server wants this version info
- accept: `application/ion+json; okta-version=${version}`,
- };
- const credentials = withCredentials === false ? 'omit' : 'include';
- const response = await request(target, { credentials, headers, body: JSON.stringify(body) });
- const requestDidSucceed = response.ok;
- const responseJSON = await response.json();
- return { ...responseJSON, requestDidSucceed };
-};
-
-export default introspect;
diff --git a/lib/idx/idx-js/parsers.ts b/lib/idx/idx-js/parsers.ts
deleted file mode 100644
index 5509a96b97..0000000000
--- a/lib/idx/idx-js/parsers.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-// We load all the current parsers, because we won't know in advance which version(s) we need to parse
-// Expect to only support current major - 1 (also suspect that this limit may never be hit)
-
-// @ts-nocheck
-import v1 from './v1/parsers'; // More granularity to be defined as needed
-
-const parsersForVersion = function parsersForVersion( version ) {
- switch (version) {
- case '1.0.0':
- return v1;
- case undefined:
- case null:
- throw new Error('Api version is required');
- default:
- throw new Error(`Unknown api version: ${version}. Use an exact semver version.`);
- }
-};
-
-export default parsersForVersion;
diff --git a/lib/idx/idx-js/util.ts b/lib/idx/idx-js/util.ts
deleted file mode 100644
index a5a3a790f3..0000000000
--- a/lib/idx/idx-js/util.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-// @ts-nocheck
-import parsersForVersion from './parsers';
-
-
-export function validateVersionConfig(version) {
- if ( !version ) {
- throw new Error('version is required');
- }
-
- const cleanVersion = (version ?? '').replace(/[^0-9a-zA-Z._-]/, '');
- if ( cleanVersion !== version || !version ) {
- throw new Error('invalid version supplied - version is required and uses semver syntax');
- }
-
- parsersForVersion(version); // will throw for invalid version
-}
diff --git a/lib/idx/idx-js/v1/actionParser.ts b/lib/idx/idx-js/v1/actionParser.ts
deleted file mode 100644
index b211199936..0000000000
--- a/lib/idx/idx-js/v1/actionParser.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-// @ts-nocheck
-const isFieldMutable = function isFieldMutable(field) {
- // mutable defaults to true, annoyingly
- return ( field.mutable !== false );
-};
-
-const divideSingleActionParamsByMutability = function divideSingleActionParamsByMutability( action ) {
- const defaultParamsForAction = {}; // mutable and present
- const neededParamsForAction = []; // mutable values
- const immutableParamsForAction = {}; // immutable
- // TODO: remove assumption that form names are unique, neededParams being an array is a temp fix
- // not all actions have value (e.g. redirect)
- // making sure they are not empty and instead hold the remediation object
- if (!action.value) {
- neededParamsForAction.push(action);
- return { defaultParamsForAction, neededParamsForAction, immutableParamsForAction };
- }
-
- for ( let field of action.value ) {
-
- if ( isFieldMutable( field ) ) {
-
- neededParamsForAction.push(field);
-
- if ( field.value ?? false ) {
- defaultParamsForAction[field.name] = field.value;
- }
-
- } else {
- immutableParamsForAction[field.name] = field.value ?? '';
- }
- }
- return { defaultParamsForAction, neededParamsForAction, immutableParamsForAction };
-};
-
-export const divideActionParamsByMutability = function divideActionParamsByMutability( actionList ) {
- // TODO: when removing form name is unique assumption, this may all be redundant
- actionList = Array.isArray(actionList) ? actionList : [ actionList ];
- const neededParams = [];
- const defaultParams = {};
- const immutableParams = {};
-
- for ( let action of actionList ) {
- const {
- defaultParamsForAction,
- neededParamsForAction,
- immutableParamsForAction
- } = divideSingleActionParamsByMutability(action);
- neededParams.push(neededParamsForAction);
- defaultParams[action.name] = defaultParamsForAction;
- immutableParams[action.name] = immutableParamsForAction;
- }
-
- return { defaultParams, neededParams, immutableParams };
-};
-
diff --git a/lib/idx/idx-js/v1/generateIdxAction.ts b/lib/idx/idx-js/v1/generateIdxAction.ts
deleted file mode 100644
index 492fc6c3c3..0000000000
--- a/lib/idx/idx-js/v1/generateIdxAction.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-/* eslint-disable max-len */
-// @ts-nocheck
-import { request } from '../client';
-import { divideActionParamsByMutability } from './actionParser';
-import { makeIdxState } from './makeIdxState';
-
-const generateDirectFetch = function generateDirectFetch({
- actionDefinition,
- defaultParamsForAction = {},
- immutableParamsForAction = {},
- toPersist
-}) {
- const target = actionDefinition.href;
- return async function(params) {
- const headers = {
- 'content-type': 'application/json',
- 'accept': actionDefinition.accepts || 'application/ion+json',
- };
- const body = JSON.stringify({
- ...defaultParamsForAction,
- ...params,
- ...immutableParamsForAction
- });
- const credentials = toPersist && toPersist.withCredentials === false ? 'omit' : 'include';
- const response = await request(target, { method: actionDefinition.method, headers, body, credentials });
- const responseJSON = await response.json();
- const requestDidSucceed = response.ok;
- const idxResponse = makeIdxState({ ...responseJSON, requestDidSucceed }, toPersist);
- if (response.status === 401 && response.headers.get('WWW-Authenticate') === 'Oktadevicejwt realm="Okta Device"') {
- // Okta server responds 401 status code with WWW-Authenticate header and new remediation
- // so that the iOS/MacOS credential SSO extension (Okta Verify) can intercept
- // the response reaches here when Okta Verify is not installed
- // set `stepUp` to true if flow should be continued without showing any errors
- idxResponse.stepUp = true;
- }
- return idxResponse;
- };
-};
-
-// TODO: Resolve in M2: Either build the final polling solution or remove this code
-// const generatePollingFetch = function generatePollingFetch( { actionDefinition, defaultParamsForAction = {}, immutableParamsForAction = {} } ) {
-// // TODO: Discussions ongoing about when/how to terminate polling: OKTA-246581
-// const target = actionDefinition.href;
-// return async function(params) {
-// return fetch(target, {
-// method: actionDefinition.method,
-// headers: {
-// 'content-type': actionDefinition.accepts,
-// },
-// body: JSON.stringify({ ...defaultParamsForAction, ...params, ...immutableParamsForAction })
-// })
-// .then( response => response.ok ? response.json() : response.json().then( err => Promise.reject(err)) )
-// .then( idxResponse => makeIdxState(idxResponse) );
-// };
-// };
-
-const generateIdxAction = function generateIdxAction( actionDefinition, toPersist ) {
- // TODO: leaving this here to see where the polling is EXPECTED to drop into the code, but removing any accidental trigger of incomplete code
- // const generator = actionDefinition.refresh ? generatePollingFetch : generateDirectFetch;
- const generator = generateDirectFetch;
- const { defaultParams, neededParams, immutableParams } = divideActionParamsByMutability( actionDefinition );
-
- const action = generator( {
- actionDefinition,
- defaultParamsForAction: defaultParams[actionDefinition.name],
- immutableParamsForAction: immutableParams[actionDefinition.name],
- toPersist
- });
- action.neededParams = neededParams;
- return action;
-};
-
-export default generateIdxAction;
diff --git a/lib/idx/idx-js/v1/idxResponseParser.ts b/lib/idx/idx-js/v1/idxResponseParser.ts
deleted file mode 100644
index 3179db2a75..0000000000
--- a/lib/idx/idx-js/v1/idxResponseParser.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-/* eslint-disable max-len */
-// @ts-nocheck
-import { generateRemediationFunctions } from './remediationParser';
-import generateIdxAction from './generateIdxAction';
-import { JSONPath } from 'jsonpath-plus';
-
-const SKIP_FIELDS = Object.fromEntries([
- 'remediation', // remediations are put into proceed/neededToProceed
- 'context', // the API response of 'context' isn't externally useful. We ignore it and put all non-action (contextual) info into idxState.context
-].map( (field) => [ field, !!'skip this field' ] ));
-
-export const parseNonRemediations = function parseNonRemediations( idxResponse, toPersist = {} ) {
- const actions = {};
- const context = {};
-
- Object.keys(idxResponse)
- .filter( field => !SKIP_FIELDS[field])
- .forEach( field => {
- const fieldIsObject = typeof idxResponse[field] === 'object' && !!idxResponse[field];
-
- if ( !fieldIsObject ) {
- // simple fields are contextual info
- context[field] = idxResponse[field];
- return;
- }
-
- if ( idxResponse[field].rel ) {
- // top level actions
- actions[idxResponse[field].name] = generateIdxAction(idxResponse[field], toPersist);
- return;
- }
-
- const { value: fieldValue, type, ...info} = idxResponse[field];
- context[field] = { type, ...info}; // add the non-action parts as context
-
- if ( type !== 'object' ) {
- // only object values hold actions
- context[field].value = fieldValue;
- return;
- }
-
- // We are an object field containing an object value
- context[field].value = {};
- Object.entries(fieldValue)
- .forEach( ([subField, value]) => {
- if (value.rel) { // is [field].value[subField] an action?
- // add any "action" value subfields to actions
- actions[`${field}-${subField.name || subField}`] = generateIdxAction(value, toPersist);
- } else {
- // add non-action value subfields to context
- context[field].value[subField] = value;
- }
- });
- });
-
- return { context, actions };
-};
-
-const expandRelatesTo = (idxResponse, value) => {
- Object.keys(value).forEach(k => {
- if (k === 'relatesTo') {
- const query = Array.isArray(value[k]) ? value[k][0] : value[k];
- if (typeof query === 'string') {
- // eslint-disable-next-line new-cap
- const result = JSONPath({ path: query, json: idxResponse })[0];
- if (result) {
- value[k] = result;
- return;
- }
- }
- }
- if (Array.isArray(value[k])) {
- value[k].forEach(innerValue => expandRelatesTo(idxResponse, innerValue));
- }
- });
-};
-
-const convertRemediationAction = (remediation, toPersist) => {
- const remediationActions = generateRemediationFunctions( [remediation], toPersist );
- const actionFn = remediationActions[remediation.name];
- return {
- ...remediation,
- action: actionFn,
- };
-};
-
-export const parseIdxResponse = function parseIdxResponse( idxResponse, toPersist = {} ): {
- remediations: IdxRemediation[];
- context: IdxContext;
- actions: IdxActions;
-} {
- const remediationData = idxResponse.remediation?.value || [];
-
- remediationData.forEach(
- remediation => expandRelatesTo(idxResponse, remediation)
- );
-
- const remediations = remediationData.map(remediation => convertRemediationAction( remediation, toPersist ));
-
- const { context, actions } = parseNonRemediations( idxResponse, toPersist );
-
- return {
- remediations,
- context,
- actions,
- };
-};
diff --git a/lib/idx/idx-js/v1/makeIdxState.ts b/lib/idx/idx-js/v1/makeIdxState.ts
deleted file mode 100644
index 323d61c9fc..0000000000
--- a/lib/idx/idx-js/v1/makeIdxState.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-import { IdxResponse } from '../../types/idx-js';
-import { parseIdxResponse } from './idxResponseParser';
-
-export function makeIdxState( idxResponse, toPersist ): IdxResponse {
- const rawIdxResponse = idxResponse;
- const { remediations, context, actions } = parseIdxResponse( idxResponse, toPersist );
- const neededToProceed = [...remediations];
-
- const proceed: IdxResponse['proceed'] = async function( remediationChoice, paramsFromUser = {} ) {
- /*
- remediationChoice is the name attribute on each form
- name should remain unique for items inside the remediation that are considered forms(identify, select-factor)
- name can be duplicate for items like redirect where its not considered a form(redirect)
- when names are not unique its a redirect to a href, so widget wont POST to idx-js layer.
- */
- const remediationChoiceObject = remediations.find((remediation) => remediation.name === remediationChoice);
- if ( !remediationChoiceObject ) {
- return Promise.reject(`Unknown remediation choice: [${remediationChoice}]`);
- }
-
- return remediationChoiceObject.action(paramsFromUser);
- };
-
- const findCode = item => item.name === 'interaction_code';
- const interactionCode = rawIdxResponse.successWithInteractionCode?.value.find( findCode ).value;
-
- return {
- proceed,
- neededToProceed,
- actions,
- context,
- rawIdxState: rawIdxResponse,
- interactionCode,
- toPersist,
- };
-}
diff --git a/lib/idx/idx-js/v1/parsers.ts b/lib/idx/idx-js/v1/parsers.ts
deleted file mode 100644
index 6f787c247c..0000000000
--- a/lib/idx/idx-js/v1/parsers.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-// @ts-nocheck
-import { makeIdxState } from './makeIdxState';
-
-export default {
- makeIdxState,
-};
diff --git a/lib/idx/idx-js/v1/remediationParser.ts b/lib/idx/idx-js/v1/remediationParser.ts
deleted file mode 100644
index 032fb81db7..0000000000
--- a/lib/idx/idx-js/v1/remediationParser.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-// @ts-nocheck
-import generateIdxAction from './generateIdxAction';
-
-export const generateRemediationFunctions = function generateRemediationFunctions( remediationValue, toPersist = {} ) {
-
- return Object.fromEntries( remediationValue.map( remediation => {
- return [
- remediation.name,
- generateIdxAction(remediation, toPersist),
- ];
- }) );
-};
diff --git a/lib/idx/interact.ts b/lib/idx/interact.ts
index c0ea623684..58ccfc6ef4 100644
--- a/lib/idx/interact.ts
+++ b/lib/idx/interact.ts
@@ -106,9 +106,7 @@ export async function interact (
// https://oktawiki.atlassian.net/wiki/spaces/eng/pages/2445902453/Support+Device+Binding+in+interact#Scenario-1%3A-Non-User-Agent-with-Confidential-Client-(top-priority)
params.client_secret = clientSecret;
}
- // const body = Object.entries(params)
- // .map( ([param, value]) => `${param}=${encodeURIComponent(value)}` )
- // .join('&');
+
const headers = {
'content-type': 'application/x-www-form-urlencoded',
};
diff --git a/test/spec/OktaAuth/constructor.ts b/test/spec/OktaAuth/constructor.ts
index 5f9ad4e2e8..d68aaf6e28 100644
--- a/test/spec/OktaAuth/constructor.ts
+++ b/test/spec/OktaAuth/constructor.ts
@@ -24,17 +24,8 @@ jest.mock('../../../lib/features', () => {
};
});
-jest.mock('../../../lib/idx/headers', () => {
- return {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- ...jest.requireActual('../../../lib/idx/headers') as any,
- setGlobalRequestInterceptor: jest.fn()
- };
-});
-
const mocked = {
features: require('../../../lib/features'),
- idxHeaders: require('../../../lib/idx/headers')
};
describe('OktaAuth (constructor)', () => {
@@ -168,11 +159,4 @@ describe('OktaAuth (constructor)', () => {
});
});
- it('sets global headers for idx requests', () => {
- const config = { issuer: 'http://fake' };
- // eslint-disable-next-line no-new
- new OktaAuth(config);
- expect(mocked.idxHeaders.setGlobalRequestInterceptor).toHaveBeenCalled();
- });
-
});
diff --git a/test/spec/idx/headers.ts b/test/spec/idx/headers.ts
deleted file mode 100644
index e29836ce08..0000000000
--- a/test/spec/idx/headers.ts
+++ /dev/null
@@ -1,275 +0,0 @@
-/*!
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- *
- */
-
-const mocked = {
-
- crossFetch: {
- __esModule: true, // fool babel require interop
- default: () => Promise.resolve({
- ok: true,
- json: () => ({})
- })
- }
-};
-
-jest.mock('cross-fetch', () => {
- return mocked.crossFetch;
-});
-
-import idx from '../../../lib/idx/idx-js';
-import { setRequestHeader } from '../../../lib/http';
-import {
- createGlobalRequestInterceptor,
- setGlobalRequestInterceptor,
- clearGlobalRequestInterceptor
-} from '../../../lib/idx/headers';
-
-describe('idx headers', () => {
-
- let testContext;
- beforeEach(() => {
- testContext = {
- url: 'fake-url',
- domain: 'fake-domain',
- interactionHandle: null,
- stateHandle: 'fake-stateHandle',
- version: '1.0.0',
- clientId: 'fake-clientid',
- baseUrl: 'fake-baseurl',
- redirectUri: 'fake-redirecturi',
- codeChallenge: 'fake-codeChallenge',
- codeChallengeMethod: 'fake-codeChallengeMethod',
- state: 'fake-state',
- sdk: {
- options: {
- httpRequestClient: () => Promise.resolve({
- responseText: null
- }),
- storageUtil: {}
- },
- storageManager: {
- getHttpCache: () => {}
- },
- _oktaUserAgent: {
- getHttpHeader: () => {
- return {
- 'X-Okta-User-Agent-Extended': 'fake-sdk-user-agent'
- };
- }
- }
- }
- };
- });
-
- async function callIntrospect() {
- const { domain, interactionHandle, stateHandle, version } = testContext;
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
- // @ts-ignore
- await idx.introspect({ domain, interactionHandle, stateHandle, version });
- }
-
- async function callInteract() {
- const { clientId, baseUrl, redirectUri, codeChallenge, codeChallengeMethod, state } = testContext;
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
- // @ts-ignore
- await idx.interact({ clientId, baseUrl, redirectUri, codeChallenge, codeChallengeMethod, state });
- }
-
- describe('without interceptor', () => {
- it('idx does not use header values set in SDK options or SDK user agent', async () => {
- const { sdk } = testContext;
- sdk.options.headers = {
- 'my-header': 'my-value',
- 'other-header': 'other-value'
- };
- jest.spyOn(mocked.crossFetch, 'default');
- await callIntrospect();
- expect(mocked.crossFetch.default).toHaveBeenCalledWith('fake-domain/idp/idx/introspect', {
- body: JSON.stringify({
- stateToken: 'fake-stateHandle'
- }),
- credentials: 'include',
- headers: {
- 'accept': 'application/ion+json; okta-version=1.0.0',
- 'content-type': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- });
-
- it('idx does not use header values set using setRequestHeader or SDK user agent', async () => {
- const { sdk } = testContext;
- setRequestHeader(sdk, 'my-header', 'my-value');
- setRequestHeader(sdk, 'other-header', 'other-value');
- jest.spyOn(mocked.crossFetch, 'default');
- await callIntrospect();
- expect(mocked.crossFetch.default).toHaveBeenCalledWith('fake-domain/idp/idx/introspect', {
- body: JSON.stringify({
- stateToken: 'fake-stateHandle'
- }),
- credentials: 'include',
- headers: {
- 'accept': 'application/ion+json; okta-version=1.0.0',
- 'content-type': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- });
- });
-
- describe('with interceptor', () => {
- beforeEach(() => {
- const { sdk } = testContext;
- setGlobalRequestInterceptor(createGlobalRequestInterceptor(sdk));
- });
-
- afterEach(() => {
- clearGlobalRequestInterceptor();
- });
-
- it('idx uses header values set in SDK options and SDK user agent', async () => {
- const { sdk } = testContext;
- sdk.options.headers = {
- 'my-header': 'my-value',
- 'other-header': 'other-value'
- };
- jest.spyOn(mocked.crossFetch, 'default');
- await callIntrospect();
- expect(mocked.crossFetch.default).toHaveBeenCalledWith('fake-domain/idp/idx/introspect', {
- body: JSON.stringify({
- stateToken: 'fake-stateHandle'
- }),
- credentials: 'include',
- headers: {
- 'X-Okta-User-Agent-Extended': 'fake-sdk-user-agent',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- 'content-type': 'application/ion+json; okta-version=1.0.0',
- 'my-header': 'my-value',
- 'other-header': 'other-value'
- },
- method: 'POST'
- });
- });
-
- it('idx uses header values set in SDK options and SDK user agent for interact', async () => {
- const { sdk } = testContext;
- sdk.options.headers = {
- 'my-header': 'my-value',
- 'other-header': 'other-value'
- };
- jest.spyOn(mocked.crossFetch, 'default');
- await callInteract();
- expect(mocked.crossFetch.default).toHaveBeenCalledWith('fake-baseurl/v1/interact', {
- body: 'client_id=fake-clientid&scope=openid%20email&redirect_uri=fake-redirecturi&code_challenge=fake-codeChallenge&code_challenge_method=fake-codeChallengeMethod&state=fake-state',
- credentials: 'include',
- headers: {
- 'X-Okta-User-Agent-Extended': 'fake-sdk-user-agent',
- 'content-type': 'application/x-www-form-urlencoded',
- 'my-header': 'my-value',
- 'other-header': 'other-value'
- },
- method: 'POST'
- });
- });
-
- it('idx uses header values set using setRequestHeader and SDK user agent', async () => {
- const { sdk } = testContext;
- setRequestHeader(sdk, 'my-header', 'my-value');
- setRequestHeader(sdk, 'other-header', 'other-value');
- jest.spyOn(mocked.crossFetch, 'default');
- await callIntrospect();
- expect(mocked.crossFetch.default).toHaveBeenCalledWith('fake-domain/idp/idx/introspect', {
- body: JSON.stringify({
- stateToken: 'fake-stateHandle'
- }),
- credentials: 'include',
- headers: {
- 'X-Okta-User-Agent-Extended': 'fake-sdk-user-agent',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- 'content-type': 'application/ion+json; okta-version=1.0.0',
- 'my-header': 'my-value',
- 'other-header': 'other-value'
- },
- method: 'POST'
- });
- });
-
- it('idx uses header values overridden using setRequestHeader and SDK user agent', async () => {
- const { sdk } = testContext;
- sdk.options.headers = {
- 'my-header': 'my-value',
- 'other-header': 'other-value'
- };
- setRequestHeader(sdk, 'my-header', 'my-value2');
- setRequestHeader(sdk, 'other-header', 'other-value2');
- jest.spyOn(mocked.crossFetch, 'default');
- await callIntrospect();
- expect(mocked.crossFetch.default).toHaveBeenCalledWith('fake-domain/idp/idx/introspect', {
- body: JSON.stringify({
- stateToken: 'fake-stateHandle'
- }),
- credentials: 'include',
- headers: {
- 'X-Okta-User-Agent-Extended': 'fake-sdk-user-agent',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- 'content-type': 'application/ion+json; okta-version=1.0.0',
- 'my-header': 'my-value2',
- 'other-header': 'other-value2'
- },
- method: 'POST'
- });
- });
-
- describe('"X-Device-Token" header', () => {
- it('idx uses header when clientSecret is in sdk.options', async () => {
- const { sdk } = testContext;
- sdk.options.headers = {
- 'X-Device-Token': 'fake-ip',
- };
- sdk.options.clientSecret = 'fake-clientSecret';
- jest.spyOn(mocked.crossFetch, 'default');
- await callInteract();
- expect(mocked.crossFetch.default).toHaveBeenCalledWith('fake-baseurl/v1/interact', {
- body: 'client_id=fake-clientid&scope=openid%20email&redirect_uri=fake-redirecturi&code_challenge=fake-codeChallenge&code_challenge_method=fake-codeChallengeMethod&state=fake-state',
- credentials: 'include',
- headers: {
- 'X-Okta-User-Agent-Extended': 'fake-sdk-user-agent',
- 'X-Device-Token': 'fake-ip',
- 'content-type': 'application/x-www-form-urlencoded'
- },
- method: 'POST'
- });
- });
-
- it('idx does not use header when clientSecret is not in options', async () => {
- const { sdk } = testContext;
- sdk.options.headers = {
- 'X-Device-Token': 'fake-ip',
- };
- sdk.options.clientSecret = undefined;
- jest.spyOn(mocked.crossFetch, 'default');
- await callInteract();
- expect(mocked.crossFetch.default).toHaveBeenCalledWith('fake-baseurl/v1/interact', {
- body: 'client_id=fake-clientid&scope=openid%20email&redirect_uri=fake-redirecturi&code_challenge=fake-codeChallenge&code_challenge_method=fake-codeChallengeMethod&state=fake-state',
- credentials: 'include',
- headers: {
- 'X-Okta-User-Agent-Extended': 'fake-sdk-user-agent',
- 'content-type': 'application/x-www-form-urlencoded'
- },
- method: 'POST'
- });
- });
-
- });
- });
-});
\ No newline at end of file
diff --git a/test/spec/idx/idx-js/mocks/authenticator-verification-password.json b/test/spec/idx/idx-js/mocks/authenticator-verification-password.json
deleted file mode 100644
index 8975fbcce6..0000000000
--- a/test/spec/idx/idx-js/mocks/authenticator-verification-password.json
+++ /dev/null
@@ -1,293 +0,0 @@
-{
- "stateHandle": "eyJ6aXAiOiJERUYiLCJhbGlhcyI6ImVuY3J5cHRpb25rZXkiLCJ2ZXIiOiIxIiwib2lkIjoiMDBvdnhhU2NRWG9TbzJvMjAwZzMiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..BzXIPn5dlBQ4QOXC.rERhFXlDsEIL7712M4I4JI9JjKaQ0MLUY-8gXipZJ_g6BR5tK5PlRhN-jYGFm6v83o-wY3SmkLiMNo_stFSi4bCgmYGBslfqd9ZzH7Jq3Ouh94BrXD02PDNe2eWK5dDr6nh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GbNFiITj-nKWPYiJWeXTfr4AYwDaEOGv0baV_zi3MMdptnT6I5TPjQEik5N5vDC8OJIhMsj9p9-7Gso13SNwr3i1ib0loQdnY7g6IuMuamlbZr-hhJESiOFKvSsVPqxnM3GXy5fichm7a188ihS8-SxTOznosdm3ftUOC1g7D4MzoRJbgA2E2PQCeyhxGYmdAaLRi3zt9iqcQYPvkEdiqHdKqTKArN-9JpsDuM7UM5lMkmmEgmi04PSVCqbAdw0z2cH3wU9705EyA0FA654wo-NaHhRrmup1LAFDPZg6NUW3X_C3jd6RkmPsjgVVm-H5YD9JsMqClcbzLEGz6SYtWyPDpPu0JH0GqOk-HHX8jfFZaRVM0ZnL0_BtU5G3B3OEyxMbl_yOQTdwMCT9Ete3Y1yAEUoJMyOwetCQRUdAH3DPHH3-4KAmJMaVMsMAI_h7DUwAvbUgiUKdr3g3an3vOxPtZI2apy9sv_Wj3DTJfwPm9axjK-laVNUKFnrweURmn4mRa74pWNf-CS1s9Izgg2yxY7fib9DlK6pkgC9nBGrpocMTJWFJI.N3s3-GTo9GSC0YG-MSmMfw",
- "version": "1.0.0",
- "expiresAt": "2020-05-05T16:58:36.000Z",
- "intent": "LOGIN",
- "remediation": {
- "type": "array",
- "value": [
- {
- "rel": [
- "create-form"
- ],
- "name": "challenge-authenticator",
- "href": "http://localhost:3000/idp/idx/challenge/answer",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "credentials",
- "form": {
- "value": [
- {
- "name": "passcode",
- "label": "Password",
- "secret": true
- }
- ]
- }
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "eyJ6aXAiOiJERUYiLCJhbGlhcyI6ImVuY3J5cHRpb25rZXkiLCJ2ZXIiOiIxIiwib2lkIjoiMDBvdnhhU2NRWG9TbzJvMjAwZzMiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..BzXIPn5dlBQ4QOXC.rERhFXlDsEIL7712M4I4JI9JjKaQ0MLUY-8gXip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k8GoP7XAgIBZuPjgYF30orMH14ttldEKFaO2gwGQQM8nnrKVwHbpyd32bwEyNyzIH-tnmVoXvU49nnzQNPlfS9S_-WeFI3OivdGbNFiITj-nKWPYiJWeXTfr4AYwDaEOGv0baV_zi3MMdptnT6I5TPjQEik5N5vDC8OJIhMsj9p9-7Gso13SNwr3i1ib0loQdnY7g6IuMuamlbZr-hhJESiOFKvSsVPqxnM3GXy5fichm7a188ihS8-SxTOznosdm3ftUOC1g7D4MzoRJbgA2E2PQCeyhxGYmdAaLRi3zt9iqcQYPvkEdiqHdKqTKArN-9JpsDuM7UM5lMkmmEgmi04PSVCqbAdw0z2cH3wU9705EyA0FA654wo-NaHhRrmup1LAFDPZg6NUW3X_C3jd6RkmPsjgVVm-H5YD9JsMqClcbzLEGz6SYtWyPDpPu0JH0GqOk-HHX8jfFZaRVM0ZnL0_BtU5G3B3OEyxMbl_yOQTdwMCT9Ete3Y1yAEUoJMyOwetCQRUdAH3DPHH3-4KAmJMaVMsMAI_h7DUwAvbUgiUKdr3g3an3vOxPtZI2apy9sv_Wj3DTJfwPm9axjK-laVNUKFnrweURmn4mRa74pWNf-CS1s9Izgg2yxY7fib9DlK6pkgC9nBGrpocMTJWFJI.N3s3-GTo9GSC0YG-MSmMfw",
- "visible": false,
- "mutable": false
- }
- ],
- "relatesTo": ["$.currentAuthenticatorEnrollment"]
- },
- {
- "rel": [
- "create-form"
- ],
- "name": "select-authenticator-authenticate",
- "href": "http://localhost:3000/idp/idx/challenge",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "authenticator",
- "type": "object",
- "options": [
- {
- "label": "Okta Password",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "required": true,
- "value": "aidwboITrg4b4yAYd0g3",
- "mutable": false
- },
- {
- "name": "methodType",
- "required": false,
- "value": "password",
- "mutable": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[0]"
- },
- {
- "label": "FIDO2 (WebAuthn)",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "fwftheidkwh282hv8g3",
- "required": true,
- "mutable": false,
- "visible": false
- },
- {
- "name": "methodType",
- "value": "webauthn",
- "required": false,
- "mutable": false,
- "visible": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[1]"
- },
- {
- "label": "FIDO2 (WebAuthn)",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "aidtheidkwh282hv8g3",
- "required": true,
- "mutable": false,
- "visible": false
- },
- {
- "name": "methodType",
- "value": "webauthn",
- "required": false,
- "mutable": false,
- "visible": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[2]"
- },
- {
- "label": "Okta Email",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "aidtm56L8gXXHI1SD0g3",
- "required": true,
- "mutable": false,
- "visible": false
- },
- {
- "name": "methodType",
- "value": "email",
- "required": false,
- "mutable": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[3]"
- },
- {
- "label": "Okta Phone",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "aid568g3mXgtID0X1SLH",
- "required": true,
- "mutable": false,
- "visible": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[4]"
- },
- {
- "label": "Okta Security Question",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "aid568g3mXgtID0HHSLH",
- "required": true,
- "mutable": false,
- "visible": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[5]"
- }
- ]
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "eyJ6aXAiOiJERUYiLCJhbGlhcyI6ImVuY3J5cHRpb25rZXkiLCJ2ZXIiOiIxIiwib2lkIjoiMDBvdnhhU2NRWG9TbzJvMjAwZzMiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..40AFMvA7ix6FA2oE.Q6jiZeKfCdON5wqqMdiDQCtgLctrI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r48yjl6T5XRg1wKG7OX0JZLjbmcJsTNagXSHbPsXuBd0te_fgNYT54_eGkIIklr4LbOEhKGNpZSXSWPbTPT7zhbebrUGglldI37k8WldRGywq_ZvZX6W5hucD_yWBqqXBq45LW_iNlAvtUIXBkq4WuPgWaYRIjqWnUxbAZkL_5ejddr18MOmbwV8ftbtYhvnYbYqBvDaqpsXoVKBT0g8ZTXuSs36Rrxi6wyBnXVcM0RrC8YhU6ybBWiovNo2chyPSPhFAvmJVmVL2t3lbA7SoBnWQvNtspHY8Xd8KNf-MUSuhHKXfrSRPwWC23D9qSxoUC0ubIINYBLD-WHYv_Yn7RBU7IQ4fzoLJrE6mUBz9tZ79drLOLd7vbe8MPpWJI-MHCTHD6XTMAWqd5q22EGAUa29XV4Jl4E6xZg8CybaOUOVpuia35UPLpCKK0wDofdAAUcPCo-hj7OH3U0XsCccF0GHfo7cqoYQanqfu7mypeGEf9_471KYQVNSlc1TGrrngY6_KRBMKDcx7fZne4ypsJfumhrpfbEkeltfwFsGVs1--2bFksLI8esRxR1qUHzT0.hCv29YrLBFcW8TjKwSmCXQ",
- "visible": false,
- "mutable": false
- }
- ]
- }
- ]
- },
- "authenticatorEnrollments": {
- "type": "array",
- "value": [
- {
- "displayName": "Okta Password",
- "type": "password",
- "id": "autwa6eD9o02iBbtv0g1",
- "authenticatorId": "aidwboITrg4b4yAYd0g3"
- },
- {
- "displayName": "FIDO2 (WebAuthn)",
- "type": "security_key",
- "id": "autwa6eD9o02iBbtv0g2",
- "authenticatorId": "aidtheidkwh282hv8g3"
- },
- {
- "displayName": "FIDO2 (WebAuthn)",
- "type": "security_key",
- "id": "autwa6eD9o02iBbtv0g2",
- "authenticatorId": "fwftheidkwh282hv8g3"
- },
- {
- "displayName": "Okta Email",
- "type": "email",
- "authenticatorId": "aidtm56L8gXXHI1SD0g3",
- "id": "autwa6eD9o02iBbtv0g3",
- "methods": [
- {
- "methodType": "email"
- }
- ]
- },
- {
- "displayName": "Okta Phone",
- "type": "phone",
- "authenticatorId": "aid568g3mXgtID0X1SLH",
- "id": "autwa6eD9o02iBbsta82"
- },
- {
- "displayName": "Okta Security Question",
- "type": "security_question",
- "authenticatorId": "aid568g3mXgtID0HHSLH",
- "id": "autwa6eD9o02iBbaaa82"
- }
- ]
- },
- "currentAuthenticatorEnrollment": {
- "type": "object",
- "value": {
- "displayName": "Okta Password",
- "profile": {
- "name": "Okta Password"
- },
- "recover": {
- "rel": [
- "create-form"
- ],
- "name": "recover",
- "href": "http://localhost:3000/idp/idx/recover",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "eyJ6aXAiOiJERUYiLCJhbGlhcyI6ImVuY3J5cHRpb25rZXkiLCJ2ZXIiOiIxIiwib2lkIjoiMDBvdnhhU2NRWG9TbzJvMjAwZzMiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..BzXIPn5dlBQ4QOXC.rERhFXlDsEIL7712M4I4JI9JjKaQ0MLUY-8gXipZJ_g6BR5tK5PlRhN-jYGFm6v83o-wY3SmkLiMNo_stFSi4bCgmYGBslfqd9ZzH7Jq3Ouh94BrXD02PDNe2eWK5dDr6nhwITcQUDgqIH7RYs_0us1vpaZSrdTMmfSeiptpYrRl4KQAv5BV5aA5CRtLQa-LpKdtq0hm0NBlrY2-OU-d82QwAKEytlyKlxIvofBiuK6b1TgW0U9l1FG0LYLtWcist2O3jT-1eQo74R0IaxiYWnko95xaPx7VkRIjqBTuZgaVPKrHcob0TKTKQftPN3tFu9Ex44Ym-v6bjrzHBC0CnIr9AYBmbCrFGBT9G9LXGbE0mTSktO25pvoxb8iv4tlT7NRbaWWgaEHfLyN-aCDIADFsbBiUSoUtDtNGLKUWUNjU8h27ZYo5d68mhz9h04rWJSGIUuEu4Stea6zTmizYZKaPVVNKmoV3BAnHnf0naSAsviifMOUicx6BFnJTpXPcNmkZ5O0mqU-qdL4E80qYTcFwCAKHX1U4m-98odNMYs61hsVg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H3DPHH3-4KAmJMaVMsMAI_h7DUwAvbUgiUKdr3g3an3vOxPtZI2apy9sv_Wj3DTJfwPm9axjK-laVNUKFnrweURmn4mRa74pWNf-CS1s9Izgg2yxY7fib9DlK6pkgC9nBGrpocMTJWFJI.N3s3-GTo9GSC0YG-MSmMfw",
- "visible": false,
- "mutable": false
- }
- ]
- },
- "type": "password",
- "authenticatorId": "autwa6eD9o02iBbtv0g1",
- "id": "aidwboITrg4b4yAYd0g3"
- }
- },
- "user": {
- "type": "object",
- "value": {
- "id": "00uwb8GLwf1HED5Xs0g3"
- }
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "http://localhost:3000/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "eyJ6aXAiOiJERUYiLCJhbGlhcyI6ImVuY3J5cHRpb25rZXkiLCJ2ZXIiOiIxIiwib2lkIjoiMDBvdnhhU2NRWG9TbzJvMjAwZzMiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..BzXIPn5dlBQ4QOXC.rERhFXlDsEIL7712M4I4JI9JjKaQ0MLUY-8gXipZJ_g6BR5tK5PlRhN-jYGFm6v83o-wY3SmkLiMNo_stFSi4bCgmYGBslfqd9ZzH7Jq3Ouh94BrXD02PDNe2eWK5dDr6nhwITcQUDgqIH7RYs_0us1vpaZSrdTMmfSeiptpYrRl4KQAv5BV5aA5CRtLQa-LpKdtq0hm0NBlrY2-OU-d82QwAKEytlyKlxIvofBiuK6b1TgW0U9l1FG0LYLtWcist2O3jT-1eQo74R0IaxiYWnko95xaPx7VkRIjqBTuZgaVPKrHcob0TKTKQftPN3tFu9Ex44Ym-v6bjrzHBC0CnIr9AYBmbCrFGBT9G9LXGbE0mTSktO25pvoxb8iv4tlT7NRbaWWgaEHfLyN-aCDIADFsbBiUSoUtDtNGLKUWUNjU8h27ZYo5d68mhz9h04rWJSGIUuEu4St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EGz6SYtWyPDpPu0JH0GqOk-HHX8jfFZaRVM0ZnL0_BtU5G3B3OEyxMbl_yOQTdwMCT9Ete3Y1yAEUoJMyOwetCQRUdAH3DPHH3-4KAmJMaVMsMAI_h7DUwAvbUgiUKdr3g3an3vOxPtZI2apy9sv_Wj3DTJfwPm9axjK-laVNUKFnrweURmn4mRa74pWNf-CS1s9Izgg2yxY7fib9DlK6pkgC9nBGrpocMTJWFJI.N3s3-GTo9GSC0YG-MSmMfw",
- "visible": false,
- "mutable": false
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/test/spec/idx/idx-js/mocks/authenticator-verification-select-authenticator.json b/test/spec/idx/idx-js/mocks/authenticator-verification-select-authenticator.json
deleted file mode 100644
index 2d3119b05d..0000000000
--- a/test/spec/idx/idx-js/mocks/authenticator-verification-select-authenticator.json
+++ /dev/null
@@ -1,232 +0,0 @@
-{
- "stateHandle": "eyJ6aXAiOiJERUYiLCJhbGlhcyI6ImVuY3J5cHRpb25rZXkiLCJ2ZXIiOiIxIiwib2lkIjoiMDBvdnhhU2NRWG9TbzJvMjAwZzMiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..40AFMvA7ix6FA2oE.Q6jiZeKfCdON5wqqMdiDQCtgLctrIrpnQzKEwub6L5KvFWcgVpdEFcoOvT1WIq9EUVOg2m_vFLV7b-PVSoCBKhKzl0IujmkjC5XyTwnDBMmJt-2-BMez0kIkABNI1BpffStyt8uJiUqGifVrZ6AqXr6zCpkGK5f7-Mu_rVF8NS2P580n2_2p9MO9haf-z56-i3DfkX-xM1a3_AQXUGr_RzDXWPXZf6mPUhYtouJz7Qdpt6n9agvqasuSz8JLehX9TIN9Y4k_M7JKxaYfdOv9Bnp7zSEtVQeG2ADzbIMKBRXA1bP_TZ7EKHInCu4gz8JR3febZLz8EZq-kaknBB_S3AvkjtzkrUyfUNo31xZhoTWO2kiMJlo_zLRqMKW8xqPNYKjtYo9rXR_v4_wA3hOCKFyKkqCD8U1Y6b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MAWqd5q22EGAUa29XV4Jl4E6xZg8CybaOUOVpuia35UPLpCKK0wDofdAAUcPCo-hj7OH3U0XsCccF0GHfo7cqoYQanqfu7mypeGEf9_471KYQVNSlc1TGrrngY6_KRBMKDcx7fZne4ypsJfumhrpfbEkeltfwFsGVs1--2bFksLI8esRxR1qUHzT0.hCv29YrLBFcW8TjKwSmCXQ",
- "version": "1.0.0",
- "expiresAt": "2020-05-05T23:34:09.000Z",
- "intent": "LOGIN",
- "remediation": {
- "type": "array",
- "value": [
- {
- "rel": [
- "create-form"
- ],
- "name": "select-authenticator-authenticate",
- "href": "http://localhost:3000/idp/idx/challenge",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "authenticator",
- "type": "object",
- "options": [
- {
- "label": "Okta Password",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "required": true,
- "value": "aidwboITrg4b4yAYd0g3",
- "mutable": false
- },
- {
- "name": "methodType",
- "required": false,
- "value": "password",
- "mutable": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[0]"
- },
- {
- "label": "FIDO2 (WebAuthn)",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "fwftheidkwh282hv8g3",
- "required": true,
- "mutable": false,
- "visible": false
- },
- {
- "name": "methodType",
- "value": "webauthn",
- "required": false,
- "mutable": false,
- "visible": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[1]"
- },
- {
- "label": "FIDO2 (WebAuthn)",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "aidtheidkwh282hv8g3",
- "required": true,
- "mutable": false,
- "visible": false
- },
- {
- "name": "methodType",
- "value": "webauthn",
- "required": false,
- "mutable": false,
- "visible": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[2]"
- },
- {
- "label": "Okta Email",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "aidtm56L8gXXHI1SD0g3",
- "required": true,
- "mutable": false,
- "visible": false
- },
- {
- "name": "methodType",
- "value": "email",
- "required": false,
- "mutable": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[3]"
- },
- {
- "label": "Okta Phone",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "aid568g3mXgtID0X1SLH",
- "required": true,
- "mutable": false,
- "visible": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[4]"
- },
- {
- "label": "Okta Security Question",
- "value": {
- "form": {
- "value": [
- {
- "name": "id",
- "value": "aid568g3mXgtID0HHSLH",
- "required": true,
- "mutable": false,
- "visible": false
- }
- ]
- }
- },
- "relatesTo": "$.authenticatorEnrollments.value[5]"
- }
- ]
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "eyJ6aXAiOiJERUYiLCJhbGlhcyI6ImVuY3J5cHRpb25rZXkiLCJ2ZXIiOiIxIiwib2lkIjoiMDBvdnhhU2NRWG9TbzJvMjAwZzMiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..40AFMvA7ix6FA2oE.Q6jiZeKfCdON5wqqMdiDQCtgLctrIrpnQzKEwub6L5KvFWcgVpdEFcoOvT1WIq9EUVOg2m_vFLV7b-PVSoCBKhKzl0IujmkjC5XyTwnDBMmJt-2-BMez0kIkABNI1BpffStyt8uJiUqGifVrZ6AqXr6zCpkGK5f7-Mu_rVF8NS2P580n2_2p9MO9haf-z56-i3DfkX-xM1a3_AQXUGr_RzDXWPXZf6mPUhYtouJz7Qdpt6n9agvqasuSz8JLehX9TIN9Y4k_M7JKxaYfdOv9Bnp7zSEtVQeG2ADzbIMKBRXA1bP_TZ7EKHInCu4gz8JR3febZLz8EZq-kaknBB_S3AvkjtzkrUyfUNo31xZhoTWO2kiMJlo_zLRqMKW8xqPNYKjtYo9rXR_v4_wA3hOCKFyKkqCD8U1Y6bbVwoicDHOZ4fNZOtcAVB8BJ8HzpAYzF8bCKHCD9CLgIU8eCezTo_Fo90Zm138Hu0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U0XsCccF0GHfo7cqoYQanqfu7mypeGEf9_471KYQVNSlc1TGrrngY6_KRBMKDcx7fZne4ypsJfumhrpfbEkeltfwFsGVs1--2bFksLI8esRxR1qUHzT0.hCv29YrLBFcW8TjKwSmCXQ",
- "visible": false,
- "mutable": false
- }
- ]
- }
- ]
- },
- "authenticatorEnrollments": {
- "type": "array",
- "value": [
- {
- "displayName": "Okta Password",
- "type": "password",
- "id": "autwa6eD9o02iBbtv0g1",
- "authenticatorId": "aidwboITrg4b4yAYd0g3"
- },
- {
- "displayName": "FIDO2 (WebAuthn)",
- "type": "security_key",
- "id": "autwa6eD9o02iBbtv0g2",
- "authenticatorId": "aidtheidkwh282hv8g3"
- },
- {
- "displayName": "FIDO2 (WebAuthn)",
- "type": "security_key",
- "id": "autwa6eD9o02iBbtv0g2",
- "authenticatorId": "fwftheidkwh282hv8g3"
- },
- {
- "displayName": "Okta Email",
- "type": "email",
- "authenticatorId": "aidtm56L8gXXHI1SD0g3",
- "id": "autwa6eD9o02iBbtv0g3",
- "methods": [
- {
- "methodType": "email"
- }
- ]
- },
- {
- "displayName": "Okta Phone",
- "type": "phone",
- "authenticatorId": "aid568g3mXgtID0X1SLH",
- "id": "autwa6eD9o02iBbsta82"
- },
- {
- "displayName": "Okta Security Question",
- "type": "security_question",
- "authenticatorId": "aid568g3mXgtID0HHSLH",
- "id": "autwa6eD9o02iBbaaa82"
- }
- ]
- },
- "user": {
- "type": "object",
- "value": {
- "id": "00uwb8GLwf1HED5Xs0g3"
- }
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "http://localhost:3000/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "eyJ6aXAiOiJERUYiLCJhbGlhcyI6ImVuY3J5cHRpb25rZXkiLCJ2ZXIiOiIxIiwib2lkIjoiMDBvdnhhU2NRWG9TbzJvMjAwZzMiLCJlbmMiOiJBMjU2R0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RTiOOZxhOBIUuVgUUnkm6x4K23-TYxf4HgV_vWrQmIdEjaP5NuYRPfLkdM8qAWCkuz5r48yjl6T5XRg1wKG7OX0JZLjbmcJsTNagXSHbPsXuBd0te_fgNYT54_eGkIIklr4LbOEhKGNpZSXSWPbTPT7zhbebrUGglldI37k8WldRGywq_ZvZX6W5hucD_yWBqqXBq45LW_iNlAvtUIXBkq4WuPgWaYRIjqWnUxbAZkL_5ejddr18MOmbwV8ftbtYhvnYbYqBvDaqpsXoVKBT0g8ZTXuSs36Rrxi6wyBnXVcM0RrC8YhU6ybBWiovNo2chyPSPhFAvmJVmVL2t3lbA7SoBnWQvNtspHY8Xd8KNf-MUSuhHKXfrSRPwWC23D9qSxoUC0ubIINYBLD-WHYv_Yn7RBU7IQ4fzoLJrE6mUBz9tZ79drLOLd7vbe8MPpWJI-MHCTHD6XTMAWqd5q22EGAUa29XV4Jl4E6xZg8CybaOUOVpuia35UPLpCKK0wDofdAAUcPCo-hj7OH3U0XsCccF0GHfo7cqoYQanqfu7mypeGEf9_471KYQVNSlc1TGrrngY6_KRBMKDcx7fZne4ypsJfumhrpfbEkeltfwFsGVs1--2bFksLI8esRxR1qUHzT0.hCv29YrLBFcW8TjKwSmCXQ",
- "visible": false,
- "mutable": false
- }
- ]
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/challenge-password.json b/test/spec/idx/idx-js/mocks/challenge-password.json
deleted file mode 100644
index c23735d610..0000000000
--- a/test/spec/idx/idx-js/mocks/challenge-password.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
- "stateHandle": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "version": "1.0.0",
- "expiresAt": "2019-12-19T21:43:24.000Z",
- "step": "AUTHENTICATE",
- "intent": "LOGIN",
- "remediation": {
- "type": "array",
- "value": [
- {
- "rel": [
- "create-form"
- ],
- "name": "challenge-factor",
- "href": "https://dev-550580.okta.com/idp/idx/challenge/answer",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "credentials",
- "form": {
- "value": [
- {
- "name": "passcode",
- "label": "Password",
- "secret": true
- }
- ]
- }
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "visible": false,
- "mutable": false
- }
- ]
- }
- ]
- },
- "factor": {
- "type": "object",
- "value": {
- "factorType": "password",
- "factorProfileId": "fpr1w2vlszZt2g3E4357",
- "factorId": "00u1wlnlh2x3sQemR357",
- "recover": {
- "rel": [
- "create-form"
- ],
- "name": "recover",
- "href": "https://dev-550580.okta.com/idp/idx/recover",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "visible": false,
- "mutable": false
- }
- ]
- }
- }
- },
- "user": {
- "type": "object",
- "value": {
- "id": "00u1wlnlh2x3sQemR357"
- }
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "https://dev-550580.okta.com/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "visible": false,
- "mutable": false
- }
- ]
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/error-authenticator-enroll.json b/test/spec/idx/idx-js/mocks/error-authenticator-enroll.json
deleted file mode 100644
index 83de65a271..0000000000
--- a/test/spec/idx/idx-js/mocks/error-authenticator-enroll.json
+++ /dev/null
@@ -1,105 +0,0 @@
-{
- "stateHandle": "02TptqPN4BOLIwMAGUVLPlZVJEnONAq7xkg19dy6Gk",
- "version": "1.0.0",
- "expiresAt": "2021-01-19T15:10:35.000Z",
- "intent": "LOGIN",
- "messages": {
- "type": "array",
- "value": [
- {
- "message": "Unable to enroll. Try again or contact your admin for assistance.",
- "i18n": {
- "key": "",
- "params": []
- },
- "class": "ERROR"
- }
- ]
- },
- "remediation": {
- "type": "array",
- "value": [
- {
- "name": "redirect-idp",
- "type": "OIDC",
- "idp": {
- "id": "0oa69chx4bZyx8O7l0g4",
- "name": "IDP Authenticator"
- },
- "href": "http://localhost:3000/sso/idps/0oa69chx4bZyx8O7l0g4?stateToken=02TptqPN4BOLIwMAGUVLPlZVJEnONAq7xkg19dy6Gk",
- "method": "GET",
- "relatesTo" : [ "$.currentAuthenticator" ]
- }
- ]
- },
- "currentAuthenticator": {
- "type": "object",
- "value": {
- "key": "external_idp",
- "type": "federated",
- "id": "aut4mhtS1b84AR0iQ0g4",
- "displayName": "IDP Authenticator",
- "methods": [
- { "type": "idp" }
- ]
- }
- },
- "authenticators": {
- "type": "array",
- "value": [
- {
- "key": "external_idp",
- "type": "federated",
- "id": "aut4mhtS1b84AR0iQ0g4",
- "displayName": "IDP Authenticator",
- "methods": [
- { "type": "idp" }
- ]
- }
- ]
- },
- "authenticatorEnrollments": {
- "type": "array",
- "value": []
- },
- "enrollmentAuthenticator": {
- "type": "object",
- "value": {
- "key": "external_idp",
- "type": "federated",
- "id": "aut4mhtS1b84AR0iQ0g4",
- "displayName": "IDP Authenticator",
- "methods": [
- { "type": "idp" }
- ]
- }
- },
- "user": {
- "type": "object",
- "value": { "id": "00u2m55pu8UZyeMMl0g4" }
- },
- "cancel": {
- "rel": [ "create-form" ],
- "name": "cancel",
- "href": "http://localhost:3000/idp/idx/cancel",
- "method": "POST",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02TptqPN4BOLIwMAGUVLPlZVJEnONAq7xkg19dy6Gk",
- "visible": false,
- "mutable": false
- }
- ],
- "accepts": "application/ion+json; okta-version=1.0.0"
- },
- "app": {
- "type": "object",
- "value": {
- "name": "oidc_client",
- "label": "Test OIDC App",
- "id": "0oa11ch8m94eTn0Qe0g4"
- }
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/interact-response.json b/test/spec/idx/idx-js/mocks/interact-response.json
deleted file mode 100644
index 527e202ec3..0000000000
--- a/test/spec/idx/idx-js/mocks/interact-response.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "interaction_handle": "ZZZZZZZINTERACTZZZZZZZZ"
-}
diff --git a/test/spec/idx/idx-js/mocks/poll-for-password.json b/test/spec/idx/idx-js/mocks/poll-for-password.json
deleted file mode 100644
index 253e74a187..0000000000
--- a/test/spec/idx/idx-js/mocks/poll-for-password.json
+++ /dev/null
@@ -1,113 +0,0 @@
-{
- "stateHandle": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "version": "1.0.0",
- "expiresAt": "2019-12-19T21:45:09.000Z",
- "step": "AUTHENTICATE",
- "intent": "LOGIN",
- "remediation": {
- "type": "array",
- "value": [
- {
- "rel": [
- "create-form"
- ],
- "name": "challenge-factor",
- "href": "https://dev-550580.okta.com/idp/idx/challenge/answer",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "credentials",
- "form": {
- "value": [
- {
- "name": "passcode",
- "label": "One-time verification code"
- }
- ]
- }
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "visible": false,
- "mutable": false
- }
- ]
- }
- ]
- },
- "factor": {
- "type": "object",
- "value": {
- "factorType": "email",
- "factorProfileId": "fpr1w2vlstxSAQsHZ357",
- "factorId": "emf2a6n2omrZ7Abnt357",
- "profile": {
- "email": "test.idx@swiftone.org"
- },
- "send": {
- "rel": [
- "create-form"
- ],
- "name": "send",
- "href": "https://dev-550580.okta.com/idp/idx/challenge/send",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "visible": false,
- "mutable": false
- }
- ]
- },
- "poll": {
- "rel": [
- "create-form"
- ],
- "name": "poll",
- "href": "https://dev-550580.okta.com/idp/idx/challenge/poll",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "refresh": 4000,
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "visible": false,
- "mutable": false
- }
- ]
- }
- }
- },
- "user": {
- "type": "object",
- "value": {
- "id": "00u1wlnlh2x3sQemR357"
- }
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "https://dev-550580.okta.com/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "visible": false,
- "mutable": false
- }
- ]
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/request-factor.json b/test/spec/idx/idx-js/mocks/request-factor.json
deleted file mode 100644
index 987f7806b2..0000000000
--- a/test/spec/idx/idx-js/mocks/request-factor.json
+++ /dev/null
@@ -1,74 +0,0 @@
-{
- "stateHandle": "02bKhpAy0YPGrDAMchQzO_EyCs1e45DZL3z1lHthqk",
- "version": "1.0.0",
- "expiresAt": "2019-12-19T21:37:32.000Z",
- "step": "AUTHENTICATE",
- "intent": "LOGIN",
- "remediation": {
- "type": "array",
- "value": [
- {
- "rel": [
- "create-form"
- ],
- "name": "select-factor",
- "href": "https://dev-550580.okta.com/idp/idx/challenge",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "factorId",
- "type": "set",
- "options": [
- {
- "label": "Okta Password",
- "value": "00u1wlnlh2x3sQemR357"
- }
- ]
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "02bKhpAy0YPGrDAMchQzO_EyCs1e45DZL3z1lHthqk",
- "visible": false,
- "mutable": false
- }
- ]
- }
- ]
- },
- "factors": {
- "type": "array",
- "value": [
- {
- "factorType": "password",
- "factorProfileId": "fpr1w2vlszZt2g3E4357",
- "factorId": "00u1wlnlh2x3sQemR357"
- }
- ]
- },
- "user": {
- "type": "object",
- "value": {
- "id": "00u1wlnlh2x3sQemR357"
- }
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "https://dev-550580.okta.com/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02bKhpAy0YPGrDAMchQzO_EyCs1e45DZL3z1lHthqk",
- "visible": false,
- "mutable": false
- }
- ]
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/request-identifier-with-idps.json b/test/spec/idx/idx-js/mocks/request-identifier-with-idps.json
deleted file mode 100644
index eb98f074d4..0000000000
--- a/test/spec/idx/idx-js/mocks/request-identifier-with-idps.json
+++ /dev/null
@@ -1,90 +0,0 @@
-{
- "stateHandle": "02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "version": "1.0.0",
- "expiresAt": "2020-04-13T22:55:53.000Z",
- "step": "IDENTIFY",
- "intent": "LOGIN",
- "remediation": {
- "type": "array",
- "value": [
- {
- "rel": [
- "create-form"
- ],
- "name": "identify",
- "href": "https://dev-550580.okta.com/idp/idx/identify",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json; okta-version=1.0.0",
- "value": [
- {
- "name": "identifier",
- "label": "Username"
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "visible": false,
- "mutable": false
- }
- ]
- },
- {
- "name": "redirect-idp",
- "type": "GOOGLE",
- "idp": {
- "id": "0oa2sykfl6Fnb9ZMN0g4",
- "name": "Google IDP"
- },
- "href": "https://dev-550580.okta.com/sso/idps/0oa2sykfl6Fnb9ZMN0g4?stateToken=02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "method": "GET"
- },
- {
- "name": "redirect-idp",
- "type": "FACEBOOK",
- "idp": {
- "id": "0oa2szc1K1YPgz1pe0g4",
- "name": "Facebook IDP"
- },
- "href": "https://dev-550580.okta.com/sso/idps/0oa2szc1K1YPgz1pe0g4?stateToken=02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "method": "GET"
- },
- {
- "rel": [
- "create-form"
- ],
- "name": "select-enroll-profile",
- "href": "https://dev-550580.okta.com/idp/idx/enroll",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "visible": false,
- "mutable": false
- }
- ]
- }
- ]
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "https://dev-550580.okta.com/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json; okta-version=1.0.0",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "visible": false,
- "mutable": false
- }
- ]
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/request-identifier.json b/test/spec/idx/idx-js/mocks/request-identifier.json
deleted file mode 100644
index 31d9fd612f..0000000000
--- a/test/spec/idx/idx-js/mocks/request-identifier.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "stateHandle": "02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "version": "1.0.0",
- "expiresAt": "2019-12-11T21:46:19.000Z",
- "step": "IDENTIFY",
- "intent": "LOGIN",
- "remediation": {
- "type": "array",
- "value": [
- {
- "rel": [
- "create-form"
- ],
- "name": "identify",
- "href": "https://dev-550580.okta.com/idp/idx/identify",
- "method": "POST",
- "accepts": "application/ion+json; okta-version=1.0.0",
- "value": [
- {
- "name": "identifier",
- "label": "Username"
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "visible": false,
- "mutable": false
- }
- ]
- },
- {
- "rel": [
- "create-form"
- ],
- "name": "select-enroll-profile",
- "href": "https://dev-550580.okta.com/idp/idx/enroll",
- "method": "POST",
- "accepts": "application/ion+json; okta-version=1.0.0",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "visible": false,
- "mutable": false
- }
- ]
- }
- ]
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "https://dev-550580.okta.com/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/ion+json; okta-version=1.0.0",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "visible": false,
- "mutable": false
- }
- ]
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/select-factor-email.json b/test/spec/idx/idx-js/mocks/select-factor-email.json
deleted file mode 100644
index 9f150439f5..0000000000
--- a/test/spec/idx/idx-js/mocks/select-factor-email.json
+++ /dev/null
@@ -1,74 +0,0 @@
-{
- "stateHandle": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "version": "1.0.0",
- "expiresAt": "2019-12-19T21:44:23.000Z",
- "step": "AUTHENTICATE",
- "intent": "LOGIN",
- "remediation": {
- "type": "array",
- "value": [
- {
- "rel": [
- "create-form"
- ],
- "name": "select-factor",
- "href": "https://dev-550580.okta.com/idp/idx/challenge",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "factorId",
- "type": "set",
- "options": [
- {
- "label": "Email",
- "value": "emf2a6n2omrZ7Abnt357"
- }
- ]
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "visible": false,
- "mutable": false
- }
- ]
- }
- ]
- },
- "factors": {
- "type": "array",
- "value": [
- {
- "factorType": "email",
- "factorProfileId": "fpr1w2vlstxSAQsHZ357",
- "factorId": "emf2a6n2omrZ7Abnt357"
- }
- ]
- },
- "user": {
- "type": "object",
- "value": {
- "id": "00u1wlnlh2x3sQemR357"
- }
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "https://dev-550580.okta.com/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02XK6MwQm7S4ajhvjKZGBSQBdp-SdtywmrSdEmadmU",
- "visible": false,
- "mutable": false
- }
- ]
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/success.json b/test/spec/idx/idx-js/mocks/success.json
deleted file mode 100644
index 5b30ad1e79..0000000000
--- a/test/spec/idx/idx-js/mocks/success.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "stateHandle": "022FJBvS6bHS7OjQSOhtfghhJvO2a2TELaMZ94s69K",
- "version": "1.0.0",
- "expiresAt": "2019-08-27T16:57:50.000Z",
- "step": "SUCCESS",
- "intent": "LOGIN",
- "user": {
- "type": "object",
- "value": {
- "id": "00ub0ttoyz062NeVa0g4"
- }
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "http://localhost:3000/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "value": "022FJBvS6bHS7OjQSOhtfghhJvO2a2TELaMZ94s69K",
- "visible": false
- }
- ]
- },
- "success": {
- "name": "success-redirect",
- "href": "https://httpbin.org?stateToken=abc123"
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/terminal-return-email.json b/test/spec/idx/idx-js/mocks/terminal-return-email.json
deleted file mode 100644
index b066988107..0000000000
--- a/test/spec/idx/idx-js/mocks/terminal-return-email.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "version": "1.0.0",
- "stateHandle": "01OCl7uyAUC4CUqHsObI9bvFiq01cRFgbnpJQ1bz82",
- "terminal" : {
- "type" : "object",
- "value" : {
- "name" : "terminal-return",
- "message" : {
- "message" : "To finish signing in, return to the screen where you requested the email link.",
- "i18n" : {
- "key" : "idx.session.expired",
- "params" : []
- }
- }
- }
- },
- "factor": {
- "type": "object",
- "value": {
- "factorType": "email",
- "provider": "okta",
- "profile": {
- "email": "o*****m@abbott.dev"
- }
- }
- }
-}
diff --git a/test/spec/idx/idx-js/mocks/unknown-user.json b/test/spec/idx/idx-js/mocks/unknown-user.json
deleted file mode 100644
index 867ecea4ac..0000000000
--- a/test/spec/idx/idx-js/mocks/unknown-user.json
+++ /dev/null
@@ -1,83 +0,0 @@
-{
- "stateHandle": "02tZJpxD03j1a3qaPcSsi16yDtqMZgfetf8OvWOepP",
- "version": "1.0.0",
- "expiresAt": "2019-09-13T20:03:50.000Z",
- "step": "IDENTIFY",
- "intent": "LOGIN",
- "remediation": {
- "type": "array",
- "value": [
- {
- "rel": [
- "create-form"
- ],
- "name": "identify",
- "href": "http://localhost:3000/idp/idx",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "identifier",
- "label": "Username"
- },
- {
- "name": "stateHandle",
- "required": true,
- "value": "02tZJpxD03j1a3qaPcSsi16yDtqMZgfetf8OvWOepP",
- "visible": false,
- "mutable": false
- }
- ]
- },
- {
- "rel": [
- "create-form"
- ],
- "name": "select-enroll-profile",
- "href": "http://localhost:3000/idp/idx/enroll",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02tZJpxD03j1a3qaPcSsi16yDtqMZgfetf8OvWOepP",
- "visible": false,
- "mutable": false
- }
- ]
- }
- ]
- },
- "messages": {
- "type": "array",
- "value": [
- {
- "message": "There is no account with the email test@rain.com . Sign up for an account",
- "i18n": {
- "key": "idx.unknown.user",
- "params": []
- },
- "class": "INFO"
- }
- ]
- },
- "cancel": {
- "rel": [
- "create-form"
- ],
- "name": "cancel",
- "href": "http://localhost:3000/idp/idx/cancel",
- "method": "POST",
- "accepts": "application/vnd.okta.v1+json",
- "value": [
- {
- "name": "stateHandle",
- "required": true,
- "value": "02tZJpxD03j1a3qaPcSsi16yDtqMZgfetf8OvWOepP",
- "visible": false,
- "mutable": false
- }
- ]
- }
-}
diff --git a/test/spec/idx/idx-js/unit/client.test.js b/test/spec/idx/idx-js/unit/client.test.js
deleted file mode 100644
index e1cb4c7c75..0000000000
--- a/test/spec/idx/idx-js/unit/client.test.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-import { HttpClient, request } from '../../../../../lib/idx/idx-js/client';
-
-jest.mock('cross-fetch');
-import fetch from 'cross-fetch'; // import to target for mockery
-
-const mockInteractResponse = require('../mocks/interact-response');
-const { Response } = jest.requireActual('cross-fetch');
-
-describe('request', () => {
- describe('credentials', () => {
- it('is set to "include" by default', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
- await request('https://example.com', { body: 'foo=bar' });
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'https://example.com' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: 'foo=bar',
- credentials: 'include',
- headers: {},
- method: 'POST',
- });
- });
- it('can be set by caller', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
- await request('https://example.com', { body: 'foo=bar', credentials: 'omit' });
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'https://example.com' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: 'foo=bar',
- credentials: 'omit',
- headers: {},
- method: 'POST',
- });
- });
- });
-
- it('does not process interceptors when none are configured', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
-
- return request('https://example.com', { body: 'foo=bar' })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'https://example.com' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: 'foo=bar',
- credentials: 'include',
- headers: {},
- method: 'POST',
- });
- });
- });
-
- it('allows consumers of the library change configuration values through interceptors', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
-
- const interceptor = (config) => {
- // Rewrite config by reference
- config.url = 'https://okta.com';
- config.headers = { 'foo': 'bar' };
- config.method = 'GET';
- config.body = 'body value';
- };
-
- HttpClient.interceptors.request.use(interceptor);
-
- return request('https://example.com', { /* use lib defaults */ })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'https://okta.com' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: 'body value',
- credentials: 'include',
- headers: {
- 'foo': 'bar',
- },
- method: 'GET'
- });
- });
- });
-
- it('allows consumers of the library add and remove interceptors', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
-
- const interceptor = (config) => {
- // Rewrite config by reference
- config.url = 'changed';
- };
-
- HttpClient.interceptors.request.use(interceptor);
-
- await request('https://example.com', { /* use lib defaults */ })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'changed' );
- });
-
- // Clear all attached interceptors
- HttpClient.interceptors.request.clear();
-
- await request('https://example.com', { /* use lib defaults */ })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(2);
- expect( fetch.mock.calls[1][0] ).toEqual( 'https://example.com' );
- });
- });
-});
diff --git a/test/spec/idx/idx-js/unit/interact.test.js b/test/spec/idx/idx-js/unit/interact.test.js
deleted file mode 100644
index f76c3d5424..0000000000
--- a/test/spec/idx/idx-js/unit/interact.test.js
+++ /dev/null
@@ -1,137 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-import interact from '../../../../../lib/idx/idx-js/interact';
-import { HttpClient } from '../../../../../lib/idx/idx-js/client';
-
-jest.mock('cross-fetch');
-import fetch from 'cross-fetch'; // import to target for mockery
-
-const mockInteractResponse = require('../mocks/interact-response');
-const { Response } = jest.requireActual('cross-fetch');
-
-const mockConfig = {
- baseUrl: 'http://okta.example.com',
- clientId: 'CLIENT_ID',
- redirectUri: 'redirect://',
- codeChallenge: 'foo',
- codeChallengeMethod: 'method',
-};
-
-describe('interact', () => {
- afterEach(() => {
- HttpClient.interceptors.request.clear();
- });
-
- it('fetches an interaction handle', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
- return interact({ ...mockConfig, scope: 'openid email' })
- .then( result => {
- expect(result).toEqual('ZZZZZZZINTERACTZZZZZZZZ');
- });
- });
-
- it('allows consumers of the library to pass in custom headers', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
-
- HttpClient.interceptors.request.use( (config) => {
- // Rewrite headers
- config.headers['X-Test-Header'] = 'foo';
- config.headers['X-Okta-User-Agent-Extended'] = 'my-sdk-value';
- });
-
- return interact({ ...mockConfig })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/v1/interact' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: 'client_id=CLIENT_ID&scope=openid%20email&redirect_uri=redirect%3A%2F%2F&code_challenge=foo&code_challenge_method=method&state=undefined',
- credentials: 'include',
- headers: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'X-Test-Header': 'foo',
- 'X-Okta-User-Agent-Extended': 'my-sdk-value',
- },
- method: 'POST'
- });
- });
- });
-
-
- it('by default, credentials are included', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
-
- return interact({ ...mockConfig })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/v1/interact' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: 'client_id=CLIENT_ID&scope=openid%20email&redirect_uri=redirect%3A%2F%2F&code_challenge=foo&code_challenge_method=method&state=undefined',
- credentials: 'include', // what we are testing
- headers: {
- 'content-type': 'application/x-www-form-urlencoded',
- },
- method: 'POST'
- });
- });
- });
-
- it('credentials can be ommitted by setting withCredentials to false', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
-
- return interact({ ...mockConfig, withCredentials: false })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/v1/interact' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: 'client_id=CLIENT_ID&scope=openid%20email&redirect_uri=redirect%3A%2F%2F&code_challenge=foo&code_challenge_method=method&state=undefined',
- credentials: 'omit', // what we are testing
- headers: {
- 'content-type': 'application/x-www-form-urlencoded',
- },
- method: 'POST'
- });
- });
- });
-
- it('passes along `activationToken` if it was provided', () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
- return interact({ ...mockConfig, scope: 'openid email', activationToken: 'xxxACTIVATIONTOKENxxx' })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/v1/interact' );
- expect( fetch.mock.calls[0][1].body ).toEqual('client_id=CLIENT_ID&scope=openid%20email&redirect_uri=redirect%3A%2F%2F&code_challenge=foo&code_challenge_method=method&state=undefined&activation_token=xxxACTIVATIONTOKENxxx');
- });
- });
-
- it('passes along `recoveryToken` if it was provided', () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
- return interact({ ...mockConfig, scope: 'openid email', recoveryToken: 'xxxRECOVERYTOKENxxx' })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/v1/interact' );
- expect( fetch.mock.calls[0][1].body ).toEqual('client_id=CLIENT_ID&scope=openid%20email&redirect_uri=redirect%3A%2F%2F&code_challenge=foo&code_challenge_method=method&state=undefined&recovery_token=xxxRECOVERYTOKENxxx');
- });
- });
-
- it('passes along `clientSecret` if it was provided', () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockInteractResponse )) ) );
- return interact({ ...mockConfig, scope: 'openid email', clientSecret: 'xxxCLIENTSECRETxxx' })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/v1/interact' );
- expect( fetch.mock.calls[0][1].body ).toEqual('client_id=CLIENT_ID&scope=openid%20email&redirect_uri=redirect%3A%2F%2F&code_challenge=foo&code_challenge_method=method&state=undefined&client_secret=xxxCLIENTSECRETxxx');
- });
- });
-});
-
diff --git a/test/spec/idx/idx-js/unit/introspect.test.js b/test/spec/idx/idx-js/unit/introspect.test.js
deleted file mode 100644
index 8ee1c10458..0000000000
--- a/test/spec/idx/idx-js/unit/introspect.test.js
+++ /dev/null
@@ -1,135 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-import introspect from '../../../../../lib/idx/idx-js/introspect';
-import { HttpClient } from '../../../../../lib/idx/idx-js/client';
-jest.mock('cross-fetch');
-import fetch from 'cross-fetch'; // import to target for mockery
-
-const mockIdxResponse = require('../mocks/request-identifier');
-const mockErrorResponse = require('../mocks/error-authenticator-enroll');
-const { Response } = jest.requireActual('cross-fetch');
-
-let domain = 'http://okta.example.com';
-let stateHandle = 'FAKEY-FAKE';
-let version = '1.0.0';
-
-describe('introspect', () => {
- afterEach(() => {
- HttpClient.interceptors.request.clear();
- });
-
- it('returns an idxResponse on success', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockIdxResponse )) ) );
- return introspect({ domain, stateHandle, version })
- .then( result => {
- expect(result).toEqual({
- ...mockIdxResponse,
- requestDidSucceed: true
- });
- });
- });
-
- it('by default, sends credentials on the request', () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockIdxResponse )) ) );
- return introspect({ domain, stateHandle, version })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/idp/idx/introspect' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"stateToken":"FAKEY-FAKE"}',
- credentials: 'include', // what we are testing
- headers: {
- 'content-type': 'application/ion+json; okta-version=1.0.0',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- });
- });
-
- it('can omit credentials by setting withCredentials to false', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockIdxResponse )) ) );
- return introspect({ domain, stateHandle, version, withCredentials: false })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/idp/idx/introspect' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"stateToken":"FAKEY-FAKE"}',
- credentials: 'omit', // what we are testing
- headers: {
- 'content-type': 'application/ion+json; okta-version=1.0.0',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- });
- });
-
- it('sets `requestDidSucceed` to `false` if the XHR request returned an HTTP error status', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockErrorResponse ), { status: 500 }) ) );
- return introspect({ domain, stateHandle, version })
- .then( err => {
- expect(err).toEqual({
- ...mockErrorResponse,
- requestDidSucceed: false
- });
- });
- });
-
- it('sends the SDK version as a custom header', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockIdxResponse )) ) );
- return introspect({ domain, stateHandle, version })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/idp/idx/introspect' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"stateToken":"FAKEY-FAKE"}',
- credentials: 'include',
- headers: {
- 'content-type': 'application/ion+json; okta-version=1.0.0',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- });
- });
-
- it('allows consumers of the library to pass in custom headers', async () => {
- fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockIdxResponse )) ) );
-
- HttpClient.interceptors.request.use( (config) => {
- // Rewrite headers
- config.headers['X-Test-Header'] = 'foo';
- config.headers['X-Okta-User-Agent-Extended'] = 'my-sdk-value';
- });
-
- return introspect({ domain, stateHandle, version })
- .then( () => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'http://okta.example.com/idp/idx/introspect' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"stateToken":"FAKEY-FAKE"}',
- credentials: 'include',
- headers: {
- 'content-type': 'application/ion+json; okta-version=1.0.0',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- 'X-Test-Header': 'foo',
- 'X-Okta-User-Agent-Extended': 'my-sdk-value',
- },
- method: 'POST'
- });
- });
- });
-
-});
diff --git a/test/spec/idx/idx-js/unit/parsers.test.js b/test/spec/idx/idx-js/unit/parsers.test.js
deleted file mode 100644
index e507d46024..0000000000
--- a/test/spec/idx/idx-js/unit/parsers.test.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-import parsersForVersion from '../../../../../lib/idx/idx-js/parsers';
-
-describe('parsersForVersion', () => {
- it('is a function', () => {
- expect(typeof parsersForVersion).toBe('function');
- });
-
- it('requires a version', () => {
- expect( () => parsersForVersion()).toThrow(new Error('Api version is required') );
- });
-
- it('throws an error on an unsupported version', () => {
- expect( () => parsersForVersion('NOT_A_VERSION')).toThrow(new Error('Unknown api version: NOT_A_VERSION. Use an exact semver version.') );
- });
-
- it('returns an object of parsers', () => {
- const parsers = parsersForVersion('1.0.0');
- expect(parsers).toBeDefined();
- expect(parsers.makeIdxState).toBeDefined();
- });
-});
diff --git a/test/spec/idx/idx-js/unit/v1/__snapshots__/idxResponseParser.test.js.snap b/test/spec/idx/idx-js/unit/v1/__snapshots__/idxResponseParser.test.js.snap
deleted file mode 100644
index 60a0dfd072..0000000000
--- a/test/spec/idx/idx-js/unit/v1/__snapshots__/idxResponseParser.test.js.snap
+++ /dev/null
@@ -1,255 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`idxResponseParser parseIdxResponse builds remediation for authenticator-verify-select-authenticator 1`] = `
-Object {
- "accepts": "application/vnd.okta.v1+json",
- "action": undefined,
- "href": "http://localhost:3000/idp/idx/challenge",
- "method": "POST",
- "name": "select-authenticator-authenticate",
- "rel": Array [
- "create-form",
- ],
- "value": Array [
- Object {
- "name": "authenticator",
- "options": Array [
- Object {
- "label": "Okta Password",
- "relatesTo": Object {
- "authenticatorId": "aidwboITrg4b4yAYd0g3",
- "displayName": "Okta Password",
- "id": "autwa6eD9o02iBbtv0g1",
- "type": "password",
- },
- "value": Object {
- "form": Object {
- "value": Array [
- Object {
- "mutable": false,
- "name": "id",
- "required": true,
- "value": "aidwboITrg4b4yAYd0g3",
- },
- Object {
- "mutable": false,
- "name": "methodType",
- "required": false,
- "value": "password",
- },
- ],
- },
- },
- },
- Object {
- "label": "FIDO2 (WebAuthn)",
- "relatesTo": Object {
- "authenticatorId": "aidtheidkwh282hv8g3",
- "displayName": "FIDO2 (WebAuthn)",
- "id": "autwa6eD9o02iBbtv0g2",
- "type": "security_key",
- },
- "value": Object {
- "form": Object {
- "value": Array [
- Object {
- "mutable": false,
- "name": "id",
- "required": true,
- "value": "fwftheidkwh282hv8g3",
- "visible": false,
- },
- Object {
- "mutable": false,
- "name": "methodType",
- "required": false,
- "value": "webauthn",
- "visible": false,
- },
- ],
- },
- },
- },
- Object {
- "label": "FIDO2 (WebAuthn)",
- "relatesTo": Object {
- "authenticatorId": "fwftheidkwh282hv8g3",
- "displayName": "FIDO2 (WebAuthn)",
- "id": "autwa6eD9o02iBbtv0g2",
- "type": "security_key",
- },
- "value": Object {
- "form": Object {
- "value": Array [
- Object {
- "mutable": false,
- "name": "id",
- "required": true,
- "value": "aidtheidkwh282hv8g3",
- "visible": false,
- },
- Object {
- "mutable": false,
- "name": "methodType",
- "required": false,
- "value": "webauthn",
- "visible": false,
- },
- ],
- },
- },
- },
- Object {
- "label": "Okta Email",
- "relatesTo": Object {
- "authenticatorId": "aidtm56L8gXXHI1SD0g3",
- "displayName": "Okta Email",
- "id": "autwa6eD9o02iBbtv0g3",
- "methods": Array [
- Object {
- "methodType": "email",
- },
- ],
- "type": "email",
- },
- "value": Object {
- "form": Object {
- "value": Array [
- Object {
- "mutable": false,
- "name": "id",
- "required": true,
- "value": "aidtm56L8gXXHI1SD0g3",
- "visible": false,
- },
- Object {
- "mutable": false,
- "name": "methodType",
- "required": false,
- "value": "email",
- },
- ],
- },
- },
- },
- Object {
- "label": "Okta Phone",
- "relatesTo": Object {
- "authenticatorId": "aid568g3mXgtID0X1SLH",
- "displayName": "Okta Phone",
- "id": "autwa6eD9o02iBbsta82",
- "type": "phone",
- },
- "value": Object {
- "form": Object {
- "value": Array [
- Object {
- "mutable": false,
- "name": "id",
- "required": true,
- "value": "aid568g3mXgtID0X1SLH",
- "visible": false,
- },
- ],
- },
- },
- },
- Object {
- "label": "Okta Security Question",
- "relatesTo": Object {
- "authenticatorId": "aid568g3mXgtID0HHSLH",
- "displayName": "Okta Security Question",
- "id": "autwa6eD9o02iBbaaa82",
- "type": "security_question",
- },
- "value": Object {
- "form": Object {
- "value": Array [
- Object {
- "mutable": false,
- "name": "id",
- "required": true,
- "value": "aid568g3mXgtID0HHSLH",
- "visible": false,
- },
- ],
- },
- },
- },
- ],
- "type": "object",
- },
- Object {
- "mutable": false,
- "name": "stateHandle",
- "required": true,
- "value": "eyJ6aXAiOiJERUYiLCJhbGlhcyI6ImVuY3J5cHRpb25rZXkiLCJ2ZXIiOiIxIiwib2lkIjoiMDBvdnhhU2NRWG9TbzJvMjAwZzMiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..40AF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-TYxf4HgV_vWrQmIdEjaP5NuYRPfLkdM8qAWCkuz5r48yjl6T5XRg1wKG7OX0JZLjbmcJsTNagXSHbPsXuBd0te_fgNYT54_eGkIIklr4LbOEhKGNpZSXSWPbTPT7zhbebrUGglldI37k8WldRGywq_ZvZX6W5hucD_yWBqqXBq45LW_iNlAvtUIXBkq4WuPgWaYRIjqWnUxbAZkL_5ejddr18MOmbwV8ftbtYhvnYbYqBvDaqpsXoVKBT0g8ZTXuSs36Rrxi6wyBnXVcM0RrC8YhU6ybBWiovNo2chyPSPhFAvmJVmVL2t3lbA7SoBnWQvNtspHY8Xd8KNf-MUSuhHKXfrSRPwWC23D9qSxoUC0ubIINYBLD-WHYv_Yn7RBU7IQ4fzoLJrE6mUBz9tZ79drLOLd7vbe8MPpWJI-MHCTHD6XTMAWqd5q22EGAUa29XV4Jl4E6xZg8CybaOUOVpuia35UPLpCKK0wDofdAAUcPCo-hj7OH3U0XsCccF0GHfo7cqoYQanqfu7mypeGEf9_471KYQVNSlc1TGrrngY6_KRBMKDcx7fZne4ypsJfumhrpfbEkeltfwFsGVs1--2bFksLI8esRxR1qUHzT0.hCv29YrLBFcW8TjKwSmCXQ",
- "visible": false,
- },
- ],
-}
-`;
-
-exports[`idxResponseParser parseIdxResponse builds remediation functions for authenticator-verify-password 1`] = `
-Object {
- "accepts": "application/vnd.okta.v1+json",
- "action": undefined,
- "href": "http://localhost:3000/idp/idx/challenge/answer",
- "method": "POST",
- "name": "challenge-authenticator",
- "rel": Array [
- "create-form",
- ],
- "relatesTo": Object {
- "type": "object",
- "value": Object {
- "authenticatorId": "autwa6eD9o02iBbtv0g1",
- "displayName": "Okta Password",
- "id": "aidwboITrg4b4yAYd0g3",
- "profile": Object {
- "name": "Okta Password",
- },
- "recover": Object {
- "accepts": "application/vnd.okta.v1+json",
- "href": "http://localhost:3000/idp/idx/recover",
- "method": "POST",
- "name": "recover",
- "rel": Array [
- "create-form",
- ],
- "value": Array [
- Object {
- "mutable": false,
- "name":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j0R5Vc9dqDaR-Gbd2_gD2fx2v_LBxYntUDqzQLG3lPIvJlPVI9RzrdaRiABPTWEhf33xurBpbGXmpP2-t9Qckdc8TiIt7zS2vVUF3Sm_K-rlykotv07xUMnPkTz-yu0TyLUCzUojQ3xoaLIPQBRtKj7KK5r_il5atIHiabm-grb3S2s7bNEWpgDTmAxPOVKufQStpBXL8kghehLUHZ75ovoXeJqaQSDgncBk8GoP7XAgIBZuPjgYF30orMH14ttldEKFaO2gwGQQM8nnrKVwHbpyd32bwEyNyzIH-tnmVoXvU49nnzQNPlfS9S_-WeFI3OivdGbNFiITj-nKWPYiJWeXTfr4AYwDaEOGv0baV_zi3MMdptnT6I5TPjQEik5N5vDC8OJIhMsj9p9-7Gso13SNwr3i1ib0loQdnY7g6IuMuamlbZr-hhJESiOFKvSsVPqxnM3GXy5fichm7a188ihS8-SxTOznosdm3ftUOC1g7D4MzoRJbgA2E2PQCeyhxGYmdAaLRi3zt9iqcQYPvkEdiqHdKqTKArN-9JpsDuM7UM5lMkmmEgmi04PSVCqbAdw0z2cH3wU9705EyA0FA654wo-NaHhRrmup1LAFDPZg6NUW3X_C3jd6RkmPsjgVVm-H5YD9JsMqClcbzLEGz6SYtWyPDpPu0JH0GqOk-HHX8jfFZaRVM0ZnL0_BtU5G3B3OEyxMbl_yOQTdwMCT9Ete3Y1yAEUoJMyOwetCQRUdAH3DPHH3-4KAmJMaVMsMAI_h7DUwAvbUgiUKdr3g3an3vOxPtZI2apy9sv_Wj3DTJfwPm9axjK-laVNUKFnrweURmn4mRa74pWNf-CS1s9Izgg2yxY7fib9DlK6pkgC9nBGrpocMTJWFJI.N3s3-GTo9GSC0YG-MSmMfw",
- "visible": false,
- },
- ],
- },
- "type": "password",
- },
- },
- "value": Array [
- Object {
- "form": Object {
- "value": Array [
- Object {
- "label": "Password",
- "name": "passcode",
- "secret": true,
- },
- ],
- },
- "name": "credentials",
- },
- Object {
- "mutable": false,
- "name": "stateHandle",
- "required": true,
- "value": "eyJ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x2v_LBxYntUDqzQLG3lPIvJlPVI9RzrdaRiABPTWEhf33xurBpbGXmpP2-t9Qckdc8TiIt7zS2vVUF3Sm_K-rlykotv07xUMnPkTz-yu0TyLUCzUojQ3xoaLIPQBRtKj7KK5r_il5atIHiabm-grb3S2s7bNEWpgDTmAxPOVKufQStpBXL8kghehLUHZ75ovoXeJqaQSDgncBk8GoP7XAgIBZuPjgYF30orMH14ttldEKFaO2gwGQQM8nnrKVwHbpyd32bwEyNyzIH-tnmVoXvU49nnzQNPlfS9S_-WeFI3OivdGbNFiITj-nKWPYiJWeXTfr4AYwDaEOGv0baV_zi3MMdptnT6I5TPjQEik5N5vDC8OJIhMsj9p9-7Gso13SNwr3i1ib0loQdnY7g6IuMuamlbZr-hhJESiOFKvSsVPqxnM3GXy5fichm7a188ihS8-SxTOznosdm3ftUOC1g7D4MzoRJbgA2E2PQCeyhxGYmdAaLRi3zt9iqcQYPvkEdiqHdKqTKArN-9JpsDuM7UM5lMkmmEgmi04PSVCqbAdw0z2cH3wU9705EyA0FA654wo-NaHhRrmup1LAFDPZg6NUW3X_C3jd6RkmPsjgVVm-H5YD9JsMqClcbzLEGz6SYtWyPDpPu0JH0GqOk-HHX8jfFZaRVM0ZnL0_BtU5G3B3OEyxMbl_yOQTdwMCT9Ete3Y1yAEUoJMyOwetCQRUdAH3DPHH3-4KAmJMaVMsMAI_h7DUwAvbUgiUKdr3g3an3vOxPtZI2apy9sv_Wj3DTJfwPm9axjK-laVNUKFnrweURmn4mRa74pWNf-CS1s9Izgg2yxY7fib9DlK6pkgC9nBGrpocMTJWFJI.N3s3-GTo9GSC0YG-MSmMfw",
- "visible": false,
- },
- ],
-}
-`;
diff --git a/test/spec/idx/idx-js/unit/v1/actionParser.test.js b/test/spec/idx/idx-js/unit/v1/actionParser.test.js
deleted file mode 100644
index 4662c6605f..0000000000
--- a/test/spec/idx/idx-js/unit/v1/actionParser.test.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-import { divideActionParamsByMutability } from '../../../../../../lib/idx/idx-js/v1/actionParser';
-
-const mockIdxResponse = require('../../mocks/request-identifier');
-
-describe('actionParser', () => {
- describe('divideActionParamsByMutability', () => {
-
- it('parses and splits multiple remediations', async () => {
- const { defaultParams, neededParams, immutableParams } = divideActionParamsByMutability( mockIdxResponse.remediation.value );
-
- expect( defaultParams ).toEqual({
- identify: {},
- 'select-enroll-profile': {},
- });
-
- expect( neededParams ).toEqual([[{'label': 'Username', 'name': 'identifier'}], []]);
-
- expect( immutableParams ).toEqual({
- identify: {stateHandle: '02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw'},
- 'select-enroll-profile': {stateHandle: '02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw'},
- });
- });
-
- it('parses and splits a non-remediation', async () => {
- const { defaultParams, neededParams, immutableParams } = divideActionParamsByMutability( mockIdxResponse.cancel);
-
- expect( defaultParams.cancel ).toEqual({});
- expect( neededParams ).toEqual([[]]);
- expect( immutableParams.cancel ).toEqual({
- stateHandle: '02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw',
- });
- });
- });
-});
diff --git a/test/spec/idx/idx-js/unit/v1/generateIdxAction.test.js b/test/spec/idx/idx-js/unit/v1/generateIdxAction.test.js
deleted file mode 100644
index 775be6280f..0000000000
--- a/test/spec/idx/idx-js/unit/v1/generateIdxAction.test.js
+++ /dev/null
@@ -1,198 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-import generateIdxAction from '../../../../../../lib/idx/idx-js/v1/generateIdxAction';
-
-const mockIdxResponse = require('../../mocks/request-identifier');
-const mockPollingIdxResponse = require('../../mocks/poll-for-password');
-
-const { Response } = jest.requireActual('cross-fetch');
-
-const deepClone = ( target ) => JSON.parse(JSON.stringify( target ));
-const mockResponse = ( respondWith ) => Promise.resolve( new Response( JSON.stringify( respondWith) ) );
-
-// import targets for mockery
-import fetch from 'cross-fetch';
-import { makeIdxState } from '../../../../../../lib/idx/idx-js/v1/makeIdxState';
-
-jest.mock('cross-fetch');
-/*
- Doing a jest.mock('../../src/makeIdxState') has problems with jest.mock causing the test to hang
- and spikes up the CPU usage for the current node process.
- Alternative mocking approach: https://jestjs.io/docs/en/es6-class-mocks
-*/
-const mockMakeIdxState = jest.fn();
-jest.mock('../../../../../../lib/idx/idx-js/v1/makeIdxState', () => ({
- makeIdxState: jest.fn().mockImplementation(() => {
- return {makeIdxState: mockMakeIdxState};
- })
-}));
-
-describe('generateIdxAction', () => {
- it('builds a function', () => {
- const actionFunction = generateIdxAction(mockIdxResponse.remediation.value[0]);
- expect(typeof actionFunction).toBe('function');
- });
-
- it('returns a function that returns an idxState', async () => {
- fetch.mockImplementationOnce( () => mockResponse( mockIdxResponse ));
- makeIdxState.mockReturnValue('mock IdxState');
- const actionFunction = generateIdxAction(mockIdxResponse.remediation.value[0]);
- return actionFunction()
- .then( result => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'https://dev-550580.okta.com/idp/idx/identify' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"stateHandle":"02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw"}',
- credentials: 'include',
- headers: {
- 'content-type': 'application/json',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- expect( result ).toBe('mock IdxState');
- });
- });
-
- it('if toPersist.withCredentials is false, it will set credentials to "omit"', async () => {
- fetch.mockImplementationOnce( () => mockResponse( mockIdxResponse ));
- makeIdxState.mockReturnValue('mock IdxState');
- const actionFunction = generateIdxAction(mockIdxResponse.remediation.value[0], { withCredentials: false });
- return actionFunction()
- .then( result => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'https://dev-550580.okta.com/idp/idx/identify' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"stateHandle":"02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw"}',
- credentials: 'omit',
- headers: {
- 'content-type': 'application/json',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- expect( result ).toBe('mock IdxState');
- });
- });
-
- it('handles the status code for Okta device authentication', async () => {
- fetch.mockImplementationOnce( () => Promise.resolve( new Response(
- JSON.stringify( mockIdxResponse ),
- { status: 401, headers: { 'content-type': 'application/json', 'WWW-Authenticate': 'Oktadevicejwt realm="Okta Device"' } }
- )));
- makeIdxState.mockReturnValue({});
- const actionFunction = generateIdxAction(mockIdxResponse.remediation.value[0]);
- return actionFunction()
- .then( result => {
- expect( fetch.mock.calls.length ).toBe(1);
- expect( fetch.mock.calls[0][0] ).toEqual( 'https://dev-550580.okta.com/idp/idx/identify' );
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"stateHandle":"02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw"}',
- credentials: 'include',
- headers: {
- 'content-type': 'application/json',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- expect( result ).toEqual({stepUp: true});
- });
- });
-
- it('sends pre-filled default field values', async () => {
- fetch.mockImplementationOnce( () => mockResponse( mockIdxResponse ));
- makeIdxState.mockReturnValue('mock IdxState');
-
- const mockRemediationWithValue = deepClone(mockIdxResponse.remediation.value[0]);
- expect(mockRemediationWithValue.value[0].name).toBe('identifier');
- mockRemediationWithValue.value[0].value = 'A_DEFAULT';
-
- const actionFunction = generateIdxAction(mockRemediationWithValue);
- return actionFunction({ })
- .catch( result => {
- fail('mock fetch failed', result);
- })
- .then( () => {
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"identifier":"A_DEFAULT","stateHandle":"02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw"}',
- credentials: 'include',
- headers: {
- 'content-type': 'application/json',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- });
- });
-
- it('does not allow overridding immutable fields', async () => {
- fetch.mockImplementationOnce( () => mockResponse( mockIdxResponse ));
- makeIdxState.mockReturnValue('mock IdxState');
- const mockRemediationWithImmutableValue = deepClone(mockIdxResponse.remediation.value[0]);
- expect(mockRemediationWithImmutableValue.value[1].name).toBe('stateHandle');
- expect(mockRemediationWithImmutableValue.value[1].mutable).toBe(false);
-
- const actionFunction = generateIdxAction(mockRemediationWithImmutableValue);
- return actionFunction({ stateHandle: 'SHOULD_NOT_CHANGE' })
- .catch( result => {
- fail('mock fetch failed', result);
- })
- .then( () => {
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"stateHandle":"02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw"}',
- credentials: 'include',
- headers: {
- 'content-type': 'application/json',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- });
- });
-
- it('does allow overridding mutable values', async () => {
- fetch.mockImplementationOnce( () => mockResponse( mockIdxResponse ));
- makeIdxState.mockReturnValue('mock IdxState');
-
- const mockRemediationWithMutableValue = JSON.parse(JSON.stringify(mockIdxResponse.remediation.value[0]));
- expect(mockRemediationWithMutableValue.value[0].name).toBe('identifier');
- expect(mockRemediationWithMutableValue.value[0].mutable).not.toBe(false);
- mockRemediationWithMutableValue.value[0].value = 'SHOULD_CHANGE';
-
- const actionFunction = generateIdxAction(mockRemediationWithMutableValue);
- return actionFunction({ identifier: 'WAS_CHANGED' })
- .catch( result => {
- fail('mock fetch failed', result);
- })
- .then( () => {
- expect( fetch.mock.calls[0][1] ).toEqual( {
- body: '{"identifier":"WAS_CHANGED","stateHandle":"02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw"}',
- credentials: 'include',
- headers: {
- 'content-type': 'application/json',
- 'accept': 'application/ion+json; okta-version=1.0.0',
- },
- method: 'POST'
- });
- });
- });
-
-
- // TODO: Conditions to decide if polling is finished are being discussed
- // eslint-disable-next-line jasmine/no-disabled-tests
- xit('generates a polling function when appropriate', () => {
- generateIdxAction( mockPollingIdxResponse.factor.value.poll );
- fail('not done yet');
- });
-});
diff --git a/test/spec/idx/idx-js/unit/v1/idxResponseParser.test.js b/test/spec/idx/idx-js/unit/v1/idxResponseParser.test.js
deleted file mode 100644
index fc0c785098..0000000000
--- a/test/spec/idx/idx-js/unit/v1/idxResponseParser.test.js
+++ /dev/null
@@ -1,168 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-import { parseNonRemediations, parseIdxResponse } from '../../../../../../lib/idx/idx-js/v1/idxResponseParser';
-
-const mockIdxResponse = require('../../mocks/challenge-password');
-const mockAuthenticatorVerificationSelectAuthenticator = require('../../mocks/authenticator-verification-select-authenticator');
-const mockAuthenticatorVerificationPassword = require('../../mocks/authenticator-verification-password');
-const mockSmallIdxResponse = require('../../mocks/request-identifier');
-const mockComplexContextIdxResponse = require('../../mocks/poll-for-password');
-const mockTerminalIdxResponse = require('../../mocks/terminal-return-email');
-const mockMessageIdxResponse = require('../../mocks/unknown-user');
-const mockSuccessIdxResponse = require('../../mocks/success');
-
-jest.mock('../../../../../../lib/idx/idx-js/v1/generateIdxAction');
-jest.mock('../../../../../../lib/idx/idx-js/v1/remediationParser');
-jest.mock('../../../../../../lib/idx/idx-js/v1/actionParser');
-
-// imports to target for mockery
-import { generateRemediationFunctions } from '../../../../../../lib/idx/idx-js/v1/remediationParser';
-import { divideActionParamsByMutability } from '../../../../../../lib/idx/idx-js/v1/actionParser';
-import generateIdxAction from '../../../../../../lib/idx/idx-js/v1/generateIdxAction';
-
-generateIdxAction.mockReturnValue('generated function');
-generateRemediationFunctions.mockReturnValue('generated collection of functions');
-divideActionParamsByMutability.mockReturnValue( { defaultParams: 'defaultParams', neededParams: 'neededParams', immutableParams: 'immutableParams'});
-
-describe('idxResponseParser', () => {
- describe('parseNonRemediations', () => {
-
- it('copies simple context items', () => {
- const { context } = parseNonRemediations( mockIdxResponse );
- expect( context ).toEqual({
- expiresAt: mockIdxResponse.expiresAt,
- step: mockIdxResponse.step,
- intent: mockIdxResponse.intent,
- user: mockIdxResponse.user,
- stateHandle: mockIdxResponse.stateHandle,
- version: '1.0.0',
- factor: {
- type: 'object',
- value: {
- factorId: '00u1wlnlh2x3sQemR357',
- factorProfileId: 'fpr1w2vlszZt2g3E4357',
- factorType: 'password',
- },
- },
- });
- });
-
- it('copies terminal messages', () => {
- const { context } = parseNonRemediations( mockTerminalIdxResponse );
- expect( context.terminal ).toEqual( mockTerminalIdxResponse.terminal );
- });
-
- it('copies non-terminal messages', () => {
- const { context } = parseNonRemediations( mockMessageIdxResponse );
- expect( context.messages ).toEqual( mockMessageIdxResponse.messages );
- });
-
- it('copies token info', () => {
- const { context } = parseNonRemediations( mockSuccessIdxResponse );
- expect( context.success ).toMatchObject( mockSuccessIdxResponse.success );
- });
-
- it('handles missing simple context items', () => {
- const { context } = parseNonRemediations( mockSmallIdxResponse );
- expect(mockSmallIdxResponse.user).not.toBeDefined();
- expect(context.user).not.toBeDefined();
- });
-
- it('translates simple actions', () => {
- const { actions } = parseNonRemediations( mockIdxResponse );
- expect( actions.cancel ).toBe('generated function');
- });
-
- it('pulls apart complicated actions/context', () => {
- const { context, actions } = parseNonRemediations( mockIdxResponse );
- expect( actions['factor-recover'] ).toBe('generated function');
- expect( context.factor ).toStrictEqual({
- type: 'object',
- value: {
- factorId: '00u1wlnlh2x3sQemR357',
- factorProfileId: 'fpr1w2vlszZt2g3E4357',
- factorType: 'password'
- }
- });
- });
-
- it('handles multiple actions in a complex context field', () => {
- const { context, actions } = parseNonRemediations( mockComplexContextIdxResponse );
- expect( actions['factor-send'] ).toBe('generated function');
- expect( actions['factor-poll'] ).toBe('generated function');
- expect( context.factor ).toStrictEqual({
- type: 'object',
- value: {
- factorId: 'emf2a6n2omrZ7Abnt357',
- factorProfileId: 'fpr1w2vlstxSAQsHZ357',
- factorType: 'email',
- profile: {
- email: 'test.idx@swiftone.org',
- },
- }
- });
- });
- });
-
- describe('parseIdxResponse', () => {
-
- it('builds remediation functions', () => {
- const { remediations } = parseIdxResponse( mockIdxResponse );
- expect( generateRemediationFunctions.mock.calls.length ).toBe(1);
- expect( generateRemediationFunctions.mock.calls[0] ).toMatchObject( [mockIdxResponse.remediation.value, {}] );
- expect( remediations[0].name ).toBe('challenge-factor');
- expect( remediations[0].href ).toBe('https://dev-550580.okta.com/idp/idx/challenge/answer');
- expect( remediations[0].method ).toBe('POST');
- });
-
- it('builds context and actions', () => {
- const { context, actions } = parseIdxResponse( mockIdxResponse );
- expect( context ).toStrictEqual({
- expiresAt: mockIdxResponse.expiresAt,
- step: mockIdxResponse.step,
- intent: mockIdxResponse.intent,
- user: mockIdxResponse.user,
- factor: {
- type: 'object',
- value: {
- factorType: mockIdxResponse.factor.value.factorType,
- factorProfileId: mockIdxResponse.factor.value.factorProfileId,
- factorId: mockIdxResponse.factor.value.factorId,
- }
- },
- stateHandle: mockIdxResponse.stateHandle,
- version: mockIdxResponse.version,
- });
- expect( actions.cancel ).toBe('generated function');
- });
-
- it('builds remediation for authenticator-verify-select-authenticator', () => {
- const toPersist = {};
- const { remediations } = parseIdxResponse( mockAuthenticatorVerificationSelectAuthenticator, toPersist );
- expect( generateRemediationFunctions.mock.calls.length ).toBe(1);
- expect( generateRemediationFunctions.mock.calls[0] ).toMatchObject( [ mockAuthenticatorVerificationSelectAuthenticator.remediation.value, toPersist ] );
- expect( remediations[0] ).toMatchSnapshot();
- });
-
- it('builds remediation functions for authenticator-verify-password', () => {
- const toPersist = {};
- const { remediations } = parseIdxResponse( mockAuthenticatorVerificationPassword, toPersist );
- expect( generateRemediationFunctions.mock.calls.length ).toBe(2);
- expect( generateRemediationFunctions.mock.calls[0] ).toMatchObject( [ [mockAuthenticatorVerificationPassword.remediation.value[0]], toPersist ] );
- expect( generateRemediationFunctions.mock.calls[1] ).toMatchObject( [ [mockAuthenticatorVerificationPassword.remediation.value[1]], toPersist ] );
- expect( remediations[0]).toMatchSnapshot();
- });
-
- });
-});
diff --git a/test/spec/idx/idx-js/unit/v1/makeIdxState.test.js b/test/spec/idx/idx-js/unit/v1/makeIdxState.test.js
deleted file mode 100644
index 1e6479fbef..0000000000
--- a/test/spec/idx/idx-js/unit/v1/makeIdxState.test.js
+++ /dev/null
@@ -1,196 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-import { makeIdxState } from '../../../../../../lib/idx/idx-js/v1/makeIdxState';
-const mockIdxResponse = require('../../mocks/request-identifier');
-const mockIdxResponseWithIdps = require('../../mocks/request-identifier-with-idps');
-
-jest.mock('cross-fetch');
-import fetch from 'cross-fetch'; // import to target for mockery
-const { Response } = jest.requireActual('cross-fetch');
-
-const setFetchMock = (mock) =>
- fetch.mockImplementation(() =>
- Promise.resolve(new Response(JSON.stringify(mock)))
- );
-
-describe('makeIdxState', () => {
- it('returns an idxState', () => {
- setFetchMock(mockIdxResponse);
- const idxState = makeIdxState(mockIdxResponse);
- expect(idxState).toBeDefined();
- expect(idxState.context).toBeDefined();
- expect(typeof idxState.proceed).toBe('function');
- expect(typeof idxState.actions.cancel).toBe('function');
- expect(idxState.rawIdxState).toEqual(mockIdxResponse);
- });
-
- it('populates neededToProceed with Ion data', () => {
- setFetchMock(mockIdxResponse);
- const idxState = makeIdxState(mockIdxResponse);
- expect(typeof idxState.neededToProceed[0].action).toBe('function');
- expect(idxState.neededToProceed[0].value).toEqual([
- { label: 'Username', name: 'identifier' },
- {
- name: 'stateHandle',
- required: true,
- value: '02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw',
- visible: false,
- mutable: false,
- },
- ]);
- expect(idxState.neededToProceed[0].method).toBe('POST');
- expect(idxState.neededToProceed[0].name).toBe('identify');
- });
-
- it('populates neededToProceed with redirect remediation objects and Ion data', () => {
- setFetchMock(mockIdxResponseWithIdps);
- const idxState = makeIdxState(mockIdxResponseWithIdps);
- expect(idxState.neededToProceed.length).toBe(4);
-
- expect(typeof idxState.neededToProceed[0].action).toBe('function');
- expect(idxState.neededToProceed[0].value).toEqual([
- { label: 'Username', name: 'identifier' },
- {
- name: 'stateHandle',
- required: true,
- value: '02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw',
- visible: false,
- mutable: false,
- },
- ]);
- expect(idxState.neededToProceed[0].method).toBe('POST');
- expect(idxState.neededToProceed[0].name).toBe('identify');
-
- expect(idxState.neededToProceed[1]).toMatchInlineSnapshot(
- `
- Object {
- "action": [Function],
- "href": "https://dev-550580.okta.com/sso/idps/0oa2sykfl6Fnb9ZMN0g4?stateToken=02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "idp": Object {
- "id": "0oa2sykfl6Fnb9ZMN0g4",
- "name": "Google IDP",
- },
- "method": "GET",
- "name": "redirect-idp",
- "type": "GOOGLE",
- }
- `
- );
-
- expect(idxState.neededToProceed[2]).toMatchInlineSnapshot(
- `
- Object {
- "action": [Function],
- "href": "https://dev-550580.okta.com/sso/idps/0oa2szc1K1YPgz1pe0g4?stateToken=02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw",
- "idp": Object {
- "id": "0oa2szc1K1YPgz1pe0g4",
- "name": "Facebook IDP",
- },
- "method": "GET",
- "name": "redirect-idp",
- "type": "FACEBOOK",
- }
- `
- );
-
- expect(typeof idxState.neededToProceed[3].action).toBe('function');
- expect(idxState.neededToProceed[3].value).toEqual([
- {
- name: 'stateHandle',
- required: true,
- value: '02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw',
- visible: false,
- mutable: false,
- },
- ]);
- expect(idxState.neededToProceed[3].method).toBe('POST');
- expect(idxState.neededToProceed[3].name).toBe('select-enroll-profile');
- });
-
- it('populates proceed to run remediation functions', () => {
- setFetchMock(mockIdxResponse);
- const idxState = makeIdxState(mockIdxResponse);
- expect(typeof idxState.proceed).toBe('function');
- });
-
- describe('idxState.proceed', () => {
- it('rejects if called with an invalid remediationChoice', async () => {
- setFetchMock(mockIdxResponse);
- const idxState = makeIdxState(mockIdxResponse);
- return idxState
- .proceed('DOES_NOT_EXIST')
- .then(() => {
- fail('expected idxState.proceed to reject');
- })
- .catch((err) => {
- expect(err).toBe('Unknown remediation choice: [DOES_NOT_EXIST]');
- });
- });
-
- it('returns a new idxState', async () => {
- setFetchMock(mockIdxResponse);
- const idxState = makeIdxState(mockIdxResponse);
- const mockFollowup = { ...mockIdxResponse, remediations: [] };
- setFetchMock(mockFollowup);
- return idxState
- .proceed('identify')
- .then((result) => {
- expect(result.neededToProceed[0].value).toEqual([
- {
- label: 'Username',
- name: 'identifier',
- },
- {
- name: 'stateHandle',
- required: true,
- value: '02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw',
- visible: false,
- mutable: false,
- },
- ]);
- expect(result.context).toBeDefined();
- expect(typeof result.proceed).toBe('function');
- expect(typeof result.actions.cancel).toBe('function');
- })
- .finally(() => {
- setFetchMock(mockIdxResponse); // test cleanup
- });
- });
- });
-
- describe('idxState.actions', () => {
- it('return a new idxState', async () => {
- setFetchMock(mockIdxResponse);
- const idxState = makeIdxState(mockIdxResponse);
- return idxState.actions.cancel().then((result) => {
- // Note: cancel won't return this data
- // this is verifying the parsing happens on mock data
- expect(result.rawIdxState.cancel).toBeDefined();
- expect(result.rawIdxState.cancel.name).toEqual('cancel');
- expect(result.rawIdxState.cancel.href).toEqual(
- 'https://dev-550580.okta.com/idp/idx/cancel'
- );
- expect(result.rawIdxState.cancel.value).toEqual([
- {
- name: 'stateHandle',
- required: true,
- value: '02Yi84bXNZ3STdPKisJIV0vQ7pY4hkyFHs6a9c12Fw',
- visible: false,
- mutable: false,
- },
- ]);
- });
- });
- });
-});
diff --git a/test/spec/idx/idx-js/unit/v1/remediationParser.test.js b/test/spec/idx/idx-js/unit/v1/remediationParser.test.js
deleted file mode 100644
index 39de77a520..0000000000
--- a/test/spec/idx/idx-js/unit/v1/remediationParser.test.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/*!
- * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
- *
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and limitations under the License.
- */
-
-
-import { generateRemediationFunctions } from '../../../../../../lib/idx/idx-js/v1/remediationParser';
-
-// imports to target for mockery
-import fetch from 'cross-fetch';
-import generateIdxAction from '../../../../../../lib/idx/idx-js/v1/generateIdxAction';
-
-jest.mock('cross-fetch');
-/*
- Doing a jest.mock('../../src/generateIdxAction') has problems with jest.mock causing the test to hang
- and spikes up the CPU usage for the current node process.
- Alternative mocking approach: https://jestjs.io/docs/en/es6-class-mocks
-*/
-const mockGenerateIdxAction = jest.fn();
-jest.mock('../../../../../../lib/idx/idx-js/v1/generateIdxAction', () => {
- return jest.fn().mockImplementation(() => {
- return {generateIdxAction: mockGenerateIdxAction};
- });
-});
-
-const { Response } = jest.requireActual('cross-fetch');
-const mockRequestIdentity = require('../../mocks/request-identifier');
-const mockIdxResponse = mockRequestIdentity;
-
-fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockRequestIdentity )) ) );
-generateIdxAction.mockImplementation( () => 'generated');
-
-describe('remediationParser', () => {
-
- describe('generateRemediationFunctions', () => {
-
- it('builds a collection of generated functions', async () => {
- const toPersist = {};
- const remediationFunctions = generateRemediationFunctions(mockIdxResponse.remediation.value);
- expect( Object.keys(remediationFunctions) ).toEqual( ['identify', 'select-enroll-profile'] );
- expect(generateIdxAction.mock.calls[0]).toEqual([mockIdxResponse.remediation.value[0], toPersist]);
- expect(generateIdxAction.mock.calls[1]).toEqual([mockIdxResponse.remediation.value[1], toPersist]);
- expect(remediationFunctions['identify']).toBe('generated');
- expect(remediationFunctions['select-enroll-profile']).toBe('generated');
- });
-
- });
-
-});
-
diff --git a/test/spec/idx/idxState/unit/v1/remediationParser.test.js b/test/spec/idx/idxState/unit/v1/remediationParser.test.js
index 39de77a520..4a453db01c 100644
--- a/test/spec/idx/idxState/unit/v1/remediationParser.test.js
+++ b/test/spec/idx/idxState/unit/v1/remediationParser.test.js
@@ -11,34 +11,45 @@
*/
-import { generateRemediationFunctions } from '../../../../../../lib/idx/idx-js/v1/remediationParser';
+import { generateRemediationFunctions } from '../../../../../../lib/idx/idxState/v1/remediationParser';
// imports to target for mockery
-import fetch from 'cross-fetch';
-import generateIdxAction from '../../../../../../lib/idx/idx-js/v1/generateIdxAction';
+import generateIdxAction from '../../../../../../lib/idx/idxState/v1/generateIdxAction';
-jest.mock('cross-fetch');
+jest.mock('../../../../../../lib/http', () => {
+ const actual = jest.requireActual('../../../../../../lib/http');
+ return {
+ ...actual,
+ httpRequest: () => {}
+ };
+});
/*
Doing a jest.mock('../../src/generateIdxAction') has problems with jest.mock causing the test to hang
and spikes up the CPU usage for the current node process.
Alternative mocking approach: https://jestjs.io/docs/en/es6-class-mocks
*/
const mockGenerateIdxAction = jest.fn();
-jest.mock('../../../../../../lib/idx/idx-js/v1/generateIdxAction', () => {
+jest.mock('../../../../../../lib/idx/idxState/v1/generateIdxAction', () => {
return jest.fn().mockImplementation(() => {
return {generateIdxAction: mockGenerateIdxAction};
});
});
-const { Response } = jest.requireActual('cross-fetch');
const mockRequestIdentity = require('../../mocks/request-identifier');
const mockIdxResponse = mockRequestIdentity;
-fetch.mockImplementation( () => Promise.resolve( new Response(JSON.stringify( mockRequestIdentity )) ) );
+const mocked = {
+ http: require('../../../../../../lib/http')
+};
+
generateIdxAction.mockImplementation( () => 'generated');
describe('remediationParser', () => {
+ beforeEach(() => {
+ jest.spyOn(mocked.http, 'httpRequest').mockResolvedValue(mockRequestIdentity);
+ });
+
describe('generateRemediationFunctions', () => {
it('builds a collection of generated functions', async () => {