@itentialopensource/adapter-dna_center 0.5.7 → 0.6.0
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/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +169 -0
- package/CHANGELOG.md +44 -26
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +14 -14
- package/PROPERTIES.md +483 -89
- package/README.md +131 -51
- package/SUMMARY.md +2 -2
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +4 -3
- package/adapter.js +66 -394
- package/adapterBase.js +648 -165
- package/entities/.system/schemaTokenReq.json +2 -6
- package/package.json +5 -3
- package/pronghorn.json +642 -642
- package/propertiesSchema.json +62 -8
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653138367120.json +120 -0
- package/sampleProperties.json +90 -1
- package/test/integration/adapterTestBasicGet.js +1 -1
- package/test/integration/adapterTestIntegration.js +24 -107
- package/test/unit/adapterBaseTestUnit.js +4 -2
- package/test/unit/adapterTestUnit.js +32 -126
- package/utils/adapterInfo.js +206 -0
- package/utils/entitiesToDB.js +12 -57
- package/utils/pre-commit.sh +3 -0
- package/utils/tbScript.js +35 -20
- package/utils/tbUtils.js +44 -39
- package/utils/testRunner.js +16 -16
package/utils/tbUtils.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/* eslint import/no-extraneous-dependencies: warn */
|
|
4
4
|
/* eslint global-require: warn */
|
|
5
5
|
/* eslint import/no-dynamic-require: warn */
|
|
6
|
+
/* eslint-disable no-console */
|
|
6
7
|
|
|
7
8
|
const path = require('path');
|
|
8
9
|
const fs = require('fs-extra');
|
|
@@ -305,9 +306,9 @@ module.exports = {
|
|
|
305
306
|
* @param {Object} sampleProperties - './sampleProperties.json' in adapter dir
|
|
306
307
|
*/
|
|
307
308
|
createAdapter: function createAdapter(pronghornProps, profileItem, sampleProperties, adapterPronghorn) {
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
const info = JSON.parse(fs.readFileSync(
|
|
309
|
+
const iapDir = this.getIAPHome();
|
|
310
|
+
const packageFile = path.join(iapDir, 'package.json');
|
|
311
|
+
const info = JSON.parse(fs.readFileSync(packageFile));
|
|
311
312
|
const version = parseInt(info.version.split('.')[0], 10);
|
|
312
313
|
|
|
313
314
|
let adapter = {};
|
|
@@ -399,52 +400,42 @@ module.exports = {
|
|
|
399
400
|
},
|
|
400
401
|
|
|
401
402
|
/**
|
|
402
|
-
* @summary
|
|
403
|
-
*
|
|
404
|
-
* @
|
|
405
|
-
* @
|
|
403
|
+
* @summary Obtain the IAP installation directory depending on how adapter is used:
|
|
404
|
+
* by IAP, or by npm run CLI interface
|
|
405
|
+
* @returns IAP installation directory or null if adapter running without IAP
|
|
406
|
+
* @function getIAPHome
|
|
406
407
|
*/
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
408
|
+
getIAPHome: function getIAPHome() {
|
|
409
|
+
let IAPHomePath = null;
|
|
410
|
+
// check if adapter started via IAP, use path injected by core
|
|
411
|
+
if (process.env.iap_home) IAPHomePath = process.env.iap_home;
|
|
412
|
+
// check if adapter started via CLI `npm run <command>` so we have to be located under
|
|
413
|
+
// <IAP_HOME>/node_modules/@itentialopensource/<adapter_name>/ directory
|
|
414
|
+
const currentExecutionPath = this.getCurrentExecutionPath();
|
|
415
|
+
if (currentExecutionPath.indexOf('/node_modules') >= 0) {
|
|
416
|
+
[IAPHomePath] = currentExecutionPath.split('/node_modules');
|
|
413
417
|
}
|
|
418
|
+
return IAPHomePath;
|
|
414
419
|
},
|
|
415
420
|
|
|
416
421
|
/**
|
|
417
|
-
* @summary
|
|
418
|
-
*
|
|
419
|
-
* @returns
|
|
420
|
-
*
|
|
421
|
-
* @function getDirname
|
|
422
|
+
* @summary get current execution path without resolving symbolic links,
|
|
423
|
+
* use `pwd` command wihout '-P' option (resolving symlinks) https://linux.die.net/man/1/pwd
|
|
424
|
+
* @returns
|
|
425
|
+
* @function getCurrentExecutionPAth
|
|
422
426
|
*/
|
|
423
|
-
|
|
424
|
-
if (this.withinIAP(path.join(__dirname, '../../../../'))) {
|
|
425
|
-
return __dirname;
|
|
426
|
-
}
|
|
427
|
+
getCurrentExecutionPath: function getCurrentExecutionPAth() {
|
|
427
428
|
const { stdout } = this.systemSync('pwd', true);
|
|
428
429
|
return stdout.trim();
|
|
429
430
|
},
|
|
430
431
|
|
|
431
432
|
/**
|
|
432
|
-
* @summary
|
|
433
|
-
*
|
|
434
|
-
* @
|
|
435
|
-
* @function getIAPHome
|
|
433
|
+
* @summary checks if command executed from <IAP_HOME>/node_modules/@itentialopensource/<adapter_name>/ location
|
|
434
|
+
* @returns true if command executed under <IAP_HOME>/node_modules/@itentialopensource/<adapter_name>/ path
|
|
435
|
+
* @function areWeUnderIAPinstallationDirectory
|
|
436
436
|
*/
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (process.env.iap_home) return process.env.iap_home;
|
|
440
|
-
// adapter started via CLI `npm run <command>` so we have to be located under
|
|
441
|
-
// <IAP_HOME>/node_modules/@itentialopensource/<adapter>/ directory,
|
|
442
|
-
// use `pwd` command wihout option -P(resolving symlinks) https://linux.die.net/man/1/pwd
|
|
443
|
-
const { stdout } = this.systemSync('pwd', true);
|
|
444
|
-
if (stdout.indexOf('/node_modules') >= 0) {
|
|
445
|
-
return stdout.trim().split('/node_modules')[0];
|
|
446
|
-
}
|
|
447
|
-
return path.join(stdout.trim(), '../../../');
|
|
437
|
+
areWeUnderIAPinstallationDirectory: function areWeUnderIAPinstallationDirectory() {
|
|
438
|
+
return path.join(this.getCurrentExecutionPath(), '../../..') === this.getIAPHome();
|
|
448
439
|
},
|
|
449
440
|
|
|
450
441
|
/**
|
|
@@ -454,9 +445,23 @@ module.exports = {
|
|
|
454
445
|
* @param {Object} properties - pronghornProps
|
|
455
446
|
*/
|
|
456
447
|
connect: async function connect(iapDir, properties) {
|
|
457
|
-
|
|
448
|
+
let dbConnectionProperties = {};
|
|
449
|
+
if (properties.mongoProps) {
|
|
450
|
+
dbConnectionProperties = properties.mongoProps;
|
|
451
|
+
} else if (properties.mongo) {
|
|
452
|
+
if (properties.mongo.url) {
|
|
453
|
+
dbConnectionProperties.url = properties.mongo.url;
|
|
454
|
+
} else {
|
|
455
|
+
dbConnectionProperties.url = `mongodb://${properties.mongo.host}:${properties.mongo.port}`;
|
|
456
|
+
}
|
|
457
|
+
dbConnectionProperties.db = properties.mongo.database;
|
|
458
|
+
}
|
|
459
|
+
if (!dbConnectionProperties.url || !dbConnectionProperties.db) {
|
|
460
|
+
throw new Error('Mongo properties are not specified in IAP configuration!');
|
|
461
|
+
}
|
|
462
|
+
|
|
458
463
|
const { MongoDBConnection } = require(path.join(iapDir, 'node_modules/@itential/database'));
|
|
459
|
-
const connection = new MongoDBConnection(
|
|
464
|
+
const connection = new MongoDBConnection(dbConnectionProperties);
|
|
460
465
|
const database = await connection.connect(true);
|
|
461
466
|
return database;
|
|
462
467
|
}
|
package/utils/testRunner.js
CHANGED
|
@@ -47,11 +47,11 @@ function replaceTestVars(test) {
|
|
|
47
47
|
let intTest = fs.readFileSync(test, 'utf8');
|
|
48
48
|
|
|
49
49
|
// replace stub variable but check if it exists first
|
|
50
|
-
let sindex = intTest.indexOf('
|
|
50
|
+
let sindex = intTest.indexOf('samProps.stub');
|
|
51
51
|
let eindex = intTest.indexOf(';', sindex);
|
|
52
52
|
let replStr = intTest.substring(sindex, eindex + 1);
|
|
53
53
|
if (sindex > -1) {
|
|
54
|
-
intTest = intTest.replace(replStr, `
|
|
54
|
+
intTest = intTest.replace(replStr, `samProps.stub = ${stub};`);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// replace isRapidFail variable but check if it exists first
|
|
@@ -71,46 +71,46 @@ function replaceTestVars(test) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// replace host variable
|
|
74
|
-
sindex = intTest.indexOf('
|
|
74
|
+
sindex = intTest.indexOf('samProps.host');
|
|
75
75
|
eindex = intTest.indexOf(';', sindex);
|
|
76
76
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
77
|
-
intTest = intTest.replace(replStr, `
|
|
77
|
+
intTest = intTest.replace(replStr, `samProps.host = '${host}';`);
|
|
78
78
|
|
|
79
79
|
// replace username variable
|
|
80
|
-
sindex = intTest.indexOf('
|
|
80
|
+
sindex = intTest.indexOf('samProps.authentication.username');
|
|
81
81
|
eindex = intTest.indexOf(';', sindex);
|
|
82
82
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
83
|
-
intTest = intTest.replace(replStr, `
|
|
83
|
+
intTest = intTest.replace(replStr, `samProps.authentication.username = '${username}';`);
|
|
84
84
|
|
|
85
85
|
// replace password variable
|
|
86
|
-
sindex = intTest.indexOf('
|
|
86
|
+
sindex = intTest.indexOf('samProps.authentication.password');
|
|
87
87
|
eindex = intTest.indexOf(';', sindex);
|
|
88
88
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
89
|
-
intTest = intTest.replace(replStr, `
|
|
89
|
+
intTest = intTest.replace(replStr, `samProps.authentication.password = '${password}';`);
|
|
90
90
|
|
|
91
91
|
// replace protocol variable
|
|
92
|
-
sindex = intTest.indexOf('
|
|
92
|
+
sindex = intTest.indexOf('samProps.protocol');
|
|
93
93
|
eindex = intTest.indexOf(';', sindex);
|
|
94
94
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
95
|
-
intTest = intTest.replace(replStr, `
|
|
95
|
+
intTest = intTest.replace(replStr, `samProps.protocol = '${protocol}';`);
|
|
96
96
|
|
|
97
97
|
// replace port variable
|
|
98
|
-
sindex = intTest.indexOf('
|
|
98
|
+
sindex = intTest.indexOf('samProps.port');
|
|
99
99
|
eindex = intTest.indexOf(';', sindex);
|
|
100
100
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
101
|
-
intTest = intTest.replace(replStr, `
|
|
101
|
+
intTest = intTest.replace(replStr, `samProps.port = ${port};`);
|
|
102
102
|
|
|
103
103
|
// replace sslenable variable
|
|
104
|
-
sindex = intTest.indexOf('
|
|
104
|
+
sindex = intTest.indexOf('samProps.ssl.enabled');
|
|
105
105
|
eindex = intTest.indexOf(';', sindex);
|
|
106
106
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
107
|
-
intTest = intTest.replace(replStr, `
|
|
107
|
+
intTest = intTest.replace(replStr, `samProps.ssl.enabled = ${sslenable};`);
|
|
108
108
|
|
|
109
109
|
// replace sslinvalid variable
|
|
110
|
-
sindex = intTest.indexOf('
|
|
110
|
+
sindex = intTest.indexOf('samProps.ssl.accept_invalid_cert');
|
|
111
111
|
eindex = intTest.indexOf(';', sindex);
|
|
112
112
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
113
|
-
intTest = intTest.replace(replStr, `
|
|
113
|
+
intTest = intTest.replace(replStr, `samProps.ssl.accept_invalid_cert = ${sslinvalid};`);
|
|
114
114
|
|
|
115
115
|
console.log(`Updates to ${test} complete`);
|
|
116
116
|
fs.writeFileSync(test, intTest);
|