@rockcarver/frodo-lib 0.17.1 → 0.17.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/cjs/api/AgentApi.js +1 -1
  3. package/cjs/api/AgentApi.js.map +1 -1
  4. package/cjs/api/AgentApi.test.js.map +1 -1
  5. package/cjs/api/AuthenticateApi.js +17 -12
  6. package/cjs/api/AuthenticateApi.js.map +1 -1
  7. package/cjs/api/AuthenticateApi.test.js.map +1 -1
  8. package/cjs/api/NodeApi.test.js.map +1 -1
  9. package/cjs/api/SecretsApi.test.js.map +1 -1
  10. package/cjs/api/TreeApi.test.js.map +1 -1
  11. package/cjs/api/VariablesApi.test.js.map +1 -1
  12. package/cjs/api/utils/ApiUtils.js +13 -4
  13. package/cjs/api/utils/ApiUtils.js.map +1 -1
  14. package/cjs/api/utils/ApiUtils.test.js.map +1 -1
  15. package/cjs/ops/AgentOps.test.js.map +1 -1
  16. package/cjs/ops/AuthenticateOps.js +6 -0
  17. package/cjs/ops/AuthenticateOps.js.map +1 -1
  18. package/cjs/ops/AuthenticateOps.test.js.map +1 -1
  19. package/cjs/ops/SecretsOps.js +3 -3
  20. package/cjs/ops/SecretsOps.js.map +1 -1
  21. package/cjs/ops/ServiceAccountOps.test.js.map +1 -1
  22. package/cjs/ops/VariablesOps.js +3 -3
  23. package/cjs/ops/VariablesOps.js.map +1 -1
  24. package/cjs/shared/State.js +42 -2
  25. package/cjs/shared/State.js.map +1 -1
  26. package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ig_mytestrun_com.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent1.json} +0 -2
  27. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/{ig_chico.json → FrodoOpsTestGatewayAgent2.json} +0 -2
  28. package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ig_chico.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent3.json} +0 -2
  29. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/{ig_mytestrun_com.json → FrodoOpsTestGatewayAgent4.json} +0 -2
  30. package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/api_client.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent5.json} +0 -2
  31. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/{api_client.json → FrodoOpsTestGatewayAgent6.json} +0 -2
  32. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent7.json +20 -0
  33. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent8.json +20 -0
  34. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent9.json +30 -0
  35. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent1.json +30 -0
  36. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent2.json +20 -0
  37. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent3.json +20 -0
  38. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/{javaAgent.json → FrodoOpsTestJavaAgent1.json} +0 -2
  39. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/{tomcatagent.json → FrodoOpsTestJavaAgent2.json} +0 -2
  40. package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/tomcatagent.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent3.json} +0 -2
  41. package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/javaAgent.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent4.json} +0 -2
  42. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent5.json +621 -0
  43. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent6.json +628 -0
  44. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent7.json +628 -0
  45. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent8.json +628 -0
  46. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent9.json +628 -0
  47. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent1.json +621 -0
  48. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent2.json +628 -0
  49. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent3.json +628 -0
  50. package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/apacheagent.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent1.json} +0 -2
  51. package/{esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/webserver.json → cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent2.json} +0 -2
  52. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/{webserver.json → FrodoOpsTestWebAgent3.json} +0 -2
  53. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/{apacheagent.json → FrodoOpsTestWebAgent4.json} +0 -2
  54. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent5.json +454 -0
  55. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent6.json +453 -0
  56. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent7.json +453 -0
  57. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent8.json +453 -0
  58. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent9.json +453 -0
  59. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent1.json +454 -0
  60. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent2.json +453 -0
  61. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent3.json +453 -0
  62. package/cjs/test/mocks/TreeApi/putTree/FrodoTest.json +0 -2
  63. package/cjs/utils/AutoSetupPolly.js +43 -30
  64. package/cjs/utils/AutoSetupPolly.js.map +1 -1
  65. package/esm/api/AgentApi.mjs +1 -1
  66. package/esm/api/AgentApi.test.mjs +323 -246
  67. package/esm/api/AuthenticateApi.mjs +16 -12
  68. package/esm/api/AuthenticateApi.test.mjs +77 -35
  69. package/esm/api/NodeApi.test.mjs +248 -914
  70. package/esm/api/SecretsApi.test.mjs +252 -245
  71. package/esm/api/TreeApi.test.mjs +323 -135
  72. package/esm/api/VariablesApi.test.mjs +153 -41
  73. package/esm/api/utils/ApiUtils.mjs +12 -4
  74. package/esm/api/utils/ApiUtils.test.mjs +80 -79
  75. package/esm/ops/AgentOps.test.mjs +780 -1210
  76. package/esm/ops/AuthenticateOps.mjs +6 -0
  77. package/esm/ops/AuthenticateOps.test.mjs +63 -12
  78. package/esm/ops/SecretsOps.mjs +3 -3
  79. package/esm/ops/ServiceAccountOps.test.mjs +5 -0
  80. package/esm/ops/VariablesOps.mjs +3 -3
  81. package/esm/shared/State.mjs +42 -2
  82. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent1.json +30 -0
  83. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent2.json +20 -0
  84. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent3.json +20 -0
  85. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent4.json +30 -0
  86. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent5.json +20 -0
  87. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent6.json +20 -0
  88. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent7.json +20 -0
  89. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent8.json +20 -0
  90. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoOpsTestGatewayAgent9.json +30 -0
  91. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent1.json +30 -0
  92. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent2.json +20 -0
  93. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/FrodoTestGatewayAgent3.json +20 -0
  94. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent1.json +621 -0
  95. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent2.json +628 -0
  96. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent3.json +628 -0
  97. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent4.json +621 -0
  98. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent5.json +621 -0
  99. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent6.json +628 -0
  100. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent7.json +628 -0
  101. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent8.json +628 -0
  102. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoOpsTestJavaAgent9.json +628 -0
  103. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent1.json +621 -0
  104. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent2.json +628 -0
  105. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/FrodoTestJavaAgent3.json +628 -0
  106. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent1.json +454 -0
  107. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent2.json +453 -0
  108. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent3.json +453 -0
  109. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent4.json +454 -0
  110. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent5.json +454 -0
  111. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent6.json +453 -0
  112. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent7.json +453 -0
  113. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent8.json +453 -0
  114. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoOpsTestWebAgent9.json +453 -0
  115. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent1.json +454 -0
  116. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent2.json +453 -0
  117. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/FrodoTestWebAgent3.json +453 -0
  118. package/esm/test/mocks/TreeApi/putTree/FrodoTest.json +0 -2
  119. package/esm/utils/AutoSetupPolly.mjs +41 -30
  120. package/package.json +4 -4
  121. package/types/api/AgentApi.d.ts.map +1 -1
  122. package/types/api/AuthenticateApi.d.ts +11 -2
  123. package/types/api/AuthenticateApi.d.ts.map +1 -1
  124. package/types/api/utils/ApiUtils.d.ts +7 -1
  125. package/types/api/utils/ApiUtils.d.ts.map +1 -1
  126. package/types/ops/AuthenticateOps.d.ts.map +1 -1
  127. package/types/ops/SecretsOps.d.ts.map +1 -1
  128. package/types/ops/VariablesOps.d.ts.map +1 -1
  129. package/types/shared/State.d.ts.map +1 -1
  130. package/types/utils/AutoSetupPolly.d.ts +2 -1
  131. package/types/utils/AutoSetupPolly.d.ts.map +1 -1
  132. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +0 -22
  133. package/cjs/utils/SetupJest.js +0 -6
  134. package/cjs/utils/SetupJest.js.map +0 -1
  135. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +0 -22
  136. package/esm/utils/SetupJest.mjs +0 -3
  137. package/types/utils/SetupJest.d.ts +0 -1
  138. package/types/utils/SetupJest.d.ts.map +0 -1
