@rockcarver/frodo-lib 0.16.2-9 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +222 -1
- package/cjs/api/AgentApi.js +14 -61
- package/cjs/api/AgentApi.js.map +1 -1
- package/cjs/api/AgentApi.test.js.map +1 -1
- package/cjs/api/ApiTypes.js +0 -5
- package/cjs/api/ApiTypes.js.map +1 -1
- package/cjs/api/AuthenticateApi.js +9 -20
- package/cjs/api/AuthenticateApi.js.map +1 -1
- package/cjs/api/AuthenticateApi.test.js.map +1 -0
- package/cjs/api/BaseApi.js +82 -124
- package/cjs/api/BaseApi.js.map +1 -1
- package/cjs/api/CirclesOfTrustApi.js +8 -32
- package/cjs/api/CirclesOfTrustApi.js.map +1 -1
- package/cjs/api/IdmConfigApi.js +9 -34
- package/cjs/api/IdmConfigApi.js.map +1 -1
- package/cjs/api/LogApi.js +8 -31
- package/cjs/api/LogApi.js.map +1 -1
- package/cjs/api/ManagedObjectApi.js +34 -31
- package/cjs/api/ManagedObjectApi.js.map +1 -1
- package/cjs/api/NodeApi.js +10 -41
- package/cjs/api/NodeApi.js.map +1 -1
- package/cjs/api/NodeApi.test.js.map +1 -1
- package/cjs/api/OAuth2ClientApi.js +7 -26
- package/cjs/api/OAuth2ClientApi.js.map +1 -1
- package/cjs/api/OAuth2OIDCApi.js +28 -34
- package/cjs/api/OAuth2OIDCApi.js.map +1 -1
- package/cjs/api/OAuth2OIDCApi.test.js.map +1 -0
- package/cjs/api/OAuth2ProviderApi.js +5 -15
- package/cjs/api/OAuth2ProviderApi.js.map +1 -1
- package/cjs/api/RealmApi.js +8 -34
- package/cjs/api/RealmApi.js.map +1 -1
- package/cjs/api/Saml2Api.js +16 -67
- package/cjs/api/Saml2Api.js.map +1 -1
- package/cjs/api/ScriptApi.js +8 -30
- package/cjs/api/ScriptApi.js.map +1 -1
- package/cjs/api/SecretsApi.js +14 -64
- package/cjs/api/SecretsApi.js.map +1 -1
- package/cjs/api/SecretsApi.test.js.map +1 -1
- package/cjs/api/ServerInfoApi.js +6 -21
- package/cjs/api/ServerInfoApi.js.map +1 -1
- package/cjs/api/ServiceApi.js +49 -47
- package/cjs/api/ServiceApi.js.map +1 -1
- package/cjs/api/SocialIdentityProvidersApi.js +9 -36
- package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
- package/cjs/api/StartupApi.js +5 -24
- package/cjs/api/StartupApi.js.map +1 -1
- package/cjs/api/StartupApi.test.js.map +1 -1
- package/cjs/api/TreeApi.js +8 -30
- package/cjs/api/TreeApi.js.map +1 -1
- package/cjs/api/TreeApi.test.js.map +1 -1
- package/cjs/api/VariablesApi.js +9 -37
- package/cjs/api/VariablesApi.js.map +1 -1
- package/cjs/api/VariablesApi.test.js.map +1 -1
- package/cjs/api/utils/ApiUtils.js +47 -57
- package/cjs/api/utils/ApiUtils.js.map +1 -1
- package/cjs/api/utils/ApiUtils.test.js.map +1 -1
- package/cjs/api/utils/Base64.js +5 -15
- package/cjs/api/utils/Base64.js.map +1 -1
- package/cjs/ext/axios-curlirize/curlirize.js +2 -9
- package/cjs/ext/axios-curlirize/curlirize.js.map +1 -1
- package/cjs/ext/axios-curlirize/lib/CurlHelper.js +7 -22
- package/cjs/ext/axios-curlirize/lib/CurlHelper.js.map +1 -1
- package/cjs/index.js +30 -89
- package/cjs/index.js.map +1 -1
- package/cjs/ops/AdminOps.js +27 -165
- package/cjs/ops/AdminOps.js.map +1 -1
- package/cjs/ops/AgentOps.js +2 -159
- package/cjs/ops/AgentOps.js.map +1 -1
- package/cjs/ops/AgentOps.test.js.map +1 -1
- package/cjs/ops/AuthenticateOps.js +266 -226
- package/cjs/ops/AuthenticateOps.js.map +1 -1
- package/cjs/ops/AuthenticateOps.test.js.map +1 -1
- package/cjs/ops/CirclesOfTrustOps.js +13 -91
- package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
- package/cjs/ops/ConnectionProfileOps.js +220 -136
- package/cjs/ops/ConnectionProfileOps.js.map +1 -1
- package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
- package/cjs/ops/EmailTemplateOps.js +35 -379
- package/cjs/ops/EmailTemplateOps.js.map +1 -1
- package/cjs/ops/EmailTemplateOps.test.js.map +1 -1
- package/cjs/ops/IdmOps.js +52 -426
- package/cjs/ops/IdmOps.js.map +1 -1
- package/cjs/ops/IdmOps.test.js.map +1 -1
- package/cjs/ops/IdpOps.js +11 -94
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/IdpOps.test.js.map +1 -1
- package/cjs/ops/JoseOps.js +81 -0
- package/cjs/ops/JoseOps.js.map +1 -0
- package/cjs/ops/JoseOps.test.js.map +1 -0
- package/cjs/ops/JourneyOps.js +139 -370
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/JourneyOps.test.js.map +1 -1
- package/cjs/ops/LogOps.js +14 -47
- package/cjs/ops/LogOps.js.map +1 -1
- package/cjs/ops/ManagedObjectOps.js +4 -12
- package/cjs/ops/ManagedObjectOps.js.map +1 -1
- package/cjs/ops/NodeOps.js +9 -67
- package/cjs/ops/NodeOps.js.map +1 -1
- package/cjs/ops/OAuth2ClientOps.js +10 -40
- package/cjs/ops/OAuth2ClientOps.js.map +1 -1
- package/cjs/ops/OpsTypes.js +0 -5
- package/cjs/ops/OpsTypes.js.map +1 -1
- package/cjs/ops/OrganizationOps.js +6 -25
- package/cjs/ops/OrganizationOps.js.map +1 -1
- package/cjs/ops/RealmOps.js +0 -19
- package/cjs/ops/RealmOps.js.map +1 -1
- package/cjs/ops/Saml2Ops.js +11 -107
- package/cjs/ops/Saml2Ops.js.map +1 -1
- package/cjs/ops/Saml2Ops.test.js.map +1 -1
- package/cjs/ops/ScriptOps.js +26 -73
- package/cjs/ops/ScriptOps.js.map +1 -1
- package/cjs/ops/SecretsOps.js +2 -58
- package/cjs/ops/SecretsOps.js.map +1 -1
- package/cjs/ops/ServiceAccountOps.js +61 -0
- package/cjs/ops/ServiceAccountOps.js.map +1 -0
- package/cjs/ops/ServiceAccountOps.test.js.map +1 -0
- package/cjs/ops/ServiceOps.js +55 -101
- package/cjs/ops/ServiceOps.js.map +1 -1
- package/cjs/ops/StartupOps.js +2 -23
- package/cjs/ops/StartupOps.js.map +1 -1
- package/cjs/ops/ThemeOps.js +230 -436
- package/cjs/ops/ThemeOps.js.map +1 -1
- package/cjs/ops/ThemeOps.test.js.map +1 -0
- package/cjs/ops/VariablesOps.js +0 -38
- package/cjs/ops/VariablesOps.js.map +1 -1
- package/cjs/ops/utils/Console.js +29 -62
- package/cjs/ops/utils/Console.js.map +1 -1
- package/cjs/ops/utils/DataProtection.js +13 -47
- package/cjs/ops/utils/DataProtection.js.map +1 -1
- package/cjs/ops/utils/DataProtection.test.js.map +1 -1
- package/cjs/ops/utils/ExportImportUtils.js +36 -74
- package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
- package/cjs/ops/utils/ExportImportUtils.test.js.map +1 -1
- package/cjs/ops/utils/OpsUtils.js +27 -43
- package/cjs/ops/utils/OpsUtils.js.map +1 -1
- package/cjs/ops/utils/OpsUtils.test.js.map +1 -1
- package/cjs/ops/utils/ValidationUtils.js +0 -13
- package/cjs/ops/utils/ValidationUtils.js.map +1 -1
- package/cjs/ops/utils/ValidationUtils.test.js.map +1 -1
- package/cjs/ops/utils/Version.js +2 -12
- package/cjs/ops/utils/Version.js.map +1 -1
- package/cjs/ops/utils/Version.test.js.map +1 -1
- package/cjs/ops/utils/Wordwrap.js +1 -2
- package/cjs/ops/utils/Wordwrap.js.map +1 -1
- package/cjs/ops/utils/Wordwrap.test.js.map +1 -0
- package/cjs/shared/State.js +239 -0
- package/cjs/shared/State.js.map +1 -0
- package/cjs/shared/State.test.js.map +1 -0
- package/cjs/storage/StaticStorage.js.map +1 -1
- package/cjs/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +161 -83
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
- package/cjs/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
- package/cjs/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
- package/cjs/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
- package/cjs/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
- package/cjs/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
- package/cjs/utils/AutoSetupPolly.js +79 -0
- package/cjs/utils/AutoSetupPolly.js.map +1 -0
- package/cjs/utils/SetupJest.js +6 -0
- package/cjs/utils/SetupJest.js.map +1 -0
- package/cjs/{test/mocks → utils}/snapshotResolve.js +10 -12
- package/cjs/utils/snapshotResolve.js.map +1 -0
- package/esm/api/AgentApi.mjs +19 -21
- package/esm/api/AgentApi.test.mjs +6 -15
- package/esm/api/ApiTypes.mjs +0 -5
- package/esm/api/AuthenticateApi.mjs +7 -10
- package/esm/api/AuthenticateApi.test.mjs +39 -0
- package/esm/api/BaseApi.mjs +96 -81
- package/esm/api/CirclesOfTrustApi.mjs +9 -12
- package/esm/api/IdmConfigApi.mjs +11 -12
- package/esm/api/LogApi.mjs +6 -10
- package/esm/api/ManagedObjectApi.mjs +23 -8
- package/esm/api/NodeApi.mjs +13 -15
- package/esm/api/NodeApi.test.mjs +13 -17
- package/esm/api/OAuth2ClientApi.mjs +7 -9
- package/esm/api/OAuth2OIDCApi.mjs +15 -9
- package/esm/api/OAuth2OIDCApi.test.mjs +53 -0
- package/esm/api/OAuth2ProviderApi.mjs +3 -5
- package/esm/api/RealmApi.mjs +10 -13
- package/esm/api/Saml2Api.mjs +25 -29
- package/esm/api/ScriptApi.mjs +9 -11
- package/esm/api/SecretsApi.mjs +21 -24
- package/esm/api/SecretsApi.test.mjs +9 -31
- package/esm/api/ServerInfoApi.mjs +5 -9
- package/esm/api/ServiceApi.mjs +53 -26
- package/esm/api/SocialIdentityProvidersApi.mjs +11 -13
- package/esm/api/StartupApi.mjs +5 -10
- package/esm/api/StartupApi.test.mjs +4 -7
- package/esm/api/TreeApi.mjs +9 -11
- package/esm/api/TreeApi.test.mjs +24 -61
- package/esm/api/VariablesApi.mjs +11 -13
- package/esm/api/VariablesApi.test.mjs +80 -222
- package/esm/api/utils/ApiUtils.mjs +45 -48
- package/esm/api/utils/ApiUtils.test.mjs +33 -32
- package/esm/api/utils/Base64.mjs +5 -9
- package/esm/ext/axios-curlirize/curlirize.mjs +2 -7
- package/esm/ext/axios-curlirize/lib/CurlHelper.mjs +7 -20
- package/esm/index.mjs +23 -13
- package/esm/ops/AdminOps.mjs +33 -119
- package/esm/ops/AgentOps.mjs +37 -80
- package/esm/ops/AgentOps.test.mjs +5 -45
- package/esm/ops/AuthenticateOps.mjs +242 -175
- package/esm/ops/AuthenticateOps.test.mjs +7 -9
- package/esm/ops/CirclesOfTrustOps.mjs +24 -61
- package/esm/ops/ConnectionProfileOps.mjs +192 -82
- package/esm/ops/ConnectionProfileOps.test.mjs +19 -19
- package/esm/ops/EmailTemplateOps.mjs +18 -276
- package/esm/ops/EmailTemplateOps.test.mjs +19 -44
- package/esm/ops/IdmOps.mjs +30 -327
- package/esm/ops/IdmOps.test.mjs +47 -54
- package/esm/ops/IdpOps.mjs +21 -59
- package/esm/ops/IdpOps.test.mjs +5 -5
- package/esm/ops/JoseOps.mjs +41 -0
- package/esm/ops/JoseOps.test.mjs +137 -0
- package/esm/ops/JourneyOps.mjs +146 -289
- package/esm/ops/JourneyOps.test.mjs +29 -27
- package/esm/ops/LogOps.mjs +15 -25
- package/esm/ops/ManagedObjectOps.mjs +6 -6
- package/esm/ops/NodeOps.mjs +9 -47
- package/esm/ops/OAuth2ClientOps.mjs +13 -19
- package/esm/ops/OpsTypes.mjs +1 -3
- package/esm/ops/OrganizationOps.mjs +7 -14
- package/esm/ops/RealmOps.mjs +4 -7
- package/esm/ops/Saml2Ops.mjs +28 -62
- package/esm/ops/Saml2Ops.test.mjs +20 -23
- package/esm/ops/ScriptOps.mjs +29 -47
- package/esm/ops/SecretsOps.mjs +15 -31
- package/esm/ops/ServiceAccountOps.mjs +41 -0
- package/esm/ops/ServiceAccountOps.test.mjs +51 -0
- package/esm/ops/ServiceOps.mjs +66 -83
- package/esm/ops/StartupOps.mjs +4 -13
- package/esm/ops/ThemeOps.mjs +189 -298
- package/esm/{api/ThemeApi.test.mjs → ops/ThemeOps.test.mjs} +91 -96
- package/esm/ops/VariablesOps.mjs +9 -18
- package/esm/ops/utils/Console.mjs +28 -46
- package/esm/ops/utils/DataProtection.mjs +15 -28
- package/esm/ops/utils/DataProtection.test.mjs +8 -8
- package/esm/ops/utils/ExportImportUtils.mjs +34 -43
- package/esm/ops/utils/ExportImportUtils.test.mjs +20 -18
- package/esm/ops/utils/OpsUtils.mjs +27 -21
- package/esm/ops/utils/OpsUtils.test.mjs +155 -27
- package/esm/ops/utils/ValidationUtils.mjs +0 -9
- package/esm/ops/utils/Version.mjs +2 -3
- package/esm/ops/utils/Version.test.mjs +0 -2
- package/esm/ops/utils/Wordwrap.mjs +1 -1
- package/esm/ops/utils/Wordwrap.test.mjs +19 -0
- package/esm/shared/State.mjs +164 -0
- package/esm/shared/State.test.mjs +249 -0
- package/esm/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +147 -31
- package/esm/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
- package/esm/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
- package/esm/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
- package/esm/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
- package/esm/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
- package/esm/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
- package/esm/utils/AutoSetupPolly.mjs +72 -0
- package/esm/utils/SetupJest.mjs +3 -0
- package/esm/{test/mocks → utils}/snapshotResolve.mjs +10 -12
- package/package.json +36 -26
- package/types/api/AgentApi.d.ts.map +1 -1
- package/types/api/ApiTypes.d.ts +15 -16
- package/types/api/ApiTypes.d.ts.map +1 -1
- package/types/api/AuthenticateApi.d.ts +1 -1
- package/types/api/AuthenticateApi.d.ts.map +1 -1
- package/types/api/BaseApi.d.ts +2 -0
- package/types/api/BaseApi.d.ts.map +1 -1
- package/types/api/CirclesOfTrustApi.d.ts.map +1 -1
- package/types/api/IdmConfigApi.d.ts.map +1 -1
- package/types/api/LogApi.d.ts.map +1 -1
- package/types/api/ManagedObjectApi.d.ts +9 -1
- package/types/api/ManagedObjectApi.d.ts.map +1 -1
- package/types/api/NodeApi.d.ts.map +1 -1
- package/types/api/OAuth2ClientApi.d.ts.map +1 -1
- package/types/api/OAuth2OIDCApi.d.ts +4 -2
- package/types/api/OAuth2OIDCApi.d.ts.map +1 -1
- package/types/api/OAuth2ProviderApi.d.ts.map +1 -1
- package/types/api/RealmApi.d.ts.map +1 -1
- package/types/api/Saml2Api.d.ts.map +1 -1
- package/types/api/ScriptApi.d.ts.map +1 -1
- package/types/api/SecretsApi.d.ts.map +1 -1
- package/types/api/ServerInfoApi.d.ts.map +1 -1
- package/types/api/ServiceApi.d.ts +14 -7
- package/types/api/ServiceApi.d.ts.map +1 -1
- package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -1
- package/types/api/StartupApi.d.ts.map +1 -1
- package/types/api/TreeApi.d.ts.map +1 -1
- package/types/api/VariablesApi.d.ts.map +1 -1
- package/types/api/utils/ApiUtils.d.ts +1 -0
- package/types/api/utils/ApiUtils.d.ts.map +1 -1
- package/types/index.d.ts +11 -5
- package/types/index.d.ts.map +1 -1
- package/types/ops/AuthenticateOps.d.ts +10 -2
- package/types/ops/AuthenticateOps.d.ts.map +1 -1
- package/types/ops/ConnectionProfileOps.d.ts +49 -21
- package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
- package/types/ops/EmailTemplateOps.d.ts +14 -33
- package/types/ops/EmailTemplateOps.d.ts.map +1 -1
- package/types/ops/IdmOps.d.ts +29 -37
- package/types/ops/IdmOps.d.ts.map +1 -1
- package/types/ops/JoseOps.d.ts +33 -0
- package/types/ops/JoseOps.d.ts.map +1 -0
- package/types/ops/JourneyOps.d.ts.map +1 -1
- package/types/ops/LogOps.d.ts.map +1 -1
- package/types/ops/NodeOps.d.ts.map +1 -1
- package/types/ops/OAuth2ClientOps.d.ts.map +1 -1
- package/types/ops/OpsTypes.d.ts +1 -1
- package/types/ops/OpsTypes.d.ts.map +1 -1
- package/types/ops/OrganizationOps.d.ts.map +1 -1
- package/types/ops/ScriptOps.d.ts.map +1 -1
- package/types/ops/ServiceAccountOps.d.ts +20 -0
- package/types/ops/ServiceAccountOps.d.ts.map +1 -0
- package/types/ops/ServiceOps.d.ts +18 -10
- package/types/ops/ServiceOps.d.ts.map +1 -1
- package/types/ops/ThemeOps.d.ts +35 -50
- package/types/ops/ThemeOps.d.ts.map +1 -1
- package/types/ops/utils/Console.d.ts +1 -1
- package/types/ops/utils/Console.d.ts.map +1 -1
- package/types/ops/utils/DataProtection.d.ts.map +1 -1
- package/types/ops/utils/ExportImportUtils.d.ts +5 -2
- package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
- package/types/ops/utils/OpsUtils.d.ts +6 -0
- package/types/ops/utils/OpsUtils.d.ts.map +1 -1
- package/types/ops/utils/Wordwrap.d.ts.map +1 -1
- package/types/shared/State.d.ts +223 -0
- package/types/shared/State.d.ts.map +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +19 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
- package/types/utils/AutoSetupPolly.d.ts +1 -0
- package/types/utils/AutoSetupPolly.d.ts.map +1 -0
- package/types/utils/SetupJest.d.ts +1 -0
- package/types/utils/SetupJest.d.ts.map +1 -0
- package/types/utils/snapshotResolve.d.ts +1 -0
- package/types/utils/snapshotResolve.d.ts.map +1 -0
- package/cjs/api/EmailTemplateApi.js +0 -73
- package/cjs/api/EmailTemplateApi.js.map +0 -1
- package/cjs/api/ThemeApi.js +0 -367
- package/cjs/api/ThemeApi.js.map +0 -1
- package/cjs/api/ThemeApi.test.js.map +0 -1
- package/cjs/storage/SessionStorage.js +0 -91
- package/cjs/storage/SessionStorage.js.map +0 -1
- package/cjs/test/mocks/snapshotResolve.js.map +0 -1
- package/esm/api/EmailTemplateApi.mjs +0 -34
- package/esm/api/ThemeApi.mjs +0 -271
- package/esm/storage/SessionStorage.mjs +0 -79
- package/types/api/EmailTemplateApi.d.ts +0 -22
- package/types/api/EmailTemplateApi.d.ts.map +0 -1
- package/types/api/ThemeApi.d.ts +0 -56
- package/types/api/ThemeApi.d.ts.map +0 -1
- package/types/storage/SessionStorage.d.ts +0 -71
- package/types/storage/SessionStorage.d.ts.map +0 -1
- package/types/test/mocks/snapshotResolve.d.ts +0 -1
- package/types/test/mocks/snapshotResolve.d.ts.map +0 -1
|
@@ -9,19 +9,17 @@ import { isEqualJson } from './utils/OpsUtils';
|
|
|
9
9
|
import { mockCreateSaml2Provider } from '../test/mocks/ForgeRockApiMockEngine';
|
|
10
10
|
import { convertTextArrayToBase64Url } from './utils/ExportImportUtils';
|
|
11
11
|
const mock = new MockAdapter(axios);
|
|
12
|
-
|
|
13
12
|
const outputHandler = message => {
|
|
14
13
|
console.log(message);
|
|
15
14
|
};
|
|
16
|
-
|
|
17
|
-
state.
|
|
18
|
-
state.
|
|
19
|
-
state.
|
|
20
|
-
state.
|
|
21
|
-
state.
|
|
22
|
-
state.
|
|
23
|
-
state.
|
|
24
|
-
state.default.session.setPrintHandler(outputHandler);
|
|
15
|
+
state.setHost('https://openam-volker-dev.forgeblocks.com/am');
|
|
16
|
+
state.setRealm('alpha');
|
|
17
|
+
state.setCookieName('cookieName');
|
|
18
|
+
state.setCookieValue('cookieValue');
|
|
19
|
+
state.setDeploymentType(globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY);
|
|
20
|
+
state.setDebug(true);
|
|
21
|
+
state.setDebugHandler(outputHandler);
|
|
22
|
+
state.setPrintHandler(outputHandler);
|
|
25
23
|
describe('Saml2Ops - createSaml2ExportTemplate()', () => {
|
|
26
24
|
test('createSaml2ExportTemplate() 0: Method is implemented', async () => {
|
|
27
25
|
expect(Saml2.createSaml2ExportTemplate).toBeDefined();
|
|
@@ -244,8 +242,8 @@ describe('Saml2Ops - importSaml2Provider()', () => {
|
|
|
244
242
|
expect(mockSaml2ProviderId64).toEqual(entityId64);
|
|
245
243
|
expect(mockSaml2ProviderLocation).toEqual(entityLocation);
|
|
246
244
|
expect(isEqualJson(importData.saml[entityLocation][entityId64], mockSaml2ProviderObj, ['_rev'])).toBeTruthy();
|
|
247
|
-
});
|
|
248
|
-
|
|
245
|
+
});
|
|
246
|
+
// expect 5 assertions because import contains 1 script
|
|
249
247
|
expect.assertions(5);
|
|
250
248
|
await Saml2.importSaml2Provider(entityId, importData);
|
|
251
249
|
});
|
|
@@ -262,8 +260,8 @@ describe('Saml2Ops - importSaml2Provider()', () => {
|
|
|
262
260
|
expect(mockSaml2ProviderId64).toEqual(entityId64);
|
|
263
261
|
expect(mockSaml2ProviderLocation).toEqual(entityLocation);
|
|
264
262
|
expect(isEqualJson(importData.saml[entityLocation][entityId64], mockSaml2ProviderObj, ['_rev'])).toBeTruthy();
|
|
265
|
-
});
|
|
266
|
-
|
|
263
|
+
});
|
|
264
|
+
// expect 7 assertions because import contains 2 scripts
|
|
267
265
|
expect.assertions(7);
|
|
268
266
|
await Saml2.importSaml2Provider(entityId, importData);
|
|
269
267
|
});
|
|
@@ -278,11 +276,11 @@ describe('Saml2Ops - importSaml2Provider()', () => {
|
|
|
278
276
|
});
|
|
279
277
|
mockCreateSaml2Provider(mock, (mockSaml2ProviderId64, mockSaml2ProviderLocation, mockSaml2ProviderObj) => {
|
|
280
278
|
expect(mockSaml2ProviderId64).toEqual(entityId64);
|
|
281
|
-
expect(mockSaml2ProviderLocation).toEqual(entityLocation);
|
|
282
|
-
|
|
279
|
+
expect(mockSaml2ProviderLocation).toEqual(entityLocation);
|
|
280
|
+
// this is an import of a remote identity provider, which can only be done using SAML2 metadata
|
|
283
281
|
expect(mockSaml2ProviderObj.standardMetadata).toEqual(convertTextArrayToBase64Url(importData.saml.metadata[entityId64]));
|
|
284
|
-
});
|
|
285
|
-
|
|
282
|
+
});
|
|
283
|
+
// expect only 3 assertions because import contains no scripts
|
|
286
284
|
expect.assertions(3);
|
|
287
285
|
await Saml2.importSaml2Provider(entityId, importData);
|
|
288
286
|
});
|
|
@@ -305,12 +303,11 @@ describe('Saml2Ops - importSaml2Providers()', () => {
|
|
|
305
303
|
});
|
|
306
304
|
mockCreateSaml2Provider(mock, (mockSaml2ProviderId64, mockSaml2ProviderLocation, mockSaml2ProviderObj) => {
|
|
307
305
|
expect(allEntityIds64).toContain(mockSaml2ProviderId64);
|
|
308
|
-
expect(mockSaml2ProviderLocation).toEqual(hostedEntityIds64.includes(mockSaml2ProviderId64) ? Saml2ProiderLocation.HOSTED : Saml2ProiderLocation.REMOTE);
|
|
309
|
-
|
|
306
|
+
expect(mockSaml2ProviderLocation).toEqual(hostedEntityIds64.includes(mockSaml2ProviderId64) ? Saml2ProiderLocation.HOSTED : Saml2ProiderLocation.REMOTE);
|
|
307
|
+
// for hosted providers compare the provider config, for remote providers compare the metadata
|
|
310
308
|
expect(isEqualJson(importData.saml[mockSaml2ProviderLocation][mockSaml2ProviderId64], mockSaml2ProviderObj, ['_rev']) || mockSaml2ProviderObj.standardMetadata === convertTextArrayToBase64Url(importData.saml.metadata[mockSaml2ProviderId64])).toBeTruthy();
|
|
311
309
|
hostedEntityIds64 = hostedEntityIds64.filter(saml2ProviderId64 => saml2ProviderId64 !== mockSaml2ProviderId64);
|
|
312
310
|
remoteEntityIds64 = remoteEntityIds64.filter(saml2ProviderId64 => saml2ProviderId64 !== mockSaml2ProviderId64);
|
|
313
|
-
|
|
314
311
|
if (mockSaml2ProviderObj.standardMetadata) {
|
|
315
312
|
metaDataIds64 = metaDataIds64.filter(saml2ProviderId64 => saml2ProviderId64 !== mockSaml2ProviderId64);
|
|
316
313
|
}
|
|
@@ -319,8 +316,8 @@ describe('Saml2Ops - importSaml2Providers()', () => {
|
|
|
319
316
|
await Saml2.importSaml2Providers(importData);
|
|
320
317
|
expect(scriptIds.length).toBe(0);
|
|
321
318
|
expect(hostedEntityIds64.length).toBe(0);
|
|
322
|
-
expect(remoteEntityIds64.length).toBe(0);
|
|
323
|
-
|
|
319
|
+
expect(remoteEntityIds64.length).toBe(0);
|
|
320
|
+
// frodo exports metadata for both hosted and remote providers but on import it is only required for remote providers
|
|
324
321
|
expect(metaDataIds64.length).toBe(6);
|
|
325
322
|
});
|
|
326
323
|
});
|
package/esm/ops/ScriptOps.mjs
CHANGED
|
@@ -5,16 +5,15 @@ import { createProgressIndicator, createTable, printMessage, stopProgressIndicat
|
|
|
5
5
|
import { getScriptByName, getScripts, putScript } from '../api/ScriptApi';
|
|
6
6
|
import wordwrap from './utils/Wordwrap';
|
|
7
7
|
import { convertBase64TextToArray, convertTextArrayToBase64, getTypedFilename, saveToFile, titleCase, validateImport } from './utils/ExportImportUtils';
|
|
8
|
-
import
|
|
8
|
+
import * as state from '../shared/State';
|
|
9
|
+
|
|
9
10
|
/**
|
|
10
11
|
* List scripts
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
13
|
export async function listScripts(long = false) {
|
|
14
14
|
try {
|
|
15
15
|
const scripts = (await getScripts()).result;
|
|
16
16
|
scripts.sort((a, b) => a.name.localeCompare(b.name));
|
|
17
|
-
|
|
18
17
|
if (long) {
|
|
19
18
|
const table = createTable(['Name', 'UUID', 'Language', 'Context', 'Description']);
|
|
20
19
|
const langMap = {
|
|
@@ -34,93 +33,83 @@ export async function listScripts(long = false) {
|
|
|
34
33
|
printMessage(`Error listing scripts - ${error}`, 'error');
|
|
35
34
|
}
|
|
36
35
|
}
|
|
36
|
+
|
|
37
37
|
/**
|
|
38
38
|
* Export script to file
|
|
39
39
|
* @param {String} name script name
|
|
40
40
|
* @param {String} file file name
|
|
41
41
|
*/
|
|
42
|
-
|
|
43
42
|
export async function exportScriptByName(name, file) {
|
|
44
43
|
let fileName = getTypedFilename(name, 'script');
|
|
45
|
-
|
|
46
44
|
if (file) {
|
|
47
45
|
fileName = file;
|
|
48
46
|
}
|
|
49
|
-
|
|
50
47
|
const scriptData = (await getScriptByName(name)).result;
|
|
51
|
-
|
|
52
48
|
if (scriptData.length > 1) {
|
|
53
49
|
printMessage(`Multiple scripts with name ${name} found...`, 'error');
|
|
54
50
|
}
|
|
55
|
-
|
|
56
51
|
scriptData.forEach(element => {
|
|
57
|
-
const scriptTextArray = convertBase64TextToArray(element.script);
|
|
58
|
-
|
|
52
|
+
const scriptTextArray = convertBase64TextToArray(element.script);
|
|
53
|
+
// eslint-disable-next-line no-param-reassign
|
|
59
54
|
element.script = scriptTextArray;
|
|
60
55
|
});
|
|
61
56
|
saveToFile('script', scriptData, '_id', fileName);
|
|
62
57
|
}
|
|
58
|
+
|
|
63
59
|
/**
|
|
64
60
|
* Export all scripts to single file
|
|
65
61
|
* @param {String} file file name
|
|
66
62
|
*/
|
|
67
|
-
|
|
68
63
|
export async function exportScriptsToFile(file) {
|
|
69
|
-
let fileName = getTypedFilename(`all${
|
|
70
|
-
|
|
64
|
+
let fileName = getTypedFilename(`all${state.getRealm()}Scripts`, 'script');
|
|
71
65
|
if (file) {
|
|
72
66
|
fileName = file;
|
|
73
67
|
}
|
|
74
|
-
|
|
75
68
|
const scriptList = (await getScripts()).result;
|
|
76
69
|
const allScriptsData = [];
|
|
77
70
|
createProgressIndicator(scriptList.length, 'Exporting script');
|
|
78
|
-
|
|
79
71
|
for (const item of scriptList) {
|
|
80
|
-
updateProgressIndicator(`Reading script ${item.name}`);
|
|
81
|
-
|
|
72
|
+
updateProgressIndicator(`Reading script ${item.name}`);
|
|
73
|
+
// eslint-disable-next-line no-await-in-loop
|
|
82
74
|
const scriptData = (await getScriptByName(item.name)).result;
|
|
83
75
|
scriptData.forEach(element => {
|
|
84
|
-
const scriptTextArray = convertBase64TextToArray(element.script);
|
|
85
|
-
|
|
76
|
+
const scriptTextArray = convertBase64TextToArray(element.script);
|
|
77
|
+
// eslint-disable-next-line no-param-reassign
|
|
86
78
|
element.script = scriptTextArray;
|
|
87
79
|
allScriptsData.push(element);
|
|
88
80
|
});
|
|
89
81
|
}
|
|
90
|
-
|
|
91
82
|
stopProgressIndicator('Done');
|
|
92
83
|
saveToFile('script', allScriptsData, '_id', fileName);
|
|
93
84
|
}
|
|
85
|
+
|
|
94
86
|
/**
|
|
95
87
|
* Export all scripts to individual files
|
|
96
88
|
*/
|
|
97
|
-
|
|
98
89
|
export async function exportScriptsToFiles() {
|
|
99
90
|
const scriptList = (await getScripts()).result;
|
|
100
91
|
createProgressIndicator(scriptList.length, 'Exporting script');
|
|
101
|
-
|
|
102
92
|
for (const item of scriptList) {
|
|
103
|
-
updateProgressIndicator(`Reading script ${item.name}`);
|
|
104
|
-
|
|
93
|
+
updateProgressIndicator(`Reading script ${item.name}`);
|
|
94
|
+
// eslint-disable-next-line no-await-in-loop
|
|
105
95
|
const scriptData = (await getScriptByName(item.name)).result;
|
|
106
96
|
scriptData.forEach(element => {
|
|
107
|
-
const scriptTextArray = convertBase64TextToArray(element.script);
|
|
108
|
-
|
|
97
|
+
const scriptTextArray = convertBase64TextToArray(element.script);
|
|
98
|
+
// eslint-disable-next-line no-param-reassign
|
|
109
99
|
element.script = scriptTextArray;
|
|
110
100
|
});
|
|
111
101
|
const fileName = getTypedFilename(item.name, 'script');
|
|
112
102
|
saveToFile('script', scriptData, '_id', fileName);
|
|
113
103
|
}
|
|
114
|
-
|
|
115
104
|
stopProgressIndicator('Done');
|
|
116
105
|
}
|
|
106
|
+
|
|
117
107
|
/**
|
|
118
108
|
* Import script
|
|
119
109
|
* @param {String} id script uuid
|
|
120
110
|
* @param {Object} data script object
|
|
121
111
|
* @returns {Object} a status object
|
|
122
112
|
*/
|
|
123
|
-
|
|
124
113
|
export async function createOrUpdateScript(id, data) {
|
|
125
114
|
try {
|
|
126
115
|
await putScript(id, data);
|
|
@@ -130,13 +119,12 @@ export async function createOrUpdateScript(id, data) {
|
|
|
130
119
|
};
|
|
131
120
|
} catch (e) {
|
|
132
121
|
var _e$response;
|
|
133
|
-
|
|
134
122
|
if (((_e$response = e.response) === null || _e$response === void 0 ? void 0 : _e$response.status) === 409) {
|
|
135
123
|
printMessage(`createOrUpdateScript WARNING: script with name ${data.name} already exists, using renaming policy... <name> => <name - imported (n)>`, 'warn');
|
|
136
|
-
const newName = applyNameCollisionPolicy(data.name);
|
|
137
|
-
|
|
138
|
-
printMessage(`Trying to save script as ${newName}`, 'warn');
|
|
139
|
-
|
|
124
|
+
const newName = applyNameCollisionPolicy(data.name);
|
|
125
|
+
// console.log(newName);
|
|
126
|
+
printMessage(`Trying to save script as ${newName}`, 'warn');
|
|
127
|
+
// eslint-disable-next-line no-param-reassign
|
|
140
128
|
data.name = newName;
|
|
141
129
|
await createOrUpdateScript(id, data);
|
|
142
130
|
return {
|
|
@@ -144,7 +132,6 @@ export async function createOrUpdateScript(id, data) {
|
|
|
144
132
|
name: data.name
|
|
145
133
|
};
|
|
146
134
|
}
|
|
147
|
-
|
|
148
135
|
printMessage(`createOrUpdateScript ERROR: put script error, script ${id} - ${e.message}`, 'error');
|
|
149
136
|
return {
|
|
150
137
|
error: true,
|
|
@@ -156,42 +143,37 @@ export async function importScriptsFromFile(name, file, reUuid = false) {
|
|
|
156
143
|
fs.readFile(file, 'utf8', (err, data) => {
|
|
157
144
|
if (err) throw err;
|
|
158
145
|
const scriptData = JSON.parse(data);
|
|
159
|
-
|
|
160
146
|
if (validateImport(scriptData.meta)) {
|
|
161
147
|
createProgressIndicator(Object.keys(scriptData.script).length, '');
|
|
162
|
-
|
|
163
148
|
for (const existingId in scriptData.script) {
|
|
164
149
|
if ({}.hasOwnProperty.call(scriptData.script, existingId)) {
|
|
165
|
-
let newId = existingId;
|
|
166
|
-
|
|
150
|
+
let newId = existingId;
|
|
151
|
+
// console.log(id);
|
|
167
152
|
const encodedScript = convertTextArrayToBase64(scriptData.script[existingId].script);
|
|
168
153
|
scriptData.script[existingId].script = encodedScript;
|
|
169
|
-
|
|
170
154
|
if (reUuid) {
|
|
171
|
-
newId = uuidv4();
|
|
155
|
+
newId = uuidv4();
|
|
156
|
+
// printMessage(
|
|
172
157
|
// `Re-uuid-ing script ${scriptData.script[existingId].name} ${existingId} => ${newId}...`
|
|
173
158
|
// );
|
|
174
|
-
|
|
175
159
|
scriptData.script[existingId]._id = newId;
|
|
176
160
|
}
|
|
177
|
-
|
|
178
161
|
if (name) {
|
|
179
162
|
// printMessage(
|
|
180
163
|
// `Renaming script ${scriptData.script[existingId].name} => ${options.script}...`
|
|
181
164
|
// );
|
|
182
165
|
scriptData.script[existingId].name = name;
|
|
183
166
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
167
|
+
updateProgressIndicator(`Importing ${scriptData.script[existingId].name}`);
|
|
168
|
+
// console.log(scriptData.script[id]);
|
|
187
169
|
createOrUpdateScript(newId, scriptData.script[existingId]).then(result => {
|
|
188
170
|
if (result == null) printMessage(`Error importing ${scriptData.script[existingId].name}`, 'error');
|
|
189
171
|
});
|
|
190
172
|
if (name) break;
|
|
191
173
|
}
|
|
192
174
|
}
|
|
193
|
-
|
|
194
|
-
|
|
175
|
+
stopProgressIndicator('Done');
|
|
176
|
+
// printMessage('Done');
|
|
195
177
|
} else {
|
|
196
178
|
printMessage('Import validation failed...', 'error');
|
|
197
179
|
}
|
package/esm/ops/SecretsOps.mjs
CHANGED
|
@@ -2,21 +2,19 @@ import { createKeyValueTable, createProgressIndicator, createTable, printMessage
|
|
|
2
2
|
import { createNewVersionOfSecret, deleteSecret, deleteVersionOfSecret, getSecret, getSecrets, getSecretVersions, putSecret, setSecretDescription, setStatusOfVersionOfSecret, VersionOfSecretStatus } from '../api/SecretsApi';
|
|
3
3
|
import wordwrap from './utils/Wordwrap';
|
|
4
4
|
import { resolveUserName } from './ManagedObjectOps';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* List secrets
|
|
7
8
|
* @param {boolean} long Long version, all the fields
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
10
|
export async function listSecrets(long) {
|
|
11
11
|
let secrets = [];
|
|
12
|
-
|
|
13
12
|
try {
|
|
14
13
|
secrets = (await getSecrets()).result;
|
|
15
14
|
} catch (error) {
|
|
16
15
|
printMessage(`${error.message}`, 'error');
|
|
17
16
|
printMessage(error.response.data, 'error');
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
if (long) {
|
|
21
19
|
const table = createTable(['Id'['brightCyan'], {
|
|
22
20
|
hAlign: 'right',
|
|
@@ -26,7 +24,6 @@ export async function listSecrets(long) {
|
|
|
26
24
|
content: 'Loaded\nVersion'['brightCyan']
|
|
27
25
|
}, 'Status'['brightCyan'], 'Description'['brightCyan'], 'Modifier'['brightCyan'], 'Modified'['brightCyan']]);
|
|
28
26
|
secrets.sort((a, b) => a._id.localeCompare(b._id));
|
|
29
|
-
|
|
30
27
|
for (const secret of secrets) {
|
|
31
28
|
table.push([secret._id, {
|
|
32
29
|
hAlign: 'right',
|
|
@@ -34,10 +31,10 @@ export async function listSecrets(long) {
|
|
|
34
31
|
}, {
|
|
35
32
|
hAlign: 'right',
|
|
36
33
|
content: secret.loadedVersion
|
|
37
|
-
}, secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], wordwrap(secret.description, 40),
|
|
34
|
+
}, secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], wordwrap(secret.description, 40),
|
|
35
|
+
// eslint-disable-next-line no-await-in-loop
|
|
38
36
|
await resolveUserName('teammember', secret.lastChangedBy), new Date(secret.lastChangeDate).toLocaleString()]);
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
printMessage(table.toString());
|
|
42
39
|
} else {
|
|
43
40
|
secrets.forEach(secret => {
|
|
@@ -45,6 +42,7 @@ export async function listSecrets(long) {
|
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
44
|
}
|
|
45
|
+
|
|
48
46
|
/**
|
|
49
47
|
* Create secret
|
|
50
48
|
* @param {String} id secret id
|
|
@@ -53,10 +51,8 @@ export async function listSecrets(long) {
|
|
|
53
51
|
* @param {String} encoding secret encoding
|
|
54
52
|
* @param {boolean} useInPlaceholders use secret in placeholders
|
|
55
53
|
*/
|
|
56
|
-
|
|
57
54
|
export async function createSecret(id, value, description, encoding, useInPlaceholders) {
|
|
58
55
|
createProgressIndicator(undefined, `Creating secret ${id}...`, 'indeterminate');
|
|
59
|
-
|
|
60
56
|
try {
|
|
61
57
|
await putSecret(id, value, description, encoding, useInPlaceholders);
|
|
62
58
|
stopProgressIndicator(`Created secret ${id}`, 'success');
|
|
@@ -64,15 +60,14 @@ export async function createSecret(id, value, description, encoding, useInPlaceh
|
|
|
64
60
|
stopProgressIndicator(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'fail');
|
|
65
61
|
}
|
|
66
62
|
}
|
|
63
|
+
|
|
67
64
|
/**
|
|
68
65
|
* Set description of secret
|
|
69
66
|
* @param {String} secretId secret id
|
|
70
67
|
* @param {String} description secret description
|
|
71
68
|
*/
|
|
72
|
-
|
|
73
69
|
export async function setDescriptionOfSecret(secretId, description) {
|
|
74
70
|
createProgressIndicator(undefined, `Setting description of secret ${secretId}...`, 'indeterminate');
|
|
75
|
-
|
|
76
71
|
try {
|
|
77
72
|
await setSecretDescription(secretId, description);
|
|
78
73
|
stopProgressIndicator(`Set description of secret ${secretId}`, 'success');
|
|
@@ -80,14 +75,13 @@ export async function setDescriptionOfSecret(secretId, description) {
|
|
|
80
75
|
stopProgressIndicator(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'fail');
|
|
81
76
|
}
|
|
82
77
|
}
|
|
78
|
+
|
|
83
79
|
/**
|
|
84
80
|
* Delete a secret
|
|
85
81
|
* @param {String} secretId secret id
|
|
86
82
|
*/
|
|
87
|
-
|
|
88
83
|
export async function deleteSecretCmd(secretId) {
|
|
89
84
|
createProgressIndicator(undefined, `Deleting secret ${secretId}...`, 'indeterminate');
|
|
90
|
-
|
|
91
85
|
try {
|
|
92
86
|
await deleteSecret(secretId);
|
|
93
87
|
stopProgressIndicator(`Deleted secret ${secretId}`, 'success');
|
|
@@ -95,15 +89,14 @@ export async function deleteSecretCmd(secretId) {
|
|
|
95
89
|
stopProgressIndicator(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'fail');
|
|
96
90
|
}
|
|
97
91
|
}
|
|
92
|
+
|
|
98
93
|
/**
|
|
99
94
|
* Delete all secrets
|
|
100
95
|
*/
|
|
101
|
-
|
|
102
96
|
export async function deleteSecretsCmd() {
|
|
103
97
|
try {
|
|
104
98
|
const secrets = (await getSecrets()).result;
|
|
105
99
|
createProgressIndicator(secrets.length, `Deleting secrets...`);
|
|
106
|
-
|
|
107
100
|
for (const secret of secrets) {
|
|
108
101
|
try {
|
|
109
102
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -113,52 +106,47 @@ export async function deleteSecretsCmd() {
|
|
|
113
106
|
printMessage(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'error');
|
|
114
107
|
}
|
|
115
108
|
}
|
|
116
|
-
|
|
117
109
|
stopProgressIndicator(`Secrets deleted.`);
|
|
118
110
|
} catch (error) {
|
|
119
111
|
printMessage(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'error');
|
|
120
112
|
}
|
|
121
113
|
}
|
|
114
|
+
|
|
122
115
|
/**
|
|
123
116
|
* List all the versions of the secret
|
|
124
117
|
* @param {String} secretId secret id
|
|
125
118
|
*/
|
|
126
|
-
|
|
127
119
|
export async function listSecretVersionsCmd(secretId) {
|
|
128
120
|
let versions = [];
|
|
129
|
-
|
|
130
121
|
try {
|
|
131
122
|
versions = await getSecretVersions(secretId);
|
|
132
123
|
} catch (error) {
|
|
133
124
|
printMessage(`${error.message}`, 'error');
|
|
134
125
|
printMessage(error.response.data, 'error');
|
|
135
126
|
}
|
|
136
|
-
|
|
137
127
|
const table = createTable([{
|
|
138
128
|
hAlign: 'right',
|
|
139
129
|
content: 'Version'['brightCyan']
|
|
140
|
-
}, 'Status'['brightCyan'], 'Loaded'['brightCyan'], 'Created'['brightCyan']]);
|
|
141
|
-
|
|
130
|
+
}, 'Status'['brightCyan'], 'Loaded'['brightCyan'], 'Created'['brightCyan']]);
|
|
131
|
+
// versions.sort((a, b) => a._id.localeCompare(b._id));
|
|
142
132
|
const statusMap = {
|
|
143
133
|
ENABLED: 'active'['brightGreen'],
|
|
144
134
|
DISABLED: 'inactive'['brightRed'],
|
|
145
135
|
DESTROYED: 'deleted'['brightRed']
|
|
146
136
|
};
|
|
147
|
-
|
|
148
137
|
for (const version of versions) {
|
|
149
138
|
table.push([{
|
|
150
139
|
hAlign: 'right',
|
|
151
140
|
content: version.version
|
|
152
141
|
}, statusMap[version.status], version.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], new Date(version.createDate).toLocaleString()]);
|
|
153
142
|
}
|
|
154
|
-
|
|
155
143
|
printMessage(table.toString());
|
|
156
144
|
}
|
|
145
|
+
|
|
157
146
|
/**
|
|
158
147
|
* Describe a secret
|
|
159
148
|
* @param {String} secretId Secret id
|
|
160
149
|
*/
|
|
161
|
-
|
|
162
150
|
export async function describeSecret(secretId) {
|
|
163
151
|
const secret = await getSecret(secretId);
|
|
164
152
|
const table = createKeyValueTable();
|
|
@@ -176,15 +164,14 @@ export async function describeSecret(secretId) {
|
|
|
176
164
|
printMessage('\nSecret Versions:');
|
|
177
165
|
await listSecretVersionsCmd(secretId);
|
|
178
166
|
}
|
|
167
|
+
|
|
179
168
|
/**
|
|
180
169
|
* Create new version of secret
|
|
181
170
|
* @param {String} secretId secret id
|
|
182
171
|
* @param {String} value secret value
|
|
183
172
|
*/
|
|
184
|
-
|
|
185
173
|
export async function createNewVersionOfSecretCmd(secretId, value) {
|
|
186
174
|
createProgressIndicator(undefined, `Creating new version of secret ${secretId}...`, 'indeterminate');
|
|
187
|
-
|
|
188
175
|
try {
|
|
189
176
|
const version = await createNewVersionOfSecret(secretId, value);
|
|
190
177
|
stopProgressIndicator(`Created version ${version.version} of secret ${secretId}`, 'success');
|
|
@@ -192,15 +179,14 @@ export async function createNewVersionOfSecretCmd(secretId, value) {
|
|
|
192
179
|
stopProgressIndicator(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'fail');
|
|
193
180
|
}
|
|
194
181
|
}
|
|
182
|
+
|
|
195
183
|
/**
|
|
196
184
|
* Activate a version of a secret
|
|
197
185
|
* @param {String} secretId secret id
|
|
198
186
|
* @param {Number} version version of secret
|
|
199
187
|
*/
|
|
200
|
-
|
|
201
188
|
export async function activateVersionOfSecret(secretId, version) {
|
|
202
189
|
createProgressIndicator(undefined, `Activating version ${version} of secret ${secretId}...`, 'indeterminate');
|
|
203
|
-
|
|
204
190
|
try {
|
|
205
191
|
await setStatusOfVersionOfSecret(secretId, version, VersionOfSecretStatus.ENABLED);
|
|
206
192
|
stopProgressIndicator(`Activated version ${version} of secret ${secretId}`, 'success');
|
|
@@ -208,15 +194,14 @@ export async function activateVersionOfSecret(secretId, version) {
|
|
|
208
194
|
stopProgressIndicator(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'fail');
|
|
209
195
|
}
|
|
210
196
|
}
|
|
197
|
+
|
|
211
198
|
/**
|
|
212
199
|
* Deactivate a version of a secret
|
|
213
200
|
* @param {String} secretId secret id
|
|
214
201
|
* @param {Number} version version of secret
|
|
215
202
|
*/
|
|
216
|
-
|
|
217
203
|
export async function deactivateVersionOfSecret(secretId, version) {
|
|
218
204
|
createProgressIndicator(undefined, `Deactivating version ${version} of secret ${secretId}...`, 'indeterminate');
|
|
219
|
-
|
|
220
205
|
try {
|
|
221
206
|
await setStatusOfVersionOfSecret(secretId, version, VersionOfSecretStatus.DISABLED);
|
|
222
207
|
stopProgressIndicator(`Deactivated version ${version} of secret ${secretId}`, 'success');
|
|
@@ -224,15 +209,14 @@ export async function deactivateVersionOfSecret(secretId, version) {
|
|
|
224
209
|
stopProgressIndicator(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'fail');
|
|
225
210
|
}
|
|
226
211
|
}
|
|
212
|
+
|
|
227
213
|
/**
|
|
228
214
|
* Delete version of secret
|
|
229
215
|
* @param {String} secretId secret id
|
|
230
216
|
* @param {Number} version version of secret
|
|
231
217
|
*/
|
|
232
|
-
|
|
233
218
|
export async function deleteVersionOfSecretCmd(secretId, version) {
|
|
234
219
|
createProgressIndicator(undefined, `Deleting version ${version} of secret ${secretId}...`, 'indeterminate');
|
|
235
|
-
|
|
236
220
|
try {
|
|
237
221
|
await deleteVersionOfSecret(secretId, version);
|
|
238
222
|
stopProgressIndicator(`Deleted version ${version} of secret ${secretId}`, 'success');
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createManagedObject } from '../api/ManagedObjectApi';
|
|
2
|
+
import { debugMessage } from './utils/Console';
|
|
3
|
+
import { getConfigEntity } from './IdmOps';
|
|
4
|
+
const moType = 'svcacct';
|
|
5
|
+
let serviceAccountsFeatureAvailable = undefined;
|
|
6
|
+
export async function isServiceAccountsFeatureAvailable() {
|
|
7
|
+
debugMessage(`ServiceAccountOps.isServiceAccountsFeatureAvailable: start`);
|
|
8
|
+
// only look up the schema once
|
|
9
|
+
if (typeof serviceAccountsFeatureAvailable !== 'undefined') return serviceAccountsFeatureAvailable;
|
|
10
|
+
serviceAccountsFeatureAvailable = false;
|
|
11
|
+
const schema = await getConfigEntity('managed');
|
|
12
|
+
for (const object of schema['objects']) {
|
|
13
|
+
if (object['name'] === 'svcacct') serviceAccountsFeatureAvailable = true;
|
|
14
|
+
}
|
|
15
|
+
debugMessage(`ServiceAccountOps.isServiceAccountsFeatureAvailable: end, available=${serviceAccountsFeatureAvailable}`);
|
|
16
|
+
return serviceAccountsFeatureAvailable;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create service account
|
|
21
|
+
* @param {string} name Human-readable name of service account
|
|
22
|
+
* @param {string} description Description of service account
|
|
23
|
+
* @param {'Active' | 'Inactive'} accountStatus Service account status
|
|
24
|
+
* @param {string[]} scopes Scopes.
|
|
25
|
+
* @param {JwksInterface} jwks Java Web Key Set
|
|
26
|
+
* @returns {Promise<ObjectSkeletonInterface>} A promise resolving to a service account object
|
|
27
|
+
*/
|
|
28
|
+
export async function createServiceAccount(name, description, accountStatus, scopes, jwks) {
|
|
29
|
+
const payload = {
|
|
30
|
+
name,
|
|
31
|
+
description,
|
|
32
|
+
accountStatus,
|
|
33
|
+
scopes,
|
|
34
|
+
jwks: JSON.stringify(jwks)
|
|
35
|
+
};
|
|
36
|
+
debugMessage(`SvcacctOps: createSvcacct: payload:`);
|
|
37
|
+
debugMessage(payload);
|
|
38
|
+
const result = await createManagedObject(moType, payload);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=ServiceAccountOps.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
|
+
import { state } from '../index';
|
|
4
|
+
import * as globalConfig from '../storage/StaticStorage';
|
|
5
|
+
import { createJwkRsa, createJwks, getJwkRsaPublic } from './JoseOps';
|
|
6
|
+
import * as ServiceAccount from './ServiceAccountOps';
|
|
7
|
+
import { mockCreateManagedObject } from '../test/mocks/ForgeRockApiMockEngine';
|
|
8
|
+
import { isEqualJson } from './utils/OpsUtils';
|
|
9
|
+
const mock = new MockAdapter(axios);
|
|
10
|
+
const outputHandler = message => {
|
|
11
|
+
console.log(message);
|
|
12
|
+
};
|
|
13
|
+
state.setHost('https://openam-frodo-dev.forgeblocks.com/am');
|
|
14
|
+
state.setRealm('alpha');
|
|
15
|
+
state.setCookieName('cookieName');
|
|
16
|
+
state.setCookieValue('cookieValue');
|
|
17
|
+
state.setDeploymentType(globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY);
|
|
18
|
+
state.setDebug(true);
|
|
19
|
+
state.setDebugHandler(outputHandler);
|
|
20
|
+
state.setPrintHandler(outputHandler);
|
|
21
|
+
state.setCurlirize(true);
|
|
22
|
+
state.setCurlirizeHandler(outputHandler);
|
|
23
|
+
describe('SvcacctOps - createSvcacct()', () => {
|
|
24
|
+
test('createSvcacct() 0: Method is implemented', async () => {
|
|
25
|
+
expect(ServiceAccount.createServiceAccount).toBeDefined();
|
|
26
|
+
});
|
|
27
|
+
test('createSvcacct() 1: Create service account', async () => {
|
|
28
|
+
let moId = null;
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
let moData = null;
|
|
31
|
+
const name = 'sa';
|
|
32
|
+
const description = 'service account';
|
|
33
|
+
const accountStatus = 'Active';
|
|
34
|
+
const scopes = ['fr:am:*', 'fr:idm:*', 'fr:idc:esv:*'];
|
|
35
|
+
const jwk = await createJwkRsa();
|
|
36
|
+
const publicJwk = await getJwkRsaPublic(jwk);
|
|
37
|
+
const jwks = await createJwks(publicJwk);
|
|
38
|
+
mockCreateManagedObject(mock, (mockManagedObjId, mockManagedObj) => {
|
|
39
|
+
moId = mockManagedObjId;
|
|
40
|
+
moData = mockManagedObj;
|
|
41
|
+
});
|
|
42
|
+
const payload = await ServiceAccount.createServiceAccount(name, description, accountStatus, scopes, jwks);
|
|
43
|
+
expect(isEqualJson(payload, moData)).toBeTruthy();
|
|
44
|
+
expect(payload).toBeTruthy();
|
|
45
|
+
expect(payload._id).toBe(moId);
|
|
46
|
+
expect(payload.name).toBe(name);
|
|
47
|
+
expect(payload.description).toBe(description);
|
|
48
|
+
expect(payload.scopes).toStrictEqual(scopes);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=ServiceAccountOps.test.js.map
|