@rockcarver/frodo-cli 0.10.4 → 0.11.1-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/README.md +3 -3
- package/package.json +17 -15
- package/src/app.js +7 -6
- package/src/cli/_template/cmd-delete.js +9 -8
- package/src/cli/_template/cmd-describe.js +9 -8
- package/src/cli/_template/cmd-export.js +9 -8
- package/src/cli/_template/cmd-import.js +9 -8
- package/src/cli/_template/cmd-list.js +9 -8
- package/src/cli/_template/cmd-sub1-delete.js +9 -8
- package/src/cli/_template/cmd-sub1-describe.js +9 -8
- package/src/cli/_template/cmd-sub1-export.js +9 -8
- package/src/cli/_template/cmd-sub1-import.js +9 -8
- package/src/cli/_template/cmd-sub1-list.js +9 -8
- package/src/cli/_template/cmd-sub2-delete.js +9 -8
- package/src/cli/_template/cmd-sub2-describe.js +9 -8
- package/src/cli/_template/cmd-sub2-export.js +9 -8
- package/src/cli/_template/cmd-sub2-import.js +9 -8
- package/src/cli/_template/cmd-sub2-list.js +9 -8
- package/src/cli/admin/admin-add-autoid-static-user-mapping.js +12 -12
- package/src/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +15 -18
- package/src/cli/admin/admin-get-access-token.js +12 -12
- package/src/cli/admin/admin-grant-oauth2-client-admin-privileges.js +13 -13
- package/src/cli/admin/admin-hide-generic-extension-attributes.js +13 -13
- package/src/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +13 -13
- package/src/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +14 -13
- package/src/cli/admin/admin-list-static-user-mappings.js +12 -12
- package/src/cli/admin/admin-remove-static-user-mapping.js +12 -12
- package/src/cli/admin/admin-repair-org-model.js +13 -13
- package/src/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +13 -13
- package/src/cli/admin/admin-show-generic-extension-attributes.js +13 -13
- package/src/cli/app/app-delete.js +9 -8
- package/src/cli/app/app-describe.js +9 -8
- package/src/cli/app/app-export.js +15 -15
- package/src/cli/app/app-import.js +11 -11
- package/src/cli/app/app-list.js +11 -12
- package/src/cli/conn/conn-add.js +11 -11
- package/src/cli/conn/conn-delete.js +3 -1
- package/src/cli/conn/conn-describe.js +3 -1
- package/src/cli/conn/conn-list.js +3 -4
- package/src/cli/email/email-template-export.js +16 -16
- package/src/cli/email/email-template-import.js +16 -16
- package/src/cli/email/email-template-list.js +11 -11
- package/src/cli/esv/esv-apply.js +12 -12
- package/src/cli/esv/esv-secret-create.js +11 -11
- package/src/cli/esv/esv-secret-delete.js +13 -13
- package/src/cli/esv/esv-secret-describe.js +11 -11
- package/src/cli/esv/esv-secret-export.js +9 -8
- package/src/cli/esv/esv-secret-import.js +9 -8
- package/src/cli/esv/esv-secret-list.js +11 -11
- package/src/cli/esv/esv-secret-set.js +11 -11
- package/src/cli/esv/esv-secret-version-activate.js +12 -12
- package/src/cli/esv/esv-secret-version-create.js +11 -11
- package/src/cli/esv/esv-secret-version-deactivate.js +12 -12
- package/src/cli/esv/esv-secret-version-delete.js +13 -13
- package/src/cli/esv/esv-secret-version-list.js +11 -11
- package/src/cli/esv/esv-variable-create.js +11 -11
- package/src/cli/esv/esv-variable-delete.js +13 -16
- package/src/cli/esv/esv-variable-describe.js +11 -11
- package/src/cli/esv/esv-variable-export.js +9 -8
- package/src/cli/esv/esv-variable-import.js +9 -8
- package/src/cli/esv/esv-variable-list.js +11 -11
- package/src/cli/esv/esv-variable-set.js +13 -16
- package/src/cli/idm/idm-count.js +11 -11
- package/src/cli/idm/idm-export.js +16 -16
- package/src/cli/idm/idm-list.js +11 -11
- package/src/cli/idp/idp-export.js +15 -19
- package/src/cli/idp/idp-import.js +18 -18
- package/src/cli/idp/idp-list.js +12 -12
- package/src/cli/info/info.js +23 -19
- package/src/cli/journey/journey-delete.js +14 -14
- package/src/cli/journey/journey-describe.js +26 -35
- package/src/cli/journey/journey-export.js +18 -21
- package/src/cli/journey/journey-import.js +17 -17
- package/src/cli/journey/journey-list.js +12 -12
- package/src/cli/journey/journey-prune.js +12 -12
- package/src/cli/logging/logs-list.js +33 -28
- package/src/cli/logging/logs-tail.js +26 -22
- package/src/cli/realm/realm-add-custom-domain.js +13 -13
- package/src/cli/realm/realm-describe.js +14 -14
- package/src/cli/realm/realm-list.js +11 -11
- package/src/cli/realm/realm-remove-custom-domain.js +16 -13
- package/src/cli/saml/saml-cot-export.js +16 -16
- package/src/cli/saml/saml-cot-import.js +18 -18
- package/src/cli/saml/saml-cot-list.js +12 -12
- package/src/cli/saml/saml-describe.js +12 -12
- package/src/cli/saml/saml-export.js +16 -19
- package/src/cli/saml/saml-import.js +19 -18
- package/src/cli/saml/saml-list.js +12 -12
- package/src/cli/saml/saml-metadata-export.js +15 -19
- package/src/cli/script/script-delete.js +9 -8
- package/src/cli/script/script-describe.js +9 -8
- package/src/cli/script/script-export.js +18 -20
- package/src/cli/script/script-import.js +13 -12
- package/src/cli/script/script-list.js +12 -12
- package/src/cli/theme/theme-delete.js +17 -21
- package/src/cli/theme/theme-export.js +19 -18
- package/src/cli/theme/theme-import.js +21 -20
- package/src/cli/theme/theme-list.js +12 -12
- package/.eslintrc +0 -29
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -30
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/README.md +0 -273
- package/.github/workflows/pipeline.yml +0 -487
- package/.prettierrc +0 -6
- package/CODE_OF_CONDUCT.md +0 -128
- package/docs/BINARIES.md +0 -22
- package/docs/CONTRIBUTE.md +0 -96
- package/docs/PIPELINE.md +0 -169
- package/docs/images/macos_warn1.png +0 -0
- package/docs/images/macos_warn2.png +0 -0
- package/docs/images/macos_warn3.png +0 -0
- package/docs/images/npm_versioning_guidelines.png +0 -0
- package/docs/images/release_pipeline.png +0 -0
- package/gulpfile.js +0 -49
- package/jsconfig.json +0 -6
- package/resources/sampleEntitiesFile.json +0 -8
- package/resources/sampleEnvFile.env +0 -2
- package/src/api/AuthenticateApi.js +0 -33
- package/src/api/BaseApi.js +0 -242
- package/src/api/CirclesOfTrustApi.js +0 -87
- package/src/api/EmailTemplateApi.js +0 -37
- package/src/api/IdmConfigApi.js +0 -88
- package/src/api/LogApi.js +0 -45
- package/src/api/ManagedObjectApi.js +0 -62
- package/src/api/OAuth2ClientApi.js +0 -69
- package/src/api/OAuth2OIDCApi.js +0 -73
- package/src/api/OAuth2ProviderApi.js +0 -32
- package/src/api/RealmApi.js +0 -99
- package/src/api/Saml2Api.js +0 -176
- package/src/api/ScriptApi.js +0 -84
- package/src/api/SecretsApi.js +0 -151
- package/src/api/ServerInfoApi.js +0 -41
- package/src/api/SocialIdentityProvidersApi.js +0 -114
- package/src/api/StartupApi.js +0 -45
- package/src/api/ThemeApi.js +0 -181
- package/src/api/TreeApi.js +0 -207
- package/src/api/VariablesApi.js +0 -104
- package/src/api/utils/ApiUtils.js +0 -77
- package/src/api/utils/Base64.js +0 -62
- package/src/cli/journey/journey-delete.e2e.test.js +0 -380
- package/src/cli/journey/journey-list.e2e.test.js +0 -141
- package/src/cli/theme/theme-delete.e2e.test.js +0 -178
- package/src/cli/theme/theme-list.e2e.test.js +0 -119
- package/src/ops/AdminOps.js +0 -901
- package/src/ops/AuthenticateOps.js +0 -342
- package/src/ops/CirclesOfTrustOps.js +0 -350
- package/src/ops/ConnectionProfileOps.js +0 -254
- package/src/ops/EmailTemplateOps.js +0 -326
- package/src/ops/IdmOps.js +0 -227
- package/src/ops/IdpOps.js +0 -342
- package/src/ops/JourneyOps.js +0 -2026
- package/src/ops/LogOps.js +0 -357
- package/src/ops/ManagedObjectOps.js +0 -34
- package/src/ops/OAuth2ClientOps.js +0 -151
- package/src/ops/OrganizationOps.js +0 -85
- package/src/ops/RealmOps.js +0 -139
- package/src/ops/SamlOps.js +0 -541
- package/src/ops/ScriptOps.js +0 -211
- package/src/ops/SecretsOps.js +0 -288
- package/src/ops/StartupOps.js +0 -114
- package/src/ops/ThemeOps.js +0 -379
- package/src/ops/VariablesOps.js +0 -185
- package/src/ops/templates/OAuth2ClientTemplate.json +0 -270
- package/src/ops/templates/OrgModelUserAttributesTemplate.json +0 -149
- package/src/ops/templates/cloud/GenericExtensionAttributesTemplate.json +0 -392
- package/src/ops/templates/cloud/managed.json +0 -4119
- package/src/ops/utils/Console.js +0 -434
- package/src/ops/utils/DataProtection.js +0 -92
- package/src/ops/utils/ExportImportUtils.js +0 -146
- package/src/ops/utils/OpsUtils.js +0 -76
- package/src/ops/utils/Wordwrap.js +0 -11
- package/src/storage/SessionStorage.js +0 -45
- package/test/client_cli/en/connections.test.js +0 -62
- package/test/client_cli/en/connections_add.test.js +0 -34
- package/test/client_cli/en/connections_delete.test.js +0 -34
- package/test/client_cli/en/connections_list.test.js +0 -34
- package/test/client_cli/en/email_templates.test.js +0 -77
- package/test/client_cli/en/email_templates_export.test.js +0 -196
- package/test/client_cli/en/email_templates_import.test.js +0 -145
- package/test/client_cli/en/email_templates_list.test.js +0 -130
- package/test/client_cli/en/idm.test.js +0 -111
- package/test/client_cli/en/idm_count.test.js +0 -121
- package/test/client_cli/en/idm_export.test.js +0 -136
- package/test/client_cli/en/idm_exportAll.test.js +0 -156
- package/test/client_cli/en/idm_exportAllRaw.test.js +0 -120
- package/test/client_cli/en/idm_import.test_.js +0 -103
- package/test/client_cli/en/idm_importAll.test_.js +0 -103
- package/test/client_cli/en/idm_list.test.js +0 -103
- package/test/client_cli/en/info.test.js +0 -125
- package/test/client_cli/en/journey.test.js +0 -127
- package/test/client_cli/en/journey_describe.test.js +0 -196
- package/test/client_cli/en/journey_export.test.js +0 -213
- package/test/client_cli/en/journey_import.test.js +0 -195
- package/test/client_cli/en/journey_importAll.test.js +0 -180
- package/test/client_cli/en/journey_list.test.js +0 -162
- package/test/client_cli/en/journey_prune.test.js +0 -148
- package/test/client_cli/en/logs.test.js +0 -79
- package/test/client_cli/en/logs_list.test.js +0 -83
- package/test/client_cli/en/logs_tail.test.js +0 -118
- package/test/client_cli/en/root.test.js +0 -91
- package/test/client_cli/en/script.test.js +0 -77
- package/test/client_cli/en/script_export.test.js +0 -213
- package/test/client_cli/en/script_import.test.js +0 -163
- package/test/client_cli/en/script_list.test.js +0 -148
- package/test/client_cli/utils/utils.js +0 -32
- package/test/e2e/journey/baseline/ForgottenUsername.journey.json +0 -216
- package/test/e2e/journey/baseline/Login.journey.json +0 -205
- package/test/e2e/journey/baseline/PasswordGrant.journey.json +0 -139
- package/test/e2e/journey/baseline/ProgressiveProfile.journey.json +0 -198
- package/test/e2e/journey/baseline/Registration.journey.json +0 -249
- package/test/e2e/journey/baseline/ResetPassword.journey.json +0 -268
- package/test/e2e/journey/baseline/UpdatePassword.journey.json +0 -323
- package/test/e2e/journey/baseline/allAlphaJourneys.journeys.json +0 -1520
- package/test/e2e/journey/delete/ForgottenUsername.journey.json +0 -216
- package/test/e2e/journey/delete/Login.journey.json +0 -205
- package/test/e2e/journey/delete/PasswordGrant.journey.json +0 -139
- package/test/e2e/journey/delete/ProgressiveProfile.journey.json +0 -198
- package/test/e2e/journey/delete/Registration.journey.json +0 -249
- package/test/e2e/journey/delete/ResetPassword.journey.json +0 -268
- package/test/e2e/journey/delete/UpdatePassword.journey.json +0 -323
- package/test/e2e/journey/delete/deleteMe.journey.json +0 -230
- package/test/e2e/journey/list/Disabled.journey.json +0 -43
- package/test/e2e/journey/list/ForgottenUsername.journey.json +0 -216
- package/test/e2e/journey/list/Login.journey.json +0 -205
- package/test/e2e/journey/list/PasswordGrant.journey.json +0 -139
- package/test/e2e/journey/list/ProgressiveProfile.journey.json +0 -198
- package/test/e2e/journey/list/Registration.journey.json +0 -249
- package/test/e2e/journey/list/ResetPassword.journey.json +0 -268
- package/test/e2e/journey/list/UpdatePassword.journey.json +0 -323
- package/test/e2e/setup.js +0 -98
- package/test/e2e/theme/baseline/Contrast.theme.json +0 -95
- package/test/e2e/theme/baseline/Highlander.theme.json +0 -95
- package/test/e2e/theme/baseline/Robroy.theme.json +0 -95
- package/test/e2e/theme/baseline/Starter-Theme.theme.json +0 -94
- package/test/e2e/theme/baseline/Zardoz.theme.json +0 -95
- package/test/e2e/theme/import/Contrast.theme.json +0 -95
- package/test/e2e/theme/import/Highlander.theme.json +0 -95
- package/test/e2e/theme/import/Robroy.theme.json +0 -95
- package/test/e2e/theme/import/Starter-Theme.theme.json +0 -94
- package/test/e2e/theme/import/Zardoz.default.theme.json +0 -95
- package/test/fs_tmp/.gitkeep +0 -2
- package/test/global/setup.js +0 -65
- package/test/lib_api/unit_tests/ApiUtils.test.js +0 -186
- package/test/lib_api/unit_tests/Base64URL.test.js +0 -22
- package/test/lib_api/unit_tests/DataProtection.test.js +0 -25
- package/test/lib_api/unit_tests/ExportImportUtils.test.js +0 -121
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
applyNameCollisionPolicy,
|
|
3
|
-
escapeRegExp,
|
|
4
|
-
getCurrentRealmPath,
|
|
5
|
-
getRealmManagedUser,
|
|
6
|
-
getTenantURL,
|
|
7
|
-
isEqualJson,
|
|
8
|
-
replaceAll,
|
|
9
|
-
} from '../../../src/api/utils/ApiUtils';
|
|
10
|
-
import sessionStorage from '../../../src/storage/SessionStorage';
|
|
11
|
-
|
|
12
|
-
test.skip('replaceAll should be deleted because it works like native String.replaceAll', () => {
|
|
13
|
-
// Arrange
|
|
14
|
-
// Act
|
|
15
|
-
// Assert
|
|
16
|
-
expect(true).toBe(false);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('getCurrentRealmPath should prepend realmPath to specified realm', () => {
|
|
20
|
-
// Arrange
|
|
21
|
-
const REALM_PATH = 'alpha';
|
|
22
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
23
|
-
// Act
|
|
24
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
25
|
-
// Assert
|
|
26
|
-
expect(testString).toBe('/realms/root/realms/alpha');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('getCurrentRealmPath should prepend realmPath to specified realm with leading slash', () => {
|
|
30
|
-
// Arrange
|
|
31
|
-
const REALM_PATH = '/alpha';
|
|
32
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
33
|
-
// Act
|
|
34
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
35
|
-
// Assert
|
|
36
|
-
expect(testString).toBe('/realms/root/realms/alpha');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('getCurrentRealmPath "/" should resolve to root', () => {
|
|
40
|
-
// Arrange
|
|
41
|
-
const REALM_PATH = '/';
|
|
42
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
43
|
-
// Act
|
|
44
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
45
|
-
// Assert
|
|
46
|
-
expect(testString).toBe('/realms/root');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('getCurrentRealmPath should not handle multiple leading slash', () => {
|
|
50
|
-
// Arrange
|
|
51
|
-
const REALM_PATH = '//alpha';
|
|
52
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
53
|
-
// Act
|
|
54
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
55
|
-
// Assert
|
|
56
|
-
expect(testString).toBe('/realms/root/realms//alpha');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test('getCurrentRealmPath should not handle nested depth realms', () => {
|
|
60
|
-
// Arrange
|
|
61
|
-
const REALM_PATH = '/alpha/erm';
|
|
62
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
63
|
-
// Act
|
|
64
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
65
|
-
// Assert
|
|
66
|
-
expect(testString).toBe('/realms/root/realms/alpha/erm');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('getTenantURL should parse the https protocol and the hostname', () => {
|
|
70
|
-
// Arrange
|
|
71
|
-
const URL_WITH_TENANT =
|
|
72
|
-
'https://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';
|
|
73
|
-
|
|
74
|
-
// Act
|
|
75
|
-
const parsed = getTenantURL(URL_WITH_TENANT);
|
|
76
|
-
|
|
77
|
-
// Assert
|
|
78
|
-
expect(parsed).toBe('https://example.frodo.com');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('getTenantURL should not validate protocol', () => {
|
|
82
|
-
// Arrange
|
|
83
|
-
const URL_WITH_TENANT =
|
|
84
|
-
'ftp://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';
|
|
85
|
-
// Act
|
|
86
|
-
const parsed = getTenantURL(URL_WITH_TENANT);
|
|
87
|
-
// Assert
|
|
88
|
-
expect(parsed).toBe('ftp://example.frodo.com');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test('getTenantURL Invalid URL should throw', () => {
|
|
92
|
-
// Arrange
|
|
93
|
-
const URL_WITH_TENANT =
|
|
94
|
-
'//:example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';
|
|
95
|
-
// Act
|
|
96
|
-
const trap = () => {
|
|
97
|
-
getTenantURL(URL_WITH_TENANT);
|
|
98
|
-
};
|
|
99
|
-
// Assert
|
|
100
|
-
expect(trap).toThrow('Invalid URL');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('applyNameCollisionPolicy should format correctly', () => {
|
|
104
|
-
// Arrange
|
|
105
|
-
const NAME = 'hello';
|
|
106
|
-
const EXPECTED = 'hello - imported (1)';
|
|
107
|
-
// Act
|
|
108
|
-
const result = applyNameCollisionPolicy(NAME);
|
|
109
|
-
// Assert
|
|
110
|
-
expect(result).toBe(EXPECTED);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test('applyNameCollisionPolicy undefined name throws', () => {
|
|
114
|
-
// Act
|
|
115
|
-
const trap = () => {
|
|
116
|
-
applyNameCollisionPolicy();
|
|
117
|
-
};
|
|
118
|
-
// Assert
|
|
119
|
-
expect(trap).toThrow();
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test('applyNameCollisionPolicy blank string name does not throw', () => {
|
|
123
|
-
// Arrange
|
|
124
|
-
const NAME = '';
|
|
125
|
-
// Act
|
|
126
|
-
const trap = () => {
|
|
127
|
-
applyNameCollisionPolicy(NAME);
|
|
128
|
-
};
|
|
129
|
-
// Assert
|
|
130
|
-
expect(trap).not.toThrow();
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test('applyNameCollisionPolicy name can have spaces', () => {
|
|
134
|
-
// Arrange
|
|
135
|
-
const NAME = 'hello world';
|
|
136
|
-
const EXPECTED = 'hello world - imported (1)';
|
|
137
|
-
// Act
|
|
138
|
-
const result = applyNameCollisionPolicy(NAME);
|
|
139
|
-
// Assert
|
|
140
|
-
expect(result).toBe(EXPECTED);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test('escapeRegExp should escape the Regular Expression special characters “^”, “$”, “”, “.”, “*”, “+”, “?”, “(“, “)”, “[“, “]”, “{“, “}”, and “|” in string.', () => {
|
|
144
|
-
// Arrange
|
|
145
|
-
const EXPECTED = /\*\?\{\}\./;
|
|
146
|
-
// Act
|
|
147
|
-
const result = escapeRegExp('/*?{}./');
|
|
148
|
-
// Assert
|
|
149
|
-
expect(result.toString()).toBe(EXPECTED.toString());
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test.skip('getRealmManagedUser in cloud environments should return differnt value', () => {
|
|
153
|
-
properties.CLOUD_DEPLOYMENT_TYPE_KEY;
|
|
154
|
-
console.log(global);
|
|
155
|
-
expect(true).toBe(true);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test('getRealmManagedUser in prem environments should return differnt value', () => {
|
|
159
|
-
// Arrange
|
|
160
|
-
sessionStorage.session.setItem('deploymentType', 'cloud');
|
|
161
|
-
sessionStorage.session.setItem('realm', 'foxtrot');
|
|
162
|
-
// Act
|
|
163
|
-
const result = getRealmManagedUser();
|
|
164
|
-
// Assert
|
|
165
|
-
expect(result).toBe('foxtrot_user');
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test('isEqualJson should check that two json formatted strings are the same', () => {
|
|
169
|
-
// Arrange
|
|
170
|
-
const json1 = JSON.stringify({ frodo: 123 });
|
|
171
|
-
const json2 = JSON.stringify({ frodo: 123 });
|
|
172
|
-
// Act
|
|
173
|
-
const result = isEqualJson(json1, json2);
|
|
174
|
-
// Assert
|
|
175
|
-
expect(result).toBe(true);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
test.skip('isEqualJson should check that two json formatted strings are the same ignoring keys', () => {
|
|
179
|
-
// Arrange
|
|
180
|
-
const json1 = JSON.stringify({ frodo: 123, ignoreme: 0 });
|
|
181
|
-
const json2 = JSON.stringify({ frodo: 123 });
|
|
182
|
-
// Act
|
|
183
|
-
const result = isEqualJson(json1, json2, ['ignoreme']);
|
|
184
|
-
// Assert
|
|
185
|
-
expect(result).toBe(true);
|
|
186
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { encode, decode } from '../../../src/api/utils/Base64URL';
|
|
2
|
-
|
|
3
|
-
test('should encode base64url', () => {
|
|
4
|
-
// Arrange
|
|
5
|
-
const URL = 'https://fr.fr?key=value&something=else';
|
|
6
|
-
const EXPECTED = 'aHR0cHM6Ly9mci5mcj9rZXk9dmFsdWUmc29tZXRoaW5nPWVsc2U';
|
|
7
|
-
// Act
|
|
8
|
-
const encoded = encode(URL);
|
|
9
|
-
// Assert
|
|
10
|
-
expect(encoded).toBe(EXPECTED);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
test('should decode base64url to UInt8 array', () => {
|
|
15
|
-
// Arrange
|
|
16
|
-
const URL = 'aHR0cHM6Ly9mci5mcj9rZXk9dmFsdWUmc29tZXRoaW5nPWVsc2U';
|
|
17
|
-
const EXPECTED = new TextEncoder().encode('https://fr.fr?key=value&something=else');
|
|
18
|
-
// Act
|
|
19
|
-
const decoded = decode(URL);
|
|
20
|
-
// Assert
|
|
21
|
-
expect(new Uint8Array(decoded)).toEqual(EXPECTED);
|
|
22
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import DataProtection from '../../../src/ops/utils/DataProtection';
|
|
2
|
-
|
|
3
|
-
test('DataProtection to encrypt', async () => {
|
|
4
|
-
// Note this test checks that encyption happned not that encryption is correct
|
|
5
|
-
// this test relys on other tests to proove the likelyhood of successful encryption
|
|
6
|
-
// Arrange
|
|
7
|
-
const dp = new DataProtection();
|
|
8
|
-
const EXPECTED = 'aMLtCqK1b+d3d88DDKrmIV7A6pifP77IItLKX7N7/UTOPxf8YCQWHCpTrmNnM5wNXue8HllEFIS+sxXRb20oCb4HImpbQM0so5DrHIqcIlF5LYDKjvzBOz1PdlclhIuIV+Gr8M3GRbNkQxXJuUZ4th5ISLpOjM+k8bDAlnHsRx5LLlbLFnAKq8Pu9DaTYUkZABOCOjfkoTb6re1p9c7xE2pAe213';
|
|
9
|
-
const originalString = 'Go not to the Elves for counsel, for they will say both no and yes.';
|
|
10
|
-
// Act
|
|
11
|
-
const RESULT = await dp.encrypt(originalString);
|
|
12
|
-
// Assert
|
|
13
|
-
expect(RESULT.length).toBe(EXPECTED.length);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('DataProtection to decrypt', async () => {
|
|
17
|
-
// Arrange
|
|
18
|
-
const dp = new DataProtection();
|
|
19
|
-
const originalString = 'Go not to the Elves for counsel, for they will say both no and yes.';
|
|
20
|
-
// Act
|
|
21
|
-
const encrypted = await dp.encrypt(originalString);
|
|
22
|
-
const RESULT = await dp.decrypt(encrypted);
|
|
23
|
-
// Assert
|
|
24
|
-
expect(RESULT).toBe(originalString);
|
|
25
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
convertArrayToBase64Script,
|
|
3
|
-
convertBase64ScriptToArray,
|
|
4
|
-
saveToFile,
|
|
5
|
-
validateImport,
|
|
6
|
-
checkTargetCompatibility
|
|
7
|
-
} from '../../../src/ops/utils/ExportImportUtils'
|
|
8
|
-
import { resolve } from 'path';
|
|
9
|
-
import { rmSync, existsSync, readFileSync } from 'fs';
|
|
10
|
-
// Warning! implimentation file contains non determinisitc functions which are either; not reasonable to test or imposible
|
|
11
|
-
// Cause: date based non overidable functions
|
|
12
|
-
// Not tested: getCurrentTimestamp
|
|
13
|
-
|
|
14
|
-
const FS_TMP_DIR = resolve('.', 'test', 'fs_tmp');
|
|
15
|
-
const PATH_TO_ARTIFACT = resolve(FS_TMP_DIR, 'export.json');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
test('convertBase64ScriptToArray returns an array of script lines in base64 encoding', () => {
|
|
19
|
-
// Arrange
|
|
20
|
-
const originalScript = `
|
|
21
|
-
function frodo() {
|
|
22
|
-
return 'ring to mt doom';
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
const base64Script = Buffer.from(originalScript).toString('base64');
|
|
26
|
-
// Act
|
|
27
|
-
const result = convertBase64ScriptToArray(base64Script);
|
|
28
|
-
// Assert
|
|
29
|
-
expect(result).toEqual(originalScript.split('\n'));
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('convertArrayToBase64Script', () => {
|
|
33
|
-
// Arrange
|
|
34
|
-
const originalArrayOfScriptLines = `
|
|
35
|
-
function frodo() {
|
|
36
|
-
return 'ring to mt doom';
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
39
|
-
const expected = Buffer.from(originalArrayOfScriptLines).toString('base64');
|
|
40
|
-
// Act
|
|
41
|
-
const result = convertArrayToBase64Script(originalArrayOfScriptLines.split('\n'));
|
|
42
|
-
// Assert
|
|
43
|
-
expect(result).toEqual(expected);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('validateImport should always return true', () => {
|
|
47
|
-
expect(validateImport()).not.toBe(false);
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
// This function has no way to determine when its asnyc task is complete, suggest using callback or promises to allow for testing
|
|
51
|
-
describe.skip('file system based tests', () => {
|
|
52
|
-
|
|
53
|
-
afterAll(() => {
|
|
54
|
-
if (existsSync(PATH_TO_ARTIFACT)) {
|
|
55
|
-
rmSync(PATH_TO_ARTIFACT);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
test('saveToFile should save a file to specified tmp directory with expected data format', async () => {
|
|
61
|
-
// Arrange
|
|
62
|
-
const id = `id-3021`;
|
|
63
|
-
const data = [
|
|
64
|
-
{
|
|
65
|
-
id,
|
|
66
|
-
location: 'The Shire',
|
|
67
|
-
character: 'Gandalf',
|
|
68
|
-
words: 1064
|
|
69
|
-
}
|
|
70
|
-
];
|
|
71
|
-
|
|
72
|
-
const expected = {
|
|
73
|
-
lotr: {
|
|
74
|
-
'id-3021': {
|
|
75
|
-
id: 'id-3021',
|
|
76
|
-
location: 'The Shire',
|
|
77
|
-
character: 'Gandalf',
|
|
78
|
-
words: 1064
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
// Act
|
|
83
|
-
// saveToFile('lotr', data, 'id', PATH_TO_ARTIFACT);
|
|
84
|
-
const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT));
|
|
85
|
-
// Assert
|
|
86
|
-
expect(resultingJSON.lotr).toEqual(expected.lotr);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
test('saveToFile should save a file with metadata', async () => {
|
|
91
|
-
// Arrange
|
|
92
|
-
const id = `id-3021`;
|
|
93
|
-
const data = [
|
|
94
|
-
{
|
|
95
|
-
id,
|
|
96
|
-
location: 'The Shire',
|
|
97
|
-
character: 'Gandalf',
|
|
98
|
-
words: 1064
|
|
99
|
-
}
|
|
100
|
-
];
|
|
101
|
-
// Act
|
|
102
|
-
saveToFile('lotr', data, 'id', PATH_TO_ARTIFACT);
|
|
103
|
-
const resultingJSON = JSON.parse(readFileSync(PATH_TO_ARTIFACT));
|
|
104
|
-
// Assert
|
|
105
|
-
expect(Object.keys(resultingJSON.meta)).toEqual([
|
|
106
|
-
'origin',
|
|
107
|
-
'exportedBy',
|
|
108
|
-
'exportDate',
|
|
109
|
-
'exportTool',
|
|
110
|
-
'exportToolVersion',
|
|
111
|
-
])
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test.skip('checkTargetCompatibility to be made testable', () => {
|
|
116
|
-
// Arrange
|
|
117
|
-
// Act
|
|
118
|
-
const result = checkTargetCompatibility();
|
|
119
|
-
// Assert
|
|
120
|
-
expect(result).toBe("not tested yet");
|
|
121
|
-
});
|