@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
|
@@ -3,44 +3,40 @@ import { lstat, readdir } from 'fs/promises';
|
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import slugify from 'slugify';
|
|
5
5
|
import { decode, decodeBase64Url, encode, encodeBase64Url } from '../../api/utils/Base64';
|
|
6
|
-
import
|
|
6
|
+
import * as state from '../../shared/State';
|
|
7
7
|
import { FRODO_METADATA_ID } from '../../storage/StaticStorage';
|
|
8
8
|
import { debugMessage, printMessage } from './Console';
|
|
9
9
|
export function getCurrentTimestamp() {
|
|
10
10
|
const ts = new Date();
|
|
11
11
|
return ts.toISOString();
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
function getMetadata() {
|
|
13
|
+
export function getMetadata() {
|
|
15
14
|
const metadata = {
|
|
16
|
-
origin:
|
|
17
|
-
originAmVersion:
|
|
18
|
-
exportedBy:
|
|
15
|
+
origin: state.getHost(),
|
|
16
|
+
originAmVersion: state.getAmVersion(),
|
|
17
|
+
exportedBy: state.getUsername(),
|
|
19
18
|
exportDate: getCurrentTimestamp(),
|
|
20
19
|
exportTool: FRODO_METADATA_ID,
|
|
21
|
-
exportToolVersion:
|
|
20
|
+
exportToolVersion: state.getFrodoVersion()
|
|
22
21
|
};
|
|
23
22
|
return metadata;
|
|
24
23
|
}
|
|
24
|
+
|
|
25
25
|
/*
|
|
26
26
|
* Output str in title case
|
|
27
27
|
*
|
|
28
28
|
* e.g.: 'ALL UPPERCASE AND all lowercase' = 'All Uppercase And All Lowercase'
|
|
29
29
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
30
|
export function titleCase(input) {
|
|
33
31
|
const str = input.toString();
|
|
34
32
|
const splitStr = str.toLowerCase().split(' ');
|
|
35
|
-
|
|
36
33
|
for (let i = 0; i < splitStr.length; i += 1) {
|
|
37
34
|
splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].slice(1);
|
|
38
35
|
}
|
|
39
|
-
|
|
40
36
|
return splitStr.join(' ');
|
|
41
37
|
}
|
|
42
38
|
export function getRealmString() {
|
|
43
|
-
const realm =
|
|
39
|
+
const realm = state.getRealm();
|
|
44
40
|
return realm.split('/').reduce((result, item) => `${result}${titleCase(item)}`, '');
|
|
45
41
|
}
|
|
46
42
|
export function convertBase64TextToArray(b64text) {
|
|
@@ -66,8 +62,9 @@ export function convertTextArrayToBase64Url(textArray) {
|
|
|
66
62
|
const joinedText = textArray.join('\n');
|
|
67
63
|
const b64encodedScript = encodeBase64Url(joinedText);
|
|
68
64
|
return b64encodedScript;
|
|
69
|
-
}
|
|
65
|
+
}
|
|
70
66
|
|
|
67
|
+
// eslint-disable-next-line no-unused-vars
|
|
71
68
|
export function validateImport(metadata) {
|
|
72
69
|
return metadata || true;
|
|
73
70
|
}
|
|
@@ -77,10 +74,9 @@ export function getTypedFilename(name, type, suffix = 'json') {
|
|
|
77
74
|
}
|
|
78
75
|
export function getWorkingDirectory() {
|
|
79
76
|
let wd = '.';
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
if (state.getDirectory()) {
|
|
78
|
+
wd = state.getDirectory().replace(/\/$/, '');
|
|
79
|
+
// create directory if it doesn't exist
|
|
84
80
|
if (!fs.existsSync(wd)) {
|
|
85
81
|
debugMessage(`ExportImportUtils.getWorkingDirectory: creating directory '${wd}'`);
|
|
86
82
|
fs.mkdirSync(wd, {
|
|
@@ -88,14 +84,12 @@ export function getWorkingDirectory() {
|
|
|
88
84
|
});
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
|
-
|
|
92
87
|
return wd;
|
|
93
88
|
}
|
|
94
89
|
export function saveToFile(type, data, identifier, filename) {
|
|
95
90
|
const exportData = {};
|
|
96
91
|
exportData['meta'] = getMetadata();
|
|
97
92
|
exportData[type] = {};
|
|
98
|
-
|
|
99
93
|
if (Array.isArray(data)) {
|
|
100
94
|
data.forEach(element => {
|
|
101
95
|
exportData[type][element[identifier]] = element;
|
|
@@ -103,54 +97,52 @@ export function saveToFile(type, data, identifier, filename) {
|
|
|
103
97
|
} else {
|
|
104
98
|
exportData[type][data[identifier]] = data;
|
|
105
99
|
}
|
|
106
|
-
|
|
107
100
|
fs.writeFile(filename, JSON.stringify(exportData, null, 2), err => {
|
|
108
101
|
if (err) {
|
|
109
102
|
return printMessage(`ERROR - can't save ${type} to file`, 'error');
|
|
110
103
|
}
|
|
111
|
-
|
|
112
104
|
return '';
|
|
113
105
|
});
|
|
114
106
|
}
|
|
107
|
+
|
|
115
108
|
/**
|
|
116
109
|
* Save JSON object to file
|
|
117
110
|
* @param {Object} data data object
|
|
118
111
|
* @param {String} filename file name
|
|
112
|
+
* @return {boolean} true if successful, false otherwise
|
|
119
113
|
*/
|
|
120
|
-
|
|
121
|
-
export function saveJsonToFile(data, filename) {
|
|
114
|
+
export function saveJsonToFile(data, filename, includeMeta = true) {
|
|
122
115
|
const exportData = data;
|
|
123
|
-
exportData.meta = getMetadata();
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return
|
|
130
|
-
}
|
|
116
|
+
if (includeMeta) exportData.meta = getMetadata();
|
|
117
|
+
try {
|
|
118
|
+
fs.writeFileSync(filename, JSON.stringify(exportData, null, 2));
|
|
119
|
+
return true;
|
|
120
|
+
} catch (err) {
|
|
121
|
+
printMessage(`ERROR - can't save ${filename}`, 'error');
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
131
124
|
}
|
|
125
|
+
|
|
132
126
|
/**
|
|
133
127
|
* Save text data to file
|
|
134
128
|
* @param {String} data text data
|
|
135
129
|
* @param {String} filename file name
|
|
136
130
|
*/
|
|
137
|
-
|
|
138
131
|
export function saveTextToFile(data, filename) {
|
|
139
132
|
fs.writeFile(filename, data, err => {
|
|
140
133
|
if (err) {
|
|
141
134
|
printMessage(`ERROR - can't save ${filename}`, 'error');
|
|
142
135
|
return false;
|
|
143
136
|
}
|
|
144
|
-
|
|
145
137
|
return true;
|
|
146
138
|
});
|
|
147
139
|
}
|
|
140
|
+
|
|
148
141
|
/**
|
|
149
142
|
* Append text data to file
|
|
150
143
|
* @param {String} data text data
|
|
151
144
|
* @param {String} filename file name
|
|
152
145
|
*/
|
|
153
|
-
|
|
154
146
|
export function appendTextToFile(data, filename) {
|
|
155
147
|
try {
|
|
156
148
|
fs.appendFileSync(filename, data);
|
|
@@ -158,6 +150,7 @@ export function appendTextToFile(data, filename) {
|
|
|
158
150
|
printMessage(`${error.message}`, 'error');
|
|
159
151
|
}
|
|
160
152
|
}
|
|
153
|
+
|
|
161
154
|
/**
|
|
162
155
|
* Find files by name
|
|
163
156
|
* @param {string} fileName file name to search for
|
|
@@ -165,40 +158,38 @@ export function appendTextToFile(data, filename) {
|
|
|
165
158
|
* @param {string} path path to directory where to start the search
|
|
166
159
|
* @returns {string[]} array of found file paths relative to starting directory
|
|
167
160
|
*/
|
|
168
|
-
|
|
169
161
|
export function findFilesByName(fileName, fast = true, path = './') {
|
|
170
162
|
const entries = fs.readdirSync(path, {
|
|
171
163
|
encoding: 'utf8',
|
|
172
164
|
withFileTypes: true
|
|
173
|
-
});
|
|
165
|
+
});
|
|
174
166
|
|
|
175
|
-
|
|
167
|
+
// Get files within the current directory and add a path key to the file objects
|
|
168
|
+
const files = entries.filter(entry => !entry.isDirectory()).filter(file => file.name === fileName)
|
|
169
|
+
// .map((file) => ({ ...file, path: path + file.name }));
|
|
176
170
|
.map(file => path + file.name);
|
|
177
|
-
if (fast && files.length > 0) return files;
|
|
171
|
+
if (fast && files.length > 0) return files;
|
|
178
172
|
|
|
173
|
+
// search sub-folders
|
|
179
174
|
const folders = entries.filter(entry => entry.isDirectory());
|
|
180
|
-
|
|
181
175
|
for (const folder of folders) files.push(...findFilesByName(fileName, fast, `${path}${folder.name}/`));
|
|
182
|
-
|
|
183
176
|
return files;
|
|
184
177
|
}
|
|
178
|
+
|
|
185
179
|
/**
|
|
186
180
|
* find all (nested) files in a directory
|
|
187
181
|
*
|
|
188
182
|
* @param directory directory to search
|
|
189
183
|
* @returns list of files
|
|
190
184
|
*/
|
|
191
|
-
|
|
192
185
|
export async function readFilesRecursive(directory) {
|
|
193
186
|
const items = await readdir(directory);
|
|
194
187
|
const filePathsNested = await Promise.all(items.map(async entity => {
|
|
195
188
|
const path = join(directory, entity);
|
|
196
189
|
const isDirectory = (await lstat(path)).isDirectory();
|
|
197
|
-
|
|
198
190
|
if (isDirectory) {
|
|
199
191
|
return readFilesRecursive(path);
|
|
200
192
|
}
|
|
201
|
-
|
|
202
193
|
return path;
|
|
203
194
|
}));
|
|
204
195
|
return filePathsNested.flat();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { rmSync, existsSync, readFileSync } from 'fs';
|
|
3
|
-
import { convertTextArrayToBase64, convertBase64TextToArray, saveToFile, validateImport } from './ExportImportUtils';
|
|
3
|
+
import { convertTextArrayToBase64, convertBase64TextToArray, saveToFile, validateImport } from './ExportImportUtils';
|
|
4
|
+
// Warning! implimentation file contains non determinisitc functions which are either; not reasonable to test or imposible
|
|
4
5
|
// Cause: date based non overidable functions
|
|
5
6
|
// Not tested: getCurrentTimestamp
|
|
6
7
|
|
|
@@ -13,10 +14,10 @@ test('convertBase64TextToArray returns an array of text lines in base64 encoding
|
|
|
13
14
|
return 'ring to mt doom';
|
|
14
15
|
}
|
|
15
16
|
`;
|
|
16
|
-
const base64Script = Buffer.from(originalScript).toString('base64');
|
|
17
|
-
|
|
18
|
-
const result = convertBase64TextToArray(base64Script);
|
|
19
|
-
|
|
17
|
+
const base64Script = Buffer.from(originalScript).toString('base64');
|
|
18
|
+
// Act
|
|
19
|
+
const result = convertBase64TextToArray(base64Script);
|
|
20
|
+
// Assert
|
|
20
21
|
expect(result).toEqual(originalScript.split('\n'));
|
|
21
22
|
});
|
|
22
23
|
test('convertTextArrayToBase64', () => {
|
|
@@ -26,16 +27,17 @@ test('convertTextArrayToBase64', () => {
|
|
|
26
27
|
return 'ring to mt doom';
|
|
27
28
|
}
|
|
28
29
|
`;
|
|
29
|
-
const expected = Buffer.from(originalArrayOfScriptLines).toString('base64');
|
|
30
|
-
|
|
31
|
-
const result = convertTextArrayToBase64(originalArrayOfScriptLines.split('\n'));
|
|
32
|
-
|
|
30
|
+
const expected = Buffer.from(originalArrayOfScriptLines).toString('base64');
|
|
31
|
+
// Act
|
|
32
|
+
const result = convertTextArrayToBase64(originalArrayOfScriptLines.split('\n'));
|
|
33
|
+
// Assert
|
|
33
34
|
expect(result).toEqual(expected);
|
|
34
35
|
});
|
|
35
36
|
test('validateImport should always return true', () => {
|
|
36
37
|
expect(validateImport(null)).not.toBe(false);
|
|
37
|
-
});
|
|
38
|
+
});
|
|
38
39
|
|
|
40
|
+
// This function has no way to determine when its asnyc task is complete, suggest using callback or promises to allow for testing
|
|
39
41
|
describe.skip('file system based tests', () => {
|
|
40
42
|
afterAll(() => {
|
|
41
43
|
if (existsSync(PATH_TO_ARTIFACT)) {
|
|
@@ -60,11 +62,11 @@ describe.skip('file system based tests', () => {
|
|
|
60
62
|
words: 1064
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
+
};
|
|
66
|
+
// Act
|
|
65
67
|
saveToFile('lotr', data, 'id', PATH_TO_ARTIFACT);
|
|
66
|
-
const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT, 'utf8'));
|
|
67
|
-
|
|
68
|
+
const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT, 'utf8'));
|
|
69
|
+
// Assert
|
|
68
70
|
expect(resultingJSON.lotr).toEqual(expected.lotr);
|
|
69
71
|
});
|
|
70
72
|
test('saveToFile should save a file with metadata', async () => {
|
|
@@ -75,11 +77,11 @@ describe.skip('file system based tests', () => {
|
|
|
75
77
|
location: 'The Shire',
|
|
76
78
|
character: 'Gandalf',
|
|
77
79
|
words: 1064
|
|
78
|
-
}];
|
|
79
|
-
|
|
80
|
+
}];
|
|
81
|
+
// Act
|
|
80
82
|
saveToFile('lotr', data, 'id', PATH_TO_ARTIFACT);
|
|
81
|
-
const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT, 'utf8'));
|
|
82
|
-
|
|
83
|
+
const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT, 'utf8'));
|
|
84
|
+
// Assert
|
|
83
85
|
expect(Object.keys(resultingJSON.meta)).toEqual(['origin', 'exportedBy', 'exportDate', 'exportTool', 'exportToolVersion']);
|
|
84
86
|
});
|
|
85
87
|
});
|
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
1
|
+
import * as state from '../../shared/State';
|
|
2
|
+
import * as globalConfig from '../../storage/StaticStorage';
|
|
3
3
|
import { getCurrentRealmName, getRealmName as _getRealmName } from '../../api/utils/ApiUtils';
|
|
4
4
|
import { lstat, readdir, readFile } from 'fs/promises';
|
|
5
5
|
import { join } from 'path';
|
|
6
|
-
import replaceall from 'replaceall';
|
|
6
|
+
import replaceall from 'replaceall';
|
|
7
7
|
|
|
8
|
+
// TODO: do we really need this? if yes: document
|
|
8
9
|
export function escapeRegExp(str) {
|
|
9
10
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
10
|
-
}
|
|
11
|
+
}
|
|
11
12
|
|
|
13
|
+
// TODO: do we really need this? if yes: document
|
|
12
14
|
export function replaceAll(str, find, replace) {
|
|
13
15
|
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
|
|
14
16
|
}
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
19
|
* Get new name when names collide
|
|
17
20
|
* @param {String} name to apply policy to
|
|
18
21
|
* @returns {String} new name according to policy
|
|
19
22
|
*/
|
|
20
|
-
|
|
21
23
|
export function applyNameCollisionPolicy(name) {
|
|
22
24
|
const capturingRegex = /(.* - imported) \(([0-9]+)\)/;
|
|
23
25
|
const found = name.match(capturingRegex);
|
|
24
|
-
|
|
25
26
|
if (found && found.length > 0 && found.length === 3) {
|
|
26
27
|
// already renamed one or more times
|
|
27
28
|
// return the next number
|
|
28
29
|
return `${found[1]} (${parseInt(found[2], 10) + 1})`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
}
|
|
31
|
+
// first time
|
|
32
32
|
return `${name} - imported (1)`;
|
|
33
33
|
}
|
|
34
|
+
|
|
34
35
|
/**
|
|
35
36
|
* Get the name of the managed user object for the current realm
|
|
36
37
|
* @returns {String} the name of the managed user object for the current realm
|
|
37
38
|
*/
|
|
38
|
-
|
|
39
39
|
export function getRealmManagedUser() {
|
|
40
40
|
let realmManagedUser = 'user';
|
|
41
|
-
|
|
42
|
-
if (storage.session.getDeploymentType() === global.CLOUD_DEPLOYMENT_TYPE_KEY) {
|
|
41
|
+
if (state.getDeploymentType() === globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY) {
|
|
43
42
|
realmManagedUser = `${getCurrentRealmName()}_user`;
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
return realmManagedUser;
|
|
47
45
|
}
|
|
46
|
+
|
|
48
47
|
/**
|
|
49
48
|
* Compare two json objects
|
|
50
49
|
* @param {Object} obj1 object 1
|
|
@@ -52,15 +51,12 @@ export function getRealmManagedUser() {
|
|
|
52
51
|
* @param {[String]} ignoreKeys array of keys to ignore in comparison
|
|
53
52
|
* @returns {boolean} true if the two json objects have the same length and all the properties have the same value
|
|
54
53
|
*/
|
|
55
|
-
|
|
56
54
|
export function isEqualJson(obj1, obj2, ignoreKeys = []) {
|
|
57
55
|
const obj1Keys = Object.keys(obj1).filter(key => !ignoreKeys.includes(key));
|
|
58
56
|
const obj2Keys = Object.keys(obj2).filter(key => !ignoreKeys.includes(key));
|
|
59
|
-
|
|
60
57
|
if (obj1Keys.length !== obj2Keys.length) {
|
|
61
58
|
return false;
|
|
62
59
|
}
|
|
63
|
-
|
|
64
60
|
for (const objKey of obj1Keys) {
|
|
65
61
|
if (obj1[objKey] !== obj2[objKey]) {
|
|
66
62
|
if (typeof obj1[objKey] === 'object' && typeof obj2[objKey] === 'object') {
|
|
@@ -72,18 +68,18 @@ export function isEqualJson(obj1, obj2, ignoreKeys = []) {
|
|
|
72
68
|
}
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
|
-
|
|
76
71
|
return true;
|
|
77
72
|
}
|
|
73
|
+
|
|
78
74
|
/**
|
|
79
75
|
* Get current realm name
|
|
80
76
|
* @param {String} realm realm
|
|
81
77
|
* @returns {String} name of the realm. /alpha -> alpha
|
|
82
78
|
*/
|
|
83
|
-
|
|
84
79
|
export function getRealmName(realm) {
|
|
85
80
|
return _getRealmName(realm);
|
|
86
81
|
}
|
|
82
|
+
|
|
87
83
|
/**
|
|
88
84
|
* find all (nested) files in a directory
|
|
89
85
|
*
|
|
@@ -91,7 +87,6 @@ export function getRealmName(realm) {
|
|
|
91
87
|
* @param childDirectory subdirectory to search
|
|
92
88
|
* @returns list of files
|
|
93
89
|
*/
|
|
94
|
-
|
|
95
90
|
export async function readFiles(baseDirectory, childDirectory = '') {
|
|
96
91
|
const targetDirectory = join(baseDirectory, childDirectory);
|
|
97
92
|
const directoryItems = await readdir(targetDirectory);
|
|
@@ -99,11 +94,9 @@ export async function readFiles(baseDirectory, childDirectory = '') {
|
|
|
99
94
|
const filePathsNested = await Promise.all(childPaths.map(async childPath => {
|
|
100
95
|
const path = join(baseDirectory, childPath);
|
|
101
96
|
const isDirectory = (await lstat(path)).isDirectory();
|
|
102
|
-
|
|
103
97
|
if (isDirectory) {
|
|
104
98
|
return readFiles(baseDirectory, childPath);
|
|
105
99
|
}
|
|
106
|
-
|
|
107
100
|
return {
|
|
108
101
|
path: childPath,
|
|
109
102
|
content: await readFile(path, 'utf8')
|
|
@@ -123,4 +116,17 @@ export function unSubstituteEnvParams(input, reader) {
|
|
|
123
116
|
});
|
|
124
117
|
return input;
|
|
125
118
|
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Check if a string is a valid URL
|
|
122
|
+
* @param {string} urlString input string to be evaluated
|
|
123
|
+
* @returns {boolean} true if a valid URL, false otherwise
|
|
124
|
+
*/
|
|
125
|
+
export function isValidUrl(urlString) {
|
|
126
|
+
try {
|
|
127
|
+
return Boolean(new URL(urlString));
|
|
128
|
+
} catch (error) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
126
132
|
//# sourceMappingURL=OpsUtils.js.map
|
|
@@ -1,50 +1,178 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as OpsUtils from './OpsUtils';
|
|
2
|
+
import * as state from '../../shared/State';
|
|
3
3
|
import { CLOUD_DEPLOYMENT_TYPE_KEY, FORGEOPS_DEPLOYMENT_TYPE_KEY, CLASSIC_DEPLOYMENT_TYPE_KEY } from '../../storage/StaticStorage';
|
|
4
|
-
describe('OpsUtils', () => {
|
|
5
|
-
test('getRealmManagedUser
|
|
4
|
+
describe('OpsUtils - getRealmManagedUser()', () => {
|
|
5
|
+
test('getRealmManagedUser() 0: Method is implemented', async () => {
|
|
6
|
+
expect(OpsUtils.getRealmManagedUser).toBeDefined();
|
|
7
|
+
});
|
|
8
|
+
test('getRealmManagedUser() 1: should prepend realm to managed user type in identity cloud', () => {
|
|
6
9
|
// Arrange
|
|
7
10
|
const REALM = 'alpha';
|
|
8
11
|
const DEPLOYMENT_TYPE = CLOUD_DEPLOYMENT_TYPE_KEY;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const testString = getRealmManagedUser();
|
|
13
|
-
|
|
12
|
+
state.setRealm(REALM);
|
|
13
|
+
state.setDeploymentType(DEPLOYMENT_TYPE);
|
|
14
|
+
// Act
|
|
15
|
+
const testString = OpsUtils.getRealmManagedUser();
|
|
16
|
+
// Assert
|
|
14
17
|
expect(testString).toBe('alpha_user');
|
|
15
18
|
});
|
|
16
|
-
test('
|
|
19
|
+
test('getRealmManagedUser() 2: should prepend realm without leading slash to managed user type in identity cloud', () => {
|
|
17
20
|
// Arrange
|
|
18
21
|
const REALM = '/alpha';
|
|
19
22
|
const DEPLOYMENT_TYPE = CLOUD_DEPLOYMENT_TYPE_KEY;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const testString = getRealmManagedUser();
|
|
24
|
-
|
|
23
|
+
state.setRealm(REALM);
|
|
24
|
+
state.setDeploymentType(DEPLOYMENT_TYPE);
|
|
25
|
+
// Act
|
|
26
|
+
const testString = OpsUtils.getRealmManagedUser();
|
|
27
|
+
// Assert
|
|
25
28
|
expect(testString).toBe('alpha_user');
|
|
26
29
|
});
|
|
27
|
-
test('getRealmManagedUser should not prepend realm to managed user type in forgeops deployments', () => {
|
|
30
|
+
test('getRealmManagedUser() 3: should not prepend realm to managed user type in forgeops deployments', () => {
|
|
28
31
|
// Arrange
|
|
29
32
|
const REALM = 'alpha';
|
|
30
33
|
const DEPLOYMENT_TYPE = FORGEOPS_DEPLOYMENT_TYPE_KEY;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const testString = getRealmManagedUser();
|
|
35
|
-
|
|
34
|
+
state.setRealm(REALM);
|
|
35
|
+
state.setDeploymentType(DEPLOYMENT_TYPE);
|
|
36
|
+
// Act
|
|
37
|
+
const testString = OpsUtils.getRealmManagedUser();
|
|
38
|
+
// Assert
|
|
36
39
|
expect(testString).toBe('user');
|
|
37
40
|
});
|
|
38
|
-
test('getRealmManagedUser should not prepend realm to managed user type in classic deployments', () => {
|
|
41
|
+
test('getRealmManagedUser() 4: should not prepend realm to managed user type in classic deployments', () => {
|
|
39
42
|
// Arrange
|
|
40
43
|
const REALM = 'alpha';
|
|
41
44
|
const DEPLOYMENT_TYPE = CLASSIC_DEPLOYMENT_TYPE_KEY;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const testString = getRealmManagedUser();
|
|
46
|
-
|
|
45
|
+
state.setRealm(REALM);
|
|
46
|
+
state.setDeploymentType(DEPLOYMENT_TYPE);
|
|
47
|
+
// Act
|
|
48
|
+
const testString = OpsUtils.getRealmManagedUser();
|
|
49
|
+
// Assert
|
|
47
50
|
expect(testString).toBe('user');
|
|
48
51
|
});
|
|
49
52
|
});
|
|
53
|
+
describe('OpsUtils - isEqualJson()', () => {
|
|
54
|
+
test('isEqualJson() 0: Method is implemented', async () => {
|
|
55
|
+
expect(OpsUtils.isEqualJson).toBeDefined();
|
|
56
|
+
});
|
|
57
|
+
test('isEqualJson() 1: two empty objects should be equal', () => {
|
|
58
|
+
const obj1 = {};
|
|
59
|
+
const obj2 = {};
|
|
60
|
+
expect(OpsUtils.isEqualJson(obj1, obj2)).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
test('isEqualJson() 2: two objects with single and equal entry should be equal', () => {
|
|
63
|
+
const obj1 = {
|
|
64
|
+
key: 'value'
|
|
65
|
+
};
|
|
66
|
+
const obj2 = {
|
|
67
|
+
key: 'value'
|
|
68
|
+
};
|
|
69
|
+
expect(OpsUtils.isEqualJson(obj1, obj2)).toBeTruthy();
|
|
70
|
+
});
|
|
71
|
+
test('isEqualJson() 3: two objects with equal key but different value should not be equal', () => {
|
|
72
|
+
const obj1 = {
|
|
73
|
+
key: 'value1'
|
|
74
|
+
};
|
|
75
|
+
const obj2 = {
|
|
76
|
+
key: 'value2'
|
|
77
|
+
};
|
|
78
|
+
expect(OpsUtils.isEqualJson(obj1, obj2)).toBeFalsy();
|
|
79
|
+
});
|
|
80
|
+
test('isEqualJson() 4: two objects with differing keys but equal values should not be equal', () => {
|
|
81
|
+
const obj1 = {
|
|
82
|
+
key1: 'value'
|
|
83
|
+
};
|
|
84
|
+
const obj2 = {
|
|
85
|
+
key2: 'value'
|
|
86
|
+
};
|
|
87
|
+
expect(OpsUtils.isEqualJson(obj1, obj2)).toBeFalsy();
|
|
88
|
+
});
|
|
89
|
+
test('isEqualJson() 5: two objects with unequal amounts of entries should not be equal', () => {
|
|
90
|
+
const obj1 = {
|
|
91
|
+
key1: 'value'
|
|
92
|
+
};
|
|
93
|
+
const obj2 = {
|
|
94
|
+
key1: 'value',
|
|
95
|
+
key2: 'value2'
|
|
96
|
+
};
|
|
97
|
+
expect(OpsUtils.isEqualJson(obj1, obj2)).toBeFalsy();
|
|
98
|
+
});
|
|
99
|
+
test('isEqualJson() 6: two objects with equal but nested keys should be equal', () => {
|
|
100
|
+
const obj1 = {
|
|
101
|
+
key1: 'value1',
|
|
102
|
+
key2: {
|
|
103
|
+
key3: 'value3'
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const obj2 = {
|
|
107
|
+
key1: 'value1',
|
|
108
|
+
key2: {
|
|
109
|
+
key3: 'value3'
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
expect(OpsUtils.isEqualJson(obj1, obj2)).toBeTruthy();
|
|
113
|
+
});
|
|
114
|
+
test('isEqualJson() 7: two objects with equal but multi-nested keys should be equal', () => {
|
|
115
|
+
const obj1 = {
|
|
116
|
+
key1: 'value1',
|
|
117
|
+
key2: {
|
|
118
|
+
key3: 'value3',
|
|
119
|
+
key4: {
|
|
120
|
+
key5: 'value5'
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const obj2 = {
|
|
125
|
+
key1: 'value1',
|
|
126
|
+
key2: {
|
|
127
|
+
key3: 'value3',
|
|
128
|
+
key4: {
|
|
129
|
+
key5: 'value5'
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
expect(OpsUtils.isEqualJson(obj1, obj2)).toBeTruthy();
|
|
134
|
+
});
|
|
135
|
+
test('isEqualJson() 8: two objects with equal multi-nested keys but unequal values should not be equal', () => {
|
|
136
|
+
const obj1 = {
|
|
137
|
+
key1: 'value1',
|
|
138
|
+
key2: {
|
|
139
|
+
key3: 'value3',
|
|
140
|
+
key4: {
|
|
141
|
+
key5: 'value5'
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const obj2 = {
|
|
146
|
+
key1: 'value1',
|
|
147
|
+
key2: {
|
|
148
|
+
key3: 'value3',
|
|
149
|
+
key4: {
|
|
150
|
+
key5: 'value'
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
expect(OpsUtils.isEqualJson(obj1, obj2)).toBeFalsy();
|
|
155
|
+
});
|
|
156
|
+
test('isEqualJson() 9: two objects with equal multi-nested keys but unequal values with the offending key excluded should be equal', () => {
|
|
157
|
+
const obj1 = {
|
|
158
|
+
key1: 'value1',
|
|
159
|
+
key2: {
|
|
160
|
+
key3: 'value3',
|
|
161
|
+
key4: {
|
|
162
|
+
key5: 'value5'
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const obj2 = {
|
|
167
|
+
key1: 'value1',
|
|
168
|
+
key2: {
|
|
169
|
+
key3: 'value3',
|
|
170
|
+
key4: {
|
|
171
|
+
key5: 'value'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
expect(OpsUtils.isEqualJson(obj1, obj2, ['key5'])).toBeTruthy();
|
|
176
|
+
});
|
|
177
|
+
});
|
|
50
178
|
//# sourceMappingURL=OpsUtils.test.js.map
|
|
@@ -2,42 +2,33 @@ import { parseScript } from 'esprima';
|
|
|
2
2
|
import { printMessage } from './Console';
|
|
3
3
|
export function validateScriptHooks(jsonData) {
|
|
4
4
|
const scriptHooks = findAllScriptHooks(jsonData);
|
|
5
|
-
|
|
6
5
|
for (const scriptHook of scriptHooks) {
|
|
7
6
|
if (!('source' in scriptHook)) {
|
|
8
7
|
continue;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
if (!isValidJs(scriptHook.source)) {
|
|
12
10
|
return false;
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
return true;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
function findAllScriptHooks(jsonData, scriptHooksArray = []) {
|
|
20
16
|
if (typeof jsonData !== 'object' || jsonData === null) {
|
|
21
17
|
return scriptHooksArray;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
for (const key in jsonData) {
|
|
25
20
|
const item = jsonData[key];
|
|
26
|
-
|
|
27
21
|
if (typeof item !== 'object' || item === null) {
|
|
28
22
|
continue;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
if ('type' in item && item.type === 'text/javascript') {
|
|
32
25
|
scriptHooksArray.push(item);
|
|
33
26
|
} else {
|
|
34
27
|
findAllScriptHooks(item, scriptHooksArray);
|
|
35
28
|
}
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
return scriptHooksArray;
|
|
39
31
|
}
|
|
40
|
-
|
|
41
32
|
function isValidJs(javascriptSource) {
|
|
42
33
|
try {
|
|
43
34
|
parseScript(javascriptSource);
|