@itentialopensource/adapter-winston_syslog 1.0.1 → 1.1.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/BROKER.md +199 -0
- package/CALLS.md +162 -0
- package/CHANGELOG.md +8 -1
- package/CODE_OF_CONDUCT.md +43 -0
- package/CONTRIBUTING.md +13 -0
- package/ENHANCE.md +69 -0
- package/LICENSE +1 -1
- package/PROPERTIES.md +641 -0
- package/README.md +89 -28
- package/SUMMARY.md +9 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +566 -0
- package/adapterBase.js +549 -879
- package/changelogs/CHANGELOG.md +9 -0
- package/metadata.json +49 -0
- package/package.json +26 -25
- package/pronghorn.json +981 -0
- package/propertiesSchema.json +506 -51
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +8 -8
- package/report/updateReport1691508888201.json +120 -0
- package/report/updateReport1692202203193.json +120 -0
- package/report/updateReport1692203305042.json +120 -0
- package/report/updateReport1694469210573.json +120 -0
- package/report/updateReport1698422912292.json +120 -0
- package/sampleProperties.json +210 -12
- package/test/integration/adapterTestBasicGet.js +83 -0
- package/test/integration/adapterTestConnectivity.js +142 -0
- package/test/integration/adapterTestIntegration.js +180 -15
- package/test/unit/adapterBaseTestUnit.js +388 -313
- package/test/unit/adapterTestUnit.js +465 -106
- package/utils/adapterInfo.js +1 -1
- package/utils/addAuth.js +1 -1
- package/utils/artifactize.js +1 -1
- package/utils/checkMigrate.js +1 -1
- package/utils/entitiesToDB.js +2 -2
- package/utils/findPath.js +1 -1
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +13 -15
- package/utils/packModificationScript.js +1 -1
- package/utils/pre-commit.sh +2 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +89 -34
- package/utils/tbUtils.js +41 -21
- package/utils/testRunner.js +1 -1
- package/utils/troubleshootingAdapter.js +9 -6
- package/workflows/README.md +0 -3
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
// include required items for testing & logging
|
|
10
10
|
const assert = require('assert');
|
|
11
11
|
const fs = require('fs');
|
|
12
|
-
const mocha = require('mocha');
|
|
13
12
|
const path = require('path');
|
|
13
|
+
const util = require('util');
|
|
14
|
+
const mocha = require('mocha');
|
|
14
15
|
const winston = require('winston');
|
|
15
16
|
const { expect } = require('chai');
|
|
16
17
|
const { use } = require('chai');
|
|
17
18
|
const td = require('testdouble');
|
|
18
|
-
const util = require('util');
|
|
19
19
|
|
|
20
20
|
const anything = td.matchers.anything();
|
|
21
21
|
|
|
@@ -36,11 +36,11 @@ const samProps = require(`${adaptdir}/sampleProperties.json`).properties;
|
|
|
36
36
|
// these variables can be changed to run in integrated mode so easier to set them here
|
|
37
37
|
// always check these in with bogus data!!!
|
|
38
38
|
samProps.stub = true;
|
|
39
|
-
samProps.host = '
|
|
39
|
+
samProps.host = 'replace.hostorip.here';
|
|
40
40
|
samProps.authentication.username = 'username';
|
|
41
41
|
samProps.authentication.password = 'password';
|
|
42
42
|
samProps.protocol = 'http';
|
|
43
|
-
samProps.port =
|
|
43
|
+
samProps.port = 80;
|
|
44
44
|
samProps.ssl.enabled = false;
|
|
45
45
|
samProps.ssl.accept_invalid_cert = false;
|
|
46
46
|
if (samProps.request.attempt_timeout < 30000) {
|
|
@@ -57,7 +57,7 @@ global.pronghornProps = {
|
|
|
57
57
|
},
|
|
58
58
|
adapterProps: {
|
|
59
59
|
adapters: [{
|
|
60
|
-
id: 'Test-
|
|
60
|
+
id: 'Test-winston_syslog',
|
|
61
61
|
type: 'WinstonSyslog',
|
|
62
62
|
properties: samProps
|
|
63
63
|
}]
|
|
@@ -249,7 +249,8 @@ describe('[integration] WinstonSyslog Adapter Test', () => {
|
|
|
249
249
|
state.passed = true;
|
|
250
250
|
|
|
251
251
|
mocha.afterEach(function x() {
|
|
252
|
-
state.passed = state.passed
|
|
252
|
+
state.passed = state.passed
|
|
253
|
+
&& (this.currentTest.state === 'passed');
|
|
253
254
|
});
|
|
254
255
|
mocha.beforeEach(function x() {
|
|
255
256
|
if (!state.passed) {
|
|
@@ -267,8 +268,7 @@ describe('[integration] WinstonSyslog Adapter Test', () => {
|
|
|
267
268
|
const checkId = global.pronghornProps.adapterProps.adapters[0].id;
|
|
268
269
|
assert.equal(checkId, a.id);
|
|
269
270
|
assert.notEqual(null, a.allProps);
|
|
270
|
-
const check = global.pronghornProps.adapterProps.adapters[0].properties
|
|
271
|
-
.healthcheck.type;
|
|
271
|
+
const check = global.pronghornProps.adapterProps.adapters[0].properties.healthcheck.type;
|
|
272
272
|
assert.equal(check, a.healthcheckType);
|
|
273
273
|
done();
|
|
274
274
|
} catch (error) {
|
|
@@ -296,16 +296,181 @@ describe('[integration] WinstonSyslog Adapter Test', () => {
|
|
|
296
296
|
done(error);
|
|
297
297
|
}
|
|
298
298
|
});
|
|
299
|
+
it('should get connected - startup healthcheck', (done) => {
|
|
300
|
+
try {
|
|
301
|
+
a.healthcheckType = 'startup';
|
|
302
|
+
a.connect();
|
|
303
|
+
|
|
304
|
+
try {
|
|
305
|
+
assert.equal(true, a.alive);
|
|
306
|
+
done();
|
|
307
|
+
} catch (error) {
|
|
308
|
+
log.error(`Test Failure: ${error}`);
|
|
309
|
+
done(error);
|
|
310
|
+
}
|
|
311
|
+
} catch (error) {
|
|
312
|
+
log.error(`Adapter Exception: ${error}`);
|
|
313
|
+
done(error);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
describe('#healthCheck', () => {
|
|
319
|
+
it('should be healthy', (done) => {
|
|
320
|
+
try {
|
|
321
|
+
a.healthCheck(null, (data) => {
|
|
322
|
+
try {
|
|
323
|
+
assert.equal(true, a.healthy);
|
|
324
|
+
saveMockData('system', 'healthcheck', 'default', data);
|
|
325
|
+
done();
|
|
326
|
+
} catch (err) {
|
|
327
|
+
log.error(`Test Failure: ${err}`);
|
|
328
|
+
done(err);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
} catch (error) {
|
|
332
|
+
log.error(`Adapter Exception: ${error}`);
|
|
333
|
+
done(error);
|
|
334
|
+
}
|
|
335
|
+
}).timeout(attemptTimeout);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// broker tests
|
|
339
|
+
describe('#getDevicesFiltered - errors', () => {
|
|
340
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
341
|
+
try {
|
|
342
|
+
const opts = {
|
|
343
|
+
filter: {
|
|
344
|
+
name: 'deviceName'
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
a.getDevicesFiltered(opts, (data, error) => {
|
|
348
|
+
try {
|
|
349
|
+
if (stub) {
|
|
350
|
+
if (samProps.devicebroker.getDevicesFiltered[0].handleFailure === 'ignore') {
|
|
351
|
+
assert.equal(null, error);
|
|
352
|
+
assert.notEqual(undefined, data);
|
|
353
|
+
assert.notEqual(null, data);
|
|
354
|
+
assert.equal(0, data.total);
|
|
355
|
+
assert.equal(0, data.list.length);
|
|
356
|
+
} else {
|
|
357
|
+
const displayE = 'Error 400 received on request';
|
|
358
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-winston_syslog-connectorRest-handleEndResponse', displayE);
|
|
359
|
+
}
|
|
360
|
+
} else {
|
|
361
|
+
runCommonAsserts(data, error);
|
|
362
|
+
}
|
|
363
|
+
done();
|
|
364
|
+
} catch (err) {
|
|
365
|
+
log.error(`Test Failure: ${err}`);
|
|
366
|
+
done(err);
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
} catch (error) {
|
|
370
|
+
log.error(`Adapter Exception: ${error}`);
|
|
371
|
+
done(error);
|
|
372
|
+
}
|
|
373
|
+
}).timeout(attemptTimeout);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
describe('#iapGetDeviceCount - errors', () => {
|
|
377
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
378
|
+
try {
|
|
379
|
+
const opts = {
|
|
380
|
+
filter: {
|
|
381
|
+
name: 'deviceName'
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
a.iapGetDeviceCount((data, error) => {
|
|
385
|
+
try {
|
|
386
|
+
if (stub) {
|
|
387
|
+
if (samProps.devicebroker.getDevicesFiltered[0].handleFailure === 'ignore') {
|
|
388
|
+
assert.equal(null, error);
|
|
389
|
+
assert.notEqual(undefined, data);
|
|
390
|
+
assert.notEqual(null, data);
|
|
391
|
+
assert.equal(0, data.count);
|
|
392
|
+
} else {
|
|
393
|
+
const displayE = 'Error 400 received on request';
|
|
394
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-winston_syslog-connectorRest-handleEndResponse', displayE);
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
runCommonAsserts(data, error);
|
|
398
|
+
}
|
|
399
|
+
done();
|
|
400
|
+
} catch (err) {
|
|
401
|
+
log.error(`Test Failure: ${err}`);
|
|
402
|
+
done(err);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
} catch (error) {
|
|
406
|
+
log.error(`Adapter Exception: ${error}`);
|
|
407
|
+
done(error);
|
|
408
|
+
}
|
|
409
|
+
}).timeout(attemptTimeout);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// exposed cache tests
|
|
413
|
+
describe('#iapPopulateEntityCache - errors', () => {
|
|
414
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
415
|
+
try {
|
|
416
|
+
a.iapPopulateEntityCache('Device', (data, error) => {
|
|
417
|
+
try {
|
|
418
|
+
if (stub) {
|
|
419
|
+
assert.equal(null, data);
|
|
420
|
+
assert.notEqual(undefined, error);
|
|
421
|
+
assert.notEqual(null, error);
|
|
422
|
+
done();
|
|
423
|
+
} else {
|
|
424
|
+
assert.equal(undefined, error);
|
|
425
|
+
assert.equal('success', data[0]);
|
|
426
|
+
done();
|
|
427
|
+
}
|
|
428
|
+
} catch (err) {
|
|
429
|
+
log.error(`Test Failure: ${err}`);
|
|
430
|
+
done(err);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
} catch (error) {
|
|
434
|
+
log.error(`Adapter Exception: ${error}`);
|
|
435
|
+
done(error);
|
|
436
|
+
}
|
|
437
|
+
}).timeout(attemptTimeout);
|
|
299
438
|
});
|
|
300
439
|
|
|
440
|
+
describe('#iapRetrieveEntitiesCache - errors', () => {
|
|
441
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
442
|
+
try {
|
|
443
|
+
a.iapRetrieveEntitiesCache('Device', {}, (data, error) => {
|
|
444
|
+
try {
|
|
445
|
+
if (stub) {
|
|
446
|
+
assert.equal(null, data);
|
|
447
|
+
assert.notEqual(null, error);
|
|
448
|
+
assert.notEqual(undefined, error);
|
|
449
|
+
} else {
|
|
450
|
+
assert.equal(undefined, error);
|
|
451
|
+
assert.notEqual(null, data);
|
|
452
|
+
assert.notEqual(undefined, data);
|
|
453
|
+
}
|
|
454
|
+
done();
|
|
455
|
+
} catch (err) {
|
|
456
|
+
log.error(`Test Failure: ${err}`);
|
|
457
|
+
done(err);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
} catch (error) {
|
|
461
|
+
log.error(`Adapter Exception: ${error}`);
|
|
462
|
+
done(error);
|
|
463
|
+
}
|
|
464
|
+
}).timeout(attemptTimeout);
|
|
465
|
+
});
|
|
301
466
|
/*
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
467
|
+
-----------------------------------------------------------------------
|
|
468
|
+
-----------------------------------------------------------------------
|
|
469
|
+
*** All code above this comment will be replaced during a migration ***
|
|
470
|
+
******************* DO NOT REMOVE THIS COMMENT BLOCK ******************
|
|
471
|
+
-----------------------------------------------------------------------
|
|
472
|
+
-----------------------------------------------------------------------
|
|
473
|
+
*/
|
|
309
474
|
describe('#postLog', () => {
|
|
310
475
|
it('should work in stub mode or fully integrated', (done) => {
|
|
311
476
|
try {
|