@rockcarver/frodo-lib 0.17.6 → 0.17.7

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 (145) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/cjs/api/AgentApi.test.js.map +1 -1
  3. package/cjs/api/BaseApi.js +7 -10
  4. package/cjs/api/BaseApi.js.map +1 -1
  5. package/cjs/api/NodeApi.test.js.map +1 -1
  6. package/cjs/api/ServerInfoApi.js +8 -2
  7. package/cjs/api/ServerInfoApi.js.map +1 -1
  8. package/cjs/api/cloud/EnvInfoApi.js +41 -0
  9. package/cjs/api/cloud/EnvInfoApi.js.map +1 -0
  10. package/cjs/api/cloud/FeatureApi.js +39 -0
  11. package/cjs/api/cloud/FeatureApi.js.map +1 -0
  12. package/cjs/api/{LogApi.js → cloud/LogApi.js} +3 -3
  13. package/cjs/api/cloud/LogApi.js.map +1 -0
  14. package/cjs/api/{SecretsApi.js → cloud/SecretsApi.js} +14 -14
  15. package/cjs/api/cloud/SecretsApi.js.map +1 -0
  16. package/cjs/api/cloud/SecretsApi.test.js.map +1 -0
  17. package/cjs/api/{StartupApi.js → cloud/StartupApi.js} +5 -5
  18. package/cjs/api/cloud/StartupApi.js.map +1 -0
  19. package/cjs/api/cloud/StartupApi.test.js.map +1 -0
  20. package/cjs/api/{VariablesApi.js → cloud/VariablesApi.js} +9 -9
  21. package/cjs/api/cloud/VariablesApi.js.map +1 -0
  22. package/cjs/api/cloud/VariablesApi.test.js.map +1 -0
  23. package/cjs/index.js +11 -19
  24. package/cjs/index.js.map +1 -1
  25. package/cjs/ops/AdminOps.js +1 -1
  26. package/cjs/ops/AdminOps.js.map +1 -1
  27. package/cjs/ops/AgentOps.test.js.map +1 -1
  28. package/cjs/ops/AuthenticateOps.js +3 -5
  29. package/cjs/ops/AuthenticateOps.js.map +1 -1
  30. package/cjs/ops/AuthenticateOps.test.js.map +1 -1
  31. package/cjs/ops/ConnectionProfileOps.js +1 -1
  32. package/cjs/ops/ConnectionProfileOps.js.map +1 -1
  33. package/cjs/ops/InfoOps.js +90 -0
  34. package/cjs/ops/InfoOps.js.map +1 -0
  35. package/cjs/ops/JoseOps.test.js.map +1 -1
  36. package/cjs/ops/JourneyOps.test.js.map +1 -1
  37. package/cjs/ops/Saml2Ops.test.js.map +1 -1
  38. package/cjs/ops/ScriptOps.test.js.map +1 -1
  39. package/cjs/ops/cloud/FeatureOps.js +54 -0
  40. package/cjs/ops/cloud/FeatureOps.js.map +1 -0
  41. package/cjs/ops/{LogOps.js → cloud/LogOps.js} +4 -4
  42. package/cjs/ops/cloud/LogOps.js.map +1 -0
  43. package/cjs/ops/{SecretsOps.js → cloud/SecretsOps.js} +4 -4
  44. package/cjs/ops/cloud/SecretsOps.js.map +1 -0
  45. package/cjs/ops/{ServiceAccountOps.js → cloud/ServiceAccountOps.js} +8 -17
  46. package/cjs/ops/cloud/ServiceAccountOps.js.map +1 -0
  47. package/cjs/ops/cloud/ServiceAccountOps.test.js.map +1 -0
  48. package/cjs/ops/{StartupOps.js → cloud/StartupOps.js} +4 -4
  49. package/cjs/ops/cloud/StartupOps.js.map +1 -0
  50. package/cjs/ops/{VariablesOps.js → cloud/VariablesOps.js} +5 -5
  51. package/cjs/ops/cloud/VariablesOps.js.map +1 -0
  52. package/cjs/utils/SetupPollyForFrodoLib.js +137 -0
  53. package/cjs/utils/SetupPollyForFrodoLib.js.map +1 -0
  54. package/esm/api/AgentApi.test.mjs +0 -5
  55. package/esm/api/BaseApi.mjs +6 -8
  56. package/esm/api/NodeApi.test.mjs +0 -5
  57. package/esm/api/ServerInfoApi.mjs +8 -2
  58. package/esm/api/cloud/EnvInfoApi.mjs +24 -0
  59. package/esm/api/cloud/FeatureApi.mjs +22 -0
  60. package/esm/api/{LogApi.mjs → cloud/LogApi.mjs} +3 -3
  61. package/esm/api/{SecretsApi.mjs → cloud/SecretsApi.mjs} +14 -14
  62. package/esm/api/{SecretsApi.test.mjs → cloud/SecretsApi.test.mjs} +2 -7
  63. package/esm/api/{StartupApi.mjs → cloud/StartupApi.mjs} +5 -5
  64. package/esm/api/{StartupApi.test.mjs → cloud/StartupApi.test.mjs} +7 -7
  65. package/esm/api/{VariablesApi.mjs → cloud/VariablesApi.mjs} +9 -9
  66. package/esm/api/{VariablesApi.test.mjs → cloud/VariablesApi.test.mjs} +2 -7
  67. package/esm/index.mjs +9 -12
  68. package/esm/ops/AdminOps.mjs +1 -1
  69. package/esm/ops/AgentOps.test.mjs +0 -5
  70. package/esm/ops/AuthenticateOps.mjs +3 -5
  71. package/esm/ops/AuthenticateOps.test.mjs +0 -5
  72. package/esm/ops/ConnectionProfileOps.mjs +1 -1
  73. package/esm/ops/InfoOps.mjs +58 -0
  74. package/esm/ops/JoseOps.test.mjs +0 -5
  75. package/esm/ops/JourneyOps.test.mjs +0 -5
  76. package/esm/ops/Saml2Ops.test.mjs +0 -5
  77. package/esm/ops/ScriptOps.test.mjs +0 -4
  78. package/esm/ops/cloud/FeatureOps.mjs +34 -0
  79. package/esm/ops/{LogOps.mjs → cloud/LogOps.mjs} +5 -5
  80. package/esm/ops/{SecretsOps.mjs → cloud/SecretsOps.mjs} +4 -4
  81. package/esm/ops/{ServiceAccountOps.mjs → cloud/ServiceAccountOps.mjs} +8 -17
  82. package/esm/ops/{ServiceAccountOps.test.mjs → cloud/ServiceAccountOps.test.mjs} +5 -7
  83. package/esm/ops/{StartupOps.mjs → cloud/StartupOps.mjs} +4 -4
  84. package/esm/ops/{VariablesOps.mjs → cloud/VariablesOps.mjs} +5 -5
  85. package/esm/utils/SetupPollyForFrodoLib.mjs +108 -0
  86. package/package.json +2 -1
  87. package/types/api/BaseApi.d.ts +2 -4
  88. package/types/api/BaseApi.d.ts.map +1 -1
  89. package/types/api/ServerInfoApi.d.ts +2 -2
  90. package/types/api/ServerInfoApi.d.ts.map +1 -1
  91. package/types/api/cloud/EnvInfoApi.d.ts +18 -0
  92. package/types/api/cloud/EnvInfoApi.d.ts.map +1 -0
  93. package/types/api/cloud/FeatureApi.d.ts +12 -0
  94. package/types/api/cloud/FeatureApi.d.ts.map +1 -0
  95. package/types/api/{LogApi.d.ts → cloud/LogApi.d.ts} +0 -0
  96. package/types/api/cloud/LogApi.d.ts.map +1 -0
  97. package/types/api/{SecretsApi.d.ts → cloud/SecretsApi.d.ts} +0 -0
  98. package/types/api/cloud/SecretsApi.d.ts.map +1 -0
  99. package/types/api/{StartupApi.d.ts → cloud/StartupApi.d.ts} +0 -0
  100. package/types/api/cloud/StartupApi.d.ts.map +1 -0
  101. package/types/api/{VariablesApi.d.ts → cloud/VariablesApi.d.ts} +0 -0
  102. package/types/api/cloud/VariablesApi.d.ts.map +1 -0
  103. package/types/index.d.ts +9 -10
  104. package/types/index.d.ts.map +1 -1
  105. package/types/ops/AdminOps.d.ts.map +1 -1
  106. package/types/ops/AuthenticateOps.d.ts.map +1 -1
  107. package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
  108. package/types/ops/InfoOps.d.ts +16 -0
  109. package/types/ops/InfoOps.d.ts.map +1 -0
  110. package/types/ops/cloud/FeatureOps.d.ts +12 -0
  111. package/types/ops/cloud/FeatureOps.d.ts.map +1 -0
  112. package/types/ops/{LogOps.d.ts → cloud/LogOps.d.ts} +0 -0
  113. package/types/ops/cloud/LogOps.d.ts.map +1 -0
  114. package/types/ops/{SecretsOps.d.ts → cloud/SecretsOps.d.ts} +0 -0
  115. package/types/ops/cloud/SecretsOps.d.ts.map +1 -0
  116. package/types/ops/{ServiceAccountOps.d.ts → cloud/ServiceAccountOps.d.ts} +3 -3
  117. package/types/ops/cloud/ServiceAccountOps.d.ts.map +1 -0
  118. package/types/ops/{StartupOps.d.ts → cloud/StartupOps.d.ts} +0 -0
  119. package/types/ops/cloud/StartupOps.d.ts.map +1 -0
  120. package/types/ops/{VariablesOps.d.ts → cloud/VariablesOps.d.ts} +0 -0
  121. package/types/ops/cloud/VariablesOps.d.ts.map +1 -0
  122. package/types/utils/SetupPollyForFrodoLib.d.ts +2 -0
  123. package/types/utils/SetupPollyForFrodoLib.d.ts.map +1 -0
  124. package/cjs/api/LogApi.js.map +0 -1
  125. package/cjs/api/SecretsApi.js.map +0 -1
  126. package/cjs/api/SecretsApi.test.js.map +0 -1
  127. package/cjs/api/StartupApi.js.map +0 -1
  128. package/cjs/api/StartupApi.test.js.map +0 -1
  129. package/cjs/api/VariablesApi.js.map +0 -1
  130. package/cjs/api/VariablesApi.test.js.map +0 -1
  131. package/cjs/ops/LogOps.js.map +0 -1
  132. package/cjs/ops/SecretsOps.js.map +0 -1
  133. package/cjs/ops/ServiceAccountOps.js.map +0 -1
  134. package/cjs/ops/ServiceAccountOps.test.js.map +0 -1
  135. package/cjs/ops/StartupOps.js.map +0 -1
  136. package/cjs/ops/VariablesOps.js.map +0 -1
  137. package/types/api/LogApi.d.ts.map +0 -1
  138. package/types/api/SecretsApi.d.ts.map +0 -1
  139. package/types/api/StartupApi.d.ts.map +0 -1
  140. package/types/api/VariablesApi.d.ts.map +0 -1
  141. package/types/ops/LogOps.d.ts.map +0 -1
  142. package/types/ops/SecretsOps.d.ts.map +0 -1
  143. package/types/ops/ServiceAccountOps.d.ts.map +0 -1
  144. package/types/ops/StartupOps.d.ts.map +0 -1
  145. package/types/ops/VariablesOps.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import axios from 'axios';
