runner-runtime 1.0.44 → 1.0.46

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/events/api.js CHANGED
@@ -9,7 +9,7 @@ const FileType = require("file-type"),
9
9
  tough = require("tough-cookie"),
10
10
  Buffer = require("buffer/").Buffer,
11
11
  isImage = require("is-image");
12
- const { getAPIFromCollection, smartUrlJoin, replace2RegExp, getParentTargetIDs, base64toCacheFile, getInsideVariables, getCaseInsensitive, camelCaseToSnakeCase } = require('../libs/utils'),
12
+ const { getAPIFromCollection, smartUrlJoin, replace2RegExp, getParentTargetIDs,encodeURIComponentUnique, base64toCacheFile, getInsideVariables, getCaseInsensitive, camelCaseToSnakeCase } = require('../libs/utils'),
13
13
  { generateHarFromRequest } = require('../libs/2har'),
14
14
 
15
15
  _ = require('lodash');
@@ -390,7 +390,10 @@ const convert2PostmanRequest = (request, option) => {
390
390
  }
391
391
  }
392
392
  }
393
- } catch (e) { }
393
+ } catch (e) {
394
+
395
+ console.log(e)
396
+ }
394
397
 
395
398
  // 处理body
396
399
  const body = {};
@@ -553,7 +556,7 @@ const convert2PostmanOptions = (request, option, variables) => {
553
556
  const globals = new sdk.VariableScope({
554
557
  values: globalsVariables,
555
558
  });
556
-
559
+ console.log(JSON.stringify(variables, null,2))
557
560
  const requester = {
558
561
  strictSSL: false,
559
562
  protocolVersion: requestJson?.protocol == 'http/1.1' ? 'http1' : 'http2',
@@ -1177,11 +1180,11 @@ const convert2PostmanEvent = (request, listen, option) => {
1177
1180
  }else if(_.get(assertObjectData, "data.type") == 'responseSize'){
1178
1181
  expertData = pm.response.responseSize;
1179
1182
  }else if(_.get(assertObjectData, "data.type") == 'tempVars'){
1180
- expertData = pm.variables.get(_.get(assertObjectData, "data.expression.path"));
1183
+ expertData = pm.variables.get(_.trim(_.get(assertObjectData, "data.expression.path"), '{}'));
1181
1184
  }else if(_.get(assertObjectData, "data.type") == 'envVars'){
1182
- expertData = pm.environment.get(_.get(assertObjectData, "data.expression.path"));
1185
+ expertData = pm.environment.get(_.trim(_.get(assertObjectData, "data.expression.path"), '{}'));
1183
1186
  }else if(_.get(assertObjectData, "data.type") == 'globalVars'){
1184
- expertData = pm.globals.get(_.get(assertObjectData, "data.expression.path"));
1187
+ expertData = pm.globals.get(_.trim(_.get(assertObjectData, "data.expression.path"), '{}'));
1185
1188
  }
1186
1189
 
1187
1190
  expertValue = pm.variables.replaceIn(_.get(assertObjectData, "data.expression.compareValue"));
@@ -2134,6 +2137,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2134
2137
 
2135
2138
  // script print
2136
2139
  console(cursor, level, ...args) {
2140
+ console.log({ level, args })
2137
2141
  if (_.isUndefined(_.get(eventRuntimeData, [event?.event_id, "console"]))) {
2138
2142
  _.set(eventRuntimeData, [event?.event_id, "console"], []);
2139
2143
  }
@@ -2199,7 +2203,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2199
2203
  })
2200
2204
  }
2201
2205
  }
2202
-
2206
+ console.log(String(request?.url), 111111)
2203
2207
  const requestOptions = convert2EchoRequest(request, requestJson, postmanJSON, history);
2204
2208
  _.set(eventRuntimeData, [event?.event_id, "request"], requestOptions);
2205
2209
 
