@rockcarver/frodo-lib 0.16.2-2 → 0.16.2-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/cjs/api/AgentApi.js +221 -0
  3. package/cjs/api/AgentApi.js.map +1 -0
  4. package/cjs/api/AgentApi.test.js.map +1 -0
  5. package/cjs/api/ApiTypes.js.map +1 -1
  6. package/cjs/api/BaseApi.js +17 -13
  7. package/cjs/api/BaseApi.js.map +1 -1
  8. package/cjs/ext/axios-curlirize/curlirize.js +47 -0
  9. package/cjs/ext/axios-curlirize/curlirize.js.map +1 -0
  10. package/cjs/ext/axios-curlirize/lib/CurlHelper.js +74 -0
  11. package/cjs/ext/axios-curlirize/lib/CurlHelper.js.map +1 -0
  12. package/cjs/index.js +5 -1
  13. package/cjs/index.js.map +1 -1
  14. package/cjs/ops/AgentOps.js +805 -0
  15. package/cjs/ops/AgentOps.js.map +1 -0
  16. package/cjs/ops/AgentOps.test.js.map +1 -0
  17. package/cjs/ops/AuthenticateOps.js +8 -8
  18. package/cjs/ops/AuthenticateOps.js.map +1 -1
  19. package/cjs/ops/JourneyOps.test.js.map +1 -1
  20. package/cjs/ops/OpsTypes.js.map +1 -1
  21. package/cjs/test/mocks/AgentApi/deleteAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +22 -0
  22. package/cjs/test/mocks/AgentApi/deleteAgentByTypeAndId/IdentityGatewayAgent/api_client.json +22 -0
  23. package/cjs/test/mocks/AgentApi/deleteAgentByTypeAndId/IdentityGatewayAgent/ig_chico.json +22 -0
  24. package/cjs/test/mocks/AgentApi/deleteAgentByTypeAndId/IdentityGatewayAgent/ig_mytestrun_com.json +32 -0
  25. package/cjs/test/mocks/AgentApi/deleteAgentByTypeAndId/J2EEAgent/javaAgent.json +623 -0
  26. package/cjs/test/mocks/AgentApi/deleteAgentByTypeAndId/J2EEAgent/tomcatagent.json +630 -0
  27. package/cjs/test/mocks/AgentApi/deleteAgentByTypeAndId/WebAgent/apacheagent.json +456 -0
  28. package/cjs/test/mocks/AgentApi/deleteAgentByTypeAndId/WebAgent/webserver.json +455 -0
  29. package/cjs/test/mocks/AgentApi/findAgentById/ajays_client.json +19 -0
  30. package/cjs/test/mocks/AgentApi/findAgentById/apacheagent.json +142 -0
  31. package/cjs/test/mocks/AgentApi/findAgentById/api_client.json +19 -0
  32. package/cjs/test/mocks/AgentApi/findAgentById/ig_chico.json +19 -0
  33. package/cjs/test/mocks/AgentApi/findAgentById/ig_mytestrun_com.json +29 -0
  34. package/cjs/test/mocks/AgentApi/findAgentById/javaAgent.json +190 -0
  35. package/cjs/test/mocks/AgentApi/findAgentById/tomcatagent.json +191 -0
  36. package/cjs/test/mocks/AgentApi/findAgentById/webserver.json +144 -0
  37. package/cjs/test/mocks/AgentApi/findAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +23 -0
  38. package/cjs/test/mocks/AgentApi/findAgentByTypeAndId/IdentityGatewayAgent/api_client.json +22 -0
  39. package/cjs/test/mocks/AgentApi/findAgentByTypeAndId/IdentityGatewayAgent/ig_chico.json +22 -0
  40. package/cjs/test/mocks/AgentApi/findAgentByTypeAndId/IdentityGatewayAgent/ig_mytestrun_com.json +33 -0
  41. package/cjs/test/mocks/AgentApi/findAgentByTypeAndId/J2EEAgent/javaAgent.json +193 -0
  42. package/cjs/test/mocks/AgentApi/findAgentByTypeAndId/J2EEAgent/tomcatagent.json +195 -0
  43. package/cjs/test/mocks/AgentApi/findAgentByTypeAndId/WebAgent/apacheagent.json +145 -0
  44. package/cjs/test/mocks/AgentApi/findAgentByTypeAndId/WebAgent/webserver.json +148 -0
  45. package/cjs/test/mocks/AgentApi/findAgentByTypeAndId/not_found.json +8 -0
  46. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +22 -0
  47. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/api_client.json +22 -0
  48. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ig_chico.json +22 -0
  49. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ig_mytestrun_com.json +32 -0
  50. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/javaAgent.json +623 -0
  51. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/tomcatagent.json +630 -0
  52. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/apacheagent.json +456 -0
  53. package/cjs/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/webserver.json +455 -0
  54. package/cjs/test/mocks/AgentApi/getAgentTypes/agentTypes.json +54 -0
  55. package/cjs/test/mocks/AgentApi/getAgents/agents.json +3862 -0
  56. package/cjs/test/mocks/AgentApi/getAgentsByType/IdentityGatewayAgents.json +73 -0
  57. package/cjs/test/mocks/AgentApi/getAgentsByType/J2EEAgents.json +379 -0
  58. package/cjs/test/mocks/AgentApi/getAgentsByType/WebAgents.json +284 -0
  59. package/cjs/test/mocks/ForgeRockApiMockEngine.js +147 -20
  60. package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
  61. package/esm/api/AgentApi.mjs +164 -0
  62. package/esm/api/AgentApi.test.mjs +267 -0
  63. package/esm/api/BaseApi.mjs +17 -5
  64. package/esm/ext/axios-curlirize/curlirize.mjs +38 -0
  65. package/esm/ext/axios-curlirize/lib/CurlHelper.mjs +67 -0
  66. package/esm/index.mjs +2 -0
  67. package/esm/ops/AgentOps.mjs +576 -0
  68. package/esm/ops/AgentOps.test.mjs +1212 -0
  69. package/esm/ops/AuthenticateOps.mjs +8 -8
  70. package/esm/ops/JourneyOps.test.mjs +4 -8
  71. package/esm/test/mocks/AgentApi/deleteAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +22 -0
  72. package/esm/test/mocks/AgentApi/deleteAgentByTypeAndId/IdentityGatewayAgent/api_client.json +22 -0
  73. package/esm/test/mocks/AgentApi/deleteAgentByTypeAndId/IdentityGatewayAgent/ig_chico.json +22 -0
  74. package/esm/test/mocks/AgentApi/deleteAgentByTypeAndId/IdentityGatewayAgent/ig_mytestrun_com.json +32 -0
  75. package/esm/test/mocks/AgentApi/deleteAgentByTypeAndId/J2EEAgent/javaAgent.json +623 -0
  76. package/esm/test/mocks/AgentApi/deleteAgentByTypeAndId/J2EEAgent/tomcatagent.json +630 -0
  77. package/esm/test/mocks/AgentApi/deleteAgentByTypeAndId/WebAgent/apacheagent.json +456 -0
  78. package/esm/test/mocks/AgentApi/deleteAgentByTypeAndId/WebAgent/webserver.json +455 -0
  79. package/esm/test/mocks/AgentApi/findAgentById/ajays_client.json +19 -0
  80. package/esm/test/mocks/AgentApi/findAgentById/apacheagent.json +142 -0
  81. package/esm/test/mocks/AgentApi/findAgentById/api_client.json +19 -0
  82. package/esm/test/mocks/AgentApi/findAgentById/ig_chico.json +19 -0
  83. package/esm/test/mocks/AgentApi/findAgentById/ig_mytestrun_com.json +29 -0
  84. package/esm/test/mocks/AgentApi/findAgentById/javaAgent.json +190 -0
  85. package/esm/test/mocks/AgentApi/findAgentById/tomcatagent.json +191 -0
  86. package/esm/test/mocks/AgentApi/findAgentById/webserver.json +144 -0
  87. package/esm/test/mocks/AgentApi/findAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +23 -0
  88. package/esm/test/mocks/AgentApi/findAgentByTypeAndId/IdentityGatewayAgent/api_client.json +22 -0
  89. package/esm/test/mocks/AgentApi/findAgentByTypeAndId/IdentityGatewayAgent/ig_chico.json +22 -0
  90. package/esm/test/mocks/AgentApi/findAgentByTypeAndId/IdentityGatewayAgent/ig_mytestrun_com.json +33 -0
  91. package/esm/test/mocks/AgentApi/findAgentByTypeAndId/J2EEAgent/javaAgent.json +193 -0
  92. package/esm/test/mocks/AgentApi/findAgentByTypeAndId/J2EEAgent/tomcatagent.json +195 -0
  93. package/esm/test/mocks/AgentApi/findAgentByTypeAndId/WebAgent/apacheagent.json +145 -0
  94. package/esm/test/mocks/AgentApi/findAgentByTypeAndId/WebAgent/webserver.json +148 -0
  95. package/esm/test/mocks/AgentApi/findAgentByTypeAndId/not_found.json +8 -0
  96. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ajays_client.json +22 -0
  97. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/api_client.json +22 -0
  98. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ig_chico.json +22 -0
  99. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/IdentityGatewayAgent/ig_mytestrun_com.json +32 -0
  100. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/javaAgent.json +623 -0
  101. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/J2EEAgent/tomcatagent.json +630 -0
  102. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/apacheagent.json +456 -0
  103. package/esm/test/mocks/AgentApi/getAgentByTypeAndId/WebAgent/webserver.json +455 -0
  104. package/esm/test/mocks/AgentApi/getAgentTypes/agentTypes.json +54 -0
  105. package/esm/test/mocks/AgentApi/getAgents/agents.json +3862 -0
  106. package/esm/test/mocks/AgentApi/getAgentsByType/IdentityGatewayAgents.json +73 -0
  107. package/esm/test/mocks/AgentApi/getAgentsByType/J2EEAgents.json +379 -0
  108. package/esm/test/mocks/AgentApi/getAgentsByType/WebAgents.json +284 -0
  109. package/esm/test/mocks/ForgeRockApiMockEngine.mjs +136 -20
  110. package/package.json +3 -4
  111. package/types/api/AgentApi.d.ts +51 -0
  112. package/types/api/AgentApi.d.ts.map +1 -0
  113. package/types/api/ApiTypes.d.ts +3 -0
  114. package/types/api/ApiTypes.d.ts.map +1 -1
  115. package/types/api/BaseApi.d.ts.map +1 -1
  116. package/types/ext/axios-curlirize/curlirize.d.ts +3 -0
  117. package/types/ext/axios-curlirize/curlirize.d.ts.map +1 -0
  118. package/types/ext/axios-curlirize/lib/CurlHelper.d.ts +11 -0
  119. package/types/ext/axios-curlirize/lib/CurlHelper.d.ts.map +1 -0
  120. package/types/index.d.ts +2 -0
  121. package/types/index.d.ts.map +1 -1
  122. package/types/ops/AgentOps.d.ts +210 -0
  123. package/types/ops/AgentOps.d.ts.map +1 -0
  124. package/types/ops/AuthenticateOps.d.ts.map +1 -1
  125. package/types/ops/OpsTypes.d.ts +5 -1
  126. package/types/ops/OpsTypes.d.ts.map +1 -1
  127. package/types/test/mocks/ForgeRockApiMockEngine.d.ts +35 -2
  128. package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
