@kumologica/sdk 3.0.27-beta2 → 3.0.27-beta4
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.
|
@@ -309,27 +309,12 @@ class TestSuiteController {
|
|
|
309
309
|
return flowFileJson.filter((node) => node.type === 'TestCase' || node.type === 'HTTPTestCase');
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if (!testCases || (testCases && testCases.length === 0)) {
|
|
319
|
-
logError(`No testcases found on flow file: ${flowFileAbsPath}`);
|
|
320
|
-
process.exit(1);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// If defined, filter the testcase that you want to test
|
|
324
|
-
if (testcase) {
|
|
325
|
-
testCases = testCases.filter(tc => tc.name.toLowerCase() === testcase.toLowerCase());
|
|
326
|
-
if (testCases && testCases.length === 0){
|
|
327
|
-
logError(`TestCase: "${testcase}" cannot be found`);
|
|
328
|
-
process.exit(1);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
|
|
312
|
+
/**
|
|
313
|
+
*
|
|
314
|
+
* @param {*} testcasesSelected - array of {id: nodeId, name: nodeName}
|
|
315
|
+
* @returns
|
|
316
|
+
*/
|
|
317
|
+
async runTestSuite(testcasesSelected) {
|
|
333
318
|
// === Starting the testSuite ===
|
|
334
319
|
this._appServer.events.emit('runtime-event', {
|
|
335
320
|
id: runtimeEvents.TEST_TESTSUITE_START,
|
|
@@ -337,7 +322,7 @@ class TestSuiteController {
|
|
|
337
322
|
});
|
|
338
323
|
|
|
339
324
|
// === Iterate over all the testCases ===
|
|
340
|
-
await this.runTestCases(
|
|
325
|
+
await this.runTestCases(testcasesSelected);
|
|
341
326
|
await this.waitForResults();
|
|
342
327
|
const errorsNum = this._testReporter.getFailedTestCases().length;
|
|
343
328
|
|
package/cli/commands/test.js
CHANGED
|
@@ -3,6 +3,7 @@ const { Select } = require('enquirer');
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const { logError } = require('./utils');
|
|
5
5
|
const path = require('path');
|
|
6
|
+
const wcmatch = require('wildcard-match');
|
|
6
7
|
|
|
7
8
|
const { AppServer } = require('@kumologica/runtime');
|
|
8
9
|
const { TestSuiteController } = require('./test-utils/TestSuiteController');
|
|
@@ -11,7 +12,7 @@ const { codegen } = require('@kumologica/builder');
|
|
|
11
12
|
const log = console.log;
|
|
12
13
|
const APP_SERVER_PORT = 1990;
|
|
13
14
|
|
|
14
|
-
async function runTest(flowFilePath,
|
|
15
|
+
async function runTest(flowFilePath, testcaseSelected, iterative) {
|
|
15
16
|
log(`\n> Starting runtime on port ${APP_SERVER_PORT}...`);
|
|
16
17
|
|
|
17
18
|
let appServer = new AppServer({
|
|
@@ -28,24 +29,31 @@ async function runTest(flowFilePath, testcase, iterative) {
|
|
|
28
29
|
await appServer.start();
|
|
29
30
|
log(`> FlowFile to be tested: ${chalk.bold(path.resolve(flowFilePath))} \n`);
|
|
30
31
|
let testSuiteController = new TestSuiteController(appServer);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
|
|
32
|
+
|
|
33
|
+
// If testcase is null, default to universal wildcard
|
|
34
|
+
testcaseSelected = testcaseSelected || "**";
|
|
35
|
+
|
|
36
|
+
// Find out all testcases available on the flow
|
|
37
|
+
let testcasesAvailable = testSuiteController.findTestCasesFromFlow(flowFilePath);
|
|
38
|
+
if (!testcasesAvailable || (testcasesAvailable && testcasesAvailable.length === 0)) {
|
|
39
|
+
logError(`No testcases found on flow file: ${flowFileAbsPath}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
};
|
|
42
|
+
let testcaseAvailableNames = testcasesAvailable.map(tc=>tc.name);
|
|
43
|
+
|
|
44
|
+
// Capture the testcase from user on iterative mode
|
|
37
45
|
if (iterative) {
|
|
38
46
|
const prompt = new Select({
|
|
39
47
|
name: 'testcase',
|
|
40
48
|
message: 'What testcase do you want to run?',
|
|
41
|
-
choices:
|
|
49
|
+
choices: [...testcaseAvailableNames, 'Run all TestCases...']
|
|
42
50
|
});
|
|
43
51
|
await prompt.run()
|
|
44
52
|
.then(tc => {
|
|
45
53
|
if (tc === 'Run all TestCases...'){
|
|
46
|
-
|
|
54
|
+
testcaseSelected = "**";
|
|
47
55
|
}else {
|
|
48
|
-
|
|
56
|
+
testcaseSelected = tc;
|
|
49
57
|
}
|
|
50
58
|
})
|
|
51
59
|
.catch(err => {
|
|
@@ -54,15 +62,31 @@ async function runTest(flowFilePath, testcase, iterative) {
|
|
|
54
62
|
});
|
|
55
63
|
}
|
|
56
64
|
|
|
65
|
+
// Filter all testcases to be part of the test suite
|
|
66
|
+
const isMatch = wcmatch(testcaseSelected);
|
|
67
|
+
let testCasesSelected = [];
|
|
68
|
+
testcasesAvailable.forEach(async tc => {
|
|
69
|
+
if (isMatch(tc.name)){
|
|
70
|
+
testCasesSelected.push({ name: tc.name, id: tc.id });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Execute the testcasesIds if any, otherwise throw an error
|
|
75
|
+
if (testCasesSelected.length === 0){
|
|
76
|
+
logError(`No matched testcases found`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
} else {
|
|
79
|
+
const errors = await testSuiteController.runTestSuite(testCasesSelected);
|
|
80
|
+
process.exit(errors > 0);
|
|
81
|
+
}
|
|
57
82
|
|
|
58
|
-
const errors = await testSuiteController.runTestSuite(testcase); // no need to wait for response
|
|
59
|
-
process.exit(errors > 0);
|
|
60
83
|
} catch (err) {
|
|
61
84
|
log(
|
|
62
85
|
chalk.red(
|
|
63
86
|
`Unexpected error occurred while starting server due to <${err.message}>`
|
|
64
87
|
)
|
|
65
88
|
);
|
|
89
|
+
console.log(err);
|
|
66
90
|
process.exit(1);
|
|
67
91
|
}
|
|
68
92
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"productName": "Kumologica Designer",
|
|
4
4
|
"copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
|
|
5
5
|
"author": "Kumologica Pty Ltd <contact@kumologica.com>",
|
|
6
|
-
"version": "3.0.27-
|
|
6
|
+
"version": "3.0.27-beta4",
|
|
7
7
|
"description": "Kumologica Designer, harnessing Serverless for your cloud integration needs",
|
|
8
8
|
"main": "src/app/main.js",
|
|
9
9
|
"files": [
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"license": "Proprietary",
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@electron/remote": "^2.0.8",
|
|
68
|
-
"@kumologica/builder": "3.0.27-
|
|
69
|
-
"@kumologica/devkit": "3.0.27-
|
|
70
|
-
"@kumologica/runtime": "3.0.27-
|
|
68
|
+
"@kumologica/builder": "3.0.27-beta4",
|
|
69
|
+
"@kumologica/devkit": "3.0.27-beta4",
|
|
70
|
+
"@kumologica/runtime": "3.0.27-beta4",
|
|
71
71
|
"adm-zip": "0.4.13",
|
|
72
72
|
"ajv": "8.10.0",
|
|
73
73
|
"aws-sdk": "2.513.0",
|
|
@@ -117,6 +117,7 @@
|
|
|
117
117
|
"tcp-port-used": "1.0.2",
|
|
118
118
|
"util": "0.12.1",
|
|
119
119
|
"when": "3.7.8",
|
|
120
|
+
"wildcard-match": "^5.1.2",
|
|
120
121
|
"ws": "7.1.1",
|
|
121
122
|
"xterm": "4.1.0",
|
|
122
123
|
"xterm-addon-fit": "0.2.1",
|
package/src/app/lib/aws/cf.js
CHANGED
|
@@ -220,10 +220,23 @@ class AWSCFTemplate {
|
|
|
220
220
|
this.handlePolicy(lambdaRole, `KLSES`, `ses:${nodes[i].operation}`, '*');
|
|
221
221
|
|
|
222
222
|
} else if (nodes[i].type === 'SSM') {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
let key;
|
|
224
|
+
if (nodes[i].operation === "GetParametersByPath") {
|
|
225
|
+
key = this.handleValue(lambda, nodes[i].Path);
|
|
226
|
+
} else {
|
|
227
|
+
key = this.handleValue(lambda, nodes[i].Key);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (key.startsWith('/')) {
|
|
231
|
+
key = key.substring(1);
|
|
232
|
+
}
|
|
233
|
+
const ssmArn = {'Fn::Sub': 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/' + key};
|
|
234
|
+
this.handlePolicy(lambdaRole, `KLSSM${new Date().valueOf()}`, `ssm:${nodes[i].operation}`, ssmArn);
|
|
226
235
|
|
|
236
|
+
if (nodes[i].operation === "GetParameter" && nodes[i].Key.startsWith("/aws/reference/secretsmanager/")) {
|
|
237
|
+
const smArn = {'Fn::Sub': 'arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:*'};
|
|
238
|
+
this.handlePolicy(lambdaRole, `KLSM${new Date().valueOf()}`, "secretsmanager:GetSecretValue", smArn);
|
|
239
|
+
}
|
|
227
240
|
} else if (nodes[i].type === 'S3') {
|
|
228
241
|
let bucketName = this.handleValue(lambda, nodes[i].Bucket);
|
|
229
242
|
const bucketArn = `arn:aws:s3:::${bucketName}/*`;
|