@rockcarver/frodo-lib 0.12.2-8 → 0.12.2
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 +33 -1
- package/cjs/index.js +3 -3
- package/cjs/index.js.map +1 -1
- package/cjs/ops/AdminOps.js +63 -34
- package/cjs/ops/AdminOps.js.map +1 -1
- package/cjs/ops/IdmOps.test.js.map +1 -0
- package/cjs/ops/IdpOps.js +75 -74
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/IdpOps.test.js.map +1 -0
- package/cjs/ops/JourneyOps.js +5 -2
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/{SamlOps.js → Saml2Ops.js} +75 -73
- package/cjs/ops/Saml2Ops.js.map +1 -0
- package/cjs/ops/Saml2Ops.test.js.map +1 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +9 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/IdmConfigApi/getAllConfigEntities/entities.json +490 -0
- package/esm/index.mjs +1 -1
- package/esm/ops/AdminOps.mjs +32 -29
- package/esm/ops/IdmOps.test.mjs +43 -0
- package/esm/ops/IdpOps.mjs +30 -29
- package/esm/ops/IdpOps.test.mjs +63 -0
- package/esm/ops/JourneyOps.mjs +5 -2
- package/esm/ops/{SamlOps.mjs → Saml2Ops.mjs} +24 -22
- package/esm/ops/Saml2Ops.test.mjs +89 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +7 -0
- package/esm/test/mocks/IdmConfigApi/getAllConfigEntities/entities.json +490 -0
- package/package.json +2 -2
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/ops/AdminOps.d.ts +1 -0
- package/types/ops/AdminOps.d.ts.map +1 -1
- package/types/ops/IdpOps.d.ts +12 -12
- package/types/ops/IdpOps.d.ts.map +1 -1
- package/types/ops/JourneyOps.d.ts.map +1 -1
- package/types/ops/{SamlOps.d.ts → Saml2Ops.d.ts} +10 -10
- package/types/ops/Saml2Ops.d.ts.map +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
- package/cjs/ops/SamlOps.js.map +0 -1
- package/types/ops/SamlOps.d.ts.map +0 -1
package/esm/ops/IdpOps.mjs
CHANGED
|
@@ -17,56 +17,57 @@ function getFileDataTemplate() {
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
export async function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
export async function listSocialProviders() {
|
|
21
|
+
try {
|
|
22
|
+
const providers = await getSocialIdentityProviders();
|
|
23
|
+
providers.result.sort((a, b) => a._id.localeCompare(b._id));
|
|
24
|
+
providers.result.forEach(socialIdentityProvider => {
|
|
24
25
|
printMessage(`${socialIdentityProvider._id}`, 'data');
|
|
25
26
|
});
|
|
26
|
-
}
|
|
27
|
-
printMessage(`
|
|
27
|
+
} catch (err) {
|
|
28
|
+
printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');
|
|
28
29
|
printMessage(err, 'error');
|
|
29
|
-
}
|
|
30
|
+
}
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Get social identity provider by id
|
|
33
|
-
* @param {String}
|
|
34
|
+
* @param {String} providerId social identity provider id/name
|
|
34
35
|
* @returns {Promise} a promise that resolves a social identity provider object
|
|
35
36
|
*/
|
|
36
37
|
|
|
37
|
-
export async function
|
|
38
|
+
export async function getSocialProvider(providerId) {
|
|
38
39
|
return getSocialIdentityProviders().then(response => {
|
|
39
|
-
const foundProviders = response.result.filter(provider => provider._id ===
|
|
40
|
+
const foundProviders = response.result.filter(provider => provider._id === providerId);
|
|
40
41
|
|
|
41
42
|
switch (foundProviders.length) {
|
|
42
43
|
case 1:
|
|
43
44
|
return foundProviders[0];
|
|
44
45
|
|
|
45
46
|
case 0:
|
|
46
|
-
throw new Error(`Provider '${
|
|
47
|
+
throw new Error(`Provider '${providerId}' not found`);
|
|
47
48
|
|
|
48
49
|
default:
|
|
49
|
-
throw new Error(`${foundProviders.length} providers '${
|
|
50
|
+
throw new Error(`${foundProviders.length} providers '${providerId}' found`);
|
|
50
51
|
}
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* Export provider by id
|
|
55
|
-
* @param {String}
|
|
56
|
+
* @param {String} providerId provider id/name
|
|
56
57
|
* @param {String} file optional export file name
|
|
57
58
|
*/
|
|
58
59
|
|
|
59
|
-
export async function
|
|
60
|
+
export async function exportSocialProviderToFile(providerId, file = '') {
|
|
60
61
|
let fileName = file;
|
|
61
62
|
|
|
62
63
|
if (!fileName) {
|
|
63
|
-
fileName = getTypedFilename(
|
|
64
|
+
fileName = getTypedFilename(providerId, 'idp');
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
createProgressIndicator(1, `Exporting ${
|
|
67
|
+
createProgressIndicator(1, `Exporting ${providerId}`);
|
|
67
68
|
|
|
68
69
|
try {
|
|
69
|
-
const idpData = await
|
|
70
|
+
const idpData = await getSocialProvider(providerId);
|
|
70
71
|
updateProgressIndicator(`Writing file ${fileName}`);
|
|
71
72
|
const fileData = getFileDataTemplate();
|
|
72
73
|
fileData.idp[idpData._id] = idpData;
|
|
@@ -78,7 +79,7 @@ export async function exportProvider(id, file = '') {
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
saveJsonToFile(fileData, fileName);
|
|
81
|
-
stopProgressIndicator(`Exported ${
|
|
82
|
+
stopProgressIndicator(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
|
|
82
83
|
} catch (err) {
|
|
83
84
|
stopProgressIndicator(`${err}`);
|
|
84
85
|
printMessage(`${err}`, 'error');
|
|
@@ -89,7 +90,7 @@ export async function exportProvider(id, file = '') {
|
|
|
89
90
|
* @param {String} file optional export file name
|
|
90
91
|
*/
|
|
91
92
|
|
|
92
|
-
export async function
|
|
93
|
+
export async function exportSocialProvidersToFile(file) {
|
|
93
94
|
let fileName = file;
|
|
94
95
|
|
|
95
96
|
if (!fileName) {
|
|
@@ -119,7 +120,7 @@ export async function exportProvidersToFile(file) {
|
|
|
119
120
|
* Export all providers to individual files
|
|
120
121
|
*/
|
|
121
122
|
|
|
122
|
-
export async function
|
|
123
|
+
export async function exportSocialProvidersToFiles() {
|
|
123
124
|
const allIdpsData = await (await getSocialIdentityProviders()).result; // printMessage(allIdpsData, 'data');
|
|
124
125
|
|
|
125
126
|
createProgressIndicator(allIdpsData.length, 'Exporting providers');
|
|
@@ -144,11 +145,11 @@ export async function exportProvidersToFiles() {
|
|
|
144
145
|
}
|
|
145
146
|
/**
|
|
146
147
|
* Import provider by id/name
|
|
147
|
-
* @param {String}
|
|
148
|
+
* @param {String} providerId provider id/name
|
|
148
149
|
* @param {String} file import file name
|
|
149
150
|
*/
|
|
150
151
|
|
|
151
|
-
export async function
|
|
152
|
+
export async function importSocialProviderFromFile(providerId, file) {
|
|
152
153
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
153
154
|
if (err) throw err;
|
|
154
155
|
const fileData = JSON.parse(data);
|
|
@@ -159,7 +160,7 @@ export async function importProviderById(id, file) {
|
|
|
159
160
|
|
|
160
161
|
for (const idpId in fileData.idp) {
|
|
161
162
|
if ({}.hasOwnProperty.call(fileData.idp, idpId)) {
|
|
162
|
-
if (idpId ===
|
|
163
|
+
if (idpId === providerId) {
|
|
163
164
|
found = true;
|
|
164
165
|
updateProgressIndicator(`Importing ${fileData.idp[idpId]._id}`);
|
|
165
166
|
const scriptId = fileData.idp[idpId].transform;
|
|
@@ -172,10 +173,10 @@ export async function importProviderById(id, file) {
|
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
putProviderByTypeAndId(fileData.idp[idpId]._type._id, idpId, fileData.idp[idpId]).then(() => {
|
|
175
|
-
stopProgressIndicator(`Successfully imported provider ${
|
|
176
|
+
stopProgressIndicator(`Successfully imported provider ${providerId}.`);
|
|
176
177
|
}).catch(importProviderErr => {
|
|
177
178
|
stopProgressIndicator(`Error importing provider ${fileData.idp[idpId]._id}`);
|
|
178
|
-
printMessage(`\nError importing provider ${
|
|
179
|
+
printMessage(`\nError importing provider ${providerId}`, 'error');
|
|
179
180
|
printMessage(importProviderErr.response.data, 'error');
|
|
180
181
|
});
|
|
181
182
|
break;
|
|
@@ -184,7 +185,7 @@ export async function importProviderById(id, file) {
|
|
|
184
185
|
}
|
|
185
186
|
|
|
186
187
|
if (!found) {
|
|
187
|
-
stopProgressIndicator(`Provider ${
|
|
188
|
+
stopProgressIndicator(`Provider ${providerId.brightCyan} not found in ${file.brightCyan}!`);
|
|
188
189
|
}
|
|
189
190
|
} else {
|
|
190
191
|
printMessage('Import validation failed...', 'error');
|
|
@@ -196,7 +197,7 @@ export async function importProviderById(id, file) {
|
|
|
196
197
|
* @param {String} file import file name
|
|
197
198
|
*/
|
|
198
199
|
|
|
199
|
-
export async function
|
|
200
|
+
export async function importFirstSocialProviderFromFile(file) {
|
|
200
201
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
201
202
|
if (err) throw err;
|
|
202
203
|
const fileData = JSON.parse(data);
|
|
@@ -237,7 +238,7 @@ export async function importFirstProvider(file) {
|
|
|
237
238
|
* @param {String} file import file name
|
|
238
239
|
*/
|
|
239
240
|
|
|
240
|
-
export async function
|
|
241
|
+
export async function importSocialProvidersFromFile(file) {
|
|
241
242
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
242
243
|
if (err) throw err;
|
|
243
244
|
const fileData = JSON.parse(data);
|
|
@@ -275,7 +276,7 @@ export async function importProvidersFromFile(file) {
|
|
|
275
276
|
* Import providers from *.idp.json files in current working directory
|
|
276
277
|
*/
|
|
277
278
|
|
|
278
|
-
export async function
|
|
279
|
+
export async function importSocialProvidersFromFiles() {
|
|
279
280
|
const names = fs.readdirSync('.');
|
|
280
281
|
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.idp.json'));
|
|
281
282
|
createProgressIndicator(jsonFiles.length, 'Importing providers...');
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
|
+
import { Idp, state } from '../index';
|
|
4
|
+
import * as global from '../storage/StaticStorage';
|
|
5
|
+
import { mockGetSocialProviders } from '../test/mocks/ForgeRockApiMockEngine';
|
|
6
|
+
const mock = new MockAdapter(axios);
|
|
7
|
+
state.default.session.setTenant('https://openam-frodo-dev.forgeblocks.com/am');
|
|
8
|
+
state.default.session.setRealm('alpha');
|
|
9
|
+
state.default.session.setCookieName('cookieName');
|
|
10
|
+
state.default.session.setCookieValue('cookieValue');
|
|
11
|
+
state.default.session.setDeploymentType(global.CLOUD_DEPLOYMENT_TYPE_KEY);
|
|
12
|
+
describe('IdpOps - exportSocialProviderToFile()', () => {
|
|
13
|
+
test('exportSocialProviderToFile() 0: Method is implemented', async () => {
|
|
14
|
+
expect(Idp.exportSocialProviderToFile).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
describe('IdpOps - exportSocialProvidersToFile()', () => {
|
|
18
|
+
test('exportSocialProvidersToFile() 0: Method is implemented', async () => {
|
|
19
|
+
expect(Idp.exportSocialProvidersToFile).toBeDefined();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('IdpOps - exportSocialProvidersToFiles()', () => {
|
|
23
|
+
test('exportSocialProvidersToFiles() 0: Method is implemented', async () => {
|
|
24
|
+
expect(Idp.exportSocialProvidersToFiles).toBeDefined();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('IdpOps - getSocialProvider()', () => {
|
|
28
|
+
test('getSocialProvider() 0: Method is implemented', async () => {
|
|
29
|
+
expect(Idp.getSocialProvider).toBeDefined();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('IdpOps - importFirstSocialProviderFromFile()', () => {
|
|
33
|
+
test('importFirstSocialProviderFromFile() 0: Method is implemented', async () => {
|
|
34
|
+
expect(Idp.importFirstSocialProviderFromFile).toBeDefined();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('IdpOps - importSocialProviderFromFile()', () => {
|
|
38
|
+
test('importSocialProviderFromFile() 0: Method is implemented', async () => {
|
|
39
|
+
expect(Idp.importSocialProviderFromFile).toBeDefined();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('IdpOps - importSocialProvidersFromFile()', () => {
|
|
43
|
+
test('importSocialProvidersFromFile() 0: Method is implemented', async () => {
|
|
44
|
+
expect(Idp.importSocialProvidersFromFile).toBeDefined();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe('IdpOps - importSocialProvidersFromFiles()', () => {
|
|
48
|
+
test('importSocialProvidersFromFiles() 0: Method is implemented', async () => {
|
|
49
|
+
expect(Idp.importSocialProvidersFromFiles).toBeDefined();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe('IdpOps - listSocialProviders()', () => {
|
|
53
|
+
test('listSocialProviders() 0: Method is implemented', async () => {
|
|
54
|
+
expect(Idp.listSocialProviders).toBeDefined();
|
|
55
|
+
});
|
|
56
|
+
test('listSocialProviders() 1: List social identity providers', async () => {
|
|
57
|
+
mockGetSocialProviders(mock);
|
|
58
|
+
expect.assertions(2);
|
|
59
|
+
await Idp.listSocialProviders();
|
|
60
|
+
expect(true).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=IdpOps.test.js.map
|
package/esm/ops/JourneyOps.mjs
CHANGED
|
@@ -416,15 +416,18 @@ export async function exportJourney(treeId, options = {
|
|
|
416
416
|
const themePromiseResults = await Promise.resolve(themePromise);
|
|
417
417
|
|
|
418
418
|
for (const themeObject of themePromiseResults) {
|
|
419
|
+
var _themeObject$linkedTr;
|
|
420
|
+
|
|
419
421
|
if (themeObject && ( // has the theme been specified by id or name in a page node?
|
|
420
422
|
themes.includes(themeObject._id) || themes.includes(themeObject.name) || // has this journey been linked to a theme?
|
|
421
|
-
themeObject.linkedTrees.includes(treeObject._id))) {
|
|
423
|
+
(_themeObject$linkedTr = themeObject.linkedTrees) !== null && _themeObject$linkedTr !== void 0 && _themeObject$linkedTr.includes(treeObject._id))) {
|
|
422
424
|
if (verbose) printMessage(` - ${themeObject._id} (${themeObject.name})`, 'info');
|
|
423
425
|
exportData.themes.push(themeObject);
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
428
|
} catch (error) {
|
|
427
|
-
printMessage(error
|
|
429
|
+
printMessage(error, 'error');
|
|
430
|
+
printMessage('Error handling themes: ' + error.message, 'error');
|
|
428
431
|
}
|
|
429
432
|
}
|
|
430
433
|
|
|
@@ -30,19 +30,21 @@ function getFileDataTemplate() {
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
export async function
|
|
33
|
+
export async function listSaml2Providers(long = false) {
|
|
34
34
|
const providerList = (await getProviders()).result;
|
|
35
35
|
providerList.sort((a, b) => a._id.localeCompare(b._id));
|
|
36
36
|
|
|
37
37
|
if (!long) {
|
|
38
|
-
|
|
39
|
-
printMessage(`${
|
|
40
|
-
}
|
|
38
|
+
for (const provider of providerList) {
|
|
39
|
+
printMessage(`${provider.entityId}`, 'data');
|
|
40
|
+
}
|
|
41
41
|
} else {
|
|
42
42
|
const table = createTable(['Entity Id'['brightCyan'], 'Location'['brightCyan'], 'Role(s)'['brightCyan']]);
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
for (const provider of providerList) {
|
|
44
45
|
table.push([provider.entityId, provider.location, provider.roles.map(role => roleMap[role]).join(', ')]);
|
|
45
|
-
}
|
|
46
|
+
}
|
|
47
|
+
|
|
46
48
|
printMessage(table.toString());
|
|
47
49
|
}
|
|
48
50
|
}
|
|
@@ -82,7 +84,7 @@ async function exportDependencies(providerData, fileData) {
|
|
|
82
84
|
*/
|
|
83
85
|
|
|
84
86
|
|
|
85
|
-
export async function
|
|
87
|
+
export async function exportSaml2ProviderToFile(entityId, file = null) {
|
|
86
88
|
let fileName = file;
|
|
87
89
|
|
|
88
90
|
if (!fileName) {
|
|
@@ -136,7 +138,7 @@ export async function exportProvider(entityId, file = null) {
|
|
|
136
138
|
* @param {String} file Optional filename
|
|
137
139
|
*/
|
|
138
140
|
|
|
139
|
-
export async function
|
|
141
|
+
export async function exportSaml2Metadata(entityId, file = null) {
|
|
140
142
|
let fileName = file;
|
|
141
143
|
|
|
142
144
|
if (!fileName) {
|
|
@@ -160,7 +162,7 @@ export async function exportMetadata(entityId, file = null) {
|
|
|
160
162
|
* @param {String} entityId Provider entity id
|
|
161
163
|
*/
|
|
162
164
|
|
|
163
|
-
export async function
|
|
165
|
+
export async function describeSaml2Provider(entityId) {
|
|
164
166
|
try {
|
|
165
167
|
const found = await findProviders(`entityId eq '${entityId}'`, 'location,roles');
|
|
166
168
|
|
|
@@ -209,7 +211,7 @@ export async function describeProvider(entityId) {
|
|
|
209
211
|
* @param {String} file Optional filename
|
|
210
212
|
*/
|
|
211
213
|
|
|
212
|
-
export async function
|
|
214
|
+
export async function exportSaml2ProvidersToFile(file = null) {
|
|
213
215
|
let fileName = file;
|
|
214
216
|
|
|
215
217
|
if (!fileName) {
|
|
@@ -221,9 +223,9 @@ export async function exportProvidersToFile(file = null) {
|
|
|
221
223
|
const found = await getProviders();
|
|
222
224
|
|
|
223
225
|
if (found.resultCount > 0) {
|
|
224
|
-
createProgressIndicator(found.
|
|
226
|
+
createProgressIndicator(found.resultCount, 'Exporting providers');
|
|
225
227
|
|
|
226
|
-
for (const stubData of found.
|
|
228
|
+
for (const stubData of found.result) {
|
|
227
229
|
updateProgressIndicator(`Exporting provider ${stubData.entityId}`); // eslint-disable-next-line no-await-in-loop
|
|
228
230
|
|
|
229
231
|
const providerData = await getProviderByLocationAndId(stubData.location, stubData._id); // eslint-disable-next-line no-await-in-loop
|
|
@@ -233,7 +235,7 @@ export async function exportProvidersToFile(file = null) {
|
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
saveJsonToFile(fileData, fileName);
|
|
236
|
-
stopProgressIndicator(`${found.
|
|
238
|
+
stopProgressIndicator(`${found.resultCount} providers exported to ${fileName}.`);
|
|
237
239
|
} else {
|
|
238
240
|
printMessage('No entity providers found.', 'info');
|
|
239
241
|
}
|
|
@@ -248,13 +250,13 @@ export async function exportProvidersToFile(file = null) {
|
|
|
248
250
|
* Export all entity providers to individual files
|
|
249
251
|
*/
|
|
250
252
|
|
|
251
|
-
export async function
|
|
253
|
+
export async function exportSaml2ProvidersToFiles() {
|
|
252
254
|
const found = await getProviders();
|
|
253
255
|
|
|
254
256
|
if (found.resultCount > 0) {
|
|
255
|
-
createProgressIndicator(found.
|
|
257
|
+
createProgressIndicator(found.resultCount, 'Exporting providers');
|
|
256
258
|
|
|
257
|
-
for (const stubData of found.
|
|
259
|
+
for (const stubData of found.result) {
|
|
258
260
|
updateProgressIndicator(`Exporting provider ${stubData.entityId}`);
|
|
259
261
|
const fileName = getTypedFilename(stubData.entityId, 'saml');
|
|
260
262
|
const fileData = getFileDataTemplate(); // eslint-disable-next-line no-await-in-loop
|
|
@@ -266,7 +268,7 @@ export async function exportProvidersToFiles() {
|
|
|
266
268
|
saveJsonToFile(fileData, fileName);
|
|
267
269
|
}
|
|
268
270
|
|
|
269
|
-
stopProgressIndicator(`${found.
|
|
271
|
+
stopProgressIndicator(`${found.resultCount} providers exported.`);
|
|
270
272
|
} else {
|
|
271
273
|
printMessage('No entity providers found.', 'info');
|
|
272
274
|
}
|
|
@@ -322,7 +324,7 @@ function getLocation(entityId64, fileData) {
|
|
|
322
324
|
*/
|
|
323
325
|
|
|
324
326
|
|
|
325
|
-
export async function
|
|
327
|
+
export async function importSaml2ProviderFromFile(entityId, file) {
|
|
326
328
|
const entityId64 = encode(entityId, false);
|
|
327
329
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
328
330
|
if (err) throw err;
|
|
@@ -362,7 +364,7 @@ export async function importProvider(entityId, file) {
|
|
|
362
364
|
* @param {String} file Import file name
|
|
363
365
|
*/
|
|
364
366
|
|
|
365
|
-
export async function
|
|
367
|
+
export async function importFirstSaml2ProviderFromFile(file) {
|
|
366
368
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
367
369
|
if (err) throw err;
|
|
368
370
|
const fileData = JSON.parse(data);
|
|
@@ -417,7 +419,7 @@ export async function importFirstProvider(file) {
|
|
|
417
419
|
* @param {String} file Import file name
|
|
418
420
|
*/
|
|
419
421
|
|
|
420
|
-
export async function
|
|
422
|
+
export async function importSaml2ProvidersFromFile(file) {
|
|
421
423
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
422
424
|
if (err) throw err;
|
|
423
425
|
const fileData = JSON.parse(data);
|
|
@@ -465,7 +467,7 @@ export async function importProvidersFromFile(file) {
|
|
|
465
467
|
* Import all SAML entity providers from all *.saml.json files in the current directory
|
|
466
468
|
*/
|
|
467
469
|
|
|
468
|
-
export async function
|
|
470
|
+
export async function importSaml2ProvidersFromFiles() {
|
|
469
471
|
const names = fs.readdirSync('.');
|
|
470
472
|
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.saml.json'));
|
|
471
473
|
createProgressIndicator(jsonFiles.length, 'Importing providers...');
|
|
@@ -518,4 +520,4 @@ export async function importProvidersFromFiles() {
|
|
|
518
520
|
|
|
519
521
|
stopProgressIndicator(`Imported ${total - totalErrors} of ${total} provider(s) from ${jsonFiles.length} file(s).`);
|
|
520
522
|
}
|
|
521
|
-
//# sourceMappingURL=
|
|
523
|
+
//# sourceMappingURL=Saml2Ops.js.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
|
+
import { Saml2, state } from '../index';
|
|
4
|
+
import * as global from '../storage/StaticStorage';
|
|
5
|
+
import { mockGetSaml2Providers, mockFindSaml2Providers, mockGetSaml2ProviderByLocationAndId, mockGetSaml2ProviderMetadata } from '../test/mocks/ForgeRockApiMockEngine';
|
|
6
|
+
const mock = new MockAdapter(axios);
|
|
7
|
+
state.default.session.setTenant('https://openam-frodo-dev.forgeblocks.com/am');
|
|
8
|
+
state.default.session.setRealm('alpha');
|
|
9
|
+
state.default.session.setCookieName('cookieName');
|
|
10
|
+
state.default.session.setCookieValue('cookieValue');
|
|
11
|
+
state.default.session.setDeploymentType(global.CLOUD_DEPLOYMENT_TYPE_KEY);
|
|
12
|
+
describe('Saml2Ops - describeSaml2Provider()', () => {
|
|
13
|
+
test('describeSaml2Provider() 0: Method is implemented', async () => {
|
|
14
|
+
expect(Saml2.describeSaml2Provider).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
test('describeSaml2Provider() 1: Describe saml2 entity provider', async () => {
|
|
17
|
+
mockFindSaml2Providers(mock);
|
|
18
|
+
mockGetSaml2ProviderByLocationAndId(mock);
|
|
19
|
+
mockGetSaml2ProviderMetadata(mock);
|
|
20
|
+
expect.assertions(2);
|
|
21
|
+
await Saml2.describeSaml2Provider('iSPAzure');
|
|
22
|
+
expect(true).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('Saml2Ops - exportSaml2Metadata()', () => {
|
|
26
|
+
test('exportSaml2Metadata() 0: Method is implemented', async () => {
|
|
27
|
+
expect(Saml2.exportSaml2Metadata).toBeDefined();
|
|
28
|
+
});
|
|
29
|
+
test('describeSaml2Provider() 1: Export hosted saml2 entity provider metadata', async () => {
|
|
30
|
+
mockGetSaml2ProviderMetadata(mock);
|
|
31
|
+
expect.assertions(2);
|
|
32
|
+
await Saml2.exportSaml2Metadata('iSPAzure');
|
|
33
|
+
expect(true).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
test('describeSaml2Provider() 2: Export remote saml2 entity provider metadata', async () => {
|
|
36
|
+
mockGetSaml2ProviderMetadata(mock);
|
|
37
|
+
expect.assertions(2);
|
|
38
|
+
await Saml2.exportSaml2Metadata('urn:federation:MicrosoftOnline');
|
|
39
|
+
expect(true).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('Saml2Ops - exportSaml2ProviderToFile()', () => {
|
|
43
|
+
test('exportSaml2ProviderToFile() 0: Method is implemented', async () => {
|
|
44
|
+
expect(Saml2.exportSaml2ProviderToFile).toBeDefined();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe('Saml2Ops - exportSaml2ProvidersToFile()', () => {
|
|
48
|
+
test('exportSaml2ProvidersToFile() 0: Method is implemented', async () => {
|
|
49
|
+
expect(Saml2.exportSaml2ProvidersToFile).toBeDefined();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe('Saml2Ops - exportSaml2ProvidersToFiles()', () => {
|
|
53
|
+
test('exportSaml2ProvidersToFiles() 0: Method is implemented', async () => {
|
|
54
|
+
expect(Saml2.exportSaml2ProvidersToFiles).toBeDefined();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('Saml2Ops - importFirstSaml2ProviderFromFile()', () => {
|
|
58
|
+
test('importFirstSaml2ProviderFromFile() 0: Method is implemented', async () => {
|
|
59
|
+
expect(Saml2.importFirstSaml2ProviderFromFile).toBeDefined();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('Saml2Ops - importSaml2ProviderFromFile()', () => {
|
|
63
|
+
test('importSaml2ProviderFromFile() 0: Method is implemented', async () => {
|
|
64
|
+
expect(Saml2.importSaml2ProviderFromFile).toBeDefined();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('Saml2Ops - importSaml2ProvidersFromFile()', () => {
|
|
68
|
+
test('importSaml2ProvidersFromFile() 0: Method is implemented', async () => {
|
|
69
|
+
expect(Saml2.importSaml2ProvidersFromFile).toBeDefined();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe('Saml2Ops - importSaml2ProvidersFromFiles()', () => {
|
|
73
|
+
test('importSaml2ProvidersFromFiles() 0: Method is implemented', async () => {
|
|
74
|
+
expect(Saml2.importSaml2ProvidersFromFiles).toBeDefined();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
describe('Saml2Ops - listSaml2Providers()', () => {
|
|
78
|
+
mockGetSaml2Providers(mock);
|
|
79
|
+
test('listSaml2Providers() 0: Method is implemented', async () => {
|
|
80
|
+
expect(Saml2.listSaml2Providers).toBeDefined();
|
|
81
|
+
});
|
|
82
|
+
test('listSaml2Providers() 1: List saml2 entity providers', async () => {
|
|
83
|
+
mockGetSaml2Providers(mock);
|
|
84
|
+
expect.assertions(2);
|
|
85
|
+
await Saml2.listSaml2Providers();
|
|
86
|
+
expect(true).toBeTruthy();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=Saml2Ops.test.js.map
|
|
@@ -251,6 +251,13 @@ export function mockPutSocialProviderByTypeAndId(mock, callback) {
|
|
|
251
251
|
* IDM Mocks and Utils
|
|
252
252
|
*/
|
|
253
253
|
|
|
254
|
+
export function mockListAllConfigEntities(mock) {
|
|
255
|
+
mock.onGet(/.*?\/openidm\/config$/).reply(function () {
|
|
256
|
+
const mockStatus = 200;
|
|
257
|
+
const mockResponse = JSON.parse(fs.readFileSync(path.resolve(__dirname, `./IdmConfigApi/getAllConfigEntities/entities.json`), 'utf8'));
|
|
258
|
+
return [mockStatus, mockResponse];
|
|
259
|
+
});
|
|
260
|
+
}
|
|
254
261
|
export function mockGetConfigEntity(mock) {
|
|
255
262
|
mock.onGet(/.*?\/openidm\/config\/.+/).reply(function (config) {
|
|
256
263
|
const entityId = config.url ? config.url.substring(config.url.indexOf('/config/') + 8) : '';
|