@rockcarver/frodo-lib 0.11.1-5 → 0.11.1-6
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 +5 -1
- package/package.json +1 -1
- package/cjs/api/utils/ApiUtils.test.js +0 -97
- package/cjs/index.test.js +0 -16
- package/cjs/ops/AuthenticateOps.test.js +0 -21
- package/cjs/ops/ConnectionProfileOps.test.js +0 -96
- package/cjs/ops/utils/DataProtection.test.js +0 -29
- package/cjs/ops/utils/ExportImportUtils.test.js +0 -98
- package/src/api/utils/ApiUtils.test.mjs +0 -93
- package/src/index.test.mjs +0 -13
- package/src/ops/AuthenticateOps.test.mjs +0 -14
- package/src/ops/ConnectionProfileOps.test.mjs +0 -90
- package/src/ops/utils/DataProtection.test.mjs +0 -28
- package/src/ops/utils/ExportImportUtils.test.mjs +0 -119
- 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/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/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.11.1-6] - 2022-08-21
|
|
11
|
+
|
|
10
12
|
## [0.11.1-5] - 2022-08-21
|
|
11
13
|
|
|
12
14
|
## [0.11.1-4] - 2022-08-21
|
|
@@ -427,7 +429,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
427
429
|
- Fixed problem with adding connection profiles
|
|
428
430
|
- Miscellaneous bug fixes
|
|
429
431
|
|
|
430
|
-
[Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.11.1-
|
|
432
|
+
[Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.11.1-6...HEAD
|
|
433
|
+
|
|
434
|
+
[0.11.1-6]: https://github.com/rockcarver/frodo-lib/compare/v0.11.1-5...v0.11.1-6
|
|
431
435
|
|
|
432
436
|
[0.11.1-5]: https://github.com/rockcarver/frodo-lib/compare/v0.11.1-4...v0.11.1-5
|
|
433
437
|
|
package/package.json
CHANGED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _ApiUtils = require("./ApiUtils");
|
|
4
|
-
|
|
5
|
-
var _SessionStorage = _interopRequireDefault(require("../../storage/SessionStorage"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
test.skip('replaceAll should be deleted because it works like native String.replaceAll', () => {
|
|
10
|
-
// Arrange
|
|
11
|
-
// Act
|
|
12
|
-
// Assert
|
|
13
|
-
expect(true).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
test('getCurrentRealmPath should prepend realmPath to specified realm', () => {
|
|
16
|
-
// Arrange
|
|
17
|
-
const REALM_PATH = 'alpha';
|
|
18
|
-
|
|
19
|
-
_SessionStorage.default.session.setItem('realm', REALM_PATH); // Act
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const testString = (0, _ApiUtils.getCurrentRealmPath)(REALM_PATH); // Assert
|
|
23
|
-
|
|
24
|
-
expect(testString).toBe('/realms/root/realms/alpha');
|
|
25
|
-
});
|
|
26
|
-
test('getCurrentRealmPath should prepend realmPath to specified realm with leading slash', () => {
|
|
27
|
-
// Arrange
|
|
28
|
-
const REALM_PATH = '/alpha';
|
|
29
|
-
|
|
30
|
-
_SessionStorage.default.session.setItem('realm', REALM_PATH); // Act
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const testString = (0, _ApiUtils.getCurrentRealmPath)(REALM_PATH); // Assert
|
|
34
|
-
|
|
35
|
-
expect(testString).toBe('/realms/root/realms/alpha');
|
|
36
|
-
});
|
|
37
|
-
test('getCurrentRealmPath "/" should resolve to root', () => {
|
|
38
|
-
// Arrange
|
|
39
|
-
const REALM_PATH = '/';
|
|
40
|
-
|
|
41
|
-
_SessionStorage.default.session.setItem('realm', REALM_PATH); // Act
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const testString = (0, _ApiUtils.getCurrentRealmPath)(REALM_PATH); // Assert
|
|
45
|
-
|
|
46
|
-
expect(testString).toBe('/realms/root');
|
|
47
|
-
});
|
|
48
|
-
test('getCurrentRealmPath should not handle multiple leading slash', () => {
|
|
49
|
-
// Arrange
|
|
50
|
-
const REALM_PATH = '//alpha';
|
|
51
|
-
|
|
52
|
-
_SessionStorage.default.session.setItem('realm', REALM_PATH); // Act
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const testString = (0, _ApiUtils.getCurrentRealmPath)(REALM_PATH); // Assert
|
|
56
|
-
|
|
57
|
-
expect(testString).toBe('/realms/root/realms//alpha');
|
|
58
|
-
});
|
|
59
|
-
test('getCurrentRealmPath should not handle nested depth realms', () => {
|
|
60
|
-
// Arrange
|
|
61
|
-
const REALM_PATH = '/alpha/erm';
|
|
62
|
-
|
|
63
|
-
_SessionStorage.default.session.setItem('realm', REALM_PATH); // Act
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const testString = (0, _ApiUtils.getCurrentRealmPath)(REALM_PATH); // Assert
|
|
67
|
-
|
|
68
|
-
expect(testString).toBe('/realms/root/realms/alpha/erm');
|
|
69
|
-
});
|
|
70
|
-
test('getTenantURL should parse the https protocol and the hostname', () => {
|
|
71
|
-
// Arrange
|
|
72
|
-
const URL_WITH_TENANT = 'https://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard'; // Act
|
|
73
|
-
|
|
74
|
-
const parsed = (0, _ApiUtils.getTenantURL)(URL_WITH_TENANT); // Assert
|
|
75
|
-
|
|
76
|
-
expect(parsed).toBe('https://example.frodo.com');
|
|
77
|
-
});
|
|
78
|
-
test('getTenantURL should not validate protocol', () => {
|
|
79
|
-
// Arrange
|
|
80
|
-
const URL_WITH_TENANT = 'ftp://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard'; // Act
|
|
81
|
-
|
|
82
|
-
const parsed = (0, _ApiUtils.getTenantURL)(URL_WITH_TENANT); // Assert
|
|
83
|
-
|
|
84
|
-
expect(parsed).toBe('ftp://example.frodo.com');
|
|
85
|
-
});
|
|
86
|
-
test('getTenantURL Invalid URL should throw', () => {
|
|
87
|
-
// Arrange
|
|
88
|
-
const URL_WITH_TENANT = '//:example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard'; // Act
|
|
89
|
-
|
|
90
|
-
const trap = () => {
|
|
91
|
-
(0, _ApiUtils.getTenantURL)(URL_WITH_TENANT);
|
|
92
|
-
}; // Assert
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
expect(trap).toThrow('Invalid URL');
|
|
96
|
-
});
|
|
97
|
-
//# sourceMappingURL=ApiUtils.test.js.map
|
package/cjs/index.test.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
4
|
-
|
|
5
|
-
var _ = require(".");
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
const pkg = JSON.parse(_fs.default.readFileSync(new URL('../package.json', require('url').pathToFileURL(__filename).toString())));
|
|
10
|
-
describe('index', () => {
|
|
11
|
-
test('get library version', () => {
|
|
12
|
-
const result = (0, _.getVersion)();
|
|
13
|
-
expect(result).toEqual(`v${pkg.version}`);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=index.test.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _index = require("../index");
|
|
4
|
-
|
|
5
|
-
describe('AuthenticationOps', () => {
|
|
6
|
-
test('getTokens() 1: ', async () => {
|
|
7
|
-
_index.state.default.session.setTenant(process.env.FRODO_HOST);
|
|
8
|
-
|
|
9
|
-
_index.state.default.session.setRealm('alpha');
|
|
10
|
-
|
|
11
|
-
_index.state.default.session.setUsername(process.env.FRODO_USER);
|
|
12
|
-
|
|
13
|
-
_index.state.default.session.setPassword(process.env.FRODO_PASSWORD);
|
|
14
|
-
|
|
15
|
-
await _index.Authenticate.getTokens();
|
|
16
|
-
expect(_index.state.default.session.getCookieName()).toBeTruthy();
|
|
17
|
-
expect(_index.state.default.session.getCookieValue()).toBeTruthy();
|
|
18
|
-
expect(_index.state.default.session.getBearerToken()).toBeTruthy();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
//# sourceMappingURL=AuthenticateOps.test.js.map
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
4
|
-
|
|
5
|
-
var _os = require("os");
|
|
6
|
-
|
|
7
|
-
var _index = require("../index");
|
|
8
|
-
|
|
9
|
-
var _StaticStorage = require("../storage/StaticStorage");
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
describe('ConnectionProfileOps', () => {
|
|
14
|
-
test('saveConnectionProfile() 1: Create connection profiles in location from state field', async () => {
|
|
15
|
-
const host = 'https://openam-tenant-name.forgeblocks.com/am';
|
|
16
|
-
const user = 'frodo.baggins@shire.me';
|
|
17
|
-
const password = 'G@nd@lfTheW153';
|
|
18
|
-
const connectionProfilePath = `${(0, _os.homedir)()}/connections1.json`;
|
|
19
|
-
|
|
20
|
-
_index.state.default.session.setTenant(host);
|
|
21
|
-
|
|
22
|
-
_index.state.default.session.setUsername(user);
|
|
23
|
-
|
|
24
|
-
_index.state.default.session.setPassword(password);
|
|
25
|
-
|
|
26
|
-
_index.state.default.session.setConnectionProfilesPath(connectionProfilePath);
|
|
27
|
-
|
|
28
|
-
await _index.ConnectionProfile.saveConnectionProfile();
|
|
29
|
-
expect(_fs.default.existsSync(connectionProfilePath)).toBeTruthy();
|
|
30
|
-
const connections = JSON.parse(_fs.default.readFileSync(connectionProfilePath, {
|
|
31
|
-
options: 'utf8',
|
|
32
|
-
indentation: 4
|
|
33
|
-
}));
|
|
34
|
-
expect(connections).toBeTruthy();
|
|
35
|
-
expect(connections[host]).toBeTruthy();
|
|
36
|
-
expect(connections[host].username).toEqual(user);
|
|
37
|
-
expect(connections[host].encodedPassword).toBeTruthy();
|
|
38
|
-
});
|
|
39
|
-
test(`saveConnectionProfile() 2: Create connection profiles in location from env ${_StaticStorage.FRODO_MASTER_KEY_PATH_KEY}`, async () => {
|
|
40
|
-
const host = 'https://openam-tenant-name.forgeblocks.com/am';
|
|
41
|
-
const user = 'frodo.baggins@shire.me';
|
|
42
|
-
const password = 'G@nd@lfTheW153';
|
|
43
|
-
const connectionProfilePath = `${(0, _os.homedir)()}/connections2.json`; // set the hard-coded master key
|
|
44
|
-
|
|
45
|
-
process.env[_StaticStorage.FRODO_CONNECTION_PROFILES_PATH_KEY] = connectionProfilePath;
|
|
46
|
-
|
|
47
|
-
_index.state.default.session.setTenant(host);
|
|
48
|
-
|
|
49
|
-
_index.state.default.session.setUsername(user);
|
|
50
|
-
|
|
51
|
-
_index.state.default.session.setPassword(password);
|
|
52
|
-
|
|
53
|
-
_index.state.default.session.setConnectionProfilesPath(null);
|
|
54
|
-
|
|
55
|
-
await _index.ConnectionProfile.saveConnectionProfile();
|
|
56
|
-
expect(_index.ConnectionProfile.getConnectionProfilesPath()).toEqual(connectionProfilePath);
|
|
57
|
-
expect(_fs.default.existsSync(connectionProfilePath)).toBeTruthy();
|
|
58
|
-
const connections = JSON.parse(_fs.default.readFileSync(connectionProfilePath, {
|
|
59
|
-
options: 'utf8',
|
|
60
|
-
indentation: 4
|
|
61
|
-
}));
|
|
62
|
-
expect(connections).toBeTruthy();
|
|
63
|
-
expect(connections[host]).toBeTruthy();
|
|
64
|
-
expect(connections[host].username).toEqual(user);
|
|
65
|
-
expect(connections[host].encodedPassword).toBeTruthy();
|
|
66
|
-
});
|
|
67
|
-
test(`saveConnectionProfile() 3: Use Master Key from env ${_StaticStorage.FRODO_MASTER_KEY_KEY}`, async () => {
|
|
68
|
-
const host = 'https://openam-tenant-name.forgeblocks.com/am';
|
|
69
|
-
const user = 'frodo.baggins@shire.me';
|
|
70
|
-
const password = 'G@nd@lfTheW153';
|
|
71
|
-
const connectionProfilePath = `${(0, _os.homedir)()}/connections3.json`;
|
|
72
|
-
const masterKey = 'bxnQlhcU5VfyDs+BBPhRhK09yHaNtdIIk85HUMKBnqg='; // set the hard-coded master key
|
|
73
|
-
|
|
74
|
-
process.env[_StaticStorage.FRODO_MASTER_KEY_KEY] = masterKey;
|
|
75
|
-
|
|
76
|
-
_index.state.default.session.setTenant(host);
|
|
77
|
-
|
|
78
|
-
_index.state.default.session.setUsername(user);
|
|
79
|
-
|
|
80
|
-
_index.state.default.session.setPassword(password);
|
|
81
|
-
|
|
82
|
-
_index.state.default.session.setConnectionProfilesPath(connectionProfilePath);
|
|
83
|
-
|
|
84
|
-
await _index.ConnectionProfile.saveConnectionProfile();
|
|
85
|
-
expect(_fs.default.existsSync(connectionProfilePath)).toBeTruthy();
|
|
86
|
-
const connections = JSON.parse(_fs.default.readFileSync(connectionProfilePath, {
|
|
87
|
-
options: 'utf8',
|
|
88
|
-
indentation: 4
|
|
89
|
-
}));
|
|
90
|
-
expect(connections).toBeTruthy();
|
|
91
|
-
expect(connections[host]).toBeTruthy();
|
|
92
|
-
expect(connections[host].username).toEqual(user);
|
|
93
|
-
expect(connections[host].encodedPassword).toBeTruthy();
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
//# sourceMappingURL=ConnectionProfileOps.test.js.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _DataProtection = _interopRequireDefault(require("./DataProtection"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
test('DataProtection to encrypt', async () => {
|
|
8
|
-
// Note this test checks that encyption happned not that encryption is correct
|
|
9
|
-
// this test relys on other tests to proove the likelyhood of successful encryption
|
|
10
|
-
// Arrange
|
|
11
|
-
const dp = new _DataProtection.default();
|
|
12
|
-
const EXPECTED = 'aMLtCqK1b+d3d88DDKrmIV7A6pifP77IItLKX7N7/UTOPxf8YCQWHCpTrmNnM5wNXue8HllEFIS+sxXRb20oCb4HImpbQM0so5DrHIqcIlF5LYDKjvzBOz1PdlclhIuIV+Gr8M3GRbNkQxXJuUZ4th5ISLpOjM+k8bDAlnHsRx5LLlbLFnAKq8Pu9DaTYUkZABOCOjfkoTb6re1p9c7xE2pAe213';
|
|
13
|
-
const originalString = 'Go not to the Elves for counsel, for they will say both no and yes.'; // Act
|
|
14
|
-
|
|
15
|
-
const RESULT = await dp.encrypt(originalString); // Assert
|
|
16
|
-
|
|
17
|
-
expect(RESULT.length).toBe(EXPECTED.length);
|
|
18
|
-
});
|
|
19
|
-
test('DataProtection to decrypt', async () => {
|
|
20
|
-
// Arrange
|
|
21
|
-
const dp = new _DataProtection.default();
|
|
22
|
-
const originalString = 'Go not to the Elves for counsel, for they will say both no and yes.'; // Act
|
|
23
|
-
|
|
24
|
-
const encrypted = await dp.encrypt(originalString);
|
|
25
|
-
const RESULT = await dp.decrypt(encrypted); // Assert
|
|
26
|
-
|
|
27
|
-
expect(RESULT).toBe(originalString);
|
|
28
|
-
});
|
|
29
|
-
//# sourceMappingURL=DataProtection.test.js.map
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _path = require("path");
|
|
4
|
-
|
|
5
|
-
var _fs = require("fs");
|
|
6
|
-
|
|
7
|
-
var _ExportImportUtils = require("./ExportImportUtils");
|
|
8
|
-
|
|
9
|
-
// Warning! implimentation file contains non determinisitc functions which are either; not reasonable to test or imposible
|
|
10
|
-
// Cause: date based non overidable functions
|
|
11
|
-
// Not tested: getCurrentTimestamp
|
|
12
|
-
const FS_TMP_DIR = (0, _path.resolve)('.', 'test', 'fs_tmp');
|
|
13
|
-
const PATH_TO_ARTIFACT = (0, _path.resolve)(FS_TMP_DIR, 'export.json');
|
|
14
|
-
test('convertBase64TextToArray returns an array of text lines in base64 encoding', () => {
|
|
15
|
-
// Arrange
|
|
16
|
-
const originalScript = `
|
|
17
|
-
function frodo() {
|
|
18
|
-
return 'ring to mt doom';
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
21
|
-
const base64Script = Buffer.from(originalScript).toString('base64'); // Act
|
|
22
|
-
|
|
23
|
-
const result = (0, _ExportImportUtils.convertBase64TextToArray)(base64Script); // Assert
|
|
24
|
-
|
|
25
|
-
expect(result).toEqual(originalScript.split('\n'));
|
|
26
|
-
});
|
|
27
|
-
test('convertTextArrayToBase64', () => {
|
|
28
|
-
// Arrange
|
|
29
|
-
const originalArrayOfScriptLines = `
|
|
30
|
-
function frodo() {
|
|
31
|
-
return 'ring to mt doom';
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
const expected = Buffer.from(originalArrayOfScriptLines).toString('base64'); // Act
|
|
35
|
-
|
|
36
|
-
const result = (0, _ExportImportUtils.convertTextArrayToBase64)(originalArrayOfScriptLines.split('\n')); // Assert
|
|
37
|
-
|
|
38
|
-
expect(result).toEqual(expected);
|
|
39
|
-
});
|
|
40
|
-
test('validateImport should always return true', () => {
|
|
41
|
-
expect((0, _ExportImportUtils.validateImport)()).not.toBe(false);
|
|
42
|
-
}); // This function has no way to determine when its asnyc task is complete, suggest using callback or promises to allow for testing
|
|
43
|
-
|
|
44
|
-
describe.skip('file system based tests', () => {
|
|
45
|
-
afterAll(() => {
|
|
46
|
-
if ((0, _fs.existsSync)(PATH_TO_ARTIFACT)) {
|
|
47
|
-
(0, _fs.rmSync)(PATH_TO_ARTIFACT);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
test('saveToFile should save a file to specified tmp directory with expected data format', async () => {
|
|
51
|
-
// Arrange
|
|
52
|
-
const id = `id-3021`;
|
|
53
|
-
const data = [{
|
|
54
|
-
id,
|
|
55
|
-
location: 'The Shire',
|
|
56
|
-
character: 'Gandalf',
|
|
57
|
-
words: 1064
|
|
58
|
-
}];
|
|
59
|
-
const expected = {
|
|
60
|
-
lotr: {
|
|
61
|
-
'id-3021': {
|
|
62
|
-
id: 'id-3021',
|
|
63
|
-
location: 'The Shire',
|
|
64
|
-
character: 'Gandalf',
|
|
65
|
-
words: 1064
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}; // Act
|
|
69
|
-
|
|
70
|
-
(0, _ExportImportUtils.saveToFile)('lotr', data, 'id', PATH_TO_ARTIFACT);
|
|
71
|
-
const resultingJSON = JSON.parse((0, _fs.readFileSync)(PATH_TO_ARTIFACT)); // Assert
|
|
72
|
-
|
|
73
|
-
expect(resultingJSON.lotr).toEqual(expected.lotr);
|
|
74
|
-
});
|
|
75
|
-
test('saveToFile should save a file with metadata', async () => {
|
|
76
|
-
// Arrange
|
|
77
|
-
const id = `id-3021`;
|
|
78
|
-
const data = [{
|
|
79
|
-
id,
|
|
80
|
-
location: 'The Shire',
|
|
81
|
-
character: 'Gandalf',
|
|
82
|
-
words: 1064
|
|
83
|
-
}]; // Act
|
|
84
|
-
|
|
85
|
-
(0, _ExportImportUtils.saveToFile)('lotr', data, 'id', PATH_TO_ARTIFACT);
|
|
86
|
-
const resultingJSON = JSON.parse((0, _fs.readFileSync)(PATH_TO_ARTIFACT)); // Assert
|
|
87
|
-
|
|
88
|
-
expect(Object.keys(resultingJSON.meta)).toEqual(['origin', 'exportedBy', 'exportDate', 'exportTool', 'exportToolVersion']);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
test.skip('checkTargetCompatibility to be made testable', () => {
|
|
92
|
-
// Arrange
|
|
93
|
-
// Act
|
|
94
|
-
const result = (0, _ExportImportUtils.checkTargetCompatibility)(); // Assert
|
|
95
|
-
|
|
96
|
-
expect(result).toBe('not tested yet');
|
|
97
|
-
});
|
|
98
|
-
//# sourceMappingURL=ExportImportUtils.test.js.map
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { getCurrentRealmPath, getTenantURL } from './ApiUtils';
|
|
2
|
-
import sessionStorage from '../../storage/SessionStorage';
|
|
3
|
-
|
|
4
|
-
test.skip('replaceAll should be deleted because it works like native String.replaceAll', () => {
|
|
5
|
-
// Arrange
|
|
6
|
-
// Act
|
|
7
|
-
// Assert
|
|
8
|
-
expect(true).toBe(false);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('getCurrentRealmPath should prepend realmPath to specified realm', () => {
|
|
12
|
-
// Arrange
|
|
13
|
-
const REALM_PATH = 'alpha';
|
|
14
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
15
|
-
// Act
|
|
16
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
17
|
-
// Assert
|
|
18
|
-
expect(testString).toBe('/realms/root/realms/alpha');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('getCurrentRealmPath should prepend realmPath to specified realm with leading slash', () => {
|
|
22
|
-
// Arrange
|
|
23
|
-
const REALM_PATH = '/alpha';
|
|
24
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
25
|
-
// Act
|
|
26
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
27
|
-
// Assert
|
|
28
|
-
expect(testString).toBe('/realms/root/realms/alpha');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('getCurrentRealmPath "/" should resolve to root', () => {
|
|
32
|
-
// Arrange
|
|
33
|
-
const REALM_PATH = '/';
|
|
34
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
35
|
-
// Act
|
|
36
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
37
|
-
// Assert
|
|
38
|
-
expect(testString).toBe('/realms/root');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('getCurrentRealmPath should not handle multiple leading slash', () => {
|
|
42
|
-
// Arrange
|
|
43
|
-
const REALM_PATH = '//alpha';
|
|
44
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
45
|
-
// Act
|
|
46
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
47
|
-
// Assert
|
|
48
|
-
expect(testString).toBe('/realms/root/realms//alpha');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('getCurrentRealmPath should not handle nested depth realms', () => {
|
|
52
|
-
// Arrange
|
|
53
|
-
const REALM_PATH = '/alpha/erm';
|
|
54
|
-
sessionStorage.session.setItem('realm', REALM_PATH);
|
|
55
|
-
// Act
|
|
56
|
-
const testString = getCurrentRealmPath(REALM_PATH);
|
|
57
|
-
// Assert
|
|
58
|
-
expect(testString).toBe('/realms/root/realms/alpha/erm');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('getTenantURL should parse the https protocol and the hostname', () => {
|
|
62
|
-
// Arrange
|
|
63
|
-
const URL_WITH_TENANT =
|
|
64
|
-
'https://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';
|
|
65
|
-
|
|
66
|
-
// Act
|
|
67
|
-
const parsed = getTenantURL(URL_WITH_TENANT);
|
|
68
|
-
|
|
69
|
-
// Assert
|
|
70
|
-
expect(parsed).toBe('https://example.frodo.com');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test('getTenantURL should not validate protocol', () => {
|
|
74
|
-
// Arrange
|
|
75
|
-
const URL_WITH_TENANT =
|
|
76
|
-
'ftp://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';
|
|
77
|
-
// Act
|
|
78
|
-
const parsed = getTenantURL(URL_WITH_TENANT);
|
|
79
|
-
// Assert
|
|
80
|
-
expect(parsed).toBe('ftp://example.frodo.com');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('getTenantURL Invalid URL should throw', () => {
|
|
84
|
-
// Arrange
|
|
85
|
-
const URL_WITH_TENANT =
|
|
86
|
-
'//:example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';
|
|
87
|
-
// Act
|
|
88
|
-
const trap = () => {
|
|
89
|
-
getTenantURL(URL_WITH_TENANT);
|
|
90
|
-
};
|
|
91
|
-
// Assert
|
|
92
|
-
expect(trap).toThrow('Invalid URL');
|
|
93
|
-
});
|
package/src/index.test.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { getVersion } from '.';
|
|
3
|
-
|
|
4
|
-
const pkg = JSON.parse(
|
|
5
|
-
fs.readFileSync(new URL('../package.json', import.meta.url))
|
|
6
|
-
);
|
|
7
|
-
|
|
8
|
-
describe('index', () => {
|
|
9
|
-
test('get library version', () => {
|
|
10
|
-
const result = getVersion();
|
|
11
|
-
expect(result).toEqual(`v${pkg.version}`);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Authenticate, state } from '../index';
|
|
2
|
-
|
|
3
|
-
describe('AuthenticationOps', () => {
|
|
4
|
-
test('getTokens() 1: ', async () => {
|
|
5
|
-
state.default.session.setTenant(process.env.FRODO_HOST);
|
|
6
|
-
state.default.session.setRealm('alpha');
|
|
7
|
-
state.default.session.setUsername(process.env.FRODO_USER);
|
|
8
|
-
state.default.session.setPassword(process.env.FRODO_PASSWORD);
|
|
9
|
-
await Authenticate.getTokens();
|
|
10
|
-
expect(state.default.session.getCookieName()).toBeTruthy();
|
|
11
|
-
expect(state.default.session.getCookieValue()).toBeTruthy();
|
|
12
|
-
expect(state.default.session.getBearerToken()).toBeTruthy();
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { homedir } from 'os';
|
|
3
|
-
import { ConnectionProfile, state } from '../index';
|
|
4
|
-
import {
|
|
5
|
-
FRODO_CONNECTION_PROFILES_PATH_KEY,
|
|
6
|
-
FRODO_MASTER_KEY_PATH_KEY,
|
|
7
|
-
FRODO_MASTER_KEY_KEY,
|
|
8
|
-
} from '../storage/StaticStorage';
|
|
9
|
-
|
|
10
|
-
describe('ConnectionProfileOps', () => {
|
|
11
|
-
test('saveConnectionProfile() 1: Create connection profiles in location from state field', async () => {
|
|
12
|
-
const host = 'https://openam-tenant-name.forgeblocks.com/am';
|
|
13
|
-
const user = 'frodo.baggins@shire.me';
|
|
14
|
-
const password = 'G@nd@lfTheW153';
|
|
15
|
-
const connectionProfilePath = `${homedir()}/connections1.json`;
|
|
16
|
-
|
|
17
|
-
state.default.session.setTenant(host);
|
|
18
|
-
state.default.session.setUsername(user);
|
|
19
|
-
state.default.session.setPassword(password);
|
|
20
|
-
state.default.session.setConnectionProfilesPath(connectionProfilePath);
|
|
21
|
-
await ConnectionProfile.saveConnectionProfile();
|
|
22
|
-
expect(fs.existsSync(connectionProfilePath)).toBeTruthy();
|
|
23
|
-
const connections = JSON.parse(
|
|
24
|
-
fs.readFileSync(connectionProfilePath, {
|
|
25
|
-
options: 'utf8',
|
|
26
|
-
indentation: 4,
|
|
27
|
-
})
|
|
28
|
-
);
|
|
29
|
-
expect(connections).toBeTruthy();
|
|
30
|
-
expect(connections[host]).toBeTruthy();
|
|
31
|
-
expect(connections[host].username).toEqual(user);
|
|
32
|
-
expect(connections[host].encodedPassword).toBeTruthy();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test(`saveConnectionProfile() 2: Create connection profiles in location from env ${FRODO_MASTER_KEY_PATH_KEY}`, async () => {
|
|
36
|
-
const host = 'https://openam-tenant-name.forgeblocks.com/am';
|
|
37
|
-
const user = 'frodo.baggins@shire.me';
|
|
38
|
-
const password = 'G@nd@lfTheW153';
|
|
39
|
-
const connectionProfilePath = `${homedir()}/connections2.json`;
|
|
40
|
-
// set the hard-coded master key
|
|
41
|
-
process.env[FRODO_CONNECTION_PROFILES_PATH_KEY] = connectionProfilePath;
|
|
42
|
-
|
|
43
|
-
state.default.session.setTenant(host);
|
|
44
|
-
state.default.session.setUsername(user);
|
|
45
|
-
state.default.session.setPassword(password);
|
|
46
|
-
state.default.session.setConnectionProfilesPath(null);
|
|
47
|
-
await ConnectionProfile.saveConnectionProfile();
|
|
48
|
-
expect(ConnectionProfile.getConnectionProfilesPath()).toEqual(
|
|
49
|
-
connectionProfilePath
|
|
50
|
-
);
|
|
51
|
-
expect(fs.existsSync(connectionProfilePath)).toBeTruthy();
|
|
52
|
-
const connections = JSON.parse(
|
|
53
|
-
fs.readFileSync(connectionProfilePath, {
|
|
54
|
-
options: 'utf8',
|
|
55
|
-
indentation: 4,
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
expect(connections).toBeTruthy();
|
|
59
|
-
expect(connections[host]).toBeTruthy();
|
|
60
|
-
expect(connections[host].username).toEqual(user);
|
|
61
|
-
expect(connections[host].encodedPassword).toBeTruthy();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test(`saveConnectionProfile() 3: Use Master Key from env ${FRODO_MASTER_KEY_KEY}`, async () => {
|
|
65
|
-
const host = 'https://openam-tenant-name.forgeblocks.com/am';
|
|
66
|
-
const user = 'frodo.baggins@shire.me';
|
|
67
|
-
const password = 'G@nd@lfTheW153';
|
|
68
|
-
const connectionProfilePath = `${homedir()}/connections3.json`;
|
|
69
|
-
const masterKey = 'bxnQlhcU5VfyDs+BBPhRhK09yHaNtdIIk85HUMKBnqg=';
|
|
70
|
-
// set the hard-coded master key
|
|
71
|
-
process.env[FRODO_MASTER_KEY_KEY] = masterKey;
|
|
72
|
-
|
|
73
|
-
state.default.session.setTenant(host);
|
|
74
|
-
state.default.session.setUsername(user);
|
|
75
|
-
state.default.session.setPassword(password);
|
|
76
|
-
state.default.session.setConnectionProfilesPath(connectionProfilePath);
|
|
77
|
-
await ConnectionProfile.saveConnectionProfile();
|
|
78
|
-
expect(fs.existsSync(connectionProfilePath)).toBeTruthy();
|
|
79
|
-
const connections = JSON.parse(
|
|
80
|
-
fs.readFileSync(connectionProfilePath, {
|
|
81
|
-
options: 'utf8',
|
|
82
|
-
indentation: 4,
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
expect(connections).toBeTruthy();
|
|
86
|
-
expect(connections[host]).toBeTruthy();
|
|
87
|
-
expect(connections[host].username).toEqual(user);
|
|
88
|
-
expect(connections[host].encodedPassword).toBeTruthy();
|
|
89
|
-
});
|
|
90
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import DataProtection from './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 =
|
|
9
|
-
'aMLtCqK1b+d3d88DDKrmIV7A6pifP77IItLKX7N7/UTOPxf8YCQWHCpTrmNnM5wNXue8HllEFIS+sxXRb20oCb4HImpbQM0so5DrHIqcIlF5LYDKjvzBOz1PdlclhIuIV+Gr8M3GRbNkQxXJuUZ4th5ISLpOjM+k8bDAlnHsRx5LLlbLFnAKq8Pu9DaTYUkZABOCOjfkoTb6re1p9c7xE2pAe213';
|
|
10
|
-
const originalString =
|
|
11
|
-
'Go not to the Elves for counsel, for they will say both no and yes.';
|
|
12
|
-
// Act
|
|
13
|
-
const RESULT = await dp.encrypt(originalString);
|
|
14
|
-
// Assert
|
|
15
|
-
expect(RESULT.length).toBe(EXPECTED.length);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('DataProtection to decrypt', async () => {
|
|
19
|
-
// Arrange
|
|
20
|
-
const dp = new DataProtection();
|
|
21
|
-
const originalString =
|
|
22
|
-
'Go not to the Elves for counsel, for they will say both no and yes.';
|
|
23
|
-
// Act
|
|
24
|
-
const encrypted = await dp.encrypt(originalString);
|
|
25
|
-
const RESULT = await dp.decrypt(encrypted);
|
|
26
|
-
// Assert
|
|
27
|
-
expect(RESULT).toBe(originalString);
|
|
28
|
-
});
|