@rockcarver/frodo-lib 0.17.3 → 0.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/cjs/api/Saml2Api.js +36 -14
- package/cjs/api/Saml2Api.js.map +1 -1
- package/cjs/api/ScriptApi.js +23 -2
- package/cjs/api/ScriptApi.js.map +1 -1
- package/cjs/ops/IdpOps.js +3 -3
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/JourneyOps.js +49 -35
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/JourneyOps.test.js.map +1 -1
- package/cjs/ops/OpsTypes.js.map +1 -1
- package/cjs/ops/Saml2Ops.js +104 -57
- package/cjs/ops/Saml2Ops.js.map +1 -1
- package/cjs/ops/Saml2Ops.test.js.map +1 -1
- package/cjs/ops/ScriptOps.js +193 -186
- package/cjs/ops/ScriptOps.js.map +1 -1
- package/cjs/ops/ScriptOps.test.js.map +1 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +5 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney1.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney2.journey.json +76 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney3.journey.json +873 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney4.journey.json +930 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney5.journey.json +873 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney6.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney7.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney8.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney9.journey.json +148 -0
- package/esm/api/Saml2Api.mjs +17 -1
- package/esm/api/ScriptApi.mjs +17 -2
- package/esm/ops/IdpOps.mjs +4 -4
- package/esm/ops/JourneyOps.mjs +30 -21
- package/esm/ops/JourneyOps.test.mjs +220 -246
- package/esm/ops/Saml2Ops.mjs +66 -31
- package/esm/ops/Saml2Ops.test.mjs +399 -333
- package/esm/ops/ScriptOps.mjs +148 -152
- package/esm/ops/ScriptOps.test.mjs +282 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +4 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney1.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney2.journey.json +76 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney3.journey.json +873 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney4.journey.json +930 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney5.journey.json +873 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney6.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney7.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney8.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney9.journey.json +148 -0
- package/package.json +10 -2
- package/types/api/Saml2Api.d.ts +8 -1
- package/types/api/Saml2Api.d.ts.map +1 -1
- package/types/api/ScriptApi.d.ts +7 -1
- package/types/api/ScriptApi.d.ts.map +1 -1
- package/types/ops/IdpOps.d.ts.map +1 -1
- package/types/ops/JourneyOps.d.ts +17 -3
- package/types/ops/JourneyOps.d.ts.map +1 -1
- package/types/ops/OpsTypes.d.ts +1 -1
- package/types/ops/OpsTypes.d.ts.map +1 -1
- package/types/ops/Saml2Ops.d.ts +24 -12
- package/types/ops/Saml2Ops.d.ts.map +1 -1
- package/types/ops/ScriptOps.d.ts +56 -20
- package/types/ops/ScriptOps.d.ts.map +1 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
package/esm/ops/JourneyOps.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import { convertBase64TextToArray, getTypedFilename, convertTextArrayToBase64, convertTextArrayToBase64Url, findFilesByName } from './utils/ExportImportUtils';
|
|
4
|
+
import { convertBase64TextToArray, getTypedFilename, convertTextArrayToBase64, convertTextArrayToBase64Url, findFilesByName, getMetadata } from './utils/ExportImportUtils';
|
|
5
5
|
import { getRealmManagedUser, replaceAll } from './utils/OpsUtils';
|
|
6
6
|
import * as state from '../shared/State';
|
|
7
7
|
import { getNode, putNode, deleteNode, getNodeTypes, getNodesByType } from '../api/NodeApi';
|
|
@@ -16,7 +16,7 @@ import { createCircleOfTrust, getCirclesOfTrust, updateCircleOfTrust } from '../
|
|
|
16
16
|
import { decode, encode, encodeBase64Url, isBase64Encoded } from '../api/utils/Base64';
|
|
17
17
|
import { getSocialIdentityProviders, putProviderByTypeAndId } from '../api/SocialIdentityProvidersApi';
|
|
18
18
|
import { getThemes, putThemes } from './ThemeOps';
|
|
19
|
-
import {
|
|
19
|
+
import { putScript } from './ScriptOps';
|
|
20
20
|
import { JourneyClassification } from './OpsTypes';
|
|
21
21
|
const containerNodes = ['PageNode', 'CustomPageNode'];
|
|
22
22
|
const scriptedNodes = ['ConfigProviderNode', 'ScriptedDecisionNode', 'ClientScriptNode', 'SocialProviderHandlerNode', 'CustomScriptNode'];
|
|
@@ -29,7 +29,7 @@ const emptyScriptPlaceholder = '[Empty]';
|
|
|
29
29
|
*/
|
|
30
30
|
export function createSingleTreeExportTemplate() {
|
|
31
31
|
return {
|
|
32
|
-
meta:
|
|
32
|
+
meta: getMetadata(),
|
|
33
33
|
innerNodes: {},
|
|
34
34
|
nodes: {},
|
|
35
35
|
scripts: {},
|
|
@@ -48,7 +48,7 @@ export function createSingleTreeExportTemplate() {
|
|
|
48
48
|
*/
|
|
49
49
|
export function createMultiTreeExportTemplate() {
|
|
50
50
|
return {
|
|
51
|
-
meta:
|
|
51
|
+
meta: getMetadata(),
|
|
52
52
|
trees: {}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
@@ -403,21 +403,28 @@ export async function exportJourney(treeId, options = {
|
|
|
403
403
|
* @returns {Promise<TreeSkeleton[]>} a promise that resolves to an array of journey objects
|
|
404
404
|
*/
|
|
405
405
|
export async function getJourneys() {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
406
|
+
const {
|
|
407
|
+
result
|
|
408
|
+
} = await getTrees();
|
|
409
|
+
result.sort((a, b) => a._id.localeCompare(b._id));
|
|
410
|
+
return result;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Get a journey/tree without all its nodes and dependencies.
|
|
415
|
+
* @param {string} journeyId journey id/name
|
|
416
|
+
* @returns {Promise<TreeSkeleton>} a promise that resolves to a journey object
|
|
417
|
+
*/
|
|
418
|
+
export async function getJourney(journeyId) {
|
|
419
|
+
const response = await getTree(journeyId);
|
|
420
|
+
return response;
|
|
415
421
|
}
|
|
416
422
|
|
|
417
423
|
/**
|
|
418
424
|
* Helper to import a tree with all dependencies from a `SingleTreeExportInterface` object (typically read from a file)
|
|
419
425
|
* @param {SingleTreeExportInterface} treeObject tree object containing tree and all its dependencies
|
|
420
426
|
* @param {TreeImportOptions} options import options
|
|
427
|
+
* @returns {Promise<boolean>} a promise that resolves to true if no errors occurred during import
|
|
421
428
|
*/
|
|
422
429
|
export async function importJourney(treeObject, options) {
|
|
423
430
|
const {
|
|
@@ -441,8 +448,10 @@ export async function importJourney(treeObject, options) {
|
|
|
441
448
|
} else if (!isBase64Encoded(scriptObject['script'])) {
|
|
442
449
|
scriptObject['script'] = encode(JSON.parse(scriptObject['script']));
|
|
443
450
|
}
|
|
444
|
-
|
|
445
|
-
|
|
451
|
+
try {
|
|
452
|
+
await putScript(scriptId, scriptObject);
|
|
453
|
+
} catch (error) {
|
|
454
|
+
throw new Error(`Error importing script ${scriptObject['name']} (${scriptId}) in journey ${treeId}: ${error.message}`);
|
|
446
455
|
}
|
|
447
456
|
if (verbose) printMessage('');
|
|
448
457
|
}
|
|
@@ -741,6 +750,7 @@ export async function importJourney(treeObject, options) {
|
|
|
741
750
|
throw new Error(`\nError importing journey flow ${treeId}`);
|
|
742
751
|
}
|
|
743
752
|
}
|
|
753
|
+
return true;
|
|
744
754
|
}
|
|
745
755
|
|
|
746
756
|
/**
|
|
@@ -1130,13 +1140,12 @@ export function getJourneyClassification(journey) {
|
|
|
1130
1140
|
* @param {string} journeyId journey id/name
|
|
1131
1141
|
* @param {Object} options deep=true also delete all the nodes and inner nodes, verbose=true print verbose info
|
|
1132
1142
|
*/
|
|
1133
|
-
export async function deleteJourney(journeyId, options
|
|
1134
|
-
const {
|
|
1135
|
-
deep
|
|
1136
|
-
} = options;
|
|
1143
|
+
export async function deleteJourney(journeyId, options) {
|
|
1137
1144
|
const {
|
|
1145
|
+
deep,
|
|
1138
1146
|
verbose
|
|
1139
1147
|
} = options;
|
|
1148
|
+
const progress = !('progress' in options) ? true : options.progress;
|
|
1140
1149
|
const status = {
|
|
1141
1150
|
nodes: {}
|
|
1142
1151
|
};
|
|
@@ -1252,8 +1261,8 @@ export async function deleteJourneys(options) {
|
|
|
1252
1261
|
createProgressIndicator(trees.length, 'Deleting journeys...');
|
|
1253
1262
|
for (const tree of trees) {
|
|
1254
1263
|
if (verbose) printMessage('');
|
|
1255
|
-
|
|
1256
|
-
status[tree._id] = await deleteJourney(tree._id, options
|
|
1264
|
+
options['progress'] = false;
|
|
1265
|
+
status[tree._id] = await deleteJourney(tree._id, options);
|
|
1257
1266
|
updateProgressIndicator(`${tree._id}`);
|
|
1258
1267
|
// introduce a 100ms wait to allow the progress bar to update before the next verbose message prints from the async function
|
|
1259
1268
|
if (verbose)
|
|
@@ -1,251 +1,225 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* To record and update snapshots, you must perform 3 steps in order:
|
|
3
|
+
*
|
|
4
|
+
* 1. Record API responses & update ESM snapshots
|
|
5
|
+
*
|
|
6
|
+
* This step breaks down into 4 phases:
|
|
7
|
+
*
|
|
8
|
+
* Phase 1: Record Non-destructive tests
|
|
9
|
+
* Phase 2: Record Group 1 of DESTRUCTIVE tests - Deletes by ID
|
|
10
|
+
* Phase 3: Record Group 2 of DESTRUCTIVE tests - Deletes by tag
|
|
11
|
+
* Phase 4: Record Group 3 of DESTRUCTIVE tests - Delete all
|
|
12
|
+
*
|
|
13
|
+
* Because destructive tests interfere with the recording of non-destructive
|
|
14
|
+
* tests and also interfere among themselves, they have to be run in groups
|
|
15
|
+
* of non-interfering tests.
|
|
16
|
+
*
|
|
17
|
+
* To record and update ESM snapshots, you must call the test:record
|
|
18
|
+
* script and override all the connection state variables required
|
|
19
|
+
* to connect to the env to record from and also indicate the phase:
|
|
20
|
+
*
|
|
21
|
+
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=1 FRODO_HOST=frodo-dev npm run test:record JourneyOps
|
|
22
|
+
*
|
|
23
|
+
* THESE TESTS ARE DESTRUCTIVE!!! DO NOT RUN AGAINST AN ENV WITH ACTIVE AGENTS!!!
|
|
24
|
+
*
|
|
25
|
+
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=2 FRODO_HOST=frodo-dev npm run test:record JourneyOps
|
|
26
|
+
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=3 FRODO_HOST=frodo-dev npm run test:record JourneyOps
|
|
27
|
+
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=4 FRODO_HOST=frodo-dev npm run test:record JourneyOps
|
|
28
|
+
*
|
|
29
|
+
* The above command assumes that you have a connection profile for
|
|
30
|
+
* 'frodo-dev' on your development machine.
|
|
31
|
+
*
|
|
32
|
+
* 2. Update CJS snapshots
|
|
33
|
+
*
|
|
34
|
+
* After recording, the ESM snapshots will already be updated as that happens
|
|
35
|
+
* in one go, but you must manually update the CJS snapshots by running:
|
|
36
|
+
*
|
|
37
|
+
* FRODO_DEBUG=1 npm run test:update JourneyOps
|
|
38
|
+
*
|
|
39
|
+
* 3. Test your changes
|
|
40
|
+
*
|
|
41
|
+
* If 1 and 2 didn't produce any errors, you are ready to run the tests in
|
|
42
|
+
* replay mode and make sure they all succeed as well:
|
|
43
|
+
*
|
|
44
|
+
* npm run test:only JourneyOps
|
|
45
|
+
*
|
|
46
|
+
* Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
|
|
47
|
+
* in case things don't function as expected
|
|
48
|
+
*/
|
|
49
|
+
import { jest } from '@jest/globals';
|
|
3
50
|
import { Journey, state } from '../index';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
state.setDeploymentType(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
51
|
+
import { getJourney } from '../test/mocks/ForgeRockApiMockEngine';
|
|
52
|
+
import { autoSetupPolly } from '../utils/AutoSetupPolly';
|
|
53
|
+
import * as globalConfig from '../storage/StaticStorage';
|
|
54
|
+
|
|
55
|
+
// Increase timeout for this test as pipeline keeps failing with error:
|
|
56
|
+
// Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
|
|
57
|
+
jest.setTimeout(30000);
|
|
58
|
+
autoSetupPolly();
|
|
59
|
+
state.setDeploymentType(globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY);
|
|
60
|
+
async function stageJourney(journey, create = true) {
|
|
61
|
+
// delete if exists, then create
|
|
62
|
+
try {
|
|
63
|
+
await Journey.getJourney(journey.id);
|
|
64
|
+
await Journey.deleteJourney(journey.id, {
|
|
65
|
+
deep: true,
|
|
66
|
+
verbose: false,
|
|
67
|
+
progress: false
|
|
68
|
+
});
|
|
69
|
+
} catch (error) {
|
|
70
|
+
// ignore
|
|
71
|
+
} finally {
|
|
72
|
+
if (create) {
|
|
73
|
+
await Journey.importJourney(getJourney(journey.id), {
|
|
74
|
+
reUuid: false,
|
|
75
|
+
deps: true
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
describe('JourneyOps', () => {
|
|
81
|
+
const journey1 = {
|
|
82
|
+
id: 'FrodoTestJourney1'
|
|
83
|
+
};
|
|
84
|
+
const journey2 = {
|
|
85
|
+
id: 'FrodoTestJourney2'
|
|
86
|
+
};
|
|
87
|
+
const journey3 = {
|
|
88
|
+
id: 'FrodoTestJourney3'
|
|
89
|
+
};
|
|
90
|
+
const journey4 = {
|
|
91
|
+
id: 'FrodoTestJourney4'
|
|
92
|
+
};
|
|
93
|
+
const journey5 = {
|
|
94
|
+
id: 'FrodoTestJourney5'
|
|
95
|
+
};
|
|
96
|
+
const journey6 = {
|
|
97
|
+
id: 'FrodoTestJourney6'
|
|
98
|
+
};
|
|
99
|
+
const journey7 = {
|
|
100
|
+
id: 'FrodoTestJourney7'
|
|
101
|
+
};
|
|
102
|
+
const journey8 = {
|
|
103
|
+
id: 'FrodoTestJourney8'
|
|
104
|
+
};
|
|
105
|
+
const journey9 = {
|
|
106
|
+
id: 'FrodoTestJourney9'
|
|
107
|
+
};
|
|
108
|
+
// in recording mode, setup test data before recording
|
|
109
|
+
beforeAll(async () => {
|
|
110
|
+
if (process.env.FRODO_POLLY_MODE === 'record') {
|
|
111
|
+
await stageJourney(journey1);
|
|
112
|
+
await stageJourney(journey2);
|
|
113
|
+
await stageJourney(journey3);
|
|
114
|
+
await stageJourney(journey4, false);
|
|
115
|
+
await stageJourney(journey5, false);
|
|
116
|
+
await stageJourney(journey6);
|
|
117
|
+
await stageJourney(journey7);
|
|
118
|
+
await stageJourney(journey8);
|
|
119
|
+
await stageJourney(journey9);
|
|
120
|
+
}
|
|
16
121
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
mockGetTree(mock);
|
|
31
|
-
mockGetNode(mock);
|
|
32
|
-
const treeId = 'FrodoTest';
|
|
33
|
-
const treeObject = getTree(treeId);
|
|
34
|
-
expect.assertions(24);
|
|
35
|
-
const journeyExport = await Journey.exportJourney(treeId, {
|
|
36
|
-
useStringArrays: false,
|
|
37
|
-
deps: false
|
|
38
|
-
});
|
|
39
|
-
expect(journeyExport).toBeTruthy();
|
|
40
|
-
expect(journeyExport.tree['_id']).toBe(treeId);
|
|
41
|
-
expect(journeyExport.tree).toStrictEqual(treeObject);
|
|
42
|
-
expect(Object.keys(journeyExport.nodes).length).toBe(7);
|
|
43
|
-
expect(Object.keys(journeyExport.innerNodes).length).toBe(5);
|
|
44
|
-
expect(Object.keys(journeyExport.circlesOfTrust).length).toBe(0);
|
|
45
|
-
expect(Object.keys(journeyExport.emailTemplates).length).toBe(0);
|
|
46
|
-
expect(Object.keys(journeyExport.saml2Entities).length).toBe(0);
|
|
47
|
-
expect(Object.keys(journeyExport.scripts).length).toBe(0);
|
|
48
|
-
expect(Object.keys(journeyExport.socialIdentityProviders).length).toBe(0);
|
|
49
|
-
expect((_journeyExport$themes = journeyExport.themes) === null || _journeyExport$themes === void 0 ? void 0 : _journeyExport$themes.length).toBe(0);
|
|
50
|
-
});
|
|
51
|
-
test('exportJourney() 2: Export journey w/ dependencies', async () => {
|
|
52
|
-
var _journeyExport$themes2;
|
|
53
|
-
mockGetTree(mock);
|
|
54
|
-
mockGetNode(mock);
|
|
55
|
-
mockGetConfigEntity(mock);
|
|
56
|
-
mockGetScript(mock);
|
|
57
|
-
mockGetSaml2Providers(mock);
|
|
58
|
-
mockGetCirclesOfTrust(mock);
|
|
59
|
-
mockGetSaml2ProviderByLocationAndId(mock);
|
|
60
|
-
mockGetSaml2ProviderMetadata(mock);
|
|
61
|
-
mockGetSocialProviders(mock);
|
|
62
|
-
const treeId = 'FrodoTest';
|
|
63
|
-
const treeObject = getTree(treeId);
|
|
64
|
-
expect.assertions(42);
|
|
65
|
-
const journeyExport = await Journey.exportJourney('FrodoTest', {
|
|
66
|
-
useStringArrays: false,
|
|
67
|
-
deps: true
|
|
68
|
-
});
|
|
69
|
-
// console.dir(journeyExport);
|
|
70
|
-
expect(journeyExport).toBeTruthy();
|
|
71
|
-
expect(journeyExport.tree['_id']).toBe(treeId);
|
|
72
|
-
expect(journeyExport.tree).toStrictEqual(treeObject);
|
|
73
|
-
expect(Object.keys(journeyExport.nodes).length).toBe(7);
|
|
74
|
-
expect(Object.keys(journeyExport.innerNodes).length).toBe(5);
|
|
75
|
-
expect(Object.keys(journeyExport.circlesOfTrust).length).toBe(1);
|
|
76
|
-
expect(Object.keys(journeyExport.emailTemplates).length).toBe(1);
|
|
77
|
-
expect(Object.keys(journeyExport.saml2Entities).length).toBe(2);
|
|
78
|
-
expect(Object.keys(journeyExport.scripts).length).toBe(9);
|
|
79
|
-
expect(Object.keys(journeyExport.socialIdentityProviders).length).toBe(8);
|
|
80
|
-
expect((_journeyExport$themes2 = journeyExport.themes) === null || _journeyExport$themes2 === void 0 ? void 0 : _journeyExport$themes2.length).toBe(1);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
describe('JourneyOps - importJourney()', () => {
|
|
84
|
-
test('importJourney() 0: Method is implemented', async () => {
|
|
85
|
-
expect(Journey.importJourney).toBeDefined();
|
|
86
|
-
});
|
|
87
|
-
test('importJourney() 1: Import journey w/o dependencies', async () => {
|
|
88
|
-
const treeId = 'FrodoTest';
|
|
89
|
-
const treeObject = getTree(treeId);
|
|
90
|
-
mockPutTree(mock, (mockTreeId, mockTreeObj) => {
|
|
91
|
-
expect(mockTreeId).toEqual(treeId);
|
|
92
|
-
expect(isEqualJson(mockTreeObj, treeObject, ['_rev'])).toBeTruthy();
|
|
93
|
-
});
|
|
94
|
-
let nodeIds = [
|
|
95
|
-
// nodes
|
|
96
|
-
'278bf084-9eea-46fe-8ce9-2600dde3b046', '64157fca-bd5b-4405-a4c8-64ffd98a5461', '731c5810-020b-45c8-a7fc-3c21903ae2b3', 'bf153f37-83dd-4f39-aa0c-74135430242e', 'd5cc2d52-6ce4-452d-85ea-3a5b50218b67', 'e2c39477-847a-4df2-9c5d-b449a752638b', 'fc7e47cd-c679-4211-8e05-a36654f23c67',
|
|
97
|
-
// inner nodes
|
|
98
|
-
'7a351800-fb7e-4145-903c-388554747556', '804e6a68-1720-442b-926a-007e90f02782', '228a44d5-fd78-4278-8999-fdd470ea7ebf', 'dd16c8d4-baca-4ae0-bcd8-fb98b9040524', '038f9b2a-36b2-489b-9e03-386c9a62ea21'];
|
|
99
|
-
mockPutNode(mock, (mockNodeId, mockNodeObj) => {
|
|
100
|
-
expect(nodeIds).toContain(mockNodeId);
|
|
101
|
-
nodeIds = nodeIds.filter(nodeId => nodeId !== mockNodeId);
|
|
102
|
-
});
|
|
103
|
-
expect.assertions(15);
|
|
104
|
-
const journeyExport = readJsonFile('./JourneyOps/importJourney/FrodoTest.journey.json');
|
|
105
|
-
await Journey.importJourney(journeyExport, {
|
|
106
|
-
reUuid: false,
|
|
107
|
-
deps: false
|
|
108
|
-
});
|
|
109
|
-
expect(nodeIds.length).toBe(0);
|
|
110
|
-
});
|
|
111
|
-
test('importJourney() 2: Import journey w/ dependencies', async () => {
|
|
112
|
-
const treeId = 'FrodoTest';
|
|
113
|
-
// mock TreeApi
|
|
114
|
-
const treeObject = getTree(treeId);
|
|
115
|
-
mockPutTree(mock, (mockTreeId, mockTreeObj) => {
|
|
116
|
-
// console.log('mockPutTree: ' + mockTreeId);
|
|
117
|
-
expect(mockTreeId).toEqual(treeId);
|
|
118
|
-
expect(isEqualJson(mockTreeObj, treeObject, ['_rev'])).toBeTruthy();
|
|
119
|
-
});
|
|
120
|
-
// mock NodeApi
|
|
121
|
-
let nodeIds = [
|
|
122
|
-
// nodes
|
|
123
|
-
'278bf084-9eea-46fe-8ce9-2600dde3b046', '64157fca-bd5b-4405-a4c8-64ffd98a5461', '731c5810-020b-45c8-a7fc-3c21903ae2b3', 'bf153f37-83dd-4f39-aa0c-74135430242e', 'd5cc2d52-6ce4-452d-85ea-3a5b50218b67', 'e2c39477-847a-4df2-9c5d-b449a752638b', 'fc7e47cd-c679-4211-8e05-a36654f23c67',
|
|
124
|
-
// inner nodes
|
|
125
|
-
'7a351800-fb7e-4145-903c-388554747556', '804e6a68-1720-442b-926a-007e90f02782', '228a44d5-fd78-4278-8999-fdd470ea7ebf', 'dd16c8d4-baca-4ae0-bcd8-fb98b9040524', '038f9b2a-36b2-489b-9e03-386c9a62ea21'];
|
|
126
|
-
mockPutNode(mock, (mockNodeId, mockNodeObj) => {
|
|
127
|
-
// console.log('mockPutNode: ' + mockNodeId);
|
|
128
|
-
expect(nodeIds).toContain(mockNodeId);
|
|
129
|
-
nodeIds = nodeIds.filter(nodeId => nodeId !== mockNodeId);
|
|
130
|
-
});
|
|
131
|
-
// mock EmailTemplateApi
|
|
132
|
-
let entityIds = ['emailTemplate/welcome', 'ui/themerealm'];
|
|
133
|
-
mockPutConfigEntity(mock, (mockEntityId, mockEntityObj) => {
|
|
134
|
-
// console.log('mockPutConfigEntity: ' + mockEntityId);
|
|
135
|
-
expect(entityIds).toContain(mockEntityId);
|
|
136
|
-
entityIds = entityIds.filter(entityId => entityId !== mockEntityId);
|
|
137
|
-
});
|
|
138
|
-
// mock ScriptApi
|
|
139
|
-
let scriptIds = ['58c824ae-84ed-4724-82cd-db128fc3f6c', '739bdc48-fd24-4c52-b353-88706d75558a', '58d29080-4563-480b-89bb-1e7719776a21', '23143919-6b78-40c3-b25e-beca19b229e0', 'bae1d54a-e97d-4997-aa5d-c027f21af82c', '484e6246-dbc6-4288-97e6-54e55431402e', '6325cf19-a49b-471e-8d26-7e4df76df0e2', 'dbe0bf9a-72aa-49d5-8483-9db147985a47', '73cecbfc-dad0-4395-be6a-6858ee3a80e5'];
|
|
140
|
-
mockPutScript(mock, (mockScriptId, mockScriptObj) => {
|
|
141
|
-
// console.log('mockPutScript: ' + mockScriptId);
|
|
142
|
-
expect(scriptIds).toContain(mockScriptId);
|
|
143
|
-
scriptIds = scriptIds.filter(scriptId => scriptId !== mockScriptId);
|
|
144
|
-
});
|
|
145
|
-
// mock CircleOfTrustApi
|
|
146
|
-
let cotIds = ['AzureCOT'];
|
|
147
|
-
mockCreateCircleOfTrust(mock, (mockCotId, mockCotObj) => {
|
|
148
|
-
// console.log('mockCreateCirclesOfTrust: ' + mockCotId);
|
|
149
|
-
expect(cotIds).toContain(mockCotId);
|
|
150
|
-
cotIds = cotIds.filter(cotId => cotId !== mockCotId);
|
|
151
|
-
});
|
|
152
|
-
mockUpdateCircleOfTrust(mock, (mockCotId, mockCotObj) => {
|
|
153
|
-
// console.log('mockUpdateCirclesOfTrust: ' + mockCotId);
|
|
154
|
-
expect(cotIds).toContain(mockCotId);
|
|
155
|
-
cotIds = cotIds.filter(cotId => cotId !== mockCotId);
|
|
156
|
-
});
|
|
157
|
-
// mock Saml2Api
|
|
158
|
-
mockFindSaml2Providers(mock);
|
|
159
|
-
let saml2ProviderIds64 = ['aVNQQXp1cmU', 'dXJuOmZlZGVyYXRpb246TWljcm9zb2Z0T25saW5l'];
|
|
160
|
-
mockCreateSaml2Provider(mock, (mockSaml2ProviderId64, mockSaml2ProviderLocation, mockSaml2ProviderObj) => {
|
|
161
|
-
// console.log('mockCreateSaml2Provider: ' + mockSaml2ProviderId64);
|
|
162
|
-
expect(saml2ProviderIds64).toContain(mockSaml2ProviderId64);
|
|
163
|
-
saml2ProviderIds64 = saml2ProviderIds64.filter(saml2ProviderId => saml2ProviderId !== mockSaml2ProviderId64);
|
|
164
|
-
});
|
|
165
|
-
mockUpdateSaml2Provider(mock, (mockSaml2ProviderId64, mockSaml2ProviderLocation, mockSaml2ProviderObj) => {
|
|
166
|
-
// console.log('mockUpdateSaml2Provider: ' + mockSaml2ProviderId64);
|
|
167
|
-
expect(saml2ProviderIds64).toContain(mockSaml2ProviderId64);
|
|
168
|
-
saml2ProviderIds64 = saml2ProviderIds64.filter(saml2ProviderId => saml2ProviderId !== mockSaml2ProviderId64);
|
|
169
|
-
});
|
|
170
|
-
// mock SocialIdentityProviderApi
|
|
171
|
-
let socialProviderIds = ['google', 'github', 'facebook', 'apple-stoyan', 'apple_web', 'okta-trial-5735851', 'adfs', 'azure'];
|
|
172
|
-
mockPutSocialProviderByTypeAndId(mock, (mockSocialProviderId, mockSocialProviderType, mockSocialProviderObj) => {
|
|
173
|
-
// console.log(
|
|
174
|
-
// 'mockPutSocialProviderByTypeAndId: ' + mockSocialProviderId
|
|
175
|
-
// );
|
|
176
|
-
expect(socialProviderIds).toContain(mockSocialProviderId);
|
|
177
|
-
socialProviderIds = socialProviderIds.filter(socialProviderId => socialProviderId !== mockSocialProviderId);
|
|
178
|
-
});
|
|
179
|
-
expect.assertions(46);
|
|
180
|
-
const journeyExport = readJsonFile('./JourneyOps/importJourney/FrodoTest.journey.json');
|
|
181
|
-
await Journey.importJourney(journeyExport, {
|
|
182
|
-
reUuid: false,
|
|
183
|
-
deps: true
|
|
184
|
-
});
|
|
185
|
-
expect(nodeIds.length).toBe(0);
|
|
186
|
-
expect(entityIds.length).toBe(0);
|
|
187
|
-
expect(scriptIds.length).toBe(0);
|
|
188
|
-
expect(cotIds.length).toBe(0);
|
|
189
|
-
expect(saml2ProviderIds64.length).toBe(0);
|
|
190
|
-
expect(socialProviderIds.length).toBe(0);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
describe('JourneyOps - enableJourney()', () => {
|
|
194
|
-
test('enableJourney() 0: Method is implemented', async () => {
|
|
195
|
-
expect(Journey.enableJourney).toBeDefined();
|
|
196
|
-
});
|
|
197
|
-
test('enableJourney() 1: Enable a disabled journey', async () => {
|
|
198
|
-
const treeId = 'Disabled';
|
|
199
|
-
mockGetTree(mock);
|
|
200
|
-
mockPutTree(mock, (mockTreeId, mockTreeObj) => {
|
|
201
|
-
expect(mockTreeId).toEqual(treeId);
|
|
202
|
-
expect(mockTreeObj['_rev']).toBeFalsy();
|
|
203
|
-
expect(mockTreeObj['enabled']).toBeTruthy();
|
|
204
|
-
});
|
|
205
|
-
expect.assertions(5);
|
|
206
|
-
const result = await Journey.enableJourney(treeId);
|
|
207
|
-
expect(result).toBeTruthy();
|
|
208
|
-
});
|
|
209
|
-
test('enableJourney() 2: Enable an already enabled journey', async () => {
|
|
210
|
-
const treeId = 'FrodoTest';
|
|
211
|
-
mockGetTree(mock);
|
|
212
|
-
mockPutTree(mock, (mockTreeId, mockTreeObj) => {
|
|
213
|
-
expect(mockTreeId).toEqual(treeId);
|
|
214
|
-
expect(mockTreeObj['_rev']).toBeFalsy();
|
|
215
|
-
expect(mockTreeObj['enabled']).toBeTruthy();
|
|
216
|
-
});
|
|
217
|
-
expect.assertions(5);
|
|
218
|
-
const result = await Journey.enableJourney(treeId);
|
|
219
|
-
expect(result).toBeTruthy();
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
describe('JourneyOps - disableJourney()', () => {
|
|
223
|
-
test('disableJourney() 0: Method is implemented', async () => {
|
|
224
|
-
expect(Journey.disableJourney).toBeDefined();
|
|
225
|
-
});
|
|
226
|
-
test('disableJourney() 1: Disable an enabled journey', async () => {
|
|
227
|
-
const treeId = 'FrodoTest';
|
|
228
|
-
mockGetTree(mock);
|
|
229
|
-
mockPutTree(mock, (mockTreeId, mockTreeObj) => {
|
|
230
|
-
expect(mockTreeId).toEqual(treeId);
|
|
231
|
-
expect(mockTreeObj['_rev']).toBeFalsy();
|
|
232
|
-
expect(mockTreeObj['enabled']).toBeFalsy();
|
|
233
|
-
});
|
|
234
|
-
expect.assertions(5);
|
|
235
|
-
const result = await Journey.disableJourney(treeId);
|
|
236
|
-
expect(result).toBeTruthy();
|
|
237
|
-
});
|
|
238
|
-
test('disableJourney() 2: Disable an already disabled journey', async () => {
|
|
239
|
-
const treeId = 'Disabled';
|
|
240
|
-
mockGetTree(mock);
|
|
241
|
-
mockPutTree(mock, (mockTreeId, mockTreeObj) => {
|
|
242
|
-
expect(mockTreeId).toEqual(treeId);
|
|
243
|
-
expect(mockTreeObj['_rev']).toBeFalsy();
|
|
244
|
-
expect(mockTreeObj['enabled']).toBeFalsy();
|
|
245
|
-
});
|
|
246
|
-
expect.assertions(5);
|
|
247
|
-
const result = await Journey.disableJourney(treeId);
|
|
248
|
-
expect(result).toBeTruthy();
|
|
122
|
+
// in recording mode, remove test data after recording
|
|
123
|
+
afterAll(async () => {
|
|
124
|
+
if (process.env.FRODO_POLLY_MODE === 'record') {
|
|
125
|
+
await stageJourney(journey1, false);
|
|
126
|
+
await stageJourney(journey2, false);
|
|
127
|
+
await stageJourney(journey3, false);
|
|
128
|
+
await stageJourney(journey4, false);
|
|
129
|
+
await stageJourney(journey5, false);
|
|
130
|
+
await stageJourney(journey6, false);
|
|
131
|
+
await stageJourney(journey7, false);
|
|
132
|
+
await stageJourney(journey8, false);
|
|
133
|
+
await stageJourney(journey9, false);
|
|
134
|
+
}
|
|
249
135
|
});
|
|
136
|
+
// Phase 1
|
|
137
|
+
if (!process.env.FRODO_POLLY_MODE || process.env.FRODO_POLLY_MODE === 'record' && process.env.FRODO_RECORD_PHASE === '1') {
|
|
138
|
+
describe('getJourneys()', () => {
|
|
139
|
+
test('0: Method is implemented', async () => {
|
|
140
|
+
expect(Journey.getJourneys).toBeDefined();
|
|
141
|
+
});
|
|
142
|
+
test('1: Get all journeys', async () => {
|
|
143
|
+
const journeys = await Journey.getJourneys();
|
|
144
|
+
expect(journeys).toMatchSnapshot();
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
describe('exportJourney()', () => {
|
|
148
|
+
test('0: Method is implemented', async () => {
|
|
149
|
+
expect(Journey.exportJourney).toBeDefined();
|
|
150
|
+
});
|
|
151
|
+
test(`1: Export journey '${journey3.id}' w/o dependencies`, async () => {
|
|
152
|
+
const response = await Journey.exportJourney(journey3.id, {
|
|
153
|
+
useStringArrays: false,
|
|
154
|
+
deps: false
|
|
155
|
+
});
|
|
156
|
+
expect(response).toMatchSnapshot({
|
|
157
|
+
meta: expect.any(Object)
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
test(`2: Export journey '${journey3.id}' w/ dependencies`, async () => {
|
|
161
|
+
const response = await Journey.exportJourney(journey3.id, {
|
|
162
|
+
useStringArrays: false,
|
|
163
|
+
deps: true
|
|
164
|
+
});
|
|
165
|
+
expect(response).toMatchSnapshot({
|
|
166
|
+
meta: expect.any(Object)
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('importJourney()', () => {
|
|
171
|
+
test('0: Method is implemented', async () => {
|
|
172
|
+
expect(Journey.importJourney).toBeDefined();
|
|
173
|
+
});
|
|
174
|
+
test(`1: Import journey '${journey4.id}' w/o dependencies`, async () => {
|
|
175
|
+
const journeyExport = getJourney(journey4.id);
|
|
176
|
+
expect.assertions(1);
|
|
177
|
+
const response = await Journey.importJourney(journeyExport, {
|
|
178
|
+
reUuid: false,
|
|
179
|
+
deps: false
|
|
180
|
+
});
|
|
181
|
+
expect(response).toBeTruthy();
|
|
182
|
+
});
|
|
183
|
+
test(`2: Import journey '${journey5.id}' w/ dependencies`, async () => {
|
|
184
|
+
const journeyExport = getJourney(journey5.id);
|
|
185
|
+
expect.assertions(1);
|
|
186
|
+
const response = await Journey.importJourney(journeyExport, {
|
|
187
|
+
reUuid: false,
|
|
188
|
+
deps: true
|
|
189
|
+
});
|
|
190
|
+
expect(response).toBeTruthy();
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
describe('enableJourney()', () => {
|
|
194
|
+
test('0: Method is implemented', async () => {
|
|
195
|
+
expect(Journey.enableJourney).toBeDefined();
|
|
196
|
+
});
|
|
197
|
+
test(`1: Enable disabled journey '${journey6.id}'`, async () => {
|
|
198
|
+
expect.assertions(1);
|
|
199
|
+
const result = await Journey.enableJourney(journey6.id);
|
|
200
|
+
expect(result).toBeTruthy();
|
|
201
|
+
});
|
|
202
|
+
test(`2: Enable already enabled journey '${journey7.id}'`, async () => {
|
|
203
|
+
expect.assertions(1);
|
|
204
|
+
const result = await Journey.enableJourney(journey7.id);
|
|
205
|
+
expect(result).toBeTruthy();
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
describe('disableJourney()', () => {
|
|
209
|
+
test('0: Method is implemented', async () => {
|
|
210
|
+
expect(Journey.disableJourney).toBeDefined();
|
|
211
|
+
});
|
|
212
|
+
test(`1: Disable enabled journey '${journey8.id}'`, async () => {
|
|
213
|
+
expect.assertions(1);
|
|
214
|
+
const result = await Journey.disableJourney(journey8.id);
|
|
215
|
+
expect(result).toBeTruthy();
|
|
216
|
+
});
|
|
217
|
+
test(`2: Disable already disabled journey '${journey9.id}'`, async () => {
|
|
218
|
+
expect.assertions(1);
|
|
219
|
+
const result = await Journey.disableJourney(journey9.id);
|
|
220
|
+
expect(result).toBeTruthy();
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
}
|
|
250
224
|
});
|
|
251
225
|
//# sourceMappingURL=JourneyOps.test.js.map
|