runner-runtime 1.0.87 → 1.0.88
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 +15 -2
- package/index.js +6 -4
- package/package.json +1 -1
- package/tmp/request.js +48 -673
package/events/api.js
CHANGED
|
@@ -1885,10 +1885,12 @@ const initRequestJson = (event, option) => {
|
|
|
1885
1885
|
|
|
1886
1886
|
// 为向上查询获取最终参数做准备,获取正确的 parent_id
|
|
1887
1887
|
if (_.includes(['sample'], event?.type)) {
|
|
1888
|
-
const sampleTargetID = _.get(getAPIFromCollection(option?.collection, _.get(event, `data.
|
|
1888
|
+
const sampleTargetID = _.get(getAPIFromCollection(option?.collection, _.get(event, `data.target_id`)), 'parent_id');
|
|
1889
|
+
// const sampleTargetID = _.get(getAPIFromCollection(option?.collection, _.get(event, `data.parent_id`)), 'target_id');
|
|
1889
1890
|
|
|
1890
1891
|
if (_.isString(sampleTargetID) && sampleTargetID) {
|
|
1891
|
-
getParentTargetIDs(option?.collection,
|
|
1892
|
+
getParentTargetIDs(option?.collection, sampleTargetID, parentIDs);
|
|
1893
|
+
// getParentTargetIDs(option?.collection, requestJson?.sampleTargetID, parentIDs);
|
|
1892
1894
|
}
|
|
1893
1895
|
} else {
|
|
1894
1896
|
getParentTargetIDs(option?.collection, _.get(event, `data.target_id`), parentIDs);
|
|
@@ -1954,6 +1956,7 @@ const initRequestJson = (event, option) => {
|
|
|
1954
1956
|
|
|
1955
1957
|
// 设置 ['auth,pre_script,test,pre_tasks,post_tasks']
|
|
1956
1958
|
let commPara = {}, envServerID = _.get(requestJson, 'server_id');
|
|
1959
|
+
|
|
1957
1960
|
_.forEach(_.reverse(parentIDs), (parent_id) => {
|
|
1958
1961
|
const request = {};
|
|
1959
1962
|
if (parent_id == "0") {
|
|
@@ -2322,6 +2325,16 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
|
|
|
2322
2325
|
}
|
|
2323
2326
|
},
|
|
2324
2327
|
|
|
2328
|
+
request: function (err, cursor, response, request, item, cookies, history) {
|
|
2329
|
+
if (_.includes(['get_parsed_request'], scene)) {
|
|
2330
|
+
callback(generateHarFromRequest(request));
|
|
2331
|
+
try {
|
|
2332
|
+
run.abort();
|
|
2333
|
+
} catch (e) { }
|
|
2334
|
+
resolve();
|
|
2335
|
+
}
|
|
2336
|
+
},
|
|
2337
|
+
|
|
2325
2338
|
responseStart: (err, cursor, response, request, item, cookies, history) => {
|
|
2326
2339
|
if (_.includes(['get_parsed_request'], scene)) {
|
|
2327
2340
|
callback(generateHarFromRequest(request));
|
package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const run = async (events, option, callback) => {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const tempEvents = _.cloneDeep(_.flatten(new Array(scene == 'auto_test' ? _.max([_.toInteger(iterationCount), 1]) : 1).fill(events))) || [];
|
|
17
|
-
const
|
|
17
|
+
// const iterationDataArr = _.flatMap(repeatArrayToLength(_.cloneDeep(iterationData), _.max([_.toInteger(iterationCount), 1])), (element) => _.times(_.size(events), () => element));
|
|
18
18
|
const eventOptions = _.pick(option, ["scene", "lang", "project", "env", "globals", "cookies", "system_configs", "custom_functions", "collection", "database_configs", "enable_sandbox", "sleep", "name", "testing_id"]);
|
|
19
19
|
|
|
20
20
|
// 初始化变量
|
|
@@ -29,11 +29,11 @@ const run = async (events, option, callback) => {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const iterationDataArrTemp = [];
|
|
33
33
|
if (scene != 'http_request') {
|
|
34
34
|
// 解析测试数据
|
|
35
35
|
const regex = /{{([^}]+)}}/g;
|
|
36
|
-
_.forEach(
|
|
36
|
+
_.forEach(_.values(_.cloneDeep(iterationData)), (obj, index) => {
|
|
37
37
|
const cloneObj = _.cloneDeep(obj);
|
|
38
38
|
if (_.isObject(obj) && !_.isEmpty(obj)) {
|
|
39
39
|
_.forEach(obj, (val, key) => {
|
|
@@ -56,10 +56,12 @@ const run = async (events, option, callback) => {
|
|
|
56
56
|
})
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
iterationDataArrTemp.push(cloneObj)
|
|
60
60
|
})
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
const iterationDataArr = _.flatMap(repeatArrayToLength(_.cloneDeep(iterationDataArrTemp), _.max([_.toInteger(iterationCount), 1])), (element) => _.times(_.size(events), () => element));
|
|
64
|
+
|
|
63
65
|
const tempVars = { environment: _.get(option, 'env.environment', {}), globals: _.get(option, 'globals', {}), iterationDataArr };
|
|
64
66
|
|
|
65
67
|
['environment', 'globals', 'iterationDataArr'].forEach((type) => {
|
package/package.json
CHANGED
package/tmp/request.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"option": {
|
|
3
3
|
"scene": "auto_test",
|
|
4
|
+
"lang": "zh-cn",
|
|
4
5
|
"globals": {},
|
|
5
6
|
"project": {
|
|
6
7
|
"request": {
|
|
@@ -68,12 +69,15 @@ module.exports = {
|
|
|
68
69
|
"name": "默认服务",
|
|
69
70
|
"sort": 1000,
|
|
70
71
|
"uri": ""
|
|
72
|
+
},
|
|
73
|
+
"4e2fc6f7d0011": {
|
|
74
|
+
"server_id": "4e2fc6f7d0011",
|
|
75
|
+
"name": "无前置URL",
|
|
76
|
+
"sort": 3000,
|
|
77
|
+
"uri": ""
|
|
71
78
|
}
|
|
72
79
|
},
|
|
73
|
-
"environment": {
|
|
74
|
-
"oooo": "gzip, deflate, br",
|
|
75
|
-
"var1": "undefined"
|
|
76
|
-
}
|
|
80
|
+
"environment": {}
|
|
77
81
|
},
|
|
78
82
|
"cookies": {
|
|
79
83
|
"switch": 1,
|
|
@@ -97,10 +101,10 @@ module.exports = {
|
|
|
97
101
|
"path": "/",
|
|
98
102
|
"secure": true,
|
|
99
103
|
"httpOnly": true,
|
|
100
|
-
"creation": "2025-06-
|
|
104
|
+
"creation": "2025-06-12T12:56:47.288Z",
|
|
101
105
|
"name": "liveCookie",
|
|
102
106
|
"cookie_id": "2f43d903d001b",
|
|
103
|
-
"expires": "Thu,
|
|
107
|
+
"expires": "Thu, 12 Jun 2025 12:58:47 GMT",
|
|
104
108
|
"project_id": "478597272401000"
|
|
105
109
|
},
|
|
106
110
|
{
|
|
@@ -111,10 +115,10 @@ module.exports = {
|
|
|
111
115
|
"path": "/",
|
|
112
116
|
"secure": true,
|
|
113
117
|
"httpOnly": true,
|
|
114
|
-
"creation": "2025-06-
|
|
118
|
+
"creation": "2025-06-12T12:56:47.288Z",
|
|
115
119
|
"name": "loseCookie",
|
|
116
120
|
"cookie_id": "2f43d903d001c",
|
|
117
|
-
"expires": "Thu,
|
|
121
|
+
"expires": "Thu, 12 Jun 2025 12:56:47 GMT",
|
|
118
122
|
"project_id": "478597272401000"
|
|
119
123
|
}
|
|
120
124
|
]
|
|
@@ -148,388 +152,69 @@ module.exports = {
|
|
|
148
152
|
"client_cert": {}
|
|
149
153
|
},
|
|
150
154
|
"custom_functions": {
|
|
151
|
-
"fn_hello": "\n// This function is generated by Apipost AI.\ntry {\n return new Date().getTime();\n} catch (error) {\n return text;\n}"
|
|
155
|
+
"fn_hello": "\n// This function is generated by Apipost AI.\ntry {\n return new Date().getTime();\n} catch (error) {\n return text;\n}",
|
|
156
|
+
"fn_cardnumber": "\n// This function is generated by Apipost AI.\n// 由于随机生成信用卡卡号需要遵循特定的发卡行规则等复杂逻辑,这里简单模拟返回一个类似信用卡卡号格式的字符串\ntry {\n let cardNumber = '';\n for (let i = 0; i < 16; i++) {\n cardNumber += Math.floor(Math.random() * 10);\n if ((i + 1) % 4 === 0 && i < 15) {\n cardNumber +='';\n }\n }\n return cardNumber;\n} catch (error) {\n return text;\n}",
|
|
157
|
+
"fn_createGH": "\n// This function is generated by Apipost AI.\ntry {\n // 随机生成后8位数字\n let lastEightDigits = '';\n for (let i = 0; i < 8; i++) {\n lastEightDigits += Math.floor(Math.random() * 10);\n }\n return '0371' + lastEightDigits;\n} catch (error) {\n return text;\n}",
|
|
158
|
+
"fn_getgh": "\n// This function is generated by Apipost AI.\ntry {\n // 随机生成后8位数字\n let lastEightDigits = '';\n for (let i = 0; i < 8; i++) {\n lastEightDigits += Math.floor(Math.random() * 10);\n }\n return '0371' + lastEightDigits;\n} catch (error) {\n return text;\n}",
|
|
159
|
+
"fn_getemail": "// This function is generated by Apipost AI.\ntry {\n const randomChars = 'abcdefghijklmnopqrstuvwxyz0123456789';\n let randomStr = '';\n for (let i = 0; i < 8; i++) {\n randomStr += randomChars.charAt(Math.floor(Math.random() * randomChars.length));\n }\n const domains = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com'];\n const randomDomainIndex = Math.floor(Math.random() * domains.length);\n return randomStr + '@' + domains[randomDomainIndex];\n} catch (error) {\n return text;\n}",
|
|
160
|
+
"fn_getmail": "// This function is generated by Apipost AI.\ntry {\n const randomChars = 'abcdefghijklmnopqrstuvwxyz0123456789';\n let randomStr = '';\n for (let i = 0; i < 8; i++) {\n randomStr += randomChars.charAt(Math.floor(Math.random() * randomChars.length));\n }\n const domains = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com'];\n const randomDomainIndex = Math.floor(Math.random() * domains.length);\n return randomStr + '@' + domains[randomDomainIndex];\n} catch (error) {\n return text;\n}"
|
|
152
161
|
},
|
|
153
162
|
"collection": [
|
|
154
163
|
{
|
|
155
|
-
"target_id": "
|
|
164
|
+
"target_id": "d34fde6bd0068",
|
|
156
165
|
"target_type": "api",
|
|
157
166
|
"parent_id": "0",
|
|
158
|
-
"name": "
|
|
167
|
+
"name": "https://go.apipost.cn",
|
|
159
168
|
"request": {
|
|
160
169
|
"auth": {
|
|
161
170
|
"type": "inherit"
|
|
162
171
|
},
|
|
163
172
|
"body": {
|
|
164
|
-
"mode": "
|
|
165
|
-
"parameter": [],
|
|
166
|
-
"raw": "{\n \"username\": \"\",\n \"password\": \"\",\n \"lastLoginAt\":\"\"\n}",
|
|
167
|
-
"raw_parameter": [],
|
|
168
|
-
"raw_schema": {
|
|
169
|
-
"type": "object"
|
|
170
|
-
},
|
|
171
|
-
"binary": null
|
|
172
|
-
},
|
|
173
|
-
"pre_tasks": [
|
|
174
|
-
{
|
|
175
|
-
"type": "customScript",
|
|
176
|
-
"enabled": 1,
|
|
177
|
-
"data": "",
|
|
178
|
-
"name": "自定义脚本",
|
|
179
|
-
"id": "3a1e79dbbff009"
|
|
180
|
-
}
|
|
181
|
-
],
|
|
182
|
-
"post_tasks": [
|
|
183
|
-
{
|
|
184
|
-
"type": "customScript",
|
|
185
|
-
"enabled": 1,
|
|
186
|
-
"data": "",
|
|
187
|
-
"name": "自定义脚本",
|
|
188
|
-
"id": "3a30e2247ff013"
|
|
189
|
-
}
|
|
190
|
-
],
|
|
191
|
-
"header": {
|
|
192
|
-
"parameter": []
|
|
193
|
-
},
|
|
194
|
-
"query": {
|
|
195
|
-
"query_add_equal": 1,
|
|
196
|
-
"parameter": []
|
|
197
|
-
},
|
|
198
|
-
"cookie": {
|
|
199
|
-
"cookie_encode": 1,
|
|
200
|
-
"parameter": []
|
|
201
|
-
},
|
|
202
|
-
"restful": {
|
|
203
|
-
"parameter": []
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
"parents": [],
|
|
207
|
-
"method": "POST",
|
|
208
|
-
"protocol": "http/1.1",
|
|
209
|
-
"url": "/api/register",
|
|
210
|
-
"pre_url": ""
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
"target_id": "3866f5e8f2a152",
|
|
214
|
-
"target_type": "api",
|
|
215
|
-
"parent_id": "0",
|
|
216
|
-
"name": "手机实名校验",
|
|
217
|
-
"request": {
|
|
218
|
-
"auth": {
|
|
219
|
-
"type": "inherit"
|
|
220
|
-
},
|
|
221
|
-
"body": {
|
|
222
|
-
"mode": "json",
|
|
173
|
+
"mode": "urlencoded",
|
|
223
174
|
"parameter": [
|
|
224
175
|
{
|
|
225
|
-
"
|
|
226
|
-
"description": "在个人中心->我的数据,接口名称上方查看",
|
|
227
|
-
"field_type": "string",
|
|
228
|
-
"is_checked": 1,
|
|
229
|
-
"key": "key",
|
|
230
|
-
"not_null": 1,
|
|
231
|
-
"value": "",
|
|
232
|
-
"content_type": "",
|
|
233
|
-
"file_name": "",
|
|
234
|
-
"file_base64": "",
|
|
235
|
-
"schema": {
|
|
236
|
-
"type": "string"
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
"param_id": "386715acf2a171",
|
|
241
|
-
"description": "姓名",
|
|
242
|
-
"field_type": "string",
|
|
243
|
-
"is_checked": 1,
|
|
244
|
-
"key": "realname",
|
|
245
|
-
"not_null": 1,
|
|
246
|
-
"value": "",
|
|
247
|
-
"content_type": "",
|
|
248
|
-
"file_name": "",
|
|
249
|
-
"file_base64": "",
|
|
250
|
-
"schema": {
|
|
251
|
-
"type": "string"
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
"param_id": "386716dbb2a174",
|
|
256
|
-
"description": "身份证号码",
|
|
257
|
-
"field_type": "string",
|
|
258
|
-
"is_checked": 1,
|
|
259
|
-
"key": "idcard",
|
|
260
|
-
"not_null": 1,
|
|
261
|
-
"value": "",
|
|
262
|
-
"content_type": "",
|
|
263
|
-
"file_name": "",
|
|
264
|
-
"file_base64": "",
|
|
265
|
-
"schema": {
|
|
266
|
-
"type": "string"
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
"param_id": "38671813b2a176",
|
|
271
|
-
"description": "手机号码",
|
|
176
|
+
"description": "用户名",
|
|
272
177
|
"field_type": "string",
|
|
273
178
|
"is_checked": 1,
|
|
274
|
-
"key": "
|
|
179
|
+
"key": "username",
|
|
180
|
+
"value": "{{username}}",
|
|
275
181
|
"not_null": 1,
|
|
276
|
-
"value": "",
|
|
277
|
-
"content_type": "",
|
|
278
|
-
"file_name": "",
|
|
279
|
-
"file_base64": "",
|
|
280
182
|
"schema": {
|
|
281
183
|
"type": "string",
|
|
282
184
|
"default": ""
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
{
|
|
286
|
-
"param_id": "386719b1f2a178",
|
|
287
|
-
"description": "是否显示手机运营商,1:显示,0:不显示(默认)",
|
|
288
|
-
"field_type": "integer",
|
|
289
|
-
"is_checked": 1,
|
|
290
|
-
"key": "type",
|
|
291
|
-
"not_null": -1,
|
|
292
|
-
"value": "",
|
|
293
|
-
"content_type": "",
|
|
294
|
-
"file_name": "",
|
|
295
|
-
"file_base64": "",
|
|
296
|
-
"schema": {
|
|
297
|
-
"type": "integer"
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
"param_id": "38671b23b2a17a",
|
|
302
|
-
"description": "是否显示聚合订单号,1:显示,0:不显示(默认)",
|
|
303
|
-
"field_type": "integer",
|
|
304
|
-
"is_checked": 1,
|
|
305
|
-
"key": "showid",
|
|
306
|
-
"not_null": -1,
|
|
307
|
-
"value": "",
|
|
308
|
-
"content_type": "",
|
|
309
|
-
"file_name": "",
|
|
310
|
-
"file_base64": "",
|
|
311
|
-
"schema": {
|
|
312
|
-
"type": "integer"
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
"param_id": "38671cc572a17c",
|
|
317
|
-
"description": "是否显示手机号归属地,1:显示,0:不显示(默认)",
|
|
318
|
-
"field_type": "integer",
|
|
319
|
-
"is_checked": 1,
|
|
320
|
-
"key": "province",
|
|
321
|
-
"not_null": -1,
|
|
322
|
-
"value": "",
|
|
323
|
-
"content_type": "",
|
|
324
|
-
"file_name": "",
|
|
325
|
-
"file_base64": "",
|
|
326
|
-
"schema": {
|
|
327
|
-
"type": "integer"
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
"param_id": "38671e0572a17e",
|
|
332
|
-
"description": "是否显示匹配详情码,1:显示,0:不显示(默认)",
|
|
333
|
-
"field_type": "integer",
|
|
334
|
-
"is_checked": 1,
|
|
335
|
-
"key": "detail",
|
|
336
|
-
"not_null": -1,
|
|
337
|
-
"value": "",
|
|
338
|
-
"content_type": "",
|
|
339
|
-
"file_name": "",
|
|
340
|
-
"file_base64": "",
|
|
341
|
-
"schema": {
|
|
342
|
-
"type": "integer"
|
|
343
|
-
}
|
|
185
|
+
},
|
|
186
|
+
"param_id": "d35865b77108c"
|
|
344
187
|
}
|
|
345
188
|
],
|
|
346
|
-
"raw": "
|
|
189
|
+
"raw": "",
|
|
347
190
|
"raw_parameter": [],
|
|
348
191
|
"raw_schema": {
|
|
349
|
-
"type": "object"
|
|
350
|
-
"required": [
|
|
351
|
-
"id"
|
|
352
|
-
],
|
|
353
|
-
"properties": {
|
|
354
|
-
"id": {
|
|
355
|
-
"type": "integer",
|
|
356
|
-
"example": 1
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
"x-schema-orders": [
|
|
360
|
-
"id"
|
|
361
|
-
]
|
|
192
|
+
"type": "object"
|
|
362
193
|
},
|
|
363
194
|
"binary": null
|
|
364
195
|
},
|
|
365
|
-
"pre_tasks": [
|
|
366
|
-
|
|
367
|
-
"type": "customScript",
|
|
368
|
-
"enabled": 1,
|
|
369
|
-
"data": "// This code is generated by [Apipost] AI.\nfunction encryptRequestParamsWithAES() {\n try {\n // 获取请求参数\n let requestParams = request.request_bodys;\n if (_.isString(requestParams)) {\n try {\n requestParams = JSON5.parse(requestParams);\n } catch (e) {\n console.warn('请求参数解析为JSON失败');\n return;\n }\n }\n // 将请求参数转换为字符串\n const paramsStr = JSON5.stringify(requestParams);\n // 使用CryptoJS进行AES加密,这里假设密钥为固定值,实际应用中应妥善处理密钥\n const encrypted = CryptoJS.AES.encrypt(paramsStr, 'Secret Passphrase');\n // 设置加密后的参数为请求体\n pm.setRequestBody(encrypted.toString());\n } catch (error) {\n console.error('加密请求参数时出错:', error);\n }\n}",
|
|
370
|
-
"name": "自定义脚本",
|
|
371
|
-
"id": "3a0094827ff006"
|
|
372
|
-
}
|
|
373
|
-
],
|
|
374
|
-
"post_tasks": [
|
|
375
|
-
{
|
|
376
|
-
"type": "customScript",
|
|
377
|
-
"enabled": 1,
|
|
378
|
-
"data": "// This code is generated by [Apipost] AI.\nfunction generateVisualizerScript() {\n try {\n const objData = pm.response.json();\n const template = `\n <style>\n .table { background-color: #FFFFFF; border-radius: 8px; }\n .table th { background-color: #F0F0F0; padding: 10px; border-bottom: 1px solid #DDDDDD; }\n .table td { padding: 10px; border-bottom: 1px solid #DDDDDD; }\n </style>\n <table class=\"table\">\n <thead>\n <tr>\n <th>字段</th>\n <th>值</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>resultcode</td>\n <td>{{resultcode}}</td>\n </tr>\n <tr>\n <td>reason</td>\n <td>{{reason}}</td>\n </tr>\n <tr>\n <td>result</td>\n <td>{{result}}</td>\n </tr>\n <tr>\n <td>error_code</td>\n <td>{{error_code}}</td>\n </tr>\n </tbody>\n </table>\n `;\n pm.visualizer.set(template, objData);\n } catch (e) {\n console.error('生成可视化脚本时出错:', e);\n }\n}\ngenerateVisualizerScript();",
|
|
379
|
-
"name": "自定义脚本",
|
|
380
|
-
"id": "39e9dc0dfff010"
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
"type": "customScript",
|
|
384
|
-
"enabled": 1,
|
|
385
|
-
"data": "// 断言响应状态码是否为200\npm.test(\"响应状态码为200\", function () {\n pm.response.to.have.status(200);\n});\n// 断言响应时间是否小于300毫秒(行业推荐平均响应时间)\npm.test(\"响应时间小于300毫秒\", function () {\n pm.expect(pm.response.responseTime).to.be.below(300);\n});\n// 断言响应体中resultcode字段是否为101\npm.test(\"响应体中resultcode字段为101\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.resultcode).to.eql(\"101\");\n});\n// 断言响应体中reason字段是否为错误的请求KEY\npm.test(\"响应体中reason字段为错误的请求KEY\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.reason).to.eql(\"错误的请求KEY\");\n});\n// 断言响应体中error_code字段是否为10001\npm.test(\"响应体中error_code字段为10001\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.error_code).to.eql(10001);\n});\n// 断言响应体是否为有效的JSON格式\npm.test(\"响应体必须是json\", function () {\n pm.response.to.be.json;\n});",
|
|
386
|
-
"name": "AI断言",
|
|
387
|
-
"id": "3a01bc577ff018"
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
"type": "customScript",
|
|
391
|
-
"enabled": 1,
|
|
392
|
-
"data": "// 断言响应状态码是否为200\npm.test(\"响应状态码为200\", function () {\n pm.response.to.have.status(200);\n});\n// 断言响应时间是否小于300毫秒(行业推荐平均响应时间)\npm.test(\"响应时间小于300毫秒\", function () {\n pm.expect(pm.response.responseTime).to.be.below(300);\n});\n// 断言响应体中的resultcode是否为101\npm.test(\"响应体中的resultcode为101\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.resultcode).to.eql(\"101\");\n});\n// 断言响应体中的reason是否为错误的请求KEY\npm.test(\"响应体中的reason为错误的请求KEY\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.reason).to.eql(\"错误的请求KEY\");\n});\n// 断言响应体中的error_code是否为10001\npm.test(\"响应体中的error_code为10001\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.error_code).to.eql(10001);\n});",
|
|
393
|
-
"name": "AI Assertion",
|
|
394
|
-
"id": "3a025d25fff008"
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
"type": "customScript",
|
|
398
|
-
"enabled": 1,
|
|
399
|
-
"data": "// 断言响应状态码是否为200,通常200表示请求成功\npm.test(\"响应状态码为200\", function () {\n pm.response.to.have.status(200);\n});\n// 断言响应时间是否小于300毫秒,300毫秒是行业推荐的平均响应时间\npm.test(\"响应时间小于300毫秒\", function () {\n pm.expect(pm.response.responseTime).to.be.below(300);\n});\n// 断言响应体中的resultcode字段是否为101\npm.test(\"响应体中的resultcode为101\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.resultcode).to.eql(\"101\");\n});\n// 断言响应体中的reason字段是否为'错误的请求KEY'\npm.test(\"响应体中的reason为错误的请求KEY\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.reason).to.eql(\"错误的请求KEY\");\n});\n// 断言响应体中的error_code字段是否为10001\npm.test(\"响应体中的error_code为10001\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.error_code).to.eql(10001);\n});",
|
|
400
|
-
"name": "AI断言",
|
|
401
|
-
"id": "3a1eabf07ff00c"
|
|
402
|
-
}
|
|
403
|
-
],
|
|
196
|
+
"pre_tasks": [],
|
|
197
|
+
"post_tasks": [],
|
|
404
198
|
"header": {
|
|
405
|
-
"parameter": [
|
|
406
|
-
{
|
|
407
|
-
"param_id": "38670379f2a15a",
|
|
408
|
-
"description": "请求内容类型",
|
|
409
|
-
"field_type": "string",
|
|
410
|
-
"is_checked": 1,
|
|
411
|
-
"key": "Content-Type",
|
|
412
|
-
"not_null": 1,
|
|
413
|
-
"value": "application/x-www-form-urlencoded",
|
|
414
|
-
"schema": {
|
|
415
|
-
"type": "string"
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
]
|
|
199
|
+
"parameter": []
|
|
419
200
|
},
|
|
420
201
|
"query": {
|
|
421
|
-
"
|
|
422
|
-
"
|
|
423
|
-
{
|
|
424
|
-
"param_id": "3867057a72a15c",
|
|
425
|
-
"description": "在个人中心->我的数据,接口名称上方查看",
|
|
426
|
-
"field_type": "string",
|
|
427
|
-
"is_checked": 1,
|
|
428
|
-
"key": "key",
|
|
429
|
-
"not_null": 1,
|
|
430
|
-
"value": "",
|
|
431
|
-
"schema": {
|
|
432
|
-
"type": "string"
|
|
433
|
-
}
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
"param_id": "386706cf72a15e",
|
|
437
|
-
"description": "姓名",
|
|
438
|
-
"field_type": "string",
|
|
439
|
-
"is_checked": 1,
|
|
440
|
-
"key": "realname",
|
|
441
|
-
"not_null": 1,
|
|
442
|
-
"value": "",
|
|
443
|
-
"schema": {
|
|
444
|
-
"type": "string"
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
"param_id": "38670830b2a160",
|
|
449
|
-
"description": "身份证号码",
|
|
450
|
-
"field_type": "string",
|
|
451
|
-
"is_checked": 1,
|
|
452
|
-
"key": "idcard",
|
|
453
|
-
"not_null": 1,
|
|
454
|
-
"value": "",
|
|
455
|
-
"schema": {
|
|
456
|
-
"type": "string"
|
|
457
|
-
}
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
"param_id": "38670975f2a162",
|
|
461
|
-
"description": "手机号码",
|
|
462
|
-
"field_type": "string",
|
|
463
|
-
"is_checked": 1,
|
|
464
|
-
"key": "mobile",
|
|
465
|
-
"not_null": 1,
|
|
466
|
-
"value": "",
|
|
467
|
-
"schema": {
|
|
468
|
-
"type": "string"
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
"param_id": "38670b59f2a164",
|
|
473
|
-
"description": "是否显示手机运营商,1:显示,0:不显示(默认)",
|
|
474
|
-
"field_type": "integer",
|
|
475
|
-
"is_checked": 1,
|
|
476
|
-
"key": "type",
|
|
477
|
-
"not_null": -1,
|
|
478
|
-
"value": "",
|
|
479
|
-
"schema": {
|
|
480
|
-
"type": "integer"
|
|
481
|
-
}
|
|
482
|
-
},
|
|
483
|
-
{
|
|
484
|
-
"param_id": "38670cfa32a166",
|
|
485
|
-
"description": "是否显示聚合订单号,1:显示,0:不显示(默认)",
|
|
486
|
-
"field_type": "integer",
|
|
487
|
-
"is_checked": 1,
|
|
488
|
-
"key": "showid",
|
|
489
|
-
"not_null": -1,
|
|
490
|
-
"value": "",
|
|
491
|
-
"schema": {
|
|
492
|
-
"type": "integer"
|
|
493
|
-
}
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
"param_id": "38670ecd72a168",
|
|
497
|
-
"description": "是否显示手机号归属地,1:显示,0:不显示(默认)",
|
|
498
|
-
"field_type": "integer",
|
|
499
|
-
"is_checked": 1,
|
|
500
|
-
"key": "province",
|
|
501
|
-
"not_null": -1,
|
|
502
|
-
"value": "",
|
|
503
|
-
"schema": {
|
|
504
|
-
"type": "integer"
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
"param_id": "38671070b2a16a",
|
|
509
|
-
"description": "是否显示匹配详情码,1:显示,0:不显示(默认)",
|
|
510
|
-
"field_type": "integer",
|
|
511
|
-
"is_checked": 1,
|
|
512
|
-
"key": "detail",
|
|
513
|
-
"not_null": -1,
|
|
514
|
-
"value": "",
|
|
515
|
-
"schema": {
|
|
516
|
-
"type": "integer"
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
]
|
|
202
|
+
"parameter": [],
|
|
203
|
+
"query_add_equal": 1
|
|
520
204
|
},
|
|
521
205
|
"cookie": {
|
|
522
|
-
"
|
|
523
|
-
"
|
|
206
|
+
"parameter": [],
|
|
207
|
+
"cookie_encode": 1
|
|
524
208
|
},
|
|
525
209
|
"restful": {
|
|
526
210
|
"parameter": []
|
|
527
|
-
}
|
|
211
|
+
},
|
|
212
|
+
"tabs_default_active_key": "query"
|
|
528
213
|
},
|
|
529
214
|
"parents": [],
|
|
530
|
-
"method": "
|
|
215
|
+
"method": "POST",
|
|
531
216
|
"protocol": "http/1.1",
|
|
532
|
-
"url": "https://
|
|
217
|
+
"url": "https://go.apipost.cn",
|
|
533
218
|
"pre_url": ""
|
|
534
219
|
}
|
|
535
220
|
],
|
|
@@ -537,338 +222,28 @@ module.exports = {
|
|
|
537
222
|
"name": "未命名测试用例",
|
|
538
223
|
"ignore_error": -1,
|
|
539
224
|
"enable_sandbox": -1,
|
|
540
|
-
"iterationCount":
|
|
225
|
+
"iterationCount": 3,
|
|
541
226
|
"sleep": 0,
|
|
542
|
-
"testing_id": "
|
|
543
|
-
"iterates_data_id": "
|
|
227
|
+
"testing_id": "d2b58cc3d0042",
|
|
228
|
+
"iterates_data_id": "d3540d6fd0073",
|
|
544
229
|
"iterationData": [
|
|
545
230
|
{
|
|
546
|
-
"
|
|
547
|
-
"a": "{{$function.fn_hello()}}",
|
|
548
|
-
"b": "{{$mockjs.idcard()}}",
|
|
549
|
-
"c": "lucy"
|
|
231
|
+
"username": "{{$mockjs.cname()}}"
|
|
550
232
|
}
|
|
551
233
|
]
|
|
552
234
|
},
|
|
553
235
|
"test_events": [
|
|
554
236
|
{
|
|
555
237
|
"type": "api",
|
|
556
|
-
"auto_sync":
|
|
557
|
-
"test_id": "
|
|
558
|
-
"event_id": "
|
|
559
|
-
"enabled": 1,
|
|
560
|
-
"data": {
|
|
561
|
-
"target_id": "38629c6b72a0d7",
|
|
562
|
-
"project_id": "478597272401000",
|
|
563
|
-
"parent_id": "0",
|
|
564
|
-
"target_type": "api",
|
|
565
|
-
"apiData": {
|
|
566
|
-
"name": "注册接口",
|
|
567
|
-
"method": "POST",
|
|
568
|
-
"protocol": "http/1.1",
|
|
569
|
-
"url": "https://go.apipost.cn/?a={{a}}",
|
|
570
|
-
"request": {
|
|
571
|
-
"auth": {
|
|
572
|
-
"type": "inherit"
|
|
573
|
-
},
|
|
574
|
-
"body": {
|
|
575
|
-
"mode": "json",
|
|
576
|
-
"parameter": [],
|
|
577
|
-
"raw": "{\n \"username\": \"\",\n \"password\": \"\",\n \"lastLoginAt\":\"\"\n}",
|
|
578
|
-
"raw_parameter": [],
|
|
579
|
-
"raw_schema": {
|
|
580
|
-
"type": "object"
|
|
581
|
-
},
|
|
582
|
-
"binary": null
|
|
583
|
-
},
|
|
584
|
-
"pre_tasks": [
|
|
585
|
-
{
|
|
586
|
-
"type": "customScript",
|
|
587
|
-
"enabled": 1,
|
|
588
|
-
"data": "",
|
|
589
|
-
"name": "自定义脚本",
|
|
590
|
-
"id": "3a1e79dbbff009"
|
|
591
|
-
}
|
|
592
|
-
],
|
|
593
|
-
"post_tasks": [
|
|
594
|
-
{
|
|
595
|
-
"type": "customScript",
|
|
596
|
-
"enabled": 1,
|
|
597
|
-
"data": "",
|
|
598
|
-
"name": "自定义脚本",
|
|
599
|
-
"id": "3a30e2247ff013"
|
|
600
|
-
}
|
|
601
|
-
],
|
|
602
|
-
"header": {
|
|
603
|
-
"parameter": []
|
|
604
|
-
},
|
|
605
|
-
"query": {
|
|
606
|
-
"query_add_equal": 1,
|
|
607
|
-
"parameter": [
|
|
608
|
-
{
|
|
609
|
-
"param_id": "41de01afd004b",
|
|
610
|
-
"field_type": "String",
|
|
611
|
-
"is_checked": 1,
|
|
612
|
-
"key": "a",
|
|
613
|
-
"not_null": 1,
|
|
614
|
-
"value": "{{a}}",
|
|
615
|
-
"description": ""
|
|
616
|
-
}
|
|
617
|
-
]
|
|
618
|
-
},
|
|
619
|
-
"cookie": {
|
|
620
|
-
"cookie_encode": 1,
|
|
621
|
-
"parameter": []
|
|
622
|
-
},
|
|
623
|
-
"restful": {
|
|
624
|
-
"parameter": []
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
},
|
|
630
|
-
{
|
|
631
|
-
"type": "api",
|
|
632
|
-
"auto_sync": false,
|
|
633
|
-
"test_id": "2f372b7bd0007",
|
|
634
|
-
"event_id": "41e136d7d006b",
|
|
238
|
+
"auto_sync": true,
|
|
239
|
+
"test_id": "d2b58cc3d0042",
|
|
240
|
+
"event_id": "d353a89bd006e",
|
|
635
241
|
"enabled": 1,
|
|
636
242
|
"data": {
|
|
637
|
-
"target_id": "
|
|
243
|
+
"target_id": "d34fde6bd0068",
|
|
638
244
|
"project_id": "478597272401000",
|
|
639
245
|
"parent_id": "0",
|
|
640
|
-
"target_type": "api"
|
|
641
|
-
"apiData": {
|
|
642
|
-
"name": "手机实名校验",
|
|
643
|
-
"method": "GET",
|
|
644
|
-
"protocol": "http/1.1",
|
|
645
|
-
"url": "https://v.juhe.cn/telecom/query?a={{a}}",
|
|
646
|
-
"request": {
|
|
647
|
-
"auth": {
|
|
648
|
-
"type": "inherit"
|
|
649
|
-
},
|
|
650
|
-
"body": {
|
|
651
|
-
"mode": "json",
|
|
652
|
-
"parameter": [
|
|
653
|
-
{
|
|
654
|
-
"param_id": "3867147772a16f",
|
|
655
|
-
"description": "在个人中心->我的数据,接口名称上方查看",
|
|
656
|
-
"field_type": "string",
|
|
657
|
-
"is_checked": 1,
|
|
658
|
-
"key": "key",
|
|
659
|
-
"not_null": 1,
|
|
660
|
-
"value": "",
|
|
661
|
-
"content_type": "",
|
|
662
|
-
"file_name": "",
|
|
663
|
-
"file_base64": "",
|
|
664
|
-
"schema": {
|
|
665
|
-
"type": "string"
|
|
666
|
-
}
|
|
667
|
-
},
|
|
668
|
-
{
|
|
669
|
-
"param_id": "386715acf2a171",
|
|
670
|
-
"description": "姓名",
|
|
671
|
-
"field_type": "string",
|
|
672
|
-
"is_checked": 1,
|
|
673
|
-
"key": "realname",
|
|
674
|
-
"not_null": 1,
|
|
675
|
-
"value": "",
|
|
676
|
-
"content_type": "",
|
|
677
|
-
"file_name": "",
|
|
678
|
-
"file_base64": "",
|
|
679
|
-
"schema": {
|
|
680
|
-
"type": "string"
|
|
681
|
-
}
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
"param_id": "386716dbb2a174",
|
|
685
|
-
"description": "身份证号码",
|
|
686
|
-
"field_type": "string",
|
|
687
|
-
"is_checked": 1,
|
|
688
|
-
"key": "idcard",
|
|
689
|
-
"not_null": 1,
|
|
690
|
-
"value": "",
|
|
691
|
-
"content_type": "",
|
|
692
|
-
"file_name": "",
|
|
693
|
-
"file_base64": "",
|
|
694
|
-
"schema": {
|
|
695
|
-
"type": "string"
|
|
696
|
-
}
|
|
697
|
-
},
|
|
698
|
-
{
|
|
699
|
-
"param_id": "38671813b2a176",
|
|
700
|
-
"description": "手机号码",
|
|
701
|
-
"field_type": "string",
|
|
702
|
-
"is_checked": 1,
|
|
703
|
-
"key": "mobile",
|
|
704
|
-
"not_null": 1,
|
|
705
|
-
"value": "",
|
|
706
|
-
"content_type": "",
|
|
707
|
-
"file_name": "",
|
|
708
|
-
"file_base64": "",
|
|
709
|
-
"schema": {
|
|
710
|
-
"type": "string",
|
|
711
|
-
"default": ""
|
|
712
|
-
}
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
"param_id": "386719b1f2a178",
|
|
716
|
-
"description": "是否显示手机运营商,1:显示,0:不显示(默认)",
|
|
717
|
-
"field_type": "integer",
|
|
718
|
-
"is_checked": 1,
|
|
719
|
-
"key": "type",
|
|
720
|
-
"not_null": -1,
|
|
721
|
-
"value": "",
|
|
722
|
-
"content_type": "",
|
|
723
|
-
"file_name": "",
|
|
724
|
-
"file_base64": "",
|
|
725
|
-
"schema": {
|
|
726
|
-
"type": "integer"
|
|
727
|
-
}
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
"param_id": "38671b23b2a17a",
|
|
731
|
-
"description": "是否显示聚合订单号,1:显示,0:不显示(默认)",
|
|
732
|
-
"field_type": "integer",
|
|
733
|
-
"is_checked": 1,
|
|
734
|
-
"key": "showid",
|
|
735
|
-
"not_null": -1,
|
|
736
|
-
"value": "",
|
|
737
|
-
"content_type": "",
|
|
738
|
-
"file_name": "",
|
|
739
|
-
"file_base64": "",
|
|
740
|
-
"schema": {
|
|
741
|
-
"type": "integer"
|
|
742
|
-
}
|
|
743
|
-
},
|
|
744
|
-
{
|
|
745
|
-
"param_id": "38671cc572a17c",
|
|
746
|
-
"description": "是否显示手机号归属地,1:显示,0:不显示(默认)",
|
|
747
|
-
"field_type": "integer",
|
|
748
|
-
"is_checked": 1,
|
|
749
|
-
"key": "province",
|
|
750
|
-
"not_null": -1,
|
|
751
|
-
"value": "",
|
|
752
|
-
"content_type": "",
|
|
753
|
-
"file_name": "",
|
|
754
|
-
"file_base64": "",
|
|
755
|
-
"schema": {
|
|
756
|
-
"type": "integer"
|
|
757
|
-
}
|
|
758
|
-
},
|
|
759
|
-
{
|
|
760
|
-
"param_id": "38671e0572a17e",
|
|
761
|
-
"description": "是否显示匹配详情码,1:显示,0:不显示(默认)",
|
|
762
|
-
"field_type": "integer",
|
|
763
|
-
"is_checked": 1,
|
|
764
|
-
"key": "detail",
|
|
765
|
-
"not_null": -1,
|
|
766
|
-
"value": "",
|
|
767
|
-
"content_type": "",
|
|
768
|
-
"file_name": "",
|
|
769
|
-
"file_base64": "",
|
|
770
|
-
"schema": {
|
|
771
|
-
"type": "integer"
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
],
|
|
775
|
-
"raw": "{\n \"lastLoginAt\":1\n}",
|
|
776
|
-
"raw_parameter": [],
|
|
777
|
-
"raw_schema": {
|
|
778
|
-
"type": "object",
|
|
779
|
-
"required": [
|
|
780
|
-
"id"
|
|
781
|
-
],
|
|
782
|
-
"properties": {
|
|
783
|
-
"id": {
|
|
784
|
-
"type": "integer",
|
|
785
|
-
"example": 1
|
|
786
|
-
}
|
|
787
|
-
},
|
|
788
|
-
"x-schema-orders": [
|
|
789
|
-
"id"
|
|
790
|
-
]
|
|
791
|
-
},
|
|
792
|
-
"binary": null
|
|
793
|
-
},
|
|
794
|
-
"pre_tasks": [
|
|
795
|
-
{
|
|
796
|
-
"type": "customScript",
|
|
797
|
-
"enabled": 1,
|
|
798
|
-
"data": "// This code is generated by [Apipost] AI.\nfunction encryptRequestParamsWithAES() {\n try {\n // 获取请求参数\n let requestParams = request.request_bodys;\n if (_.isString(requestParams)) {\n try {\n requestParams = JSON5.parse(requestParams);\n } catch (e) {\n console.warn('请求参数解析为JSON失败');\n return;\n }\n }\n // 将请求参数转换为字符串\n const paramsStr = JSON5.stringify(requestParams);\n // 使用CryptoJS进行AES加密,这里假设密钥为固定值,实际应用中应妥善处理密钥\n const encrypted = CryptoJS.AES.encrypt(paramsStr, 'Secret Passphrase');\n // 设置加密后的参数为请求体\n pm.setRequestBody(encrypted.toString());\n } catch (error) {\n console.error('加密请求参数时出错:', error);\n }\n}",
|
|
799
|
-
"name": "自定义脚本",
|
|
800
|
-
"id": "3a0094827ff006"
|
|
801
|
-
}
|
|
802
|
-
],
|
|
803
|
-
"post_tasks": [
|
|
804
|
-
{
|
|
805
|
-
"type": "customScript",
|
|
806
|
-
"enabled": 1,
|
|
807
|
-
"data": "// This code is generated by [Apipost] AI.\nfunction generateVisualizerScript() {\n try {\n const objData = pm.response.json();\n const template = `\n <style>\n .table { background-color: #FFFFFF; border-radius: 8px; }\n .table th { background-color: #F0F0F0; padding: 10px; border-bottom: 1px solid #DDDDDD; }\n .table td { padding: 10px; border-bottom: 1px solid #DDDDDD; }\n </style>\n <table class=\"table\">\n <thead>\n <tr>\n <th>字段</th>\n <th>值</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>resultcode</td>\n <td>{{resultcode}}</td>\n </tr>\n <tr>\n <td>reason</td>\n <td>{{reason}}</td>\n </tr>\n <tr>\n <td>result</td>\n <td>{{result}}</td>\n </tr>\n <tr>\n <td>error_code</td>\n <td>{{error_code}}</td>\n </tr>\n </tbody>\n </table>\n `;\n pm.visualizer.set(template, objData);\n } catch (e) {\n console.error('生成可视化脚本时出错:', e);\n }\n}\ngenerateVisualizerScript();",
|
|
808
|
-
"name": "自定义脚本",
|
|
809
|
-
"id": "39e9dc0dfff010"
|
|
810
|
-
},
|
|
811
|
-
{
|
|
812
|
-
"type": "customScript",
|
|
813
|
-
"enabled": 1,
|
|
814
|
-
"data": "// 断言响应状态码是否为200\npm.test(\"响应状态码为200\", function () {\n pm.response.to.have.status(200);\n});\n// 断言响应时间是否小于300毫秒(行业推荐平均响应时间)\npm.test(\"响应时间小于300毫秒\", function () {\n pm.expect(pm.response.responseTime).to.be.below(300);\n});\n// 断言响应体中resultcode字段是否为101\npm.test(\"响应体中resultcode字段为101\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.resultcode).to.eql(\"101\");\n});\n// 断言响应体中reason字段是否为错误的请求KEY\npm.test(\"响应体中reason字段为错误的请求KEY\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.reason).to.eql(\"错误的请求KEY\");\n});\n// 断言响应体中error_code字段是否为10001\npm.test(\"响应体中error_code字段为10001\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.error_code).to.eql(10001);\n});\n// 断言响应体是否为有效的JSON格式\npm.test(\"响应体必须是json\", function () {\n pm.response.to.be.json;\n});",
|
|
815
|
-
"name": "AI断言",
|
|
816
|
-
"id": "3a01bc577ff018"
|
|
817
|
-
},
|
|
818
|
-
{
|
|
819
|
-
"type": "customScript",
|
|
820
|
-
"enabled": 1,
|
|
821
|
-
"data": "// 断言响应状态码是否为200\npm.test(\"响应状态码为200\", function () {\n pm.response.to.have.status(200);\n});\n// 断言响应时间是否小于300毫秒(行业推荐平均响应时间)\npm.test(\"响应时间小于300毫秒\", function () {\n pm.expect(pm.response.responseTime).to.be.below(300);\n});\n// 断言响应体中的resultcode是否为101\npm.test(\"响应体中的resultcode为101\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.resultcode).to.eql(\"101\");\n});\n// 断言响应体中的reason是否为错误的请求KEY\npm.test(\"响应体中的reason为错误的请求KEY\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.reason).to.eql(\"错误的请求KEY\");\n});\n// 断言响应体中的error_code是否为10001\npm.test(\"响应体中的error_code为10001\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.error_code).to.eql(10001);\n});",
|
|
822
|
-
"name": "AI Assertion",
|
|
823
|
-
"id": "3a025d25fff008"
|
|
824
|
-
},
|
|
825
|
-
{
|
|
826
|
-
"type": "customScript",
|
|
827
|
-
"enabled": 1,
|
|
828
|
-
"data": "// 断言响应状态码是否为200,通常200表示请求成功\npm.test(\"响应状态码为200\", function () {\n pm.response.to.have.status(200);\n});\n// 断言响应时间是否小于300毫秒,300毫秒是行业推荐的平均响应时间\npm.test(\"响应时间小于300毫秒\", function () {\n pm.expect(pm.response.responseTime).to.be.below(300);\n});\n// 断言响应体中的resultcode字段是否为101\npm.test(\"响应体中的resultcode为101\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.resultcode).to.eql(\"101\");\n});\n// 断言响应体中的reason字段是否为'错误的请求KEY'\npm.test(\"响应体中的reason为错误的请求KEY\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.reason).to.eql(\"错误的请求KEY\");\n});\n// 断言响应体中的error_code字段是否为10001\npm.test(\"响应体中的error_code为10001\", function () {\n var jsonData = pm.response.json();\n pm.expect(jsonData.error_code).to.eql(10001);\n});",
|
|
829
|
-
"name": "AI断言",
|
|
830
|
-
"id": "3a1eabf07ff00c"
|
|
831
|
-
}
|
|
832
|
-
],
|
|
833
|
-
"header": {
|
|
834
|
-
"parameter": [
|
|
835
|
-
{
|
|
836
|
-
"param_id": "38670379f2a15a",
|
|
837
|
-
"description": "请求内容类型",
|
|
838
|
-
"field_type": "string",
|
|
839
|
-
"is_checked": 1,
|
|
840
|
-
"key": "Content-Type",
|
|
841
|
-
"not_null": 1,
|
|
842
|
-
"value": "application/x-www-form-urlencoded",
|
|
843
|
-
"schema": {
|
|
844
|
-
"type": "string"
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
]
|
|
848
|
-
},
|
|
849
|
-
"query": {
|
|
850
|
-
"query_add_equal": 1,
|
|
851
|
-
"parameter": [
|
|
852
|
-
{
|
|
853
|
-
"param_id": "3867057a72a15c",
|
|
854
|
-
"field_type": "string",
|
|
855
|
-
"is_checked": 1,
|
|
856
|
-
"key": "a",
|
|
857
|
-
"not_null": 1,
|
|
858
|
-
"value": "{{a}}",
|
|
859
|
-
"description": "在个人中心->我的数据,接口名称上方查看"
|
|
860
|
-
}
|
|
861
|
-
]
|
|
862
|
-
},
|
|
863
|
-
"cookie": {
|
|
864
|
-
"cookie_encode": 1,
|
|
865
|
-
"parameter": []
|
|
866
|
-
},
|
|
867
|
-
"restful": {
|
|
868
|
-
"parameter": []
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
246
|
+
"target_type": "api"
|
|
872
247
|
}
|
|
873
248
|
}
|
|
874
249
|
]
|