@@ -2257,6 +2261,8 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2257
2261
  if (_.isUndefined(_.get(eventRuntimeData, [event?.event_id, "assertions"]))) {
2258
2262
  _.set(eventRuntimeData, [event?.event_id, "assertions"], []);
2259
2263
  }
2264
+
2265
+ console.log(assertions,`assertionsassertionsassertionsassertionsassertions`)
2260
2266
  eventRuntimeData[event?.event_id].assertions = _.unionWith(_.concat(_.get(eventRuntimeData, [event?.event_id, "assertions"]), assertions), _.isEqual);
2261
2267
  }
2262
2268
  }
@@ -2287,10 +2293,10 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2287
2293
  done(err, summary) {
2288
2294
  if (!_.includes(['get_parsed_request'], scene)) {
2289
2295
  if (!err) {
2290
- const success_assert = _.map(_.get(eventRuntimeData, [event?.event_id, "assertions"]), (item) => {
2296
+ const success_assert = _.filter(_.get(eventRuntimeData, [event?.event_id, "assertions"]), (item) => {
2291
2297
  return item?.passed === false
2292
2298
  })
2293
-
2299
+
2294
2300
  _.set(eventRuntimeData, [event?.event_id, "status"], {
2295
2301
  assert: _.get(eventRuntimeData, [event?.event_id, "assertions"], []),
2296
2302
  success_assert,
@@ -2310,7 +2316,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2310
2316
  data: _.assign(
2311
2317
  {
2312
2318
  variables: {
2313
- global: _.get(tempVars, '_globals', {}),
2319
+ globals: _.get(tempVars, '_globals', {}),
2314
2320
  environment: _.get(tempVars, 'environment', {})
2315
2321
  }
2316
2322
  },
package/events/index.js CHANGED
@@ -26,7 +26,7 @@ const events = {
26
26
  if (returnBoolean(exp, compare, value)) {
27
27
  if (_.isArray(children) && !_.isEmpty(children)) {
28
28
  const { iterationData } = option;
29
- await iterationEvent(children, _.assign(_.cloneDeep(option), { iterationData: [iterationData] }), callback, eventRuntimeData, eventResultList)
29
+ await iterationEvent(children, _.assign(_.cloneDeep(option), { iterationDataArr: [iterationData] }), callback, eventRuntimeData, eventResultList)
30
30
  }
31
31
 
32
32
  return ({
@@ -57,7 +57,7 @@ const events = {
57
57
  const { iterationData, enable_data } = data;
58
58
 
59
59
  if (_.toInteger(enable_data) > 0) {
60
- await iterationEvent(children, _.assign(_.cloneDeep(option), { iterationData }), callback, eventRuntimeData, eventResultList)
60
+ await iterationEvent(children, _.assign(_.cloneDeep(option), { iterationDataArr: iterationData }), callback, eventRuntimeData, eventResultList)
61
61
  } else {
62
62
  await iterationEvent(children, option, callback, eventRuntimeData, eventResultList)
63
63
  }
package/index.js CHANGED
@@ -77,7 +77,7 @@ const run = async (events, option, callback) => {
77
77
  {
78
78
  list: formatAutotestReportList(eventResultList),
79
79
  variables: {
80
- global: option?.enable_sandbox > 0 ? {} : _.get(tempVars, '_globals', {}),
80
+ globals: option?.enable_sandbox > 0 ? {} : _.get(tempVars, '_globals', {}),
81
81
  environment: option?.enable_sandbox > 0 ? {} : _.get(tempVars, 'environment', {})
82
82
  }
83
83
  },
package/libs/utils.js CHANGED
@@ -449,7 +449,7 @@ const formatAutotestReportList = (eventResultList) => {
449
449
  if (_.includes(['assert_visual', 'assert'], item?.type)) {
450
450
  type = 'api';
451
451
  }
452
-
452
+ console.log(item?.status?.success_assert,`item?.status?.success_assertitem?.status?.success_assertitem?.status?.success_assertitem?.status?.success_assert`)
453
453
  list.push(_.assign(
454
454
  _.pick(item?.response, ['timings', 'response_time', 'response_at', 'proxy', 'status', 'code', 'response_size']),
455
455
  _.pick(item?.request, ['url', 'method', 'name', 'target_id', 'project_id']),
@@ -534,6 +534,22 @@ const camelCaseToSnakeCase = (obj) => {
534
534
 
535
535
  return obj;
536
536
  }
537
+
538
+ const encodeURIComponentUnique = (str) =>{
539
+ if (_.startsWith(str, '{{') && _.endsWith(str, '}}')) {
540
+ return str;
541
+ } else {
542
+ try {
543
+ if (decodeURIComponent(str) == str) {
544
+ return encodeURIComponent(str);
545
+ }
546
+ return str;
547
+ } catch (e) {
548
+ return encodeURIComponent(str);
549
+ }
550
+ }
551
+ }
552
+
537
553
  module.exports = {
538
554
  atomicSleep,
539
555
  getAPIFromCollection,
@@ -549,5 +565,6 @@ module.exports = {
549
565
  variableReplace,
550
566
  // createPipeServer,
551
567
  formatAutotestReport,
568
+ encodeURIComponentUnique,
552
569
  smartUrlJoin
553
570
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runner-runtime",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "description": "runner-runtime.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tmp/request.js CHANGED
@@ -1,7 +1,6 @@
1
- module.exports =
2
- {
1
+ module.exports = {
3
2
  "option": {
4
- "scene": "http_request",
3
+ "scene": "auto_test",
5
4
  "globals": {},
6
5
  "project": {
7
6
  "request": {
@@ -55,27 +54,184 @@ module.exports =
55
54
  },
56
55
  "env": {
57
56
  "env_id": "1",
58
- "env_name": "本地环境",
57
+ "env_name": "默认环境",
59
58
  "env_pre_url": "",
60
59
  "env_pre_urls": {
61
60
  "1": {
62
- "server_id": "1",
61
+ "sort": 200,
63
62
  "name": "默认服务",
64
- "sort": 1000,
63
+ "server_id": "1",
64
+ "server_type": 1,
65
65
  "uri": ""
66
66
  },
67
67
  "default": {
68
- "server_id": "1",
68
+ "sort": 200,
69
69
  "name": "默认服务",
70
- "sort": 1000,
70
+ "server_id": "1",
71
+ "server_type": 1,
71
72
  "uri": ""
72
73
  }
73
74
  },
74
- "environment": {}
75
+ "environment": {
76
+ "ID": "222",
77
+ "key": "value"
78
+ }
75
79
  },
76
80
  "cookies": {
77
81
  "switch": 1,
78
- "data": []
82
+ "data": [
83
+ {
84
+ "key": "security_session_verify",
85
+ "value": "4560bdb4c5ddc22643bc99515ea21fcf",
86
+ "expires": "2025-04-19T14:45:34.000Z",
87
+ "path": "/",
88
+ "httpOnly": true,
89
+ "creation": "2025-04-16T06:45:35.543Z",
90
+ "name": "security_session_verify",
91
+ "cookie_id": "375d8dd3f700a",
92
+ "domain": "echo.apipost.cn",
93
+ "project_id": "1a8a2a84eb7da002"
94
+ },
95
+ {
96
+ "key": "security_session_verify",
97
+ "value": "4560bdb4c5ddc22643bc99515ea21fcf",
98
+ "expires": "2025-04-19T14:10:50.000Z",
99
+ "path": "/",
100
+ "httpOnly": true,
101
+ "creation": "2025-04-16T06:10:50.623Z",
102
+ "name": "security_session_verify",
103
+ "cookie_id": "375d8dd3f700b",
104
+ "domain": "echo.apipost.cn",
105
+ "project_id": "1a8a2a84eb7da002"
106
+ },
107
+ {
108
+ "key": "cookie-test1-folder",
109
+ "value": "B",
110
+ "expires": "Wed, 16 Apr 2025 07:45:42 GMT",
111
+ "maxAge": 3600,
112
+ "domain": "echo.apipost.cn",
113
+ "path": "/echo",
114
+ "creation": "2025-04-16T06:45:35.542Z",
115
+ "name": "cookie-test1-folder",
116
+ "cookie_id": "375d8dd3f700c",
117
+ "project_id": "1a8a2a84eb7da002"
118
+ },
119
+ {
120
+ "key": "cookie-test1",
121
+ "value": "0",
122
+ "expires": "Wed, 16 Apr 2025 07:45:42 GMT",
123
+ "maxAge": 3600,
124
+ "domain": "echo.apipost.cn",
125
+ "path": "/",
126
+ "creation": "2025-04-16T06:45:35.542Z",
127
+ "name": "cookie-test1",
128
+ "cookie_id": "375d8dd3f700d",
129
+ "project_id": "1a8a2a84eb7da002"
130
+ },
131
+ {
132
+ "key": "cookie-test2",
133
+ "value": "0",
134
+ "expires": "Wed, 16 Apr 2025 07:45:42 GMT",
135
+ "maxAge": 3600,
136
+ "domain": "echo.apipost.cn",
137
+ "path": "/",
138
+ "creation": "2025-04-16T06:45:35.542Z",
139
+ "name": "cookie-test2",
140
+ "cookie_id": "375d8dd3f700e",
141
+ "project_id": "1a8a2a84eb7da002"
142
+ },
143
+ {
144
+ "key": "cookie-test3",
145
+ "value": "%25E4%25BD%25A0%25E5%25A5%25BD",
146
+ "expires": "Wed, 16 Apr 2025 07:45:42 GMT",
147
+ "maxAge": 3600,
148
+ "domain": "echo.apipost.cn",
149
+ "path": "/",
150
+ "creation": "2025-04-16T06:45:35.542Z",
151
+ "name": "cookie-test3",
152
+ "cookie_id": "375d8dd3f700f",
153
+ "project_id": "1a8a2a84eb7da002"
154
+ },
155
+ {
156
+ "key": "cookie-test6",
157
+ "value": "deleted",
158
+ "expires": "Wed, 16 Apr 2025 06:45:42 GMT",
159
+ "maxAge": 0,
160
+ "domain": "echo.apipost.cn",
161
+ "path": "/",
162
+ "creation": "2025-04-16T06:45:35.543Z",
163
+ "name": "cookie-test6",
164
+ "cookie_id": "375d8dd3f7012",
165
+ "project_id": "1a8a2a84eb7da002"
166
+ },
167
+ {
168
+ "key": "cookie-test7",
169
+ "value": "0",
170
+ "expires": "Wed, 16 Apr 2025 06:45:42 GMT",
171
+ "maxAge": 0,
172
+ "domain": "echo.apipost.cn",
173
+ "path": "/",
174
+ "creation": "2025-04-16T06:45:35.543Z",
175
+ "name": "cookie-test7",
176
+ "cookie_id": "375d8dd3f7013",
177
+ "project_id": "1a8a2a84eb7da002"
178
+ },
179
+ {
180
+ "key": "cookie-test8",
181
+ "value": "renge%3D%3D%3B-%2F%3F",
182
+ "creation": "2025-04-16T06:45:35.543Z",
183
+ "name": "cookie-test8",
184
+ "cookie_id": "375d8dd3f7014",
185
+ "domain": "echo.apipost.cn",
186
+ "project_id": "1a8a2a84eb7da002"
187
+ },
188
+ {
189
+ "key": "httponly-cookie",
190
+ "value": "httponly-value",
191
+ "httpOnly": true,
192
+ "creation": "2025-04-16T06:45:35.543Z",
193
+ "name": "httponly-cookie",
194
+ "cookie_id": "375d8dd3f7015",
195
+ "domain": "echo.apipost.cn",
196
+ "project_id": "1a8a2a84eb7da002"
197
+ },
198
+ {
199
+ "key": "security_session_verify",
200
+ "value": "4560bdb4c5ddc22643bc99515ea21fcf",
201
+ "expires": "2025-04-19T14:10:50.000Z",
202
+ "path": "/",
203
+ "httpOnly": true,
204
+ "creation": "2025-04-16T06:10:50.626Z",
205
+ "name": "security_session_verify",
206
+ "cookie_id": "375d8dd3f7016",
207
+ "domain": "echo.apipost.cn",
208
+ "project_id": "1a8a2a84eb7da002"
209
+ },
210
+ {
211
+ "key": "cookie-test4",
212
+ "value": "%E4%BD%A0%E5%A5%BD%3D%3D%3D",
213
+ "expires": "Wed, 16 Apr 2025 07:45:42 GMT",
214
+ "maxAge": 3600,
215
+ "domain": "apipost.cn",
216
+ "path": "/",
217
+ "creation": "2025-04-16T06:45:35.542Z",
218
+ "name": "cookie-test4",
219
+ "cookie_id": "375d8dd3f7010",
220
+ "project_id": "1a8a2a84eb7da002"
221
+ },
222
+ {
223
+ "key": "cookie-test5",
224
+ "value": "nihao",
225
+ "expires": "Wed, 16 Apr 2025 07:45:42 GMT",
226
+ "maxAge": 3600,
227
+ "domain": "apipost.cn",
228
+ "path": "/",
229
+ "creation": "2025-04-16T06:45:35.542Z",
230
+ "name": "cookie-test5",
231
+ "cookie_id": "375d8dd3f7011",
232
+ "project_id": "1a8a2a84eb7da002"
233
+ }
234
+ ]
79
235
  },
80
236
  "system_configs": {
81
237
  "send_timeout": 0,
@@ -85,7 +241,7 @@ module.exports =
85
241
  "request_param_auto_json": -1,
86
242
  "proxy": {
87
243
  "type": 2,
88
- "envfirst": -1,
244
+ "envfirst": 1,
89
245
  "bypass": [],
90
246
  "protocols": [
91
247
  "http"
@@ -98,7 +254,7 @@ module.exports =
98
254
  }
99
255
  },
100
256
  "ca_cert": {
101
- "open": -1,
257
+ "open": 1,
102
258
  "path": "",
103
259
  "base64": ""
104
260
  },
@@ -107,10 +263,10 @@ module.exports =
107
263
  "custom_functions": {},
108
264
  "collection": [
109
265
  {
110
- "target_id": "35cdc50717006",
266
+ "target_id": "378a5473f704e",
111
267
  "target_type": "api",
112
268
  "parent_id": "0",
113
- "name": "新建接口",
269
+ "name": "副本",
114
270
  "request": {
115
271
  "auth": {
116
272
  "type": "inherit"
@@ -131,7 +287,20 @@ module.exports =
131
287
  "parameter": []
132
288
  },
133
289
  "query": {
134
- "parameter": [],
290
+ "parameter": [
291
+ {
292
+ "description": "",
293
+ "field_type": "string",
294
+ "is_checked": 1,
295
+ "key": "id",
296
+ "value": "{{id}}",
297
+ "not_null": 1,
298
+ "schema": {
299
+ "type": "string"
300
+ },
301
+ "param_id": "375b74ab9b006"
302
+ }
303
+ ],
135
304
  "query_add_equal": 1
136
305
  },
137
306
  "cookie": {
@@ -140,27 +309,135 @@ module.exports =
140
309
  },
141
310
  "restful": {
142
311
  "parameter": []
143
- },
144
- "tabs_default_active_key": "query"
312
+ }
145
313
  },
146
314
  "parents": [],
147
- "method": "GET",
315
+ "method": "POST",
148
316
  "protocol": "http/1.1",
149
- "url": "",
317
+ "url": "echo.apipost.cn/get.php?id={{id}}",
150
318
  "pre_url": ""
151
319
  }
152
320
  ],
153
- "database_configs": {}
321
+ "database_configs": {},
322
+ "name": "新建用例2",
323
+ "ignore_error": -1,
324
+ "enable_sandbox": -1,
325
+ "iterationCount": 1,
326
+ "sleep": 0,
327
+ "testing_id": "37896d73f7045",
328
+ "iterates_data_id": "0",
329
+ "iterationData": []
154
330
  },
155
331
  "test_events": [
156
332
  {
157
- "type": "api",
333
+ "parent_event_id": "0",
334
+ "enabled": 1,
335
+ "type": "assert_visual",
158
336
  "data": {
159
- "target_id": "35cdc50717006",
160
- "project_id": "guest",
161
- "parent_id": "0",
162
- "target_type": "api"
163
- }
337
+ "name": "可视化断言",
338
+ "data": {
339
+ "type": "envVars",
340
+ "expression": {
341
+ "compareType": "eq",
342
+ "compareValue": "222",
343
+ "path": "{{ID}}"
344
+ }
345
+ }
346
+ },
347
+ "project_id": "1a8a2a84eb7da002",
348
+ "test_id": "37896d73f7045",
349
+ "event_id": "37c37987f706e",
350
+ "sort": 0
351
+ },
352
+ {
353
+ "parent_event_id": "0",
354
+ "enabled": -1,
355
+ "type": "loop",
356
+ "data": {
357
+ "name": "循环",
358
+ "loop_type": 3,
359
+ "sleep": 0,
360
+ "loop_timeout": 0,
361
+ "loop_condition": {
362
+ "var": "{{ID}}",
363
+ "compare": "eq",
364
+ "value": "222"
365
+ },
366
+ "loop_traverse_data": {
367
+ "type": 1,
368
+ "iterationData": [],
369
+ "name": ""
370
+ }
371
+ },
372
+ "project_id": "1a8a2a84eb7da002",
373
+ "test_id": "37896d73f7045",
374
+ "event_id": "37d3975bf7079",
375
+ "sort": 2,
376
+ "children": [
377
+ {
378
+ "type": "api",
379
+ "auto_sync": false,
380
+ "test_id": "37896d73f7045",
381
+ "event_id": "378b6a33f7053",
382
+ "enabled": -1,
383
+ "data": {
384
+ "target_id": "378a5473f704e",
385
+ "project_id": "1a8a2a84eb7da002",
386
+ "parent_id": "0",
387
+ "target_type": "api",
388
+ "apiData": {
389
+ "name": "测试 副本",
390
+ "method": "POST",
391
+ "protocol": "http/1.1",
392
+ "url": "echo.apipost.cn/get.php?id={{id}}",
393
+ "request": {
394
+ "auth": {
395
+ "type": "inherit"
396
+ },
397
+ "body": {
398
+ "raw": "",
399
+ "mode": "none",
400
+ "binary": "",
401
+ "parameter": [],
402
+ "raw_schema": {
403
+ "type": "object"
404
+ },
405
+ "raw_parameter": []
406
+ },
407
+ "query": {
408
+ "parameter": [
409
+ {
410
+ "key": "id",
411
+ "value": "{{id}}",
412
+ "schema": {
413
+ "type": "string"
414
+ },
415
+ "not_null": 1,
416
+ "param_id": "375b74ab9b006",
417
+ "field_type": "string",
418
+ "is_checked": 1,
419
+ "description": ""
420
+ }
421
+ ],
422
+ "query_add_equal": 1
423
+ },
424
+ "cookie": {
425
+ "parameter": [],
426
+ "cookie_encode": 1
427
+ },
428
+ "header": {
429
+ "parameter": []
430
+ },
431
+ "restful": {
432
+ "parameter": []
433
+ },
434
+ "pre_tasks": [],
435
+ "post_tasks": []
436
+ }
437
+ }
438
+ }
439
+ }
440
+ ]
164
441
  }
165
442
  ]
166
443
  }