2
2
  import MockAdapter from 'axios-mock-adapter';
3
- import { StartupRaw, state } from '../index';
3
+ import { StartupRaw, state } from '../../index';
4
4
  import fs from 'fs';
5
5
  import path from 'path';
6
6
  import { fileURLToPath } from 'url';
@@ -12,14 +12,14 @@ state.setCookieName('cookieName');
12
12
  state.setCookieValue('cookieValue');
13
13
  describe('StartupApi - getStatus()', () => {
14
14
  test('getStatus() 1: Get restart status - expect "ready"', async () => {
15
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/StartupApi/getStatus/ready.json'), 'utf8'));
15
+ const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/StartupApi/getStatus/ready.json'), 'utf8'));
16
16
  mock.onGet('https://openam-frodo-dev.forgeblocks.com/environment/startup').reply(200, response);
17
17
  const status = await StartupRaw.getStatus();
18
18
  expect(status in StartupRaw.RestartStatus).toBeTruthy();
19
19
  expect(status).toBe(StartupRaw.RestartStatus.ready);
20
20
  });
21
21
  test('getStatus() 2: Get restart status - expect "restarting"', async () => {
22
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/StartupApi/getStatus/restarting.json'), 'utf8'));
22
+ const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/StartupApi/getStatus/restarting.json'), 'utf8'));
23
23
  mock.onGet('https://openam-frodo-dev.forgeblocks.com/environment/startup').reply(200, response);
24
24
  const status = await StartupRaw.getStatus();
25
25
  expect(status in StartupRaw.RestartStatus).toBeTruthy();
@@ -28,18 +28,18 @@ describe('StartupApi - getStatus()', () => {
28
28
  });
29
29
  describe('StartupApi - initiateRestart()', () => {
30
30
  test('initiateRestart() 1: Initiate restart - expect "ready" -> "restarting"', async () => {
31
- const response1 = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/StartupApi/getStatus/ready.json'), 'utf8'));
31
+ const response1 = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/StartupApi/getStatus/ready.json'), 'utf8'));
32
32
  mock.onGet('https://openam-frodo-dev.forgeblocks.com/environment/startup').reply(200, response1);
33
- const response2 = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/StartupApi/initiateRestart/restarting.json'), 'utf8'));
33
+ const response2 = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/StartupApi/initiateRestart/restarting.json'), 'utf8'));
34
34
  mock.onPost('https://openam-frodo-dev.forgeblocks.com/environment/startup?_action=restart').reply(200, response2);
35
35
  const status = await StartupRaw.initiateRestart();
36
36
  expect(status in StartupRaw.RestartStatus).toBeTruthy();
37
37
  expect(status).toBe(StartupRaw.RestartStatus.restarting);
38
38
  });
39
39
  test('initiateRestart() 2: Initiate restart - expect "restarting" -> exception', async () => {
40
- const response1 = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/StartupApi/getStatus/restarting.json'), 'utf8'));
40
+ const response1 = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/StartupApi/getStatus/restarting.json'), 'utf8'));
41
41
  mock.onGet('https://openam-frodo-dev.forgeblocks.com/environment/startup').reply(200, response1);
42
- const response2 = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/StartupApi/initiateRestart/restarting.json'), 'utf8'));
42
+ const response2 = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/StartupApi/initiateRestart/restarting.json'), 'utf8'));
43
43
  mock.onPost('https://openam-frodo-dev.forgeblocks.com/environment/startup?_action=restart').reply(200, response2);
44
44
  expect.assertions(2);
45
45
  try {
@@ -1,8 +1,8 @@
1
1
  import util from 'util';
2
- import { encode } from './utils/Base64';
3
- import { getTenantURL, getCurrentRealmPath } from './utils/ApiUtils';
4
- import { generateESVApi } from './BaseApi';
5
- import * as state from '../shared/State';
2
+ import { encode } from '../utils/Base64';
3
+ import { getTenantURL, getCurrentRealmPath } from '../utils/ApiUtils';
4
+ import { generateEnvApi } from '../BaseApi';
5
+ import * as state from '../../shared/State';
6
6
  const variablesListURLTemplate = '%s/environment/variables';
7
7
  const variableURLTemplate = '%s/environment/variables/%s';
8
8
  const variableSetDescriptionURLTemplate = `${variableURLTemplate}?_action=setDescription`;
@@ -23,7 +23,7 @@ export async function getVariables() {
23
23
  const urlString = util.format(variablesListURLTemplate, getTenantURL(state.getHost()));
24
24
  const {
25
25
  data
26
- } = await generateESVApi(getApiConfig()).get(urlString, {
26
+ } = await generateEnvApi(getApiConfig()).get(urlString, {
27
27
  withCredentials: true
28
28
  });
29
29
  return data;
@@ -38,7 +38,7 @@ export async function getVariable(variableId) {
38
38
  const urlString = util.format(variableURLTemplate, getTenantURL(state.getHost()), variableId);
39
39
  const {
40
40
  data
41
- } = await generateESVApi(getApiConfig()).get(urlString, {
41
+ } = await generateEnvApi(getApiConfig()).get(urlString, {
42
42
  withCredentials: true
43
43
  });
44
44
  return data;
@@ -58,7 +58,7 @@ export async function putVariable(variableId, value, description) {
58
58
  const urlString = util.format(variableURLTemplate, getTenantURL(state.getHost()), variableId);
59
59
  const {
60
60
  data
61
- } = await generateESVApi(getApiConfig()).put(urlString, variableData, {
61
+ } = await generateEnvApi(getApiConfig()).put(urlString, variableData, {
62
62
  withCredentials: true
63
63
  });
64
64
  return data;
@@ -74,7 +74,7 @@ export async function setVariableDescription(variableId, description) {
74
74
  const urlString = util.format(variableSetDescriptionURLTemplate, getTenantURL(state.getHost()), variableId);
75
75
  const {
76
76
  data
77
- } = await generateESVApi(getApiConfig()).post(urlString, {
77
+ } = await generateEnvApi(getApiConfig()).post(urlString, {
78
78
  description
79
79
  }, {
80
80
  withCredentials: true
@@ -91,7 +91,7 @@ export async function deleteVariable(variableId) {
91
91
  const urlString = util.format(variableURLTemplate, getTenantURL(state.getHost()), variableId);
92
92
  const {
93
93
  data
94
- } = await generateESVApi(getApiConfig()).delete(urlString, {
94
+ } = await generateEnvApi(getApiConfig()).delete(urlString, {
95
95
  withCredentials: true
96
96
  });
97
97
  return data;
@@ -29,13 +29,8 @@
29
29
  * Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
30
30
  * in case things don't function as expected
31
31
  */
32
- import { jest } from '@jest/globals';
33
- import { VariablesRaw } 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);
32
+ import { VariablesRaw } from '../../index';
33
+ import { autoSetupPolly } from '../../utils/AutoSetupPolly';
39
34
  autoSetupPolly();
40
35
  describe('VariablesApi', () => {
41
36
  const var1 = {
package/esm/index.mjs CHANGED
@@ -9,12 +9,12 @@ export * as NodeRaw from './api/NodeApi';
9
9
  // use a public oauth2/oidc library. might be ok for now since there is only
10
10
  // one place where the cli needs to execute an oauth flow.
11
11
  export * as OAuth2OIDCApi from './api/OAuth2OIDCApi';
12
- export * as SecretsRaw from './api/SecretsApi';
12
+ export * as SecretsRaw from './api/cloud/SecretsApi';
13
13
  export * as SocialIdentityProvidersRaw from './api/SocialIdentityProvidersApi';
14
- export * as StartupRaw from './api/StartupApi';
14
+ export * as StartupRaw from './api/cloud/StartupApi';
15
15
  export * as TreeRaw from './api/TreeApi';
16
16
  export * as TypesRaw from './api/ApiTypes';
17
- export * as VariablesRaw from './api/VariablesApi';
17
+ export * as VariablesRaw from './api/cloud/VariablesApi';
18
18
  export * as IdmConfigRaw from './api/IdmConfigApi';
19
19
 
20
20
  // Ops Layer
@@ -26,9 +26,10 @@ export * as ConnectionProfile from './ops/ConnectionProfileOps';
26
26
  export * as EmailTemplate from './ops/EmailTemplateOps';
27
27
  export * as Idp from './ops/IdpOps';
28
28
  export * as Idm from './ops/IdmOps';
29
+ export * as Info from './ops/InfoOps';
29
30
  export * as Journey from './ops/JourneyOps';
30
31
  export * as Jose from './ops/JoseOps';
31
- export * as Log from './ops/LogOps';
32
+ export * as Log from './ops/cloud/LogOps';
32
33
  export * as ManagedObject from './ops/ManagedObjectOps';
33
34
  export * as Node from './ops/NodeOps';
34
35
  export * as OAuth2Client from './ops/OAuth2ClientOps';
@@ -37,12 +38,12 @@ export * as Realm from './ops/RealmOps';
37
38
  export * as Saml2 from './ops/Saml2Ops';
38
39
  export * as Script from './ops/ScriptOps';
39
40
  export * as Service from './ops/ServiceOps';
40
- export * as Secrets from './ops/SecretsOps';
41
- export * as ServiceAccount from './ops/ServiceAccountOps';
42
- export * as Startup from './ops/StartupOps';
41
+ export * as Secrets from './ops/cloud/SecretsOps';
42
+ export * as ServiceAccount from './ops/cloud/ServiceAccountOps';
43
+ export * as Startup from './ops/cloud/StartupOps';
43
44
  export * as Theme from './ops/ThemeOps';
44
45
  export * as Types from './ops/OpsTypes';
45
- export * as Variables from './ops/VariablesOps';
46
+ export * as Variables from './ops/cloud/VariablesOps';
46
47
  // TODO: revisit if there are better ways
47
48
  export * as Utils from './ops/utils/OpsUtils';
48
49
  export * as ValidationUtils from './ops/utils/ValidationUtils';
@@ -52,8 +53,4 @@ export * as ExportImportUtils from './ops/utils/ExportImportUtils';
52
53
  // lib should be stateless, an aplication should own its state
53
54
  export * as state from './shared/State';
54
55
  export * as constants from './storage/StaticStorage';
55
-
56
- // Mock Engine
57
- export * as ForgeRockApiMockEngine from './test/mocks/ForgeRockApiMockEngine';
58
- export { FrodoMockAdapter } from './api/BaseApi';
59
56
  //# sourceMappingURL=index.js.map
@@ -5,7 +5,7 @@ import { getConfigEntity, putConfigEntity } from '../api/IdmConfigApi';
5
5
  import { isEqualJson, getRealmManagedUser } from './utils/OpsUtils';
6
6
  import { getRealmManagedOrganization } from './OrganizationOps';
7
7
  import { getOAuth2Provider } from '../api/OAuth2ProviderApi';
8
- import { putSecret } from '../api/SecretsApi';
8
+ import { putSecret } from '../api/cloud/SecretsApi';
9
9
  import { clientCredentialsGrant } from '../api/OAuth2OIDCApi';
10
10
  import { printMessage } from './utils/Console';
11
11
  import path from 'path';
@@ -46,14 +46,9 @@
46
46
  * Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
47
47
  * in case things don't function as expected
48
48
  */
49
- import { jest } from '@jest/globals';
50
49
  import { Agent, AgentRaw } from '../index';
51
50
  import { getAgent } from '../test/mocks/ForgeRockApiMockEngine';
52
51
  import { autoSetupPolly } from '../utils/AutoSetupPolly';
53
-
54
- // Increase timeout for this test as pipeline keeps failing with error:
55
- // Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
56
- jest.setTimeout(30000);
57
52
  autoSetupPolly();
58
53
  async function stageAgent(agent, create = true) {
59
54
  // delete if exists, then create
@@ -15,7 +15,7 @@ import { createSignedJwtToken } from './JoseOps';
15
15
  import { getManagedObject } from '../api/ManagedObjectApi';
16
16
  const adminClientPassword = 'doesnotmatter';
17
17
  const redirectUrlTemplate = '/platform/appAuthHelperRedirect.html';
18
- const idmAdminScopes = 'fr:idm:* openid';
18
+ const idmAdminScopes = 'fr:idm:* fr:idc:esv:*';
19
19
  const serviceAccountScopes = 'fr:am:* fr:idm:* fr:idc:esv:*';
20
20
  let adminClientId = 'idmAdminClient';
21
21
 
@@ -25,9 +25,7 @@ let adminClientId = 'idmAdminClient';
25
25
  */
26
26
  async function determineCookieName() {
27
27
  try {
28
- const {
29
- data
30
- } = await getServerInfo();
28
+ const data = await getServerInfo();
31
29
  debugMessage(`AuthenticateOps.getCookieName: cookieName=${data.cookieName}`);
32
30
  return data.cookieName;
33
31
  } catch (error) {
@@ -332,7 +330,7 @@ async function determineDeploymentTypeAndDefaultRealmAndVersion() {
332
330
  }
333
331
  determineDefaultRealm(state.getDeploymentType());
334
332
  debugMessage(`AuthenticateOps.determineDeploymentTypeAndDefaultRealmAndVersion: realm=${state.getRealm()}, type=${state.getDeploymentType()}`);
335
- const versionInfo = (await getServerVersionInfo()).data;
333
+ const versionInfo = await getServerVersionInfo();
336
334
 
337
335
  // https://github.com/rockcarver/frodo-cli/issues/109
338
336
  debugMessage(`Full version: ${versionInfo.fullVersion}`);
@@ -28,7 +28,6 @@
28
28
  * Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
29
29
  * in case things don't function as expected
30
30
  */
31
- import { jest } from '@jest/globals';
32
31
  import { Authenticate, state } from '../index';
33
32
  import { autoSetupPolly, defaultMatchRequestsBy } from '../utils/AutoSetupPolly';
34
33
 
@@ -38,10 +37,6 @@ matchConfig.body = false; // oauth flows are tricky because of the PKCE challeng
38
37
  matchConfig.order = true; // since we instruct Polly not to match the body, we need to enable ordering of the requests
39
38
 
40
39
  autoSetupPolly(matchConfig);
41
-
42
- // Increase timeout for this test as pipeline keeps failing with error:
43
- // Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
44
- jest.setTimeout(30000);
45
40
  describe('AuthenticateOps', () => {
46
41
  describe('getTokens()', () => {
47
42
  test('0: Method is implemented', async () => {
@@ -6,7 +6,7 @@ import DataProtection from './utils/DataProtection';
6
6
  import { createObjectTable, createTable, debugMessage, printMessage, verboseMessage } from './utils/Console';
7
7
  import { FRODO_CONNECTION_PROFILES_PATH_KEY } from '../storage/StaticStorage';
8
8
  import { createJwkRsa, createJwks, getJwkRsaPublic } from './JoseOps';
9
- import { createServiceAccount } from './ServiceAccountOps';
9
+ import { createServiceAccount } from './cloud/ServiceAccountOps';
10
10
  import { saveJsonToFile } from './utils/ExportImportUtils';
11
11
  import { isValidUrl } from './utils/OpsUtils';
12
12
  const crypto = new DataProtection();
@@ -0,0 +1,58 @@
1
+ import { getEnvInfo } from '../api/cloud/EnvInfoApi';
2
+ import * as state from '../shared/State';
3
+ import * as globalConfig from '../storage/StaticStorage';
4
+ import { getServerVersionInfo } from '../api/ServerInfoApi';
5
+ import { getManagedObject } from '../api/ManagedObjectApi';
6
+ import { printMessage } from './utils/Console';
7
+ async function getCloudInfo() {
8
+ let info = {};
9
+ try {
10
+ info = await getEnvInfo();
11
+ delete info.message_box_html;
12
+ delete info.message_box_title;
13
+ delete info.message_variant;
14
+ delete info.warning_message_html;
15
+ if (!info.placeholder_management_migration_date) delete info.placeholder_management_migration_date;
16
+ } catch (error) {
17
+ var _error$response;
18
+ printMessage((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, 'error');
19
+ printMessage(`Error getting env info: ${error.message}`, 'error');
20
+ }
21
+ return info;
22
+ }
23
+ async function getAmVersion() {
24
+ const versionObj = await getServerVersionInfo();
25
+ const amVersion = `${versionObj['version']} Build ${versionObj['revision']} (${versionObj['date']})`;
26
+ return amVersion;
27
+ }
28
+ async function getAuthenticatedSubject() {
29
+ let subjectString = `${state.getUsername()} (User)`;
30
+ if (state.getUseBearerTokenForAmApis()) {
31
+ const name = (await getManagedObject('svcacct', state.getServiceAccountId(), ['name'])).data.name;
32
+ subjectString = `${name} [${state.getServiceAccountId()}] (Service Account)`;
33
+ }
34
+ return subjectString;
35
+ }
36
+
37
+ /**
38
+ * Get info about the platform instance
39
+ * @returns {Promise<PlatformInfo>} a promise that resolves to a json blob with information about the instance and tokens
40
+ */
41
+ export async function getInfo() {
42
+ const info = {
43
+ host: state.getHost(),
44
+ amVersion: await getAmVersion(),
45
+ authenticatedSubject: await getAuthenticatedSubject(),
46
+ deploymentType: state.getDeploymentType(),
47
+ cookieName: state.getCookieName(),
48
+ sessionToken: state.getCookieValue(),
49
+ // only add bearerToken if we have it
50
+ ...(state.getBearerToken() && {
51
+ bearerToken: state.getBearerToken()
52
+ }),
53
+ // only add cloud env info if deployment type is cloud
54
+ ...(state.getDeploymentType() === globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY && (await getCloudInfo()))
55
+ };
56
+ return info;
57
+ }
58
+ //# sourceMappingURL=InfoOps.js.map
@@ -1,13 +1,8 @@
1
- import { jest } from '@jest/globals';
2
1
  import * as Jose from './JoseOps';
3
2
  import { parseUrl } from '../api/utils/ApiUtils';
4
3
  import { v4 } from 'uuid';
5
4
  import { isEqualJson } from './utils/OpsUtils';
6
5
  import { decode } from '../api/utils/Base64';
7
-
8
- // Increase timeout for this test as pipeline keeps failing with error:
9
- // Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
10
- jest.setTimeout(30000);
11
6
  describe('JoseOps - createJWK()', () => {
12
7
  test('createJWK() 0: Method is implemented', async () => {
13
8
  expect(Jose.createJwkRsa).toBeDefined();
@@ -46,15 +46,10 @@
46
46
  * Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
47
47
  * in case things don't function as expected
48
48
  */
49
- import { jest } from '@jest/globals';
50
49
  import { Journey, state } from '../index';
51
50
  import { getJourney } from '../test/mocks/ForgeRockApiMockEngine';
52
51
  import { autoSetupPolly } from '../utils/AutoSetupPolly';
53
52
  import * as globalConfig from '../storage/StaticStorage';
54
-
55
- // Increase timeout for this test as pipeline keeps failing with error:
56
- // Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
57
- jest.setTimeout(30000);
58
53
  autoSetupPolly();
59
54
  state.setDeploymentType(globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY);
60
55
  async function stageJourney(journey, create = true) {
@@ -48,17 +48,12 @@
48
48
  * Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
49
49
  * in case things don't function as expected
50
50
  */
51
- import { jest } from '@jest/globals';
52
51
  import { Saml2, state } from '../index';
53
52
  import * as globalConfig from '../storage/StaticStorage';
54
53
  import { Saml2ProiderLocation } from '../api/ApiTypes';
55
54
  import { getSaml2ProviderImportData, getSaml2ProvidersImportData } from '../test/mocks/ForgeRockApiMockEngine';
56
55
  import { encodeBase64Url } from '../api/utils/Base64';
57
56
  import { autoSetupPolly } from '../utils/AutoSetupPolly';
58
-
59
- // Increase timeout for this test as pipeline keeps failing with error:
60
- // Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
61
- jest.setTimeout(30000);
62
57
  autoSetupPolly();
63
58
  state.setDeploymentType(globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY);
64
59
  async function stageProvider(provider, create = true) {
@@ -29,12 +29,8 @@
29
29
  * Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
30
30
  * in case things don't function as expected
31
31
  */
32
- import { jest } from '@jest/globals';
33
32
  import { Script } from '../index';
34
33
  import { autoSetupPolly } from '../utils/AutoSetupPolly';
35
- // Increase timeout for this test as pipeline keeps failing with error:
36
- // Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
37
- jest.setTimeout(30000);
38
34
  autoSetupPolly();
39
35
  async function stageScript(script, create = true) {
40
36
  // delete if exists, then create
@@ -0,0 +1,34 @@
1
+ import { getFeatures as _getFeatures } from '../../api/cloud/FeatureApi';
2
+ import { debugMessage } from '../utils/Console';
3
+ let _features = undefined;
4
+
5
+ /**
6
+ * Get all features
7
+ * @returns {Promise<FeatureInterface[]>} a promise that resolves to an array of feature objects
8
+ */
9
+ export async function getFeatures() {
10
+ if (typeof _features !== 'undefined') return _features;
11
+ try {
12
+ const {
13
+ result
14
+ } = await _getFeatures();
15
+ _features = JSON.parse(JSON.stringify(result));
16
+ } catch (error) {
17
+ var _error$response;
18
+ debugMessage((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data);
19
+ _features = [];
20
+ }
21
+ return _features;
22
+ }
23
+
24
+ /**
25
+ * Check if feature is available
26
+ * @param {string} featureId feature id (e.g. 'service-accounts')
27
+ * @returns {Promise<boolean>} a promise that resolves to true if the feature is available and to false otherwise
28
+ */
29
+ export async function hasFeature(featureId) {
30
+ if (typeof _features === 'undefined') await getFeatures();
31
+ const featureIds = _features.map(feature => feature._id);
32
+ return featureIds.includes(featureId);
33
+ }
34
+ //# sourceMappingURL=FeatureOps.js.map
@@ -1,8 +1,8 @@
1
- import { printMessage } from './utils/Console';
2
- import { getCurrentTimestamp } from './utils/ExportImportUtils';
3
- import { createAPIKeyAndSecret, getAPIKeys, getSources } from '../api/LogApi';
4
- import * as state from '../shared/State';
5
- import * as LogApi from '../api/LogApi';
1
+ import { printMessage } from '../utils/Console';
2
+ import { getCurrentTimestamp } from '../utils/ExportImportUtils';
3
+ import { createAPIKeyAndSecret, getAPIKeys, getSources } from '../../api/cloud/LogApi';
4
+ import * as state from '../../shared/State';
5
+ import * as LogApi from '../../api/cloud/LogApi';
6
6
 
7
7
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
8
  const unfilterableNoise = ['text/plain' // Unfortunately, it is impossible to filter out those without excluding IDM script logging as well
@@ -1,7 +1,7 @@
1
- import { createKeyValueTable, createProgressIndicator, createTable, printMessage, stopProgressIndicator, updateProgressIndicator } from './utils/Console';
2
- import { createNewVersionOfSecret, deleteSecret, deleteVersionOfSecret, getSecret, getSecrets, getSecretVersions, putSecret, setSecretDescription, setStatusOfVersionOfSecret, VersionOfSecretStatus } from '../api/SecretsApi';
3
- import wordwrap from './utils/Wordwrap';
4
- import { resolveUserName } from './ManagedObjectOps';
1
+ import { createKeyValueTable, createProgressIndicator, createTable, printMessage, stopProgressIndicator, updateProgressIndicator } from '../utils/Console';
2
+ import { createNewVersionOfSecret, deleteSecret, deleteVersionOfSecret, getSecret, getSecrets, getSecretVersions, putSecret, setSecretDescription, setStatusOfVersionOfSecret, VersionOfSecretStatus } from '../../api/cloud/SecretsApi';
3
+ import wordwrap from '../utils/Wordwrap';
4
+ import { resolveUserName } from '../ManagedObjectOps';
5
5
 
6
6
  /**
7
7
  * List secrets
@@ -1,11 +1,11 @@
1
- import { createManagedObject } from '../api/ManagedObjectApi';
2
- import { debugMessage } from './utils/Console';
3
- import { step } from '../api/AuthenticateApi';
1
+ import { createManagedObject } from '../../api/ManagedObjectApi';
2
+ import { debugMessage } from '../utils/Console';
3
+ import { hasFeature } from './FeatureOps';
4
4
  const moType = 'svcacct';
5
5
  /**
6
6
  * Global flag indicating if service accounts are available
7
7
  */
8
- let serviceAccountsFeatureAvailable = undefined;
8
+ let _featureAvailable = undefined;
9
9
 
10
10
  /**
11
11
  * Check if service accounts are available
@@ -14,19 +14,10 @@ let serviceAccountsFeatureAvailable = undefined;
14
14
  export async function isServiceAccountsFeatureAvailable() {
15
15
  debugMessage(`ServiceAccountOps.isServiceAccountsFeatureAvailable: start`);
16
16
  // only perform check once
17
- if (typeof serviceAccountsFeatureAvailable !== 'undefined') return serviceAccountsFeatureAvailable;
18
- serviceAccountsFeatureAvailable = true;
19
- try {
20
- await step({}, {}, '/', 'FRServiceAccountInternal');
21
- } catch (error) {
22
- var _error$response, _error$response2, _error$response3, _error$response3$data;
23
- debugMessage((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data);
24
- if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 400 && ((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : (_error$response3$data = _error$response3.data) === null || _error$response3$data === void 0 ? void 0 : _error$response3$data.message) === 'No Configuration found') {
25
- serviceAccountsFeatureAvailable = false;
26
- }
27
- }
28
- debugMessage(`ServiceAccountOps.isServiceAccountsFeatureAvailable: end, available=${serviceAccountsFeatureAvailable}`);
29
- return serviceAccountsFeatureAvailable;
17
+ if (typeof _featureAvailable !== 'undefined') return _featureAvailable;
18
+ _featureAvailable = await hasFeature('service-accounts');
19
+ debugMessage(`ServiceAccountOps.isServiceAccountsFeatureAvailable: end, available=${_featureAvailable}`);
20
+ return _featureAvailable;
30
21
  }
31
22
 
32
23
  /**
@@ -7,6 +7,9 @@
7
7
  * override all the connection state variables required to connect to the
8
8
  * env to record from:
9
9
  *
10
+ * ATTENTION: For the recording to succeed, you MUST make sure to use a
11
+ * user account, not a service account.
12
+ *
10
13
  * FRODO_DEBUG=1 FRODO_HOST=frodo-dev npm run test:record ServiceAccountOps
11
14
  *
12
15
  * The above command assumes that you have a connection profile for
@@ -29,14 +32,9 @@
29
32
  * Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
30
33
  * in case things don't function as expected
31
34
  */
32
- import { jest } from '@jest/globals';
33
- import { createJwkRsa, createJwks, getJwkRsaPublic } from './JoseOps';
35
+ import { createJwkRsa, createJwks, getJwkRsaPublic } from '../JoseOps';
34
36
  import * as ServiceAccount from './ServiceAccountOps';
35
- import { autoSetupPolly, defaultMatchRequestsBy } from '../utils/AutoSetupPolly';
36
-
37
- // Increase timeout for this test as pipeline keeps failing with error:
38
- // Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
39
- jest.setTimeout(30000);
37
+ import { autoSetupPolly, defaultMatchRequestsBy } from '../../utils/AutoSetupPolly';
40
38
 
41
39
  // need to modify the default matching rules to allow the mocking to work for service account tests.
42
40
  const matchConfig = defaultMatchRequestsBy();
@@ -1,7 +1,7 @@
1
- import { createProgressIndicator, updateProgressIndicator, stopProgressIndicator } from './utils/Console';
2
- import { getSecrets } from '../api/SecretsApi';
3
- import { getStatus, initiateRestart, RestartStatus } from '../api/StartupApi';
4
- import { getVariables } from '../api/VariablesApi';
1
+ import { createProgressIndicator, updateProgressIndicator, stopProgressIndicator } from '../utils/Console';
2
+ import { getSecrets } from '../../api/cloud/SecretsApi';
3
+ import { getStatus, initiateRestart, RestartStatus } from '../../api/cloud/StartupApi';
4
+ import { getVariables } from '../../api/cloud/VariablesApi';
5
5
 
6
6
  /**
7
7
  * Updates that need to be applied.
@@ -1,8 +1,8 @@
1
- import { createKeyValueTable, createProgressIndicator, createTable, printMessage, stopProgressIndicator, updateProgressIndicator } from './utils/Console';
2
- import { deleteVariable, getVariable, getVariables, putVariable, setVariableDescription } from '../api/VariablesApi';
3
- import wordwrap from './utils/Wordwrap';
4
- import { resolveUserName } from './ManagedObjectOps';
5
- import { decode } from '../api/utils/Base64';
1
+ import { createKeyValueTable, createProgressIndicator, createTable, printMessage, stopProgressIndicator, updateProgressIndicator } from '../utils/Console';
2
+ import { deleteVariable, getVariable, getVariables, putVariable, setVariableDescription } from '../../api/cloud/VariablesApi';
3
+ import wordwrap from '../utils/Wordwrap';
4
+ import { resolveUserName } from '../ManagedObjectOps';
5
+ import { decode } from '../../api/utils/Base64';
6
6
 
7
7
  /**
8
8
  * List variables