@@ -1,927 +1,261 @@
1
- import axios from 'axios';
2
- import MockAdapter from 'axios-mock-adapter';
3
- import { NodeRaw, state } from '../index';
4
- import fs from 'fs';
5
- import path from 'path';
6
- import { fileURLToPath } from 'url';
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
- const mock = new MockAdapter(axios);
9
- state.setHost('');
10
- state.setRealm('alpha');
11
- state.setCookieName('cookieName');
12
- state.setCookieValue('cookieValue');
13
- describe('NodeApi - getNodeTypes()', () => {
14
- test('getNodeTypes() 0: Method is implemented', async () => {
15
- expect(NodeRaw.getNodeTypes).toBeDefined();
16
- });
17
- test('getNodeTypes() 1: Get all node types', async () => {
18
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/NodeApi/getNodeTypes/types.json'), 'utf8'));
19
- mock.onPost(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes?_action=getAllTypes`).reply(200, response);
20
- const types = await NodeRaw.getNodeTypes();
21
- expect(types).toBeTruthy();
22
- expect(types.result.length).toBe(99);
23
- });
24
- });
25
- describe('NodeApi - getNodes()', () => {
26
- test('getNodes() 0: Method is implemented', async () => {
27
- expect(NodeRaw.getNodes).toBeDefined();
28
- });
29
- test('getNodes() 1: Get all nodes', async () => {
30
- const response = {
31
- result: [{
32
- usernameAttribute: 'userName',
33
- validateInput: true,
34
- _id: '7fcaf48e-a754-4959-858b-05b2933b825f',
35
- _type: {
36
- _id: 'ValidatedUsernameNode',
37
- name: 'Platform Username',
38
- collection: true
39
- },
40
- _outcomes: [{
41
- id: 'outcome',
42
- displayName: 'Outcome'
43
- }]
44
- }, {
45
- usernameAttribute: 'userName',
46
- validateInput: false,
47
- _id: '7354982f-57b6-4b04-9ddc-f1dd1e1e07d0',
48
- _type: {
49
- _id: 'ValidatedUsernameNode',
50
- name: 'Platform Username',
51
- collection: true
52
- },
53
- _outcomes: [{
54
- id: 'outcome',
55
- displayName: 'Outcome'
56
- }]
57
- }, {
58
- interval: 'AT',
59
- identityAttribute: 'userName',
60
- amount: 3,
61
- _id: '8afdaec3-275e-4301-bb53-34f03e6a4b29',
62
- _type: {
63
- _id: 'LoginCountDecisionNode',
64
- name: 'Login Count Decision',
65
- collection: true
66
- },
67
- _outcomes: [{
68
- id: 'true',
69
- displayName: 'True'
70
- }, {
71
- id: 'false',
72
- displayName: 'False'
73
- }]
74
- }, {
75
- identityAttribute: 'mail',
76
- identifier: 'userName',
77
- _id: '21b8ddf3-0203-4ae1-ab05-51cf3a3a707a',
78
- _type: {
79
- _id: 'IdentifyExistingUserNode',
80
- name: 'Identify Existing User',
81
- collection: true
82
- },
83
- _outcomes: [{
84
- id: 'true',
85
- displayName: 'True'
86
- }, {
87
- id: 'false',
88
- displayName: 'False'
89
- }]
90
- }, {
91
- identityAttribute: 'mail',
92
- identifier: 'userName',
93
- _id: 'bf9ea8d5-9802-4f26-9664-a21840faac23',
94
- _type: {
95
- _id: 'IdentifyExistingUserNode',
96
- name: 'Identify Existing User',
97
- collection: true
98
- },
99
- _outcomes: [{
100
- id: 'true',
101
- displayName: 'True'
102
- }, {
103
- id: 'false',
104
- displayName: 'False'
105
- }]
106
- }, {
107
- _id: '59952413-9bc2-47e5-a9b2-b04c1d729e24',
108
- _type: {
109
- _id: 'UsernameCollectorNode',
110
- name: 'Username Collector',
111
- collection: true
112
- },
113
- _outcomes: [{
114
- id: 'outcome',
115
- displayName: 'Outcome'
116
- }]
117
- }, {
118
- identityResource: 'managed/alpha_user',
119
- _id: 'ad5dcbb3-7335-49b7-b3e7-7d850bb88237',
120
- _type: {
121
- _id: 'CreateObjectNode',
122
- name: 'Create Object',
123
- collection: true
124
- },
125
- _outcomes: [{
126
- id: 'CREATED',
127
- displayName: 'Created'
128
- }, {
129
- id: 'FAILURE',
130
- displayName: 'Failed'
131
- }]
132
- }, {
133
- nodes: [{
134
- _id: '7354982f-57b6-4b04-9ddc-f1dd1e1e07d0',
135
- nodeType: 'ValidatedUsernameNode',
136
- displayName: 'Platform Username'
137
- }, {
138
- _id: '0c80c39b-4813-4e67-b4fb-5a0bba85f994',
139
- nodeType: 'ValidatedPasswordNode',
140
- displayName: 'Platform Password'
141
- }],
142
- pageDescription: {
143
- en: 'New here? <a href="#/service/Registration">Create an account</a><br><a href="#/service/ForgottenUsername">Forgot username?</a><a href="#/service/ResetPassword"> Forgot password?</a>'
144
- },
145
- pageHeader: {
146
- en: 'Sign In'
147
- },
148
- _id: 'a12bc72f-ad97-4f1e-a789-a1fa3dd566c8',
149
- _type: {
150
- _id: 'PageNode',
151
- name: 'Page Node',
152
- collection: true
153
- },
154
- _outcomes: [{
155
- id: 'outcome',
156
- displayName: 'Outcome'
157
- }]
158
- }, {
159
- nodes: [{
160
- _id: '7fcaf48e-a754-4959-858b-05b2933b825f',
161
- nodeType: 'ValidatedUsernameNode',
162
- displayName: 'Platform Username'
163
- }, {
164
- _id: 'd3ce2036-1523-4ce8-b1a2-895a2a036667',
165
- nodeType: 'AttributeCollectorNode',
166
- displayName: 'Attribute Collector'
167
- }, {
168
- _id: '3d8709a1-f09f-4d1f-8094-2850e472c1db',
169
- nodeType: 'ValidatedPasswordNode',
170
- displayName: 'Platform Password'
171
- }, {
172
- _id: '120c69d3-90b4-4ad4-b7af-380e8b119340',
173
- nodeType: 'KbaCreateNode',
174
- displayName: 'KBA Definition'
175
- }, {
176
- _id: 'b4a0e915-c15d-4b83-9c9d-18347d645976',
177
- nodeType: 'AcceptTermsAndConditionsNode',
178
- displayName: 'Accept Terms and Conditions'
179
- }],
180
- pageDescription: {
181
- en: "Signing up is fast and easy.<br>Already have an account? <a href='#/service/Login'>Sign In</a>"
182
- },
183
- pageHeader: {
184
- en: 'Sign Up'
185
- },
186
- _id: '0c091c49-f3af-48fb-ac6f-07fba0499dd6',
187
- _type: {
188
- _id: 'PageNode',
189
- name: 'Page Node',
190
- collection: true
191
- },
192
- _outcomes: [{
193
- id: 'outcome',
194
- displayName: 'Outcome'
195
- }]
196
- }, {
197
- nodes: [{
198
- _id: '21a99653-a7a7-47ee-b650-f493a84bba09',
199
- nodeType: 'ValidatedPasswordNode',
200
- displayName: 'Platform Password'
201
- }],
202
- pageDescription: {
203
- en: 'Enter new password'
204
- },
205
- pageHeader: {
206
- en: 'Update Password'
207
- },
208
- _id: 'd018fcd1-4e22-4160-8c41-63bee51c9cb3',
209
- _type: {
210
- _id: 'PageNode',
211
- name: 'Page Node',
212
- collection: true
213
- },
214
- _outcomes: [{
215
- id: 'outcome',
216
- displayName: 'Outcome'
217
- }]
218
- }, {
219
- nodes: [{
220
- _id: '0a042e10-b22e-4e02-86c4-65e26e775f7a',
221
- nodeType: 'AttributeCollectorNode',
222
- displayName: 'Attribute Collector'
223
- }],
224
- pageDescription: {},
225
- pageHeader: {
226
- en: 'Please select your preferences'
227
- },
228
- _id: 'a5aecad8-854a-4ed5-b719-ff6c90e858c0',
229
- _type: {
230
- _id: 'PageNode',
231
- name: 'Page Node',
232
- collection: true
233
- },
234
- _outcomes: [{
235
- id: 'outcome',
236
- displayName: 'Outcome'
237
- }]
238
- }, {
239
- nodes: [{
240
- _id: 'fe2962fc-4db3-4066-8624-553649afc438',
241
- nodeType: 'ValidatedPasswordNode',
242
- displayName: 'Platform Password'
243
- }],
244
- pageDescription: {
245
- en: 'Enter current password'
246
- },
247
- pageHeader: {
248
- en: 'Verify Existing Password'
249
- },
250
- _id: '20237b34-26cb-4a0b-958f-abb422290d42',
251
- _type: {
252
- _id: 'PageNode',
253
- name: 'Page Node',
254
- collection: true
255
- },
256
- _outcomes: [{
257
- id: 'outcome',
258
- displayName: 'Outcome'
259
- }]
260
- }, {
261
- nodes: [{
262
- _id: '59952413-9bc2-47e5-a9b2-b04c1d729e24',
263
- nodeType: 'UsernameCollectorNode',
264
- displayName: 'Username Collector'
265
- }, {
266
- _id: '8c217417-11dd-4a0f-a9e4-59c2390085be',
267
- nodeType: 'PasswordCollectorNode',
268
- displayName: 'Password Collector'
269
- }],
270
- pageDescription: {},
271
- pageHeader: {},
272
- _id: '6b9a715d-ea23-4eae-9a59-69797c147157',
273
- _type: {
274
- _id: 'PageNode',
275
- name: 'Page Node',
276
- collection: true
277
- },
278
- _outcomes: [{
279
- id: 'outcome',
280
- displayName: 'Outcome'
281
- }]
282
- }, {
283
- nodes: [{
284
- _id: '009c19c8-9572-47bb-adb2-1f092c559a43',
285
- nodeType: 'ValidatedPasswordNode',
286
- displayName: 'Platform Password'
287
- }],
288
- pageDescription: {
289
- en: 'Change password'
290
- },
291
- pageHeader: {
292
- en: 'Reset Password'
293
- },
294
- _id: 'e4c752f9-c625-48c9-9644-a58802fa9e9c',
295
- _type: {
296
- _id: 'PageNode',
297
- name: 'Page Node',
298
- collection: true
299
- },
300
- _outcomes: [{
301
- id: 'outcome',
302
- displayName: 'Outcome'
303
- }]
304
- }, {
305
- nodes: [{
306
- _id: 'a3f63691-1a79-4b11-be47-26f40403292d',
307
- nodeType: 'ScriptedDecisionNode',
308
- displayName: 'Remove Button'
309
- }],
310
- pageDescription: {},
311
- stage: '{"themeId":"63e19668-909f-479e-83d7-be7a01cd8187"}',
312
- pageHeader: {
313
- en: 'No Access'
314
- },
315
- _id: 'bdda3e99-3a7f-45ec-b39d-17d1056af3c9',
316
- _type: {
317
- _id: 'PageNode',
318
- name: 'Page Node',
319
- collection: true
320
- },
321
- _outcomes: [{
322
- id: 'true',
323
- displayName: 'true'
324
- }]
325
- }, {
326
- nodes: [{
327
- _id: '9f1e8d94-4922-481b-9e14-212b66548900',
328
- nodeType: 'AttributeCollectorNode',
329
- displayName: 'Attribute Collector'
330
- }],
331
- pageDescription: {
332
- en: 'Enter your email address or <a href="#/service/Login">Sign in</a>'
333
- },
334
- pageHeader: {
335
- en: 'Forgotten Username'
336
- },
337
- _id: '5e2a7c95-94af-4b23-8724-deb13853726a',
338
- _type: {
339
- _id: 'PageNode',
340
- name: 'Page Node',
341
- collection: true
342
- },
343
- _outcomes: [{
344
- id: 'outcome',
345
- displayName: 'Outcome'
346
- }]
347
- }, {
348
- nodes: [{
349
- _id: '276afa7c-a680-4cf4-a5f6-d6c78191f5c9',
350
- nodeType: 'AttributeCollectorNode',
351
- displayName: 'Attribute Collector'
352
- }],
353
- pageDescription: {
354
- en: 'Enter your email address or <a href="#/service/Login">Sign in</a>'
355
- },
356
- pageHeader: {
357
- en: 'Reset Password'
358
- },
359
- _id: 'cc3e1ed2-25f1-47bf-83c6-17084f8b2b2b',
360
- _type: {
361
- _id: 'PageNode',
362
- name: 'Page Node',
363
- collection: true
364
- },
365
- _outcomes: [{
366
- id: 'outcome',
367
- displayName: 'Outcome'
368
- }]
369
- }, {
370
- identityAttribute: 'userName',
371
- queryFilter: '!(/preferences pr) or /preferences/marketing eq false or /preferences/updates eq false',
372
- _id: 'a1f45b44-5bf7-4c57-aa3f-75c619c7db8e',
373
- _type: {
374
- _id: 'QueryFilterDecisionNode',
375
- name: 'Query Filter Decision',
376
- collection: true
377
- },
378
- _outcomes: [{
379
- id: 'true',
380
- displayName: 'True'
381
- }, {
382
- id: 'false',
383
- displayName: 'False'
384
- }]
385
- }, {
386
- _id: 'b4a0e915-c15d-4b83-9c9d-18347d645976',
387
- _type: {
388
- _id: 'AcceptTermsAndConditionsNode',
389
- name: 'Accept Terms and Conditions',
390
- collection: true
391
- },
392
- _outcomes: [{
393
- id: 'outcome',
394
- displayName: 'Outcome'
395
- }]
396
- }, {
397
- sessionDataKey: 'UserToken',
398
- sharedStateKey: 'userName',
399
- _id: 'd1b79744-493a-44fe-bc26-7d324a8caa4e',
400
- _type: {
401
- _id: 'SessionDataNode',
402
- name: 'Get Session Data',
403
- collection: true
404
- },
405
- _outcomes: [{
406
- id: 'outcome',
407
- displayName: 'Outcome'
408
- }]
409
- }, {
410
- emailSuspendMessage: {
411
- en: 'An email has been sent to the address you entered. Click the link in that email to proceed.'
412
- },
413
- emailTemplateName: 'forgottenUsername',
414
- identityAttribute: 'mail',
415
- emailAttribute: 'mail',
416
- objectLookup: true,
417
- _id: 'd9a79f01-2ce3-4be2-a28a-975f35c3c8ca',
418
- _type: {
419
- _id: 'EmailSuspendNode',
420
- name: 'Email Suspend Node',
421
- collection: true
422
- },
423
- _outcomes: [{
424
- id: 'outcome',
425
- displayName: 'Outcome'
426
- }]
427
- }, {
428
- emailSuspendMessage: {
429
- en: 'An email has been sent to the address you entered. Click the link in that email to proceed.'
430
- },
431
- emailTemplateName: 'resetPassword',
432
- identityAttribute: 'mail',
433
- emailAttribute: 'mail',
434
- objectLookup: true,
435
- _id: '06c97be5-7fdd-4739-aea1-ecc7fe082865',
436
- _type: {
437
- _id: 'EmailSuspendNode',
438
- name: 'Email Suspend Node',
439
- collection: true
440
- },
441
- _outcomes: [{
442
- id: 'outcome',
443
- displayName: 'Outcome'
444
- }]
445
- }, {
446
- emailSuspendMessage: {
447
- en: 'An email has been sent to your address, please verify your email address to update your password. Click the link in that email to proceed.'
448
- },
449
- emailTemplateName: 'updatePassword',
450
- identityAttribute: 'userName',
451
- emailAttribute: 'mail',
452
- objectLookup: true,
453
- _id: 'a3d97b53-e38a-4b24-aed0-a021050eb744',
454
- _type: {
455
- _id: 'EmailSuspendNode',
456
- name: 'Email Suspend Node',
457
- collection: true
458
- },
459
- _outcomes: [{
460
- id: 'outcome',
461
- displayName: 'Outcome'
462
- }]
463
- }, {
464
- attributesToCollect: ['mail'],
465
- identityAttribute: 'mail',
466
- validateInputs: false,
467
- required: true,
468
- _id: '9f1e8d94-4922-481b-9e14-212b66548900',
469
- _type: {
470
- _id: 'AttributeCollectorNode',
471
- name: 'Attribute Collector',
472
- collection: true
473
- },
474
- _outcomes: [{
475
- id: 'outcome',
476
- displayName: 'Outcome'
477
- }]
478
- }, {
479
- attributesToCollect: ['mail'],
480
- identityAttribute: 'mail',
481
- validateInputs: false,
482
- required: true,
483
- _id: '276afa7c-a680-4cf4-a5f6-d6c78191f5c9',
484
- _type: {
485
- _id: 'AttributeCollectorNode',
486
- name: 'Attribute Collector',
487
- collection: true
488
- },
489
- _outcomes: [{
490
- id: 'outcome',
491
- displayName: 'Outcome'
492
- }]
493
- }, {
494
- attributesToCollect: ['preferences/updates', 'preferences/marketing'],
495
- identityAttribute: 'userName',
496
- validateInputs: false,
497
- required: false,
498
- _id: '0a042e10-b22e-4e02-86c4-65e26e775f7a',
499
- _type: {
500
- _id: 'AttributeCollectorNode',
501
- name: 'Attribute Collector',
502
- collection: true
503
- },
504
- _outcomes: [{
505
- id: 'outcome',
506
- displayName: 'Outcome'
507
- }]
508
- }, {
509
- attributesToCollect: ['givenName', 'sn', 'mail', 'preferences/marketing', 'preferences/updates'],
510
- identityAttribute: 'userName',
511
- validateInputs: true,
512
- required: true,
513
- _id: 'd3ce2036-1523-4ce8-b1a2-895a2a036667',
514
- _type: {
515
- _id: 'AttributeCollectorNode',
516
- name: 'Attribute Collector',
517
- collection: true
518
- },
519
- _outcomes: [{
520
- id: 'outcome',
521
- displayName: 'Outcome'
522
- }]
523
- }, {
524
- _id: '8c217417-11dd-4a0f-a9e4-59c2390085be',
525
- _type: {
526
- _id: 'PasswordCollectorNode',
527
- name: 'Password Collector',
528
- collection: true
529
- },
530
- _outcomes: [{
531
- id: 'outcome',
532
- displayName: 'Outcome'
533
- }]
534
- }, {
535
- passwordAttribute: 'password',
536
- validateInput: true,
537
- _id: '009c19c8-9572-47bb-adb2-1f092c559a43',
538
- _type: {
539
- _id: 'ValidatedPasswordNode',
540
- name: 'Platform Password',
541
- collection: true
542
- },
543
- _outcomes: [{
544
- id: 'outcome',
545
- displayName: 'Outcome'
546
- }]
547
- }, {
548
- passwordAttribute: 'password',
549
- validateInput: true,
550
- _id: '3d8709a1-f09f-4d1f-8094-2850e472c1db',
551
- _type: {
552
- _id: 'ValidatedPasswordNode',
553
- name: 'Platform Password',
554
- collection: true
555
- },
556
- _outcomes: [{
557
- id: 'outcome',
558
- displayName: 'Outcome'
559
- }]
560
- }, {
561
- passwordAttribute: 'password',
562
- validateInput: false,
563
- _id: '0c80c39b-4813-4e67-b4fb-5a0bba85f994',
564
- _type: {
565
- _id: 'ValidatedPasswordNode',
566
- name: 'Platform Password',
567
- collection: true
568
- },
569
- _outcomes: [{
570
- id: 'outcome',
571
- displayName: 'Outcome'
572
- }]
573
- }, {
574
- passwordAttribute: 'password',
575
- validateInput: true,
576
- _id: '21a99653-a7a7-47ee-b650-f493a84bba09',
577
- _type: {
578
- _id: 'ValidatedPasswordNode',
579
- name: 'Platform Password',
580
- collection: true
581
- },
582
- _outcomes: [{
583
- id: 'outcome',
584
- displayName: 'Outcome'
585
- }]
586
- }, {
587
- passwordAttribute: 'password',
588
- validateInput: false,
589
- _id: 'fe2962fc-4db3-4066-8624-553649afc438',
590
- _type: {
591
- _id: 'ValidatedPasswordNode',
592
- name: 'Platform Password',
593
- collection: true
594
- },
595
- _outcomes: [{
596
- id: 'outcome',
597
- displayName: 'Outcome'
598
- }]
599
- }, {
600
- presentAttribute: 'password',
601
- identityAttribute: 'userName',
602
- _id: '0f0904e6-1da3-4cdb-9abf-0d2545016fab',
603
- _type: {
604
- _id: 'AttributePresentDecisionNode',
605
- name: 'Attribute Present Decision',
606
- collection: true
607
- },
608
- _outcomes: [{
609
- id: 'true',
610
- displayName: 'True'
611
- }, {
612
- id: 'false',
613
- displayName: 'False'
614
- }]
615
- }, {
616
- _id: '2998c1c9-f4c8-4a00-b2c6-3426783ee49d',
617
- _type: {
618
- _id: 'DataStoreDecisionNode',
619
- name: 'Data Store Decision',
620
- collection: true
621
- },
622
- _outcomes: [{
623
- id: 'true',
624
- displayName: 'True'
625
- }, {
626
- id: 'false',
627
- displayName: 'False'
628
- }]
629
- }, {
630
- _id: 'e2988546-a459-4c9a-b0e2-fa65ae136b34',
631
- _type: {
632
- _id: 'DataStoreDecisionNode',
633
- name: 'Data Store Decision',
634
- collection: true
635
- },
636
- _outcomes: [{
637
- id: 'true',
638
- displayName: 'True'
639
- }, {
640
- id: 'false',
641
- displayName: 'False'
642
- }]
643
- }, {
644
- _id: '7d1deabe-cd98-49c8-943f-ca12305775f3',
645
- _type: {
646
- _id: 'DataStoreDecisionNode',
647
- name: 'Data Store Decision',
648
- collection: true
649
- },
650
- _outcomes: [{
651
- id: 'true',
652
- displayName: 'True'
653
- }, {
654
- id: 'false',
655
- displayName: 'False'
656
- }]
657
- }, {
658
- identityAttribute: 'userName',
659
- _id: '97a15eb2-a015-4b6d-81a0-be78c3aa1a3b',
660
- _type: {
661
- _id: 'IncrementLoginCountNode',
662
- name: 'Increment Login Count',
663
- collection: true
664
- },
665
- _outcomes: [{
666
- id: 'outcome',
667
- displayName: 'Outcome'
668
- }]
669
- }, {
670
- identityAttribute: 'userName',
671
- _id: 'bba3e0d8-8525-4e82-bf48-ac17f7988917',
672
- _type: {
673
- _id: 'IncrementLoginCountNode',
674
- name: 'Increment Login Count',
675
- collection: true
676
- },
677
- _outcomes: [{
678
- id: 'outcome',
679
- displayName: 'Outcome'
680
- }]
681
- }, {
682
- tree: 'ProgressiveProfile',
683
- _id: '33b24514-3e50-4180-8f08-ab6f4e51b07e',
684
- _type: {
685
- _id: 'InnerTreeEvaluatorNode',
686
- name: 'Inner Tree Evaluator',
687
- collection: true
688
- },
689
- _outcomes: [{
690
- id: 'true',
691
- displayName: 'True'
692
- }, {
693
- id: 'false',
694
- displayName: 'False'
695
- }]
696
- }, {
697
- tree: 'iAccessRestrictions',
698
- _id: '2da98485-ee0e-4305-826c-b6fcc842a7b8',
699
- _type: {
700
- _id: 'InnerTreeEvaluatorNode',
701
- name: 'Inner Tree Evaluator',
702
- collection: true
703
- },
704
- _outcomes: [{
705
- id: 'true',
706
- displayName: 'True'
707
- }, {
708
- id: 'false',
709
- displayName: 'False'
710
- }]
711
- }, {
712
- tree: 'Login',
713
- _id: 'b93ce36e-1976-4610-b24f-8d6760b5463b',
714
- _type: {
715
- _id: 'InnerTreeEvaluatorNode',
716
- name: 'Inner Tree Evaluator',
717
- collection: true
718
- },
719
- _outcomes: [{
720
- id: 'true',
721
- displayName: 'True'
722
- }, {
723
- id: 'false',
724
- displayName: 'False'
725
- }]
726
- }, {
727
- identityResource: 'managed/alpha_user',
728
- patchAsObject: false,
729
- ignoredFields: [],
730
- identityAttribute: 'mail',
731
- _id: '989f0bf8-a328-4217-b82b-5275d79ca8bd',
732
- _type: {
733
- _id: 'PatchObjectNode',
734
- name: 'Patch Object',
735
- collection: true
736
- },
737
- _outcomes: [{
738
- id: 'PATCHED',
739
- displayName: 'Patched'
740
- }, {
741
- id: 'FAILURE',
742
- displayName: 'Failed'
743
- }]
744
- }, {
745
- identityResource: 'managed/alpha_user',
746
- patchAsObject: false,
747
- ignoredFields: [],
748
- identityAttribute: 'userName',
749
- _id: '423a959a-a1b9-498a-b0f7-596b6b6e775a',
750
- _type: {
751
- _id: 'PatchObjectNode',
752
- name: 'Patch Object',
753
- collection: true
754
- },
755
- _outcomes: [{
756
- id: 'PATCHED',
757
- displayName: 'Patched'
758
- }, {
759
- id: 'FAILURE',
760
- displayName: 'Failed'
761
- }]
762
- }, {
763
- identityResource: 'managed/alpha_user',
764
- patchAsObject: false,
765
- ignoredFields: ['userName'],
766
- identityAttribute: 'userName',
767
- _id: '3990ce1f-cce6-435b-ae1c-f138e89411c1',
768
- _type: {
769
- _id: 'PatchObjectNode',
770
- name: 'Patch Object',
771
- collection: true
772
- },
773
- _outcomes: [{
774
- id: 'PATCHED',
775
- displayName: 'Patched'
776
- }, {
777
- id: 'FAILURE',
778
- displayName: 'Failed'
779
- }]
780
- }, {
781
- script: '7fb962a5-9f20-41d3-a077-b424a29c1198',
782
- outcomes: ['allow', 'deny'],
783
- outputs: ['*'],
784
- inputs: ['*'],
785
- _id: 'f4e9be5d-25d7-44cc-b15e-989b99724b4d',
786
- _type: {
787
- _id: 'ScriptedDecisionNode',
788
- name: 'Scripted Decision',
789
- collection: true
790
- },
791
- _outcomes: [{
792
- id: 'allow',
793
- displayName: 'allow'
794
- }, {
795
- id: 'deny',
796
- displayName: 'deny'
797
- }]
798
- }, {
799
- script: '9535446c-0ff6-4a76-8576-616599119d64',
800
- outcomes: ['true'],
801
- outputs: ['*'],
802
- inputs: ['*'],
803
- _id: 'a3f63691-1a79-4b11-be47-26f40403292d',
804
- _type: {
805
- _id: 'ScriptedDecisionNode',
806
- name: 'Scripted Decision',
807
- collection: true
808
- },
809
- _outcomes: [{
810
- id: 'true',
811
- displayName: 'true'
812
- }]
813
- }, {
814
- message: {
815
- en: 'Select a security question'
816
- },
817
- allowUserDefinedQuestions: true,
818
- _id: '120c69d3-90b4-4ad4-b7af-380e8b119340',
819
- _type: {
820
- _id: 'KbaCreateNode',
821
- name: 'KBA Definition',
822
- collection: true
823
- },
824
- _outcomes: [{
825
- id: 'outcome',
826
- displayName: 'Outcome'
827
- }]
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=volker-dev npm run test:record NodeApi
11
+ *
12
+ * The above command assumes that you have a connection profile for
13
+ * 'volker-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 must manually update the CJS snapshots by running:
19
+ *
20
+ * FRODO_DEBUG=1 npm run test:update NodeApi
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 NodeApi
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 { jest } from '@jest/globals';
33
+ import { NodeRaw } from '../index';
34
+ import { autoSetupPolly } from '../utils/AutoSetupPolly';
35
+
36
+ // Increase timeout for this test as pipeline keeps failing with error:
37
+ // Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
38
+ jest.setTimeout(30000);
39
+ autoSetupPolly();
40
+ describe('NodeApi', () => {
41
+ const node1 = {
42
+ id: '67693475-3a58-4e38-bcc6-037b3fe46a58',
43
+ type: 'ValidatedUsernameNode',
44
+ node: {
45
+ usernameAttribute: 'userName',
46
+ validateInput: false,
47
+ _type: {
48
+ _id: 'ValidatedUsernameNode',
49
+ name: 'Platform Username',
50
+ collection: true
51
+ },
52
+ _outcomes: [{
53
+ id: 'outcome',
54
+ displayName: 'Outcome'
828
55
  }]
829
- };
830
- mock.onPost(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes?_action=nextdescendents`).reply(200, response);
831
- const nodes = await NodeRaw.getNodes();
832
- expect(nodes).toBeTruthy();
833
- expect(nodes.result.length).toBe(48);
834
- });
835
- });
836
- describe('NodeApi - getNodesByType()', () => {
837
- test('getNodesByType() 0: Method is implemented', async () => {
838
- expect(NodeRaw.getNodesByType).toBeDefined();
839
- });
840
- test('getNodesByType() 1: Get all page nodes', async () => {
841
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/NodeApi/getNodesByType/PageNode.json'), 'utf8'));
842
- mock.onGet(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode?_queryFilter=true`).reply(200, response);
843
- const nodes = await NodeRaw.getNodesByType('PageNode');
844
- expect(nodes).toBeTruthy();
845
- expect(nodes.result.length).toBe(161);
846
- });
847
- });
848
- describe('NodeApi - getNode()', () => {
849
- test('getNode() 0: Method is implemented', async () => {
850
- expect(NodeRaw.getNode).toBeDefined();
851
- });
852
- test('getNode() 1: Get existing page node [1aea363f-d8d2-4711-b88d-d58fff92dbae]', async () => {
853
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/NodeApi/getNode/PageNode_1aea363f-d8d2-4711-b88d-d58fff92dbae.json'), 'utf8'));
854
- mock.onGet(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/1aea363f-d8d2-4711-b88d-d58fff92dbae`).reply(200, response);
855
- const node = await NodeRaw.getNode('1aea363f-d8d2-4711-b88d-d58fff92dbae', 'PageNode');
856
- expect(node).toBeTruthy();
857
- expect(node).toMatchObject(response);
56
+ }
57
+ };
58
+ const node2 = {
59
+ id: '18ffdd4b-41b7-41b3-8248-f4fdfd68423f',
60
+ type: 'ValidatedPasswordNode',
61
+ node: {
62
+ validateInput: false,
63
+ passwordAttribute: 'password',
64
+ _type: {
65
+ _id: 'ValidatedPasswordNode',
66
+ name: 'Platform Password',
67
+ collection: true
68
+ },
69
+ _outcomes: [{
70
+ id: 'outcome',
71
+ displayName: 'Outcome'
72
+ }]
73
+ }
74
+ };
75
+ const node3 = {
76
+ id: 'b726262c-641e-4fa5-b276-98e129b44cd9',
77
+ type: 'PatchObjectNode',
78
+ node: {
79
+ identityResource: 'managed/user',
80
+ patchAsObject: false,
81
+ ignoredFields: [],
82
+ identityAttribute: 'userName',
83
+ _type: {
84
+ _id: 'PatchObjectNode',
85
+ name: 'Patch Object',
86
+ collection: true
87
+ },
88
+ _outcomes: [{
89
+ id: 'PATCHED',
90
+ displayName: 'Patched'
91
+ }, {
92
+ id: 'FAILURE',
93
+ displayName: 'Failed'
94
+ }]
95
+ }
96
+ };
97
+ const node4 = {
98
+ id: '23bab9d4-1663-450f-8a4b-680f44f54fd6',
99
+ type: 'CreateObjectNode',
100
+ node: {
101
+ identityResource: 'managed/user',
102
+ _type: {
103
+ _id: 'CreateObjectNode',
104
+ name: 'Create Object',
105
+ collection: true
106
+ },
107
+ _outcomes: [{
108
+ id: 'CREATED',
109
+ displayName: 'Created'
110
+ }, {
111
+ id: 'FAILURE',
112
+ displayName: 'Failed'
113
+ }]
114
+ }
115
+ };
116
+ // in recording mode, setup test data before recording
117
+ beforeAll(async () => {
118
+ if (process.env.FRODO_POLLY_MODE === 'record') {
119
+ // setup node1 - delete if exists, then create
120
+ try {
121
+ await NodeRaw.getNode(node1.id, node1.type);
122
+ await NodeRaw.deleteNode(node1.id, node1.type);
123
+ } catch (error) {
124
+ // ignore
125
+ } finally {
126
+ await NodeRaw.putNode(node1.id, node1.type, node1.node);
127
+ }
128
+ // setup node2 - delete if exists
129
+ try {
130
+ await NodeRaw.getNode(node2.id, node2.type);
131
+ await NodeRaw.deleteNode(node2.id, node2.type);
132
+ } catch (error) {
133
+ // ignore
134
+ } finally {
135
+ await NodeRaw.putNode(node2.id, node2.type, node2.node);
136
+ }
137
+ // setup node3 - delete if exists, then create
138
+ try {
139
+ await NodeRaw.getNode(node3.id, node3.type);
140
+ await NodeRaw.deleteNode(node3.id, node3.type);
141
+ } catch (error) {
142
+ // ignore
143
+ } finally {
144
+ await NodeRaw.putNode(node3.id, node3.type, node3.node);
145
+ }
146
+ // setup node4 - delete if exists, then create
147
+ try {
148
+ await NodeRaw.getNode(node4.id, node4.type);
149
+ await NodeRaw.deleteNode(node4.id, node4.type);
150
+ } catch (error) {
151
+ // ignore
152
+ } finally {
153
+ await NodeRaw.putNode(node4.id, node4.type, node4.node);
154
+ }
155
+ }
858
156
  });
859
- test('getNode() 2: Get non-existing page node [00000000-0000-0000-0000-000000000000]', async () => {
860
- mock.onGet(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/00000000-0000-0000-0000-000000000000`).reply(404, {
861
- code: 404,
862
- reason: 'Not Found',
863
- message: 'Not Found'
864
- });
865
- expect.assertions(2);
866
- try {
867
- await NodeRaw.getNode('00000000-0000-0000-0000-000000000000', 'PageNode');
868
- } catch (error) {
869
- expect(error.response).toBeTruthy();
870
- expect(error.response.data).toMatchObject({
871
- code: 404,
872
- reason: 'Not Found',
873
- message: 'Not Found'
874
- });
157
+ // in recording mode, remove test data after recording
158
+ afterAll(async () => {
159
+ if (process.env.FRODO_POLLY_MODE === 'record') {
160
+ try {
161
+ await NodeRaw.getNode(node1.id, node1.type);
162
+ await NodeRaw.deleteNode(node1.id, node1.type);
163
+ } catch (error) {
164
+ // ignore
165
+ }
166
+ try {
167
+ await NodeRaw.getNode(node2.id, node2.type);
168
+ await NodeRaw.deleteNode(node2.id, node2.type);
169
+ } catch (error) {
170
+ // ignore
171
+ }
172
+ try {
173
+ await NodeRaw.getNode(node3.id, node3.type);
174
+ await NodeRaw.deleteNode(node3.id, node3.type);
175
+ } catch (error) {
176
+ // ignore
177
+ }
178
+ try {
179
+ await NodeRaw.getNode(node4.id, node4.type);
180
+ await NodeRaw.deleteNode(node4.id, node4.type);
181
+ } catch (error) {
182
+ // ignore
183
+ }
875
184
  }
876
185
  });
877
- });
878
- describe('NodeApi - putNode()', () => {
879
- test('putNode() 0: Method is implemented', async () => {
880
- expect(NodeRaw.putNode).toBeDefined();
186
+ describe('getNodeTypes()', () => {
187
+ test('0: Method is implemented', async () => {
188
+ expect(NodeRaw.getNodeTypes).toBeDefined();
189
+ });
190
+ test('1: Get all node types', async () => {
191
+ const response = await NodeRaw.getNodeTypes();
192
+ expect(response).toMatchSnapshot();
193
+ });
881
194
  });
882
- test('putNode() 1: Create page node [0ad90971-d08a-4af3-86f3-01729572dc8f]', async () => {
883
- const nodeData = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/NodeApi/putNode/PageNode_0ad90971-d08a-4af3-86f3-01729572dc8f.json'), 'utf8'));
884
- mock.onPut(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/0ad90971-d08a-4af3-86f3-01729572dc8f`).reply(201, nodeData);
885
- const node = await NodeRaw.putNode('0ad90971-d08a-4af3-86f3-01729572dc8f', 'PageNode', nodeData);
886
- expect(node).toBeTruthy();
887
- expect(node).toMatchObject(nodeData);
195
+ describe('getNodes()', () => {
196
+ test('0: Method is implemented', async () => {
197
+ expect(NodeRaw.getNodes).toBeDefined();
198
+ });
199
+ test('1: Get all nodes', async () => {
200
+ const response = await NodeRaw.getNodes();
201
+ expect(response).toMatchSnapshot();
202
+ });
888
203
  });
889
- test('putNode() 1: Update existing page node [1aea363f-d8d2-4711-b88d-d58fff92dbae]', async () => {
890
- const nodeData = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/NodeApi/putNode/PageNode_1aea363f-d8d2-4711-b88d-d58fff92dbae.json'), 'utf8'));
891
- mock.onPut(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/1aea363f-d8d2-4711-b88d-d58fff92dbae`).reply(200, nodeData);
892
- const node = await NodeRaw.putNode('1aea363f-d8d2-4711-b88d-d58fff92dbae', 'PageNode', nodeData);
893
- expect(node).toBeTruthy();
894
- expect(node).toMatchObject(nodeData);
204
+ describe('getNodesByType()', () => {
205
+ test('0: Method is implemented', async () => {
206
+ expect(NodeRaw.getNodesByType).toBeDefined();
207
+ });
208
+ test('1: Get all page nodes', async () => {
209
+ const response = await NodeRaw.getNodesByType('PageNode');
210
+ expect(response).toMatchSnapshot();
211
+ });
895
212
  });
896
- });
897
- describe('NodeApi - deleteNode()', () => {
898
- test('deleteNode() 0: Method is implemented', async () => {
899
- expect(NodeRaw.deleteNode).toBeDefined();
213
+ describe('getNode()', () => {
214
+ test('0: Method is implemented', async () => {
215
+ expect(NodeRaw.getNode).toBeDefined();
216
+ });
217
+ test(`1: Get existing node [${node1.id} - ${node1.type}]`, async () => {
218
+ const response = await NodeRaw.getNode(node1.id, node1.type);
219
+ expect(response).toMatchSnapshot();
220
+ });
221
+ test('2: Get non-existing node [00000000-0000-0000-0000-000000000000 - PageNode]', async () => {
222
+ expect.assertions(1);
223
+ try {
224
+ await NodeRaw.getNode('00000000-0000-0000-0000-000000000000', 'PageNode');
225
+ } catch (error) {
226
+ expect(error.response.data).toMatchSnapshot();
227
+ }
228
+ });
900
229
  });
901
- test('deleteNode() 1: Delete existing node [1aea363f-d8d2-4711-b88d-d58fff92dbae]', async () => {
902
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/NodeApi/deleteNode/PageNode_1aea363f-d8d2-4711-b88d-d58fff92dbae.json'), 'utf8'));
903
- mock.onDelete(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/1aea363f-d8d2-4711-b88d-d58fff92dbae`).reply(200, response);
904
- const node = await NodeRaw.deleteNode('1aea363f-d8d2-4711-b88d-d58fff92dbae', 'PageNode');
905
- expect(node).toBeTruthy();
906
- expect(node._id).toEqual('1aea363f-d8d2-4711-b88d-d58fff92dbae');
230
+ describe('putNode()', () => {
231
+ test('0: Method is implemented', async () => {
232
+ expect(NodeRaw.putNode).toBeDefined();
233
+ });
234
+ test(`1: Create new node [${node2.id} - ${node2.type}]`, async () => {
235
+ const response = await NodeRaw.putNode(node2.id, node2.type, node2.node);
236
+ expect(response).toMatchSnapshot();
237
+ });
238
+ test(`2: Update existing node [${node3.id} - ${node3.type}]`, async () => {
239
+ const node = await NodeRaw.putNode(node3.id, node3.type, node3.node);
240
+ expect(node).toMatchSnapshot();
241
+ });
907
242
  });
908
- test('deleteNode() 2: Delete non-existing node [00000000-0000-0000-0000-000000000000]', async () => {
909
- mock.onDelete(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/00000000-0000-0000-0000-000000000000`).reply(404, {
910
- code: 404,
911
- reason: 'Not Found',
912
- message: 'Not Found'
243
+ describe('deleteNode()', () => {
244
+ test('0: Method is implemented', async () => {
245
+ expect(NodeRaw.deleteNode).toBeDefined();
246
+ });
247
+ test(`1: Delete existing node [${node4.id} - ${node4.type}]`, async () => {
248
+ const node = await NodeRaw.deleteNode(node4.id, node4.type);
249
+ expect(node).toMatchSnapshot();
250
+ });
251
+ test('2: Delete non-existing node [00000000-0000-0000-0000-000000000000 - PageNode]', async () => {
252
+ expect.assertions(1);
253
+ try {
254
+ await NodeRaw.deleteNode('00000000-0000-0000-0000-000000000000', 'PageNode');
255
+ } catch (error) {
256
+ expect(error.response.data).toMatchSnapshot();
257
+ }
913
258
  });
914
- expect.assertions(2);
915
- try {
916
- await NodeRaw.deleteNode('00000000-0000-0000-0000-000000000000', 'PageNode');
917
- } catch (error) {
918
- expect(error.response).toBeTruthy();
919
- expect(error.response.data).toMatchObject({
920
- code: 404,
921
- reason: 'Not Found',
922
- message: 'Not Found'
923
- });
924
- }
925
259
  });
926
260
  });
927
261
  //# sourceMappingURL=NodeApi.test.js.map