@@ -0,0 +1,1212 @@
1
+ import axios from 'axios';
2
+ import MockAdapter from 'axios-mock-adapter';
3
+ import { Agent, state } from '../index';
4
+ import * as global from '../storage/StaticStorage';
5
+ import { isEqualJson } from './utils/OpsUtils';
6
+ import { mockGetAgentsByType, mockGetAgentByTypeAndId, mockFindAgentById, mockPutAgentByTypeAndId, getAgent, mockDeleteAgentByTypeAndId, mockFindAgentByTypeAndId } from '../test/mocks/ForgeRockApiMockEngine';
7
+ const mock = new MockAdapter(axios);
8
+ state.default.session.setTenant('https://openam-frodo-dev.forgeblocks.com/am');
9
+ state.default.session.setRealm('alpha');
10
+ state.default.session.setCookieName('cookieName');
11
+ state.default.session.setCookieValue('cookieValue');
12
+ state.default.session.setDeploymentType(global.CLOUD_DEPLOYMENT_TYPE_KEY);
13
+ describe('AgentOps - createAgentExportTemplate()', () => {
14
+ test('createAgentExportTemplate() 0: Method is implemented', async () => {
15
+ expect(Agent.createAgentExportTemplate).toBeDefined();
16
+ });
17
+ test('createAgentExportTemplate() 1: Get all agent types', async () => {
18
+ const template = {
19
+ meta: {},
20
+ agents: {}
21
+ };
22
+ const exportTemplate = Agent.createAgentExportTemplate();
23
+ console.dir(exportTemplate);
24
+ expect(exportTemplate).toBeTruthy();
25
+ expect(exportTemplate).toMatchObject(template);
26
+ });
27
+ });
28
+ describe('AgentOps - getAgents()', () => {
29
+ test('getAgents() 0: Method is implemented', async () => {
30
+ expect(Agent.getAgents).toBeDefined();
31
+ });
32
+ test('getAgents() 1: Get all agents', async () => {
33
+ const agentTypes = ['IdentityGatewayAgent', 'J2EEAgent', 'WebAgent'];
34
+ const agentIds = ['ig_mytestrun_com', 'ig_chico', 'ajays_client', 'api_client', 'tomcatagent', 'javaAgent', 'apacheagent', 'webserver'];
35
+ mockGetAgentsByType(mock);
36
+ expect.assertions(21);
37
+ const agents = await Agent.getAgents();
38
+ expect(agents).toBeTruthy();
39
+ expect(agents.length).toBe(8);
40
+ for (const agent of agents) {
41
+ expect(agentTypes).toContain(agent._type._id);
42
+ expect(agentIds).toContain(agent._id);
43
+ }
44
+ });
45
+ });
46
+ describe('AgentOps - getAgent()', () => {
47
+ test('getAgent() 0: Method is implemented', async () => {
48
+ expect(Agent.getAgent).toBeDefined();
49
+ });
50
+ test('getAgent() 1: Get agent "ig_mytestrun_com" (gateway)', async () => {
51
+ const agentType = 'IdentityGatewayAgent';
52
+ const agentId = 'ig_mytestrun_com';
53
+ mockFindAgentById(mock);
54
+ mockGetAgentByTypeAndId(mock);
55
+ expect.assertions(5);
56
+ const agent = await Agent.getAgent(agentId);
57
+ expect(agent).toBeTruthy();
58
+ expect(agent._type._id).toBe(agentType);
59
+ expect(agent._id).toBe(agentId);
60
+ });
61
+ test('getAgent() 2: Get agent "tomcatagent" (java)', async () => {
62
+ const agentType = 'J2EEAgent';
63
+ const agentId = 'tomcatagent';
64
+ mockFindAgentById(mock);
65
+ mockGetAgentByTypeAndId(mock);
66
+ expect.assertions(5);
67
+ const agent = await Agent.getAgent(agentId);
68
+ expect(agent).toBeTruthy();
69
+ expect(agent._type._id).toBe(agentType);
70
+ expect(agent._id).toBe(agentId);
71
+ });
72
+ test('getAgent() 3: Get agent "apacheagent" (web)', async () => {
73
+ const agentType = 'WebAgent';
74
+ const agentId = 'apacheagent';
75
+ mockFindAgentById(mock);
76
+ mockGetAgentByTypeAndId(mock);
77
+ expect.assertions(5);
78
+ const agent = await Agent.getAgent(agentId);
79
+ expect(agent).toBeTruthy();
80
+ expect(agent._type._id).toBe(agentType);
81
+ expect(agent._id).toBe(agentId);
82
+ });
83
+ });
84
+ describe('AgentOps - getAgentByTypeAndId()', () => {
85
+ test('getAgentByTypeAndId() 0: Method is implemented', async () => {
86
+ expect(Agent.getAgentByTypeAndId).toBeDefined();
87
+ });
88
+ test('getAgentByTypeAndId() 1: Get gateway agent "ig_mytestrun_com"', async () => {
89
+ const agentType = 'IdentityGatewayAgent';
90
+ const agentId = 'ig_mytestrun_com';
91
+ mockGetAgentByTypeAndId(mock);
92
+ expect.assertions(4);
93
+ const agent = await Agent.getAgentByTypeAndId(agentType, agentId);
94
+ expect(agent).toBeTruthy();
95
+ expect(agent._type._id).toBe(agentType);
96
+ expect(agent._id).toBe(agentId);
97
+ });
98
+ test('getAgentByTypeAndId() 2: Get java agent "tomcatagent"', async () => {
99
+ const agentType = 'J2EEAgent';
100
+ const agentId = 'tomcatagent';
101
+ mockGetAgentByTypeAndId(mock);
102
+ expect.assertions(4);
103
+ const agent = await Agent.getAgentByTypeAndId(agentType, agentId);
104
+ expect(agent).toBeTruthy();
105
+ expect(agent._type._id).toBe(agentType);
106
+ expect(agent._id).toBe(agentId);
107
+ });
108
+ test('getAgentByTypeAndId() 3: Get web agent "apacheagent"', async () => {
109
+ const agentType = 'WebAgent';
110
+ const agentId = 'apacheagent';
111
+ mockGetAgentByTypeAndId(mock);
112
+ expect.assertions(4);
113
+ const agent = await Agent.getAgentByTypeAndId(agentType, agentId);
114
+ expect(agent).toBeTruthy();
115
+ expect(agent._type._id).toBe(agentType);
116
+ expect(agent._id).toBe(agentId);
117
+ });
118
+ });
119
+ describe('AgentOps - getIdentityGatewayAgents()', () => {
120
+ test('getIdentityGatewayAgents() 0: Method is implemented', async () => {
121
+ expect(Agent.getIdentityGatewayAgents).toBeDefined();
122
+ });
123
+ test('getIdentityGatewayAgents() 1: Get gateway agents', async () => {
124
+ const agentType = 'IdentityGatewayAgent';
125
+ const agentIds = ['ig_mytestrun_com', 'ig_chico', 'ajays_client', 'api_client'];
126
+ mockGetAgentsByType(mock);
127
+ expect.assertions(10);
128
+ const agents = await Agent.getIdentityGatewayAgents();
129
+ expect(agents).toBeTruthy();
130
+ for (const agent of agents) {
131
+ expect(agent._type._id).toBe(agentType);
132
+ expect(agentIds).toContain(agent._id);
133
+ }
134
+ });
135
+ });
136
+ describe('AgentOps - getIdentityGatewayAgent()', () => {
137
+ test('getIdentityGatewayAgent() 0: Method is implemented', async () => {
138
+ expect(Agent.getIdentityGatewayAgent).toBeDefined();
139
+ });
140
+ test('getIdentityGatewayAgent() 1: Get gateway agent "ig_mytestrun_com"', async () => {
141
+ const agentType = 'IdentityGatewayAgent';
142
+ const agentId = 'ig_mytestrun_com';
143
+ mockGetAgentByTypeAndId(mock);
144
+ expect.assertions(4);
145
+ const agent = await Agent.getIdentityGatewayAgent(agentId);
146
+ expect(agent).toBeTruthy();
147
+ expect(agent._type._id).toBe(agentType);
148
+ expect(agent._id).toBe(agentId);
149
+ });
150
+ test('getIdentityGatewayAgent() 2: Get gateway agent "ig_chico"', async () => {
151
+ const agentType = 'IdentityGatewayAgent';
152
+ const agentId = 'ig_chico';
153
+ mockGetAgentByTypeAndId(mock);
154
+ expect.assertions(4);
155
+ const agent = await Agent.getIdentityGatewayAgent(agentId);
156
+ expect(agent).toBeTruthy();
157
+ expect(agent._type._id).toBe(agentType);
158
+ expect(agent._id).toBe(agentId);
159
+ });
160
+ test('getIdentityGatewayAgent() 3: Get gateway agent "ajays_client"', async () => {
161
+ const agentType = 'IdentityGatewayAgent';
162
+ const agentId = 'ajays_client';
163
+ mockGetAgentByTypeAndId(mock);
164
+ expect.assertions(4);
165
+ const agent = await Agent.getIdentityGatewayAgent(agentId);
166
+ expect(agent).toBeTruthy();
167
+ expect(agent._type._id).toBe(agentType);
168
+ expect(agent._id).toBe(agentId);
169
+ });
170
+ test('getIdentityGatewayAgent() 4: Get gateway agent "api_client"', async () => {
171
+ const agentType = 'IdentityGatewayAgent';
172
+ const agentId = 'api_client';
173
+ mockGetAgentByTypeAndId(mock);
174
+ expect.assertions(4);
175
+ const agent = await Agent.getIdentityGatewayAgent(agentId);
176
+ expect(agent).toBeTruthy();
177
+ expect(agent._type._id).toBe(agentType);
178
+ expect(agent._id).toBe(agentId);
179
+ });
180
+ });
181
+ describe('AgentOps - putIdentityGatewayAgent()', () => {
182
+ test('putIdentityGatewayAgent() 0: Method is implemented', async () => {
183
+ expect(Agent.putIdentityGatewayAgent).toBeDefined();
184
+ });
185
+ test('putIdentityGatewayAgent() 1: Put gateway agent "ig_mytestrun_com"', async () => {
186
+ const agentType = 'IdentityGatewayAgent';
187
+ const agentId = 'ig_mytestrun_com';
188
+ const agentData = getAgent(agentType, agentId);
189
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
190
+ expect(agentType).toBe(mockAgentType);
191
+ expect(agentId).toBe(mockAgentId);
192
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
193
+ });
194
+ expect.assertions(5);
195
+ const agent = await Agent.putIdentityGatewayAgent(agentId, agentData);
196
+ expect(agent).toBeTruthy();
197
+ expect(agent._id).toBe(agentId);
198
+ });
199
+ test('putIdentityGatewayAgent() 2: Put gateway agent "ig_chico"', async () => {
200
+ const agentType = 'IdentityGatewayAgent';
201
+ const agentId = 'ig_chico';
202
+ const agentData = getAgent(agentType, agentId);
203
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
204
+ expect(agentType).toBe(mockAgentType);
205
+ expect(agentId).toBe(mockAgentId);
206
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
207
+ });
208
+ expect.assertions(5);
209
+ const agent = await Agent.putIdentityGatewayAgent(agentId, agentData);
210
+ expect(agent).toBeTruthy();
211
+ expect(agent._id).toBe(agentId);
212
+ });
213
+ test('putIdentityGatewayAgent() 3: Put gateway agent "ajays_client"', async () => {
214
+ const agentType = 'IdentityGatewayAgent';
215
+ const agentId = 'ajays_client';
216
+ const agentData = getAgent(agentType, agentId);
217
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
218
+ expect(agentType).toBe(mockAgentType);
219
+ expect(agentId).toBe(mockAgentId);
220
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
221
+ });
222
+ expect.assertions(5);
223
+ const agent = await Agent.putIdentityGatewayAgent(agentId, agentData);
224
+ expect(agent).toBeTruthy();
225
+ expect(agent._id).toBe(agentId);
226
+ });
227
+ test('putIdentityGatewayAgent() 4: Put gateway agent "api_client"', async () => {
228
+ const agentType = 'IdentityGatewayAgent';
229
+ const agentId = 'api_client';
230
+ const agentData = getAgent(agentType, agentId);
231
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
232
+ expect(agentType).toBe(mockAgentType);
233
+ expect(agentId).toBe(mockAgentId);
234
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
235
+ });
236
+ expect.assertions(5);
237
+ const agent = await Agent.putIdentityGatewayAgent(agentId, agentData);
238
+ expect(agent).toBeTruthy();
239
+ expect(agent._id).toBe(agentId);
240
+ });
241
+ });
242
+ describe('AgentOps - getJavaAgents()', () => {
243
+ test('getJavaAgents() 0: Method is implemented', async () => {
244
+ expect(Agent.getJavaAgents).toBeDefined();
245
+ });
246
+ test('getJavaAgents() 1: Get java agents', async () => {
247
+ const agentType = 'J2EEAgent';
248
+ const agentIds = ['tomcatagent', 'javaAgent'];
249
+ mockGetAgentsByType(mock);
250
+ expect.assertions(6);
251
+ const agents = await Agent.getJavaAgents();
252
+ expect(agents).toBeTruthy();
253
+ for (const agent of agents) {
254
+ expect(agent._type._id).toBe(agentType);
255
+ expect(agentIds).toContain(agent._id);
256
+ }
257
+ });
258
+ });
259
+ describe('AgentOps - getJavaAgent()', () => {
260
+ test('getJavaAgent() 0: Method is implemented', async () => {
261
+ expect(Agent.getJavaAgent).toBeDefined();
262
+ });
263
+ test('getJavaAgent() 1: Get java agent "tomcatagent"', async () => {
264
+ const agentType = 'J2EEAgent';
265
+ const agentId = 'tomcatagent';
266
+ mockGetAgentByTypeAndId(mock);
267
+ expect.assertions(4);
268
+ const agent = await Agent.getJavaAgent(agentId);
269
+ expect(agent).toBeTruthy();
270
+ expect(agent._type._id).toBe(agentType);
271
+ expect(agent._id).toBe(agentId);
272
+ });
273
+ test('getJavaAgent() 2: Get java agent "javaAgent"', async () => {
274
+ const agentType = 'J2EEAgent';
275
+ const agentId = 'javaAgent';
276
+ mockGetAgentByTypeAndId(mock);
277
+ expect.assertions(4);
278
+ const agent = await Agent.getJavaAgent(agentId);
279
+ expect(agent).toBeTruthy();
280
+ expect(agent._type._id).toBe(agentType);
281
+ expect(agent._id).toBe(agentId);
282
+ });
283
+ });
284
+ describe('AgentOps - putJavaAgent()', () => {
285
+ test('putJavaAgent() 0: Method is implemented', async () => {
286
+ expect(Agent.putJavaAgent).toBeDefined();
287
+ });
288
+ test('putJavaAgent() 1: Put java agent "tomcatagent"', async () => {
289
+ const agentType = 'J2EEAgent';
290
+ const agentId = 'tomcatagent';
291
+ const agentData = getAgent(agentType, agentId);
292
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
293
+ expect(agentType).toBe(mockAgentType);
294
+ expect(agentId).toBe(mockAgentId);
295
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
296
+ });
297
+ expect.assertions(5);
298
+ const agent = await Agent.putJavaAgent(agentId, agentData);
299
+ expect(agent).toBeTruthy();
300
+ expect(agent._id).toBe(agentId);
301
+ });
302
+ test('putJavaAgent() 2: Put java agent "javaAgent"', async () => {
303
+ const agentType = 'J2EEAgent';
304
+ const agentId = 'javaAgent';
305
+ const agentData = getAgent(agentType, agentId);
306
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
307
+ expect(agentType).toBe(mockAgentType);
308
+ expect(agentId).toBe(mockAgentId);
309
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
310
+ });
311
+ expect.assertions(5);
312
+ const agent = await Agent.putJavaAgent(agentId, agentData);
313
+ expect(agent).toBeTruthy();
314
+ expect(agent._id).toBe(agentId);
315
+ });
316
+ });
317
+ describe('AgentOps - getWebAgents()', () => {
318
+ test('getWebAgents() 0: Method is implemented', async () => {
319
+ expect(Agent.getWebAgents).toBeDefined();
320
+ });
321
+ test('getWebAgents() 1: Get web agents', async () => {
322
+ const agentType = 'WebAgent';
323
+ const agentIds = ['apacheagent', 'webserver'];
324
+ mockGetAgentsByType(mock);
325
+ expect.assertions(6);
326
+ const agents = await Agent.getWebAgents();
327
+ expect(agents).toBeTruthy();
328
+ for (const agent of agents) {
329
+ expect(agent._type._id).toBe(agentType);
330
+ expect(agentIds).toContain(agent._id);
331
+ }
332
+ });
333
+ });
334
+ describe('AgentOps - getWebAgent()', () => {
335
+ test('getWebAgent() 0: Method is implemented', async () => {
336
+ expect(Agent.getWebAgent).toBeDefined();
337
+ });
338
+ test('getWebAgent() 1: Get web agent "apacheagent"', async () => {
339
+ const agentType = 'WebAgent';
340
+ const agentId = 'apacheagent';
341
+ mockGetAgentByTypeAndId(mock);
342
+ expect.assertions(4);
343
+ const agent = await Agent.getWebAgent(agentId);
344
+ expect(agent).toBeTruthy();
345
+ expect(agent._type._id).toBe(agentType);
346
+ expect(agent._id).toBe(agentId);
347
+ });
348
+ test('getWebAgent() 2: Get web agent "webserver"', async () => {
349
+ const agentType = 'WebAgent';
350
+ const agentId = 'webserver';
351
+ mockGetAgentByTypeAndId(mock);
352
+ expect.assertions(4);
353
+ const agent = await Agent.getWebAgent(agentId);
354
+ expect(agent).toBeTruthy();
355
+ expect(agent._type._id).toBe(agentType);
356
+ expect(agent._id).toBe(agentId);
357
+ });
358
+ });
359
+ describe('AgentOps - putWebAgent()', () => {
360
+ test('putWebAgent() 0: Method is implemented', async () => {
361
+ expect(Agent.putWebAgent).toBeDefined();
362
+ });
363
+ test('putWebAgent() 1: Put java agent "apacheagent"', async () => {
364
+ const agentType = 'WebAgent';
365
+ const agentId = 'apacheagent';
366
+ const agentData = getAgent(agentType, agentId);
367
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
368
+ expect(agentType).toBe(mockAgentType);
369
+ expect(agentId).toBe(mockAgentId);
370
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
371
+ });
372
+ expect.assertions(5);
373
+ const agent = await Agent.putWebAgent(agentId, agentData);
374
+ expect(agent).toBeTruthy();
375
+ expect(agent._id).toBe(agentId);
376
+ });
377
+ test('putWebAgent() 2: Put web agent "webserver"', async () => {
378
+ const agentType = 'WebAgent';
379
+ const agentId = 'webserver';
380
+ const agentData = getAgent(agentType, agentId);
381
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
382
+ expect(agentType).toBe(mockAgentType);
383
+ expect(agentId).toBe(mockAgentId);
384
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
385
+ });
386
+ expect.assertions(5);
387
+ const agent = await Agent.putWebAgent(agentId, agentData);
388
+ expect(agent).toBeTruthy();
389
+ expect(agent._id).toBe(agentId);
390
+ });
391
+ });
392
+ describe('AgentOps - exportAgents()', () => {
393
+ test('exportAgents() 0: Method is implemented', async () => {
394
+ expect(Agent.exportAgents).toBeDefined();
395
+ });
396
+ test('exportAgents() 1: Export all agents', async () => {
397
+ const agentTypes = ['IdentityGatewayAgent', 'J2EEAgent', 'WebAgent'];
398
+ const agentIds = ['ig_mytestrun_com', 'ig_chico', 'ajays_client', 'api_client', 'tomcatagent', 'javaAgent', 'apacheagent', 'webserver'];
399
+ mockGetAgentsByType(mock);
400
+ expect.assertions(22);
401
+ const exportData = await Agent.exportAgents();
402
+ expect(exportData).toBeTruthy();
403
+ expect(exportData.agents).toBeTruthy();
404
+ expect(Object.keys(exportData.agents).length).toBe(8);
405
+ for (const agent of Object.values(exportData.agents)) {
406
+ expect(agentTypes).toContain(agent._type._id);
407
+ expect(agentIds).toContain(agent._id);
408
+ }
409
+ });
410
+ });
411
+ describe('AgentOps - exportIdentityGatewayAgents()', () => {
412
+ test('exportIdentityGatewayAgents() 0: Method is implemented', async () => {
413
+ expect(Agent.exportIdentityGatewayAgents).toBeDefined();
414
+ });
415
+ test('exportIdentityGatewayAgents() 1: Export gateway agents', async () => {
416
+ const agentTypes = ['IdentityGatewayAgent'];
417
+ const agentIds = ['ig_mytestrun_com', 'ig_chico', 'ajays_client', 'api_client'];
418
+ mockGetAgentsByType(mock);
419
+ expect.assertions(12);
420
+ const exportData = await Agent.exportIdentityGatewayAgents();
421
+ expect(exportData).toBeTruthy();
422
+ expect(exportData.agents).toBeTruthy();
423
+ expect(Object.keys(exportData.agents).length).toBe(4);
424
+ for (const agent of Object.values(exportData.agents)) {
425
+ expect(agentTypes).toContain(agent._type._id);
426
+ expect(agentIds).toContain(agent._id);
427
+ }
428
+ });
429
+ });
430
+ describe('AgentOps - exportJavaAgents()', () => {
431
+ test('exportJavaAgents() 0: Method is implemented', async () => {
432
+ expect(Agent.exportJavaAgents).toBeDefined();
433
+ });
434
+ test('exportJavaAgents() 1: Export java agents', async () => {
435
+ const agentTypes = ['J2EEAgent'];
436
+ const agentIds = ['tomcatagent', 'javaAgent'];
437
+ mockGetAgentsByType(mock);
438
+ expect.assertions(8);
439
+ const exportData = await Agent.exportJavaAgents();
440
+ expect(exportData).toBeTruthy();
441
+ expect(exportData.agents).toBeTruthy();
442
+ expect(Object.keys(exportData.agents).length).toBe(2);
443
+ for (const agent of Object.values(exportData.agents)) {
444
+ expect(agentTypes).toContain(agent._type._id);
445
+ expect(agentIds).toContain(agent._id);
446
+ }
447
+ });
448
+ });
449
+ describe('AgentOps - exportWebAgents()', () => {
450
+ test('exportWebAgents() 0: Method is implemented', async () => {
451
+ expect(Agent.exportJavaAgents).toBeDefined();
452
+ });
453
+ test('exportWebAgents() 1: Export web agents', async () => {
454
+ const agentTypes = ['WebAgent'];
455
+ const agentIds = ['apacheagent', 'webserver'];
456
+ mockGetAgentsByType(mock);
457
+ expect.assertions(8);
458
+ const exportData = await Agent.exportWebAgents();
459
+ expect(exportData).toBeTruthy();
460
+ expect(exportData.agents).toBeTruthy();
461
+ expect(Object.keys(exportData.agents).length).toBe(2);
462
+ for (const agent of Object.values(exportData.agents)) {
463
+ expect(agentTypes).toContain(agent._type._id);
464
+ expect(agentIds).toContain(agent._id);
465
+ }
466
+ });
467
+ });
468
+ describe('AgentOps - exportAgent()', () => {
469
+ test('exportAgent() 0: Method is implemented', async () => {
470
+ expect(Agent.exportAgent).toBeDefined();
471
+ });
472
+ test('exportAgent() 1: Export agent "ig_mytestrun_com" (gateway)', async () => {
473
+ const agentType = 'IdentityGatewayAgent';
474
+ const agentId = 'ig_mytestrun_com';
475
+ mockFindAgentById(mock);
476
+ mockGetAgentByTypeAndId(mock);
477
+ expect.assertions(7);
478
+ const exportData = await Agent.exportAgent(agentId);
479
+ expect(exportData).toBeTruthy();
480
+ expect(exportData.agents).toBeTruthy();
481
+ expect(Object.keys(exportData.agents).length).toBe(1);
482
+ for (const agent of Object.values(exportData.agents)) {
483
+ expect(agentType).toBe(agent._type._id);
484
+ expect(agentId).toBe(agent._id);
485
+ }
486
+ });
487
+ test('exportAgent() 2: Export agent "tomcatagent" (java)', async () => {
488
+ const agentType = 'J2EEAgent';
489
+ const agentId = 'tomcatagent';
490
+ mockFindAgentById(mock);
491
+ mockGetAgentByTypeAndId(mock);
492
+ expect.assertions(7);
493
+ const exportData = await Agent.exportAgent(agentId);
494
+ expect(exportData).toBeTruthy();
495
+ expect(exportData.agents).toBeTruthy();
496
+ expect(Object.keys(exportData.agents).length).toBe(1);
497
+ for (const agent of Object.values(exportData.agents)) {
498
+ expect(agentType).toBe(agent._type._id);
499
+ expect(agentId).toBe(agent._id);
500
+ }
501
+ });
502
+ test('exportAgent() 3: Export agent "apacheagent" (web)', async () => {
503
+ const agentType = 'WebAgent';
504
+ const agentId = 'apacheagent';
505
+ mockFindAgentById(mock);
506
+ mockGetAgentByTypeAndId(mock);
507
+ expect.assertions(7);
508
+ const exportData = await Agent.exportAgent(agentId);
509
+ expect(exportData).toBeTruthy();
510
+ expect(exportData.agents).toBeTruthy();
511
+ expect(Object.keys(exportData.agents).length).toBe(1);
512
+ for (const agent of Object.values(exportData.agents)) {
513
+ expect(agentType).toBe(agent._type._id);
514
+ expect(agentId).toBe(agent._id);
515
+ }
516
+ });
517
+ });
518
+ describe('AgentOps - exportIdentityGatewayAgent()', () => {
519
+ test('exportIdentityGatewayAgent() 0: Method is implemented', async () => {
520
+ expect(Agent.exportIdentityGatewayAgent).toBeDefined();
521
+ });
522
+ test('exportIdentityGatewayAgent() 1: Export gateway agent "ig_mytestrun_com"', async () => {
523
+ const agentType = 'IdentityGatewayAgent';
524
+ const agentId = 'ig_mytestrun_com';
525
+ mockGetAgentByTypeAndId(mock);
526
+ expect.assertions(6);
527
+ const exportData = await Agent.exportIdentityGatewayAgent(agentId);
528
+ expect(exportData).toBeTruthy();
529
+ expect(exportData.agents).toBeTruthy();
530
+ expect(Object.keys(exportData.agents).length).toBe(1);
531
+ for (const agent of Object.values(exportData.agents)) {
532
+ expect(agentType).toBe(agent._type._id);
533
+ expect(agentId).toBe(agent._id);
534
+ }
535
+ });
536
+ });
537
+ describe('AgentOps - exportJavaAgent()', () => {
538
+ test('exportJavaAgent() 0: Method is implemented', async () => {
539
+ expect(Agent.exportJavaAgent).toBeDefined();
540
+ });
541
+ test('exportJavaAgent() 2: Export java agent "tomcatagent"', async () => {
542
+ const agentType = 'J2EEAgent';
543
+ const agentId = 'tomcatagent';
544
+ mockGetAgentByTypeAndId(mock);
545
+ expect.assertions(6);
546
+ const exportData = await Agent.exportJavaAgent(agentId);
547
+ expect(exportData).toBeTruthy();
548
+ expect(exportData.agents).toBeTruthy();
549
+ expect(Object.keys(exportData.agents).length).toBe(1);
550
+ for (const agent of Object.values(exportData.agents)) {
551
+ expect(agentType).toBe(agent._type._id);
552
+ expect(agentId).toBe(agent._id);
553
+ }
554
+ });
555
+ });
556
+ describe('AgentOps - exportWebAgent()', () => {
557
+ test('exportWebAgent() 0: Method is implemented', async () => {
558
+ expect(Agent.exportWebAgent).toBeDefined();
559
+ });
560
+ test('exportWebAgent() 3: Export web agent "apacheagent"', async () => {
561
+ const agentType = 'WebAgent';
562
+ const agentId = 'apacheagent';
563
+ mockGetAgentByTypeAndId(mock);
564
+ expect.assertions(6);
565
+ const exportData = await Agent.exportWebAgent(agentId);
566
+ expect(exportData).toBeTruthy();
567
+ expect(exportData.agents).toBeTruthy();
568
+ expect(Object.keys(exportData.agents).length).toBe(1);
569
+ for (const agent of Object.values(exportData.agents)) {
570
+ expect(agentType).toBe(agent._type._id);
571
+ expect(agentId).toBe(agent._id);
572
+ }
573
+ });
574
+ });
575
+ describe('AgentOps - importAgents()', () => {
576
+ test('importAgents() 0: Method is implemented', async () => {
577
+ expect(Agent.importAgents).toBeDefined();
578
+ });
579
+ test('importAgents() 1: Import all agents', async () => {
580
+ const agents = {
581
+ ig_mytestrun_com: 'IdentityGatewayAgent',
582
+ ig_chico: 'IdentityGatewayAgent',
583
+ ajays_client: 'IdentityGatewayAgent',
584
+ api_client: 'IdentityGatewayAgent',
585
+ tomcatagent: 'J2EEAgent',
586
+ javaAgent: 'J2EEAgent',
587
+ apacheagent: 'WebAgent',
588
+ webserver: 'WebAgent'
589
+ };
590
+ const exportData = Agent.createAgentExportTemplate();
591
+ for (const agentId of Object.keys(agents)) {
592
+ const agentType = agents[agentId];
593
+ const agentData = getAgent(agentType, agentId);
594
+ exportData.agents[agentId] = agentData;
595
+ }
596
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
597
+ expect(mockAgentObj).toBeTruthy();
598
+ expect(Object.values(agents)).toContain(mockAgentType);
599
+ expect(Object.keys(agents)).toContain(mockAgentId);
600
+ });
601
+ expect.assertions(25);
602
+ await Agent.importAgents(exportData);
603
+ expect(true).toBeTruthy();
604
+ });
605
+ });
606
+ describe('AgentOps - importIdentityGatewayAgents()', () => {
607
+ test('importIdentityGatewayAgents() 0: Method is implemented', async () => {
608
+ expect(Agent.importIdentityGatewayAgents).toBeDefined();
609
+ });
610
+ test('importIdentityGatewayAgents() 1: Import all gateway agents', async () => {
611
+ const agents = {
612
+ ig_mytestrun_com: 'IdentityGatewayAgent',
613
+ ig_chico: 'IdentityGatewayAgent',
614
+ ajays_client: 'IdentityGatewayAgent',
615
+ api_client: 'IdentityGatewayAgent'
616
+ };
617
+ const exportData = Agent.createAgentExportTemplate();
618
+ for (const agentId of Object.keys(agents)) {
619
+ const agentType = agents[agentId];
620
+ const agentData = getAgent(agentType, agentId);
621
+ exportData.agents[agentId] = agentData;
622
+ }
623
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
624
+ expect(mockAgentObj).toBeTruthy();
625
+ expect(Object.values(agents)).toContain(mockAgentType);
626
+ expect(Object.keys(agents)).toContain(mockAgentId);
627
+ });
628
+ expect.assertions(13);
629
+ await Agent.importIdentityGatewayAgents(exportData);
630
+ expect(true).toBeTruthy();
631
+ });
632
+ test('importIdentityGatewayAgents() 2: Import agents with wrong type', async () => {
633
+ const agents = {
634
+ tomcatagent: 'J2EEAgent',
635
+ javaAgent: 'J2EEAgent'
636
+ };
637
+ const exportData = Agent.createAgentExportTemplate();
638
+ for (const agentId of Object.keys(agents)) {
639
+ const agentType = agents[agentId];
640
+ const agentData = getAgent(agentType, agentId);
641
+ exportData.agents[agentId] = agentData;
642
+ }
643
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
644
+ expect(mockAgentObj).toBeTruthy();
645
+ expect(Object.values(agents)).toContain(mockAgentType);
646
+ expect(Object.keys(agents)).toContain(mockAgentId);
647
+ });
648
+ expect.assertions(2);
649
+ try {
650
+ await Agent.importIdentityGatewayAgents(exportData);
651
+ } catch (error) {
652
+ expect(error).toBeTruthy();
653
+ expect(error.message).toBe("Wrong agent type! Expected 'IdentityGatewayAgent' but got 'J2EEAgent'.");
654
+ }
655
+ });
656
+ });
657
+ describe('AgentOps - importJavaAgents()', () => {
658
+ test('importJavaAgents() 0: Method is implemented', async () => {
659
+ expect(Agent.importJavaAgents).toBeDefined();
660
+ });
661
+ test('importJavaAgents() 1: Import all java agents', async () => {
662
+ const agents = {
663
+ tomcatagent: 'J2EEAgent',
664
+ javaAgent: 'J2EEAgent'
665
+ };
666
+ const exportData = Agent.createAgentExportTemplate();
667
+ for (const agentId of Object.keys(agents)) {
668
+ const agentType = agents[agentId];
669
+ const agentData = getAgent(agentType, agentId);
670
+ exportData.agents[agentId] = agentData;
671
+ }
672
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
673
+ expect(mockAgentObj).toBeTruthy();
674
+ expect(Object.values(agents)).toContain(mockAgentType);
675
+ expect(Object.keys(agents)).toContain(mockAgentId);
676
+ });
677
+ expect.assertions(7);
678
+ await Agent.importJavaAgents(exportData);
679
+ expect(true).toBeTruthy();
680
+ });
681
+ test('importJavaAgents() 2: Import agents with wrong type', async () => {
682
+ const agents = {
683
+ apacheagent: 'WebAgent',
684
+ webserver: 'WebAgent'
685
+ };
686
+ const exportData = Agent.createAgentExportTemplate();
687
+ for (const agentId of Object.keys(agents)) {
688
+ const agentType = agents[agentId];
689
+ const agentData = getAgent(agentType, agentId);
690
+ exportData.agents[agentId] = agentData;
691
+ }
692
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
693
+ expect(mockAgentObj).toBeTruthy();
694
+ expect(Object.values(agents)).toContain(mockAgentType);
695
+ expect(Object.keys(agents)).toContain(mockAgentId);
696
+ });
697
+ expect.assertions(2);
698
+ try {
699
+ await Agent.importJavaAgents(exportData);
700
+ } catch (error) {
701
+ expect(error).toBeTruthy();
702
+ expect(error.message).toBe("Wrong agent type! Expected 'J2EEAgent' but got 'WebAgent'.");
703
+ }
704
+ });
705
+ });
706
+ describe('AgentOps - importWebAgents()', () => {
707
+ test('importWebAgents() 0: Method is implemented', async () => {
708
+ expect(Agent.importWebAgents).toBeDefined();
709
+ });
710
+ test('importWebAgents() 1: Import all web agents', async () => {
711
+ const agents = {
712
+ apacheagent: 'WebAgent',
713
+ webserver: 'WebAgent'
714
+ };
715
+ const exportData = Agent.createAgentExportTemplate();
716
+ for (const agentId of Object.keys(agents)) {
717
+ const agentType = agents[agentId];
718
+ const agentData = getAgent(agentType, agentId);
719
+ exportData.agents[agentId] = agentData;
720
+ }
721
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
722
+ expect(mockAgentObj).toBeTruthy();
723
+ expect(Object.values(agents)).toContain(mockAgentType);
724
+ expect(Object.keys(agents)).toContain(mockAgentId);
725
+ });
726
+ expect.assertions(7);
727
+ await Agent.importWebAgents(exportData);
728
+ expect(true).toBeTruthy();
729
+ });
730
+ test('importWebAgents() 2: Import agents with wrong type', async () => {
731
+ const agents = {
732
+ ig_mytestrun_com: 'IdentityGatewayAgent',
733
+ ig_chico: 'IdentityGatewayAgent',
734
+ ajays_client: 'IdentityGatewayAgent',
735
+ api_client: 'IdentityGatewayAgent'
736
+ };
737
+ const exportData = Agent.createAgentExportTemplate();
738
+ for (const agentId of Object.keys(agents)) {
739
+ const agentType = agents[agentId];
740
+ const agentData = getAgent(agentType, agentId);
741
+ exportData.agents[agentId] = agentData;
742
+ }
743
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
744
+ expect(mockAgentObj).toBeTruthy();
745
+ expect(Object.values(agents)).toContain(mockAgentType);
746
+ expect(Object.keys(agents)).toContain(mockAgentId);
747
+ });
748
+ expect.assertions(2);
749
+ try {
750
+ await Agent.importWebAgents(exportData);
751
+ } catch (error) {
752
+ expect(error).toBeTruthy();
753
+ expect(error.message).toBe("Wrong agent type! Expected 'WebAgent' but got 'IdentityGatewayAgent'.");
754
+ }
755
+ });
756
+ });
757
+ describe('AgentOps - importAgent()', () => {
758
+ test('importAgent() 0: Method is implemented', async () => {
759
+ expect(Agent.importAgent).toBeDefined();
760
+ });
761
+ test('importAgent() 1: Import gateway agent', async () => {
762
+ const exportData = Agent.createAgentExportTemplate();
763
+ const agentType = 'IdentityGatewayAgent';
764
+ const agentId = 'ig_mytestrun_com';
765
+ const agentData = getAgent(agentType, agentId);
766
+ exportData.agents[agentId] = agentData;
767
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
768
+ expect(agentType).toBe(mockAgentType);
769
+ expect(agentId).toBe(mockAgentId);
770
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
771
+ });
772
+ expect.assertions(4);
773
+ await Agent.importAgent(agentId, exportData);
774
+ expect(true).toBeTruthy();
775
+ });
776
+ test('importAgent() 2: Import java agent', async () => {
777
+ const exportData = Agent.createAgentExportTemplate();
778
+ const agentType = 'J2EEAgent';
779
+ const agentId = 'tomcatagent';
780
+ const agentData = getAgent(agentType, agentId);
781
+ exportData.agents[agentId] = agentData;
782
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
783
+ expect(agentType).toBe(mockAgentType);
784
+ expect(agentId).toBe(mockAgentId);
785
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
786
+ });
787
+ expect.assertions(4);
788
+ await Agent.importAgent(agentId, exportData);
789
+ expect(true).toBeTruthy();
790
+ });
791
+ test('importAgent() 3: Import web agent', async () => {
792
+ const exportData = Agent.createAgentExportTemplate();
793
+ const agentType = 'WebAgent';
794
+ const agentId = 'apacheagent';
795
+ const agentData = getAgent(agentType, agentId);
796
+ exportData.agents[agentId] = agentData;
797
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
798
+ expect(agentType).toBe(mockAgentType);
799
+ expect(agentId).toBe(mockAgentId);
800
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
801
+ });
802
+ expect.assertions(4);
803
+ await Agent.importAgent(agentId, exportData);
804
+ expect(true).toBeTruthy();
805
+ });
806
+ });
807
+ describe('AgentOps - importIdentityGatewayAgent()', () => {
808
+ test('importIdentityGatewayAgent() 0: Method is implemented', async () => {
809
+ expect(Agent.importIdentityGatewayAgent).toBeDefined();
810
+ });
811
+ test('importIdentityGatewayAgent() 1: Import gateway agent "ig_mytestrun_com"', async () => {
812
+ const exportData = Agent.createAgentExportTemplate();
813
+ const agentType = 'IdentityGatewayAgent';
814
+ const agentId = 'ig_mytestrun_com';
815
+ const agentData = getAgent(agentType, agentId);
816
+ exportData.agents[agentId] = agentData;
817
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
818
+ expect(agentType).toBe(mockAgentType);
819
+ expect(agentId).toBe(mockAgentId);
820
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
821
+ });
822
+ expect.assertions(4);
823
+ await Agent.importIdentityGatewayAgent(agentId, exportData);
824
+ expect(true).toBeTruthy();
825
+ });
826
+ test('importIdentityGatewayAgent() 2: Import agent with wrong type', async () => {
827
+ const exportData = Agent.createAgentExportTemplate();
828
+ const agentType = 'J2EEAgent';
829
+ const agentId = 'tomcatagent';
830
+ const agentData = getAgent(agentType, agentId);
831
+ exportData.agents[agentId] = agentData;
832
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
833
+ expect(agentType).toBe(mockAgentType);
834
+ expect(agentId).toBe(mockAgentId);
835
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
836
+ });
837
+ expect.assertions(2);
838
+ try {
839
+ await Agent.importIdentityGatewayAgent(agentId, exportData);
840
+ } catch (error) {
841
+ expect(error).toBeTruthy();
842
+ expect(error.message).toBe("Wrong agent type! Expected 'IdentityGatewayAgent' but got 'J2EEAgent'.");
843
+ }
844
+ });
845
+ });
846
+ describe('AgentOps - importJavaAgent()', () => {
847
+ test('importJavaAgent() 0: Method is implemented', async () => {
848
+ expect(Agent.importJavaAgents).toBeDefined();
849
+ });
850
+ test('importJavaAgent() 1: Import java agent "tomcatagent"', async () => {
851
+ const exportData = Agent.createAgentExportTemplate();
852
+ const agentType = 'J2EEAgent';
853
+ const agentId = 'tomcatagent';
854
+ const agentData = getAgent(agentType, agentId);
855
+ exportData.agents[agentId] = agentData;
856
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
857
+ expect(agentType).toBe(mockAgentType);
858
+ expect(agentId).toBe(mockAgentId);
859
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
860
+ });
861
+ expect.assertions(4);
862
+ await Agent.importJavaAgent(agentId, exportData);
863
+ expect(true).toBeTruthy();
864
+ });
865
+ test('importJavaAgent() 2: Import agent with wrong type', async () => {
866
+ const exportData = Agent.createAgentExportTemplate();
867
+ const agentType = 'WebAgent';
868
+ const agentId = 'apacheagent';
869
+ const agentData = getAgent(agentType, agentId);
870
+ exportData.agents[agentId] = agentData;
871
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
872
+ expect(agentType).toBe(mockAgentType);
873
+ expect(agentId).toBe(mockAgentId);
874
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
875
+ });
876
+ expect.assertions(2);
877
+ try {
878
+ await Agent.importJavaAgent(agentId, exportData);
879
+ } catch (error) {
880
+ expect(error).toBeTruthy();
881
+ expect(error.message).toBe("Wrong agent type! Expected 'J2EEAgent' but got 'WebAgent'.");
882
+ }
883
+ });
884
+ });
885
+ describe('AgentOps - importWebAgent()', () => {
886
+ test('importWebAgent() 0: Method is implemented', async () => {
887
+ expect(Agent.importWebAgent).toBeDefined();
888
+ });
889
+ test('importWebAgent() 1: Import web agent "apacheagent"', async () => {
890
+ const exportData = Agent.createAgentExportTemplate();
891
+ const agentType = 'WebAgent';
892
+ const agentId = 'apacheagent';
893
+ const agentData = getAgent(agentType, agentId);
894
+ exportData.agents[agentId] = agentData;
895
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
896
+ expect(agentType).toBe(mockAgentType);
897
+ expect(agentId).toBe(mockAgentId);
898
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
899
+ });
900
+ expect.assertions(4);
901
+ await Agent.importWebAgent(agentId, exportData);
902
+ expect(true).toBeTruthy();
903
+ });
904
+ test('importWebAgent() 2: Import agent with wrong type', async () => {
905
+ const exportData = Agent.createAgentExportTemplate();
906
+ const agentType = 'IdentityGatewayAgent';
907
+ const agentId = 'ig_mytestrun_com';
908
+ const agentData = getAgent(agentType, agentId);
909
+ exportData.agents[agentId] = agentData;
910
+ mockPutAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
911
+ expect(agentType).toBe(mockAgentType);
912
+ expect(agentId).toBe(mockAgentId);
913
+ expect(isEqualJson(mockAgentObj, agentData, ['_rev'])).toBeTruthy();
914
+ });
915
+ expect.assertions(2);
916
+ try {
917
+ await Agent.importWebAgent(agentId, exportData);
918
+ } catch (error) {
919
+ expect(error).toBeTruthy();
920
+ expect(error.message).toBe("Wrong agent type! Expected 'WebAgent' but got 'IdentityGatewayAgent'.");
921
+ }
922
+ });
923
+ });
924
+ describe('AgentOps - deleteAgents()', () => {
925
+ test('deleteAgents() 0: Method is implemented', async () => {
926
+ expect(Agent.deleteAgents).toBeDefined();
927
+ });
928
+ test('deleteAgents() 1: Delete all agents', async () => {
929
+ const agents = {
930
+ ig_mytestrun_com: 'IdentityGatewayAgent',
931
+ ig_chico: 'IdentityGatewayAgent',
932
+ ajays_client: 'IdentityGatewayAgent',
933
+ api_client: 'IdentityGatewayAgent',
934
+ tomcatagent: 'J2EEAgent',
935
+ javaAgent: 'J2EEAgent',
936
+ apacheagent: 'WebAgent',
937
+ webserver: 'WebAgent'
938
+ };
939
+ mockGetAgentsByType(mock);
940
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
941
+ expect(mockAgentObj).toBeTruthy();
942
+ expect(Object.values(agents)).toContain(mockAgentType);
943
+ expect(Object.keys(agents)).toContain(mockAgentId);
944
+ });
945
+ expect.assertions(28);
946
+ await Agent.deleteAgents();
947
+ expect(true).toBeTruthy();
948
+ });
949
+ });
950
+ describe('AgentOps - deleteAgent()', () => {
951
+ test('deleteAgent() 0: Method is implemented', async () => {
952
+ expect(Agent.deleteAgent).toBeDefined();
953
+ });
954
+ test('deleteAgent() 1: Delete agent "ig_mytestrun_com" (gateway)', async () => {
955
+ const agentType = 'IdentityGatewayAgent';
956
+ const agentId = 'ig_mytestrun_com';
957
+ mockFindAgentById(mock);
958
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
959
+ expect(mockAgentObj).toBeTruthy();
960
+ expect(agentType).toBe(mockAgentType);
961
+ expect(agentId).toBe(mockAgentId);
962
+ });
963
+ expect.assertions(5);
964
+ await Agent.deleteAgent(agentId);
965
+ expect(true).toBeTruthy();
966
+ });
967
+ test('deleteAgent() 2: Delete agent "tomcatagent" (java)', async () => {
968
+ const agentType = 'J2EEAgent';
969
+ const agentId = 'tomcatagent';
970
+ mockFindAgentById(mock);
971
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
972
+ expect(mockAgentObj).toBeTruthy();
973
+ expect(agentType).toBe(mockAgentType);
974
+ expect(agentId).toBe(mockAgentId);
975
+ });
976
+ expect.assertions(5);
977
+ await Agent.deleteAgent(agentId);
978
+ expect(true).toBeTruthy();
979
+ });
980
+ test('deleteAgent() 3: Delete agent "apacheagent" (web)', async () => {
981
+ const agentType = 'WebAgent';
982
+ const agentId = 'apacheagent';
983
+ mockFindAgentById(mock);
984
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
985
+ expect(mockAgentObj).toBeTruthy();
986
+ expect(agentType).toBe(mockAgentType);
987
+ expect(agentId).toBe(mockAgentId);
988
+ });
989
+ expect.assertions(5);
990
+ await Agent.deleteAgent(agentId);
991
+ expect(true).toBeTruthy();
992
+ });
993
+ });
994
+ describe('AgentOps - deleteIdentityGatewayAgents()', () => {
995
+ test('deleteIdentityGatewayAgents() 0: Method is implemented', async () => {
996
+ expect(Agent.deleteIdentityGatewayAgents).toBeDefined();
997
+ });
998
+ test('deleteIdentityGatewayAgents() 1: Delete all gateway agents', async () => {
999
+ const agents = {
1000
+ ig_mytestrun_com: 'IdentityGatewayAgent',
1001
+ ig_chico: 'IdentityGatewayAgent',
1002
+ ajays_client: 'IdentityGatewayAgent',
1003
+ api_client: 'IdentityGatewayAgent'
1004
+ };
1005
+ mockGetAgentsByType(mock);
1006
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1007
+ expect(mockAgentObj).toBeTruthy();
1008
+ expect(Object.values(agents)).toContain(mockAgentType);
1009
+ expect(Object.keys(agents)).toContain(mockAgentId);
1010
+ });
1011
+ expect.assertions(14);
1012
+ await Agent.deleteIdentityGatewayAgents();
1013
+ expect(true).toBeTruthy();
1014
+ });
1015
+ });
1016
+ describe('AgentOps - deleteIdentityGatewayAgent()', () => {
1017
+ test('deleteIdentityGatewayAgent() 0: Method is implemented', async () => {
1018
+ expect(Agent.deleteIdentityGatewayAgent).toBeDefined();
1019
+ });
1020
+ test('deleteIdentityGatewayAgent() 1: Delete gateway agent "ig_mytestrun_com"', async () => {
1021
+ const agentType = 'IdentityGatewayAgent';
1022
+ const agentId = 'ig_mytestrun_com';
1023
+ mockFindAgentByTypeAndId(mock);
1024
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1025
+ expect(mockAgentObj).toBeTruthy();
1026
+ expect(agentType).toBe(mockAgentType);
1027
+ expect(agentId).toBe(mockAgentId);
1028
+ });
1029
+ expect.assertions(5);
1030
+ await Agent.deleteIdentityGatewayAgent(agentId);
1031
+ expect(true).toBeTruthy();
1032
+ });
1033
+ test('deleteIdentityGatewayAgent() 2: Delete agent of wrong type "tomcatagent" (java)', async () => {
1034
+ const agentType = 'J2EEAgent';
1035
+ const agentId = 'tomcatagent';
1036
+ mockFindAgentByTypeAndId(mock);
1037
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1038
+ expect(mockAgentObj).toBeTruthy();
1039
+ expect(agentType).toBe(mockAgentType);
1040
+ expect(agentId).toBe(mockAgentId);
1041
+ });
1042
+ expect.assertions(2);
1043
+ try {
1044
+ await Agent.deleteIdentityGatewayAgent(agentId);
1045
+ } catch (error) {
1046
+ expect(error).toBeTruthy();
1047
+ expect(error.message).toBe(`Identity gateway agent '${agentId}' not found!`);
1048
+ }
1049
+ });
1050
+ test('deleteIdentityGatewayAgent() 3: Delete agent of wrong type "apacheagent" (web)', async () => {
1051
+ const agentType = 'WebAgent';
1052
+ const agentId = 'apacheagent';
1053
+ mockFindAgentByTypeAndId(mock);
1054
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1055
+ expect(mockAgentObj).toBeTruthy();
1056
+ expect(agentType).toBe(mockAgentType);
1057
+ expect(agentId).toBe(mockAgentId);
1058
+ });
1059
+ expect.assertions(2);
1060
+ try {
1061
+ await Agent.deleteIdentityGatewayAgent(agentId);
1062
+ } catch (error) {
1063
+ expect(error).toBeTruthy();
1064
+ expect(error.message).toBe(`Identity gateway agent '${agentId}' not found!`);
1065
+ }
1066
+ });
1067
+ });
1068
+ describe('AgentOps - deleteJavaAgents()', () => {
1069
+ test('deleteJavaAgents() 0: Method is implemented', async () => {
1070
+ expect(Agent.deleteJavaAgents).toBeDefined();
1071
+ });
1072
+ test('deleteJavaAgents() 1: Delete all java agents', async () => {
1073
+ const agents = {
1074
+ tomcatagent: 'J2EEAgent',
1075
+ javaAgent: 'J2EEAgent'
1076
+ };
1077
+ mockGetAgentsByType(mock);
1078
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1079
+ expect(mockAgentObj).toBeTruthy();
1080
+ expect(Object.values(agents)).toContain(mockAgentType);
1081
+ expect(Object.keys(agents)).toContain(mockAgentId);
1082
+ });
1083
+ expect.assertions(8);
1084
+ await Agent.deleteJavaAgents();
1085
+ expect(true).toBeTruthy();
1086
+ });
1087
+ });
1088
+ describe('AgentOps - deleteJavaAgent()', () => {
1089
+ test('deleteJavaAgent() 0: Method is implemented', async () => {
1090
+ expect(Agent.deleteJavaAgent).toBeDefined();
1091
+ });
1092
+ test('deleteJavaAgent() 1: Delete java agent "tomcatagent"', async () => {
1093
+ const agentType = 'J2EEAgent';
1094
+ const agentId = 'tomcatagent';
1095
+ mockFindAgentByTypeAndId(mock);
1096
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1097
+ expect(mockAgentObj).toBeTruthy();
1098
+ expect(agentType).toBe(mockAgentType);
1099
+ expect(agentId).toBe(mockAgentId);
1100
+ });
1101
+ expect.assertions(5);
1102
+ await Agent.deleteJavaAgent(agentId);
1103
+ expect(true).toBeTruthy();
1104
+ });
1105
+ test('deleteJavaAgent() 2: Delete agent of wrong type "ig_mytestrun_com" (gateway)', async () => {
1106
+ const agentType = 'IdentityGatewayAgent';
1107
+ const agentId = 'ig_mytestrun_com';
1108
+ mockFindAgentByTypeAndId(mock);
1109
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1110
+ expect(mockAgentObj).toBeTruthy();
1111
+ expect(agentType).toBe(mockAgentType);
1112
+ expect(agentId).toBe(mockAgentId);
1113
+ });
1114
+ expect.assertions(2);
1115
+ try {
1116
+ await Agent.deleteJavaAgent(agentId);
1117
+ } catch (error) {
1118
+ expect(error).toBeTruthy();
1119
+ expect(error.message).toBe(`Java agent '${agentId}' not found!`);
1120
+ }
1121
+ });
1122
+ test('deleteJavaAgent() 3: Delete agent of wrong type "apacheagent" (web)', async () => {
1123
+ const agentType = 'WebAgent';
1124
+ const agentId = 'apacheagent';
1125
+ mockFindAgentByTypeAndId(mock);
1126
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1127
+ expect(mockAgentObj).toBeTruthy();
1128
+ expect(agentType).toBe(mockAgentType);
1129
+ expect(agentId).toBe(mockAgentId);
1130
+ });
1131
+ expect.assertions(2);
1132
+ try {
1133
+ await Agent.deleteJavaAgent(agentId);
1134
+ } catch (error) {
1135
+ expect(error).toBeTruthy();
1136
+ expect(error.message).toBe(`Java agent '${agentId}' not found!`);
1137
+ }
1138
+ });
1139
+ });
1140
+ describe('AgentOps - deleteWebAgents()', () => {
1141
+ test('deleteWebAgents() 0: Method is implemented', async () => {
1142
+ expect(Agent.deleteWebAgents).toBeDefined();
1143
+ });
1144
+ test('deleteWebAgents() 1: Delete all web agents', async () => {
1145
+ const agents = {
1146
+ apacheagent: 'WebAgent',
1147
+ webserver: 'WebAgent'
1148
+ };
1149
+ mockGetAgentsByType(mock);
1150
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1151
+ expect(mockAgentObj).toBeTruthy();
1152
+ expect(Object.values(agents)).toContain(mockAgentType);
1153
+ expect(Object.keys(agents)).toContain(mockAgentId);
1154
+ });
1155
+ expect.assertions(8);
1156
+ await Agent.deleteWebAgents();
1157
+ expect(true).toBeTruthy();
1158
+ });
1159
+ });
1160
+ describe('AgentOps - deleteWebAgent()', () => {
1161
+ test('deleteWebAgent() 0: Method is implemented', async () => {
1162
+ expect(Agent.deleteWebAgent).toBeDefined();
1163
+ });
1164
+ test('deleteWebAgent() 1: Delete web agent "apacheagent"', async () => {
1165
+ const agentType = 'WebAgent';
1166
+ const agentId = 'apacheagent';
1167
+ mockFindAgentByTypeAndId(mock);
1168
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1169
+ expect(mockAgentObj).toBeTruthy();
1170
+ expect(agentType).toBe(mockAgentType);
1171
+ expect(agentId).toBe(mockAgentId);
1172
+ });
1173
+ expect.assertions(5);
1174
+ await Agent.deleteWebAgent(agentId);
1175
+ expect(true).toBeTruthy();
1176
+ });
1177
+ test('deleteWebAgent() 2: Delete agent of wrong type "ig_mytestrun_com" (gateway)', async () => {
1178
+ const agentType = 'IdentityGatewayAgent';
1179
+ const agentId = 'ig_mytestrun_com';
1180
+ mockFindAgentByTypeAndId(mock);
1181
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1182
+ expect(mockAgentObj).toBeTruthy();
1183
+ expect(agentType).toBe(mockAgentType);
1184
+ expect(agentId).toBe(mockAgentId);
1185
+ });
1186
+ expect.assertions(2);
1187
+ try {
1188
+ await Agent.deleteWebAgent(agentId);
1189
+ } catch (error) {
1190
+ expect(error).toBeTruthy();
1191
+ expect(error.message).toBe(`Web agent '${agentId}' not found!`);
1192
+ }
1193
+ });
1194
+ test('deleteWebAgent() 3: Delete agent of wrong type "tomcatagent" (java)', async () => {
1195
+ const agentType = 'J2EEAgent';
1196
+ const agentId = 'tomcatagent';
1197
+ mockFindAgentByTypeAndId(mock);
1198
+ mockDeleteAgentByTypeAndId(mock, (mockAgentType, mockAgentId, mockAgentObj) => {
1199
+ expect(mockAgentObj).toBeTruthy();
1200
+ expect(agentType).toBe(mockAgentType);
1201
+ expect(agentId).toBe(mockAgentId);
1202
+ });
1203
+ expect.assertions(2);
1204
+ try {
1205
+ await Agent.deleteWebAgent(agentId);
1206
+ } catch (error) {
1207
+ expect(error).toBeTruthy();
1208
+ expect(error.message).toBe(`Web agent '${agentId}' not found!`);
1209
+ }
1210
+ });
1211
+ });
1212
+ //# sourceMappingURL=AgentOps.test.js.map