@rockcarver/frodo-lib 0.17.2-0 → 0.17.3
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 +9 -1
- package/cjs/api/AgentApi.js +1 -1
- package/cjs/api/AgentApi.js.map +1 -1
- package/cjs/api/AgentApi.test.js.map +1 -1
- package/cjs/api/ApiTypes.js +16 -16
- package/cjs/api/ApiTypes.js.map +1 -1
- package/cjs/api/AuthenticateApi.js +17 -12
- package/cjs/api/AuthenticateApi.js.map +1 -1
- package/cjs/api/AuthenticateApi.test.js.map +1 -1
- package/cjs/api/IdmConfigApi.js +28 -7
- package/cjs/api/IdmConfigApi.js.map +1 -1
- package/cjs/api/NodeApi.test.js.map +1 -1
- package/cjs/api/SecretsApi.test.js.map +1 -1
- package/cjs/api/SocialIdentityProvidersApi.js +22 -0
- package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
- package/cjs/api/TreeApi.test.js.map +1 -1
- package/cjs/api/VariablesApi.test.js.map +1 -1
- package/cjs/api/utils/ApiUtils.js +13 -4
- package/cjs/api/utils/ApiUtils.js.map +1 -1
- package/cjs/api/utils/ApiUtils.test.js.map +1 -1
- package/cjs/index.js +3 -1
- package/cjs/index.js.map +1 -1
- package/cjs/ops/AgentOps.test.js.map +1 -1
- package/cjs/ops/AuthenticateOps.js +0 -7
- package/cjs/ops/AuthenticateOps.js.map +1 -1
- package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
- package/cjs/ops/EmailTemplateOps.test.js.map +1 -1
- package/cjs/ops/IdmOps.test.js.map +1 -1
- package/cjs/ops/IdpOps.js +182 -275
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/IdpOps.test.js.map +1 -1
- package/cjs/ops/SecretsOps.js +3 -3
- package/cjs/ops/SecretsOps.js.map +1 -1
- package/cjs/ops/VariablesOps.js +3 -3
- package/cjs/ops/VariablesOps.js.map +1 -1
- package/cjs/shared/State.js +1 -1
- package/cjs/shared/State.js.map +1 -1
- package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ig_mytestrun_com.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent1.json} +0 -2
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/{ig_chico.json → FrodoOpsTestGatewayAgent2.json} +0 -2
- package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ig_chico.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent3.json} +0 -2
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/{ig_mytestrun_com.json → FrodoOpsTestGatewayAgent4.json} +0 -2
- package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/api_client.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent5.json} +0 -2
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/{api_client.json → FrodoOpsTestGatewayAgent6.json} +0 -2
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent7.json +20 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent8.json +20 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent9.json +30 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent1.json +30 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent2.json +20 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent3.json +20 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/{javaAgent.json → FrodoOpsTestJavaAgent1.json} +0 -2
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/{tomcatagent.json → FrodoOpsTestJavaAgent2.json} +0 -2
- package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/tomcatagent.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent3.json} +0 -2
- package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/javaAgent.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent4.json} +0 -2
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent5.json +621 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent6.json +628 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent7.json +628 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent8.json +628 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent9.json +628 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent1.json +621 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent2.json +628 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent3.json +628 -0
- package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/apacheagent.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent1.json} +0 -2
- package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/webserver.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent2.json} +0 -2
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/{webserver.json → FrodoOpsTestWebAgent3.json} +0 -2
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/{apacheagent.json → FrodoOpsTestWebAgent4.json} +0 -2
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent5.json +454 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent6.json +453 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent7.json +453 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent8.json +453 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent9.json +453 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent1.json +454 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent2.json +453 -0
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent3.json +453 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +1 -108
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/esm/api/AgentApi.mjs +1 -1
- package/esm/api/AgentApi.test.mjs +323 -246
- package/esm/api/ApiTypes.mjs +16 -16
- package/esm/api/AuthenticateApi.mjs +16 -12
- package/esm/api/AuthenticateApi.test.mjs +77 -35
- package/esm/api/IdmConfigApi.mjs +19 -4
- package/esm/api/NodeApi.test.mjs +248 -914
- package/esm/api/SecretsApi.test.mjs +252 -245
- package/esm/api/SocialIdentityProvidersApi.mjs +16 -0
- package/esm/api/TreeApi.test.mjs +190 -105
- package/esm/api/VariablesApi.test.mjs +108 -12
- package/esm/api/utils/ApiUtils.mjs +12 -4
- package/esm/api/utils/ApiUtils.test.mjs +80 -79
- package/esm/index.mjs +1 -0
- package/esm/ops/AgentOps.test.mjs +780 -1210
- package/esm/ops/AuthenticateOps.mjs +0 -7
- package/esm/ops/ConnectionProfileOps.test.mjs +94 -54
- package/esm/ops/EmailTemplateOps.test.mjs +140 -28
- package/esm/ops/IdmOps.test.mjs +159 -62
- package/esm/ops/IdpOps.mjs +139 -210
- package/esm/ops/IdpOps.test.mjs +651 -52
- package/esm/ops/SecretsOps.mjs +3 -3
- package/esm/ops/VariablesOps.mjs +3 -3
- package/esm/shared/State.mjs +1 -1
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent1.json +30 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent2.json +20 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent3.json +20 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent4.json +30 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent5.json +20 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent6.json +20 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent7.json +20 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent8.json +20 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent9.json +30 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent1.json +30 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent2.json +20 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent3.json +20 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent1.json +621 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent2.json +628 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent3.json +628 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent4.json +621 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent5.json +621 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent6.json +628 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent7.json +628 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent8.json +628 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent9.json +628 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent1.json +621 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent2.json +628 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent3.json +628 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent1.json +454 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent2.json +453 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent3.json +453 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent4.json +454 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent5.json +454 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent6.json +453 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent7.json +453 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent8.json +453 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent9.json +453 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent1.json +454 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent2.json +453 -0
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent3.json +453 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +1 -98
- package/package.json +1 -1
- package/types/api/AgentApi.d.ts.map +1 -1
- package/types/api/ApiTypes.d.ts +21 -21
- package/types/api/ApiTypes.d.ts.map +1 -1
- package/types/api/AuthenticateApi.d.ts +11 -2
- package/types/api/AuthenticateApi.d.ts.map +1 -1
- package/types/api/IdmConfigApi.d.ts +11 -5
- package/types/api/IdmConfigApi.d.ts.map +1 -1
- package/types/api/SocialIdentityProvidersApi.d.ts +7 -0
- package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -1
- package/types/api/utils/ApiUtils.d.ts +7 -1
- package/types/api/utils/ApiUtils.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/ops/AuthenticateOps.d.ts.map +1 -1
- package/types/ops/IdpOps.d.ts +31 -24
- package/types/ops/IdpOps.d.ts.map +1 -1
- package/types/ops/SecretsOps.d.ts.map +1 -1
- package/types/ops/VariablesOps.d.ts.map +1 -1
- package/types/shared/State.d.ts.map +1 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +1 -11
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
- package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +0 -22
- package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +0 -22
|
@@ -398,17 +398,10 @@ export async function getTokens() {
|
|
|
398
398
|
const token = await authenticate(state.getUsername(), state.getPassword());
|
|
399
399
|
if (token) state.setCookieValue(token);
|
|
400
400
|
await determineDeploymentTypeAndDefaultRealmAndVersion();
|
|
401
|
-
debugMessage(`AuthenticateOps.getTokens: before bearer`);
|
|
402
|
-
debugMessage(`AuthenticateOps.getTokens: cookie=${state.getCookieValue()}`);
|
|
403
|
-
debugMessage(`AuthenticateOps.getTokens: bearer=${state.getBearerToken()}`);
|
|
404
|
-
debugMessage(`AuthenticateOps.getTokens: type=${state.getDeploymentType()}`);
|
|
405
|
-
debugMessage(`AuthenticateOps.getTokens: condition=${state.getCookieValue() && !state.getBearerToken() && (state.getDeploymentType() === globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY || state.getDeploymentType() === globalConfig.FORGEOPS_DEPLOYMENT_TYPE_KEY)}`);
|
|
406
401
|
if (state.getCookieValue() && !state.getBearerToken() && (state.getDeploymentType() === globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY || state.getDeploymentType() === globalConfig.FORGEOPS_DEPLOYMENT_TYPE_KEY)) {
|
|
407
|
-
debugMessage(`AuthenticateOps.getTokens: in bearer`);
|
|
408
402
|
const accessToken = await getAccessTokenForUser();
|
|
409
403
|
if (accessToken) state.setBearerToken(accessToken);
|
|
410
404
|
}
|
|
411
|
-
debugMessage(`AuthenticateOps.getTokens: after bearer`);
|
|
412
405
|
}
|
|
413
406
|
// incomplete or no credentials
|
|
414
407
|
else {
|
|
@@ -3,62 +3,102 @@ import { homedir } from 'os';
|
|
|
3
3
|
import { ConnectionProfile, state } from '../index';
|
|
4
4
|
import { FRODO_CONNECTION_PROFILES_PATH_KEY, FRODO_MASTER_KEY_PATH_KEY, FRODO_MASTER_KEY_KEY } from '../storage/StaticStorage';
|
|
5
5
|
describe('ConnectionProfileOps', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
const connectionProfilePath1 = `${homedir()}/connections1.json`;
|
|
7
|
+
const connectionProfilePath2 = `${homedir()}/connections2.json`;
|
|
8
|
+
const connectionProfilePath3 = `${homedir()}/connections3.json`;
|
|
9
|
+
|
|
10
|
+
// delete all connection profile files before running the tests
|
|
11
|
+
beforeAll(() => {
|
|
12
|
+
try {
|
|
13
|
+
fs.unlinkSync(connectionProfilePath1);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
// ignore
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
fs.unlinkSync(connectionProfilePath2);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
// ignore
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
fs.unlinkSync(connectionProfilePath3);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
// ignore
|
|
26
|
+
}
|
|
22
27
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
expect(connections[host].encodedPassword).toBeTruthy();
|
|
28
|
+
|
|
29
|
+
// clean up all connection profile files after running the tests
|
|
30
|
+
afterAll(() => {
|
|
31
|
+
try {
|
|
32
|
+
fs.unlinkSync(connectionProfilePath1);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
// ignore
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
fs.unlinkSync(connectionProfilePath2);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
// ignore
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
fs.unlinkSync(connectionProfilePath3);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
// ignore
|
|
45
|
+
}
|
|
42
46
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
describe('saveConnectionProfile()', () => {
|
|
48
|
+
test('1: Create connection profiles in location from state field', async () => {
|
|
49
|
+
const host = 'https://openam-tenant-name.forgeblocks.com/am';
|
|
50
|
+
const user = 'frodo.baggins@shire.me';
|
|
51
|
+
const password = 'G@nd@lfTheW153';
|
|
52
|
+
state.setHost(host);
|
|
53
|
+
state.setUsername(user);
|
|
54
|
+
state.setPassword(password);
|
|
55
|
+
state.setConnectionProfilesPath(connectionProfilePath1);
|
|
56
|
+
await ConnectionProfile.saveConnectionProfile(host);
|
|
57
|
+
expect(fs.existsSync(connectionProfilePath1)).toBeTruthy();
|
|
58
|
+
const connections = JSON.parse(fs.readFileSync(connectionProfilePath1, 'utf8'));
|
|
59
|
+
expect(connections).toBeTruthy();
|
|
60
|
+
expect(connections[host]).toBeTruthy();
|
|
61
|
+
expect(connections[host].username).toEqual(user);
|
|
62
|
+
expect(connections[host].encodedPassword).toBeTruthy();
|
|
63
|
+
});
|
|
64
|
+
test(`2: Create connection profiles in location from env ${FRODO_MASTER_KEY_PATH_KEY}`, async () => {
|
|
65
|
+
const host = 'https://openam-tenant-name.forgeblocks.com/am';
|
|
66
|
+
const user = 'frodo.baggins@shire.me';
|
|
67
|
+
const password = 'G@nd@lfTheW153';
|
|
68
|
+
// set the hard-coded master key
|
|
69
|
+
process.env[FRODO_CONNECTION_PROFILES_PATH_KEY] = connectionProfilePath2;
|
|
70
|
+
state.setHost(host);
|
|
71
|
+
state.setUsername(user);
|
|
72
|
+
state.setPassword(password);
|
|
73
|
+
state.setConnectionProfilesPath('');
|
|
74
|
+
await ConnectionProfile.saveConnectionProfile(host);
|
|
75
|
+
expect(ConnectionProfile.getConnectionProfilesPath()).toEqual(connectionProfilePath2);
|
|
76
|
+
expect(fs.existsSync(connectionProfilePath2)).toBeTruthy();
|
|
77
|
+
const connections = JSON.parse(fs.readFileSync(connectionProfilePath2, 'utf8'));
|
|
78
|
+
expect(connections).toBeTruthy();
|
|
79
|
+
expect(connections[host]).toBeTruthy();
|
|
80
|
+
expect(connections[host].username).toEqual(user);
|
|
81
|
+
expect(connections[host].encodedPassword).toBeTruthy();
|
|
82
|
+
});
|
|
83
|
+
test(`3: Use Master Key from env ${FRODO_MASTER_KEY_KEY}`, async () => {
|
|
84
|
+
const host = 'https://openam-tenant-name.forgeblocks.com/am';
|
|
85
|
+
const user = 'frodo.baggins@shire.me';
|
|
86
|
+
const password = 'G@nd@lfTheW153';
|
|
87
|
+
const masterKey = 'bxnQlhcU5VfyDs+BBPhRhK09yHaNtdIIk85HUMKBnqg=';
|
|
88
|
+
// set the hard-coded master key
|
|
89
|
+
process.env[FRODO_MASTER_KEY_KEY] = masterKey;
|
|
90
|
+
state.setHost(host);
|
|
91
|
+
state.setUsername(user);
|
|
92
|
+
state.setPassword(password);
|
|
93
|
+
state.setConnectionProfilesPath(connectionProfilePath3);
|
|
94
|
+
await ConnectionProfile.saveConnectionProfile(host);
|
|
95
|
+
expect(fs.existsSync(connectionProfilePath3)).toBeTruthy();
|
|
96
|
+
const connections = JSON.parse(fs.readFileSync(connectionProfilePath3, 'utf8'));
|
|
97
|
+
expect(connections).toBeTruthy();
|
|
98
|
+
expect(connections[host]).toBeTruthy();
|
|
99
|
+
expect(connections[host].username).toEqual(user);
|
|
100
|
+
expect(connections[host].encodedPassword).toBeTruthy();
|
|
101
|
+
});
|
|
62
102
|
});
|
|
63
103
|
});
|
|
64
104
|
//# sourceMappingURL=ConnectionProfileOps.test.js.map
|
|
@@ -1,34 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
state
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
* To record and update ESM snapshots, you must call the test:record
|
|
7
|
+
* script and override all the connection state variables required
|
|
8
|
+
* to connect to the env to record from:
|
|
9
|
+
*
|
|
10
|
+
* FRODO_DEBUG=1 FRODO_HOST=frodo-dev npm run test:record EmailTemplateOps
|
|
11
|
+
*
|
|
12
|
+
* The above command assumes that you have a connection profile for
|
|
13
|
+
* 'frodo-dev' on your development machine.
|
|
14
|
+
*
|
|
15
|
+
* 2. Update CJS snapshots
|
|
16
|
+
*
|
|
17
|
+
* After recording, the ESM snapshots will already be updated as that happens
|
|
18
|
+
* in one go, but you musty manually update the CJS snapshots by running:
|
|
19
|
+
*
|
|
20
|
+
* FRODO_DEBUG=1 npm run test:update EmailTemplateOps
|
|
21
|
+
*
|
|
22
|
+
* 3. Test your changes
|
|
23
|
+
*
|
|
24
|
+
* If 1 and 2 didn't produce any errors, you are ready to run the tests in
|
|
25
|
+
* replay mode and make sure they all succeed as well:
|
|
26
|
+
*
|
|
27
|
+
* npm run test:only EmailTemplateOps
|
|
28
|
+
*
|
|
29
|
+
* Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
|
|
30
|
+
* in case things don't function as expected
|
|
31
|
+
*/
|
|
32
|
+
import { EmailTemplate, IdmConfigRaw } from '../index';
|
|
33
|
+
import { autoSetupPolly } from '../utils/AutoSetupPolly';
|
|
34
|
+
autoSetupPolly();
|
|
35
|
+
const {
|
|
36
|
+
EMAIL_TEMPLATE_TYPE
|
|
37
|
+
} = EmailTemplate;
|
|
38
|
+
async function stageTemplate(template, create = true) {
|
|
39
|
+
// delete if exists, then create
|
|
40
|
+
try {
|
|
41
|
+
await IdmConfigRaw.getConfigEntity(`${EMAIL_TEMPLATE_TYPE}/${template.id}`);
|
|
42
|
+
await IdmConfigRaw.deleteConfigEntity(`${EMAIL_TEMPLATE_TYPE}/${template.id}`);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
// ignore
|
|
45
|
+
} finally {
|
|
46
|
+
if (create) {
|
|
47
|
+
await IdmConfigRaw.putConfigEntity(`${EMAIL_TEMPLATE_TYPE}/${template.id}`, template.data);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
describe('EmailTemplateOps', () => {
|
|
52
|
+
const template1 = {
|
|
53
|
+
id: 'FrodoTestEmailTemplate1',
|
|
54
|
+
data: {
|
|
55
|
+
defaultLocale: 'en',
|
|
56
|
+
displayName: 'Frodo Test Email Template One',
|
|
57
|
+
enabled: true,
|
|
58
|
+
from: '',
|
|
59
|
+
message: {
|
|
60
|
+
en: '<h3>Click to reset your password</h3><h4><a href="{{object.resumeURI}}">Password reset link</a></h4>',
|
|
61
|
+
fr: '<h3>Cliquez pour réinitialiser votre mot de passe</h3><h4><a href="{{object.resumeURI}}">Mot de passe lien de réinitialisation</a></h4>'
|
|
62
|
+
},
|
|
63
|
+
mimeType: 'text/html',
|
|
64
|
+
subject: {
|
|
65
|
+
en: 'Reset your password',
|
|
66
|
+
fr: 'Réinitialisez votre mot de passe'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const template2 = {
|
|
71
|
+
id: 'FrodoTestEmailTemplate2',
|
|
72
|
+
data: {
|
|
73
|
+
defaultLocale: 'en',
|
|
74
|
+
displayName: 'Frodo Test Email Template Two',
|
|
75
|
+
enabled: true,
|
|
76
|
+
from: '',
|
|
77
|
+
message: {
|
|
78
|
+
en: '<h3>This is your one-time password:</h3><h4>{{object.description}}</a></h4>'
|
|
79
|
+
},
|
|
80
|
+
mimeType: 'text/html',
|
|
81
|
+
subject: {
|
|
82
|
+
en: 'One-Time Password for login'
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const template3 = {
|
|
87
|
+
id: 'FrodoTestEmailTemplate3',
|
|
88
|
+
data: {
|
|
89
|
+
defaultLocale: 'en',
|
|
90
|
+
displayName: 'Frodo Test Email Template Three',
|
|
91
|
+
enabled: true,
|
|
92
|
+
from: '',
|
|
93
|
+
message: {
|
|
94
|
+
en: '<html><body><h3>You started a login or profile update that requires MFA. </h3><h4><a href="{{object.resumeURI}}">Click to Proceed</a></h4></body></html>'
|
|
95
|
+
},
|
|
96
|
+
mimeType: 'text/html',
|
|
97
|
+
subject: {
|
|
98
|
+
en: 'Multi-Factor Email for Identity Cloud login'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
// in recording mode, setup test data before recording
|
|
103
|
+
beforeAll(async () => {
|
|
104
|
+
if (process.env.FRODO_POLLY_MODE === 'record') {
|
|
105
|
+
await stageTemplate(template1);
|
|
106
|
+
await stageTemplate(template2);
|
|
107
|
+
await stageTemplate(template3, false);
|
|
108
|
+
}
|
|
15
109
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
110
|
+
// in recording mode, remove test data after recording
|
|
111
|
+
afterAll(async () => {
|
|
112
|
+
if (process.env.FRODO_POLLY_MODE === 'record') {
|
|
113
|
+
await stageTemplate(template1, false);
|
|
114
|
+
await stageTemplate(template2, false);
|
|
115
|
+
await stageTemplate(template3, false);
|
|
116
|
+
}
|
|
20
117
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
118
|
+
describe('getEmailTemplate()', () => {
|
|
119
|
+
test('0: Method is implemented', async () => {
|
|
120
|
+
expect(EmailTemplate.getEmailTemplate).toBeDefined();
|
|
121
|
+
});
|
|
122
|
+
test(`1: Get email template '${template1.id}'`, async () => {
|
|
123
|
+
const response = await EmailTemplate.getEmailTemplate(template1.id);
|
|
124
|
+
expect(response).toMatchSnapshot();
|
|
125
|
+
});
|
|
27
126
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
127
|
+
describe('getEmailTemplates()', () => {
|
|
128
|
+
test('0: Method is implemented', async () => {
|
|
129
|
+
expect(EmailTemplate.getEmailTemplates).toBeDefined();
|
|
130
|
+
});
|
|
131
|
+
test('1: Get all email templates', async () => {
|
|
132
|
+
const response = await EmailTemplate.getEmailTemplates();
|
|
133
|
+
expect(response).toMatchSnapshot();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
describe('putEmailTemplate()', () => {
|
|
137
|
+
test('0: Method is implemented', async () => {
|
|
138
|
+
expect(EmailTemplate.putEmailTemplate).toBeDefined();
|
|
139
|
+
});
|
|
140
|
+
test(`1: Create email template '${template3.id}'`, async () => {
|
|
141
|
+
const response = await EmailTemplate.putEmailTemplate(template3.id, template3.data);
|
|
142
|
+
expect(response).toMatchSnapshot();
|
|
143
|
+
});
|
|
32
144
|
});
|
|
33
145
|
});
|
|
34
146
|
//# sourceMappingURL=EmailTemplateOps.test.js.map
|
package/esm/ops/IdmOps.test.mjs
CHANGED
|
@@ -1,72 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
* To record and update ESM snapshots, you must call the test:record
|
|
7
|
+
* script and override all the connection state variables required
|
|
8
|
+
* to connect to the env to record from:
|
|
9
|
+
*
|
|
10
|
+
* FRODO_DEBUG=1 FRODO_HOST=frodo-dev npm run test:record IdmOps
|
|
11
|
+
*
|
|
12
|
+
* The above command assumes that you have a connection profile for
|
|
13
|
+
* 'frodo-dev' on your development machine.
|
|
14
|
+
*
|
|
15
|
+
* 2. Update CJS snapshots
|
|
16
|
+
*
|
|
17
|
+
* After recording, the ESM snapshots will already be updated as that happens
|
|
18
|
+
* in one go, but you musty manually update the CJS snapshots by running:
|
|
19
|
+
*
|
|
20
|
+
* FRODO_DEBUG=1 npm run test:update IdmOps
|
|
21
|
+
*
|
|
22
|
+
* 3. Test your changes
|
|
23
|
+
*
|
|
24
|
+
* If 1 and 2 didn't produce any errors, you are ready to run the tests in
|
|
25
|
+
* replay mode and make sure they all succeed as well:
|
|
26
|
+
*
|
|
27
|
+
* npm run test:only IdmOps
|
|
28
|
+
*
|
|
29
|
+
* Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
|
|
30
|
+
* in case things don't function as expected
|
|
31
|
+
*/
|
|
32
|
+
import { Idm, IdmConfigRaw } from '../index';
|
|
33
|
+
import { autoSetupPolly } from '../utils/AutoSetupPolly';
|
|
34
|
+
autoSetupPolly();
|
|
35
|
+
async function stageConfigEntity(configEntity, create = true) {
|
|
36
|
+
// delete if exists, then create
|
|
37
|
+
try {
|
|
38
|
+
await IdmConfigRaw.getConfigEntity(configEntity.id);
|
|
39
|
+
await IdmConfigRaw.deleteConfigEntity(configEntity.id);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// ignore
|
|
42
|
+
} finally {
|
|
43
|
+
if (create) {
|
|
44
|
+
await IdmConfigRaw.putConfigEntity(configEntity.id, configEntity.data);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
describe('IdmOps', () => {
|
|
49
|
+
const configEntity1 = {
|
|
50
|
+
id: 'emailTemplate/FrodoTestConfigEntity1',
|
|
51
|
+
data: {
|
|
52
|
+
defaultLocale: 'en',
|
|
53
|
+
displayName: 'Frodo Test Email Template One',
|
|
54
|
+
enabled: true,
|
|
55
|
+
from: '',
|
|
56
|
+
message: {
|
|
57
|
+
en: '<h3>Click to reset your password</h3><h4><a href="{{object.resumeURI}}">Password reset link</a></h4>',
|
|
58
|
+
fr: '<h3>Cliquez pour réinitialiser votre mot de passe</h3><h4><a href="{{object.resumeURI}}">Mot de passe lien de réinitialisation</a></h4>'
|
|
59
|
+
},
|
|
60
|
+
mimeType: 'text/html',
|
|
61
|
+
subject: {
|
|
62
|
+
en: 'Reset your password',
|
|
63
|
+
fr: 'Réinitialisez votre mot de passe'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const configEntity2 = {
|
|
68
|
+
id: 'emailTemplate/FrodoTestConfigEntity2',
|
|
69
|
+
data: {
|
|
70
|
+
defaultLocale: 'en',
|
|
71
|
+
displayName: 'Frodo Test Email Template Two',
|
|
72
|
+
enabled: true,
|
|
73
|
+
from: '',
|
|
74
|
+
message: {
|
|
75
|
+
en: '<h3>This is your one-time password:</h3><h4>{{object.description}}</a></h4>'
|
|
76
|
+
},
|
|
77
|
+
mimeType: 'text/html',
|
|
78
|
+
subject: {
|
|
79
|
+
en: 'One-Time Password for login'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const configEntity3 = {
|
|
84
|
+
id: 'emailTemplate/FrodoTestConfigEntity3',
|
|
85
|
+
data: {
|
|
86
|
+
defaultLocale: 'en',
|
|
87
|
+
displayName: 'Frodo Test Email Template Three',
|
|
88
|
+
enabled: true,
|
|
89
|
+
from: '',
|
|
90
|
+
message: {
|
|
91
|
+
en: '<html><body><h3>You started a login or profile update that requires MFA. </h3><h4><a href="{{object.resumeURI}}">Click to Proceed</a></h4></body></html>'
|
|
92
|
+
},
|
|
93
|
+
mimeType: 'text/html',
|
|
94
|
+
subject: {
|
|
95
|
+
en: 'Multi-Factor Email for Identity Cloud login'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
// in recording mode, setup test data before recording
|
|
100
|
+
beforeAll(async () => {
|
|
101
|
+
if (process.env.FRODO_POLLY_MODE === 'record') {
|
|
102
|
+
await stageConfigEntity(configEntity1);
|
|
103
|
+
await stageConfigEntity(configEntity2);
|
|
104
|
+
await stageConfigEntity(configEntity3, false);
|
|
105
|
+
}
|
|
19
106
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
107
|
+
// in recording mode, remove test data after recording
|
|
108
|
+
afterAll(async () => {
|
|
109
|
+
if (process.env.FRODO_POLLY_MODE === 'record') {
|
|
110
|
+
await stageConfigEntity(configEntity1, false);
|
|
111
|
+
await stageConfigEntity(configEntity2, false);
|
|
112
|
+
await stageConfigEntity(configEntity3, false);
|
|
113
|
+
}
|
|
26
114
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const configEntity = await Idm.getConfigEntitiesByType('emailTemplate');
|
|
36
|
-
expect(configEntity).toBeTruthy();
|
|
37
|
-
expect(configEntity).toMatchSnapshot();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('IdmOps - getConfigEntity()', () => {
|
|
41
|
-
test('getConfigEntity() 0: Method is implemented', async () => {
|
|
42
|
-
expect(Idm.getConfigEntity).toBeDefined();
|
|
115
|
+
describe('getAllConfigEntities()', () => {
|
|
116
|
+
test('0: Method is implemented', async () => {
|
|
117
|
+
expect(Idm.getAllConfigEntities).toBeDefined();
|
|
118
|
+
});
|
|
119
|
+
test('1: get all config entities', async () => {
|
|
120
|
+
const response = await Idm.getAllConfigEntities();
|
|
121
|
+
expect(response).toMatchSnapshot();
|
|
122
|
+
});
|
|
43
123
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
124
|
+
describe('getConfigEntitiesByType()', () => {
|
|
125
|
+
test('0: Method is implemented', async () => {
|
|
126
|
+
expect(Idm.getConfigEntitiesByType).toBeDefined();
|
|
127
|
+
});
|
|
128
|
+
test('1: Get config entity by type (emailTemplate)', async () => {
|
|
129
|
+
const response = await Idm.getConfigEntitiesByType('emailTemplate');
|
|
130
|
+
expect(response).toMatchSnapshot();
|
|
131
|
+
});
|
|
132
|
+
test('2: Get config entity by type (managed)', async () => {
|
|
133
|
+
const response = await Idm.getConfigEntitiesByType('managed');
|
|
134
|
+
expect(response).toMatchSnapshot();
|
|
135
|
+
});
|
|
50
136
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
137
|
+
describe('getConfigEntity()', () => {
|
|
138
|
+
test('0: Method is implemented', async () => {
|
|
139
|
+
expect(Idm.getConfigEntity).toBeDefined();
|
|
140
|
+
});
|
|
141
|
+
test(`1: Get config entity '${configEntity1.id}'`, async () => {
|
|
142
|
+
const response = await Idm.getConfigEntity(configEntity1.id);
|
|
143
|
+
expect(response).toMatchSnapshot();
|
|
144
|
+
});
|
|
145
|
+
test("2: Get config entity 'managed'", async () => {
|
|
146
|
+
const response = await Idm.getConfigEntity('managed');
|
|
147
|
+
expect(response).toMatchSnapshot();
|
|
148
|
+
});
|
|
55
149
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
150
|
+
describe('putConfigEntity()', () => {
|
|
151
|
+
test('0: Method is implemented', async () => {
|
|
152
|
+
expect(Idm.putConfigEntity).toBeDefined();
|
|
153
|
+
});
|
|
154
|
+
test(`1: Put a config entity '${configEntity3.id}'`, async () => {
|
|
155
|
+
const response = await Idm.putConfigEntity(configEntity3.id, configEntity3.data);
|
|
156
|
+
expect(response).toMatchSnapshot();
|
|
61
157
|
});
|
|
62
|
-
await Idm.putConfigEntity('emailTemplate/welcome', templateData);
|
|
63
|
-
expect(uploaded).toBeDefined();
|
|
64
|
-
expect(uploaded).toMatchSnapshot();
|
|
65
158
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
159
|
+
describe('queryAllManagedObjectsByType()', () => {
|
|
160
|
+
test('0: Method is implemented', async () => {
|
|
161
|
+
expect(Idm.queryAllManagedObjectsByType).toBeDefined();
|
|
162
|
+
});
|
|
163
|
+
test(`1: Query managed objects of type 'alpha_user'`, async () => {
|
|
164
|
+
const response = await Idm.queryAllManagedObjectsByType('alpha_user', ['*'], null);
|
|
165
|
+
expect(response).toMatchSnapshot();
|
|
166
|
+
});
|
|
70
167
|
});
|
|
71
168
|
});
|
|
72
169
|
//# sourceMappingURL=IdmOps.test.js.map
|