支持从响应头等对象中提取
This commit is contained in:
parent
ef724bdccb
commit
56d25dfcd8
|
@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode;
|
|||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ExtractRegex extends ExtractCommon {
|
||||
private String useHeaders;
|
||||
public ExtractRegex() {
|
||||
setType(ExtractType.REGEX);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{{$t('api_test.request.extract.description')}}
|
||||
</div>
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="4">
|
||||
<el-col :span="2">
|
||||
<el-select :disabled="isReadOnly" class="extract-item" v-model="type" :placeholder="$t('api_test.request.extract.select_type')"
|
||||
size="small">
|
||||
<el-option :label="$t('api_test.request.extract.regex')" :value="options.REGEX"/>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<el-option label="XPath" :value="options.XPATH"/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-col :span="22">
|
||||
<ms-api-extract-common :is-read-only="isReadOnly" :extract-type="type" :list="list" v-if="type" :callback="after"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-row :gutter="10" type="flex" justify="space-between" align="middle">
|
||||
<el-col :span="10">
|
||||
<el-col v-if="extractType == 'Regex'" :span="5">
|
||||
<el-select :disabled="isReadOnly" class="extract-item" v-model="common.useHeaders" :placeholder="$t('api_test.request.assertions.select_subject')" size="small">
|
||||
<el-option v-for="item in useHeadersOption" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col>
|
||||
<ms-api-variable-input :is-read-only="isReadOnly" v-model="common.variable" size="small" maxlength="60"
|
||||
@change="change" show-word-limit :placeholder="$t('api_test.variable_name')"/>
|
||||
</el-col>
|
||||
|
@ -53,7 +58,17 @@
|
|||
|
||||
data() {
|
||||
return {
|
||||
visible: false
|
||||
visible: false,
|
||||
useHeadersOption: [
|
||||
{label: 'Body',value:'false'},
|
||||
{label: 'Request Headers',value:'request_headers'},
|
||||
{label: 'Body (unescaped)', value:'unescaped'},
|
||||
{label: 'Body as a Document', value:'as_document'},
|
||||
{label: 'Response Headers', value:'true'},
|
||||
{label: 'URL', value:'URL'},
|
||||
{label: 'Response Code', value:'code'},
|
||||
{label: 'Response Message', value:'message'}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -344,6 +344,7 @@ export class ExtractCommon extends ExtractType {
|
|||
constructor(type, options) {
|
||||
super(type);
|
||||
this.variable = undefined;
|
||||
this.useHeaders = undefined;
|
||||
this.value = ""; // ${variable}
|
||||
this.expression = undefined;
|
||||
this.description = undefined;
|
||||
|
@ -562,7 +563,7 @@ class JMXGenerator {
|
|||
switch (extractCommon.type) {
|
||||
case EXTRACT_TYPE.REGEX:
|
||||
testName += " RegexExtractor";
|
||||
props.headers = "false"; // 对应jMeter body
|
||||
props.headers = extractCommon.useHeaders; // 对应jMeter body
|
||||
props.template = "$1$";
|
||||
return new RegexExtractor(testName, props);
|
||||
case EXTRACT_TYPE.JSON_PATH:
|
||||
|
|
Loading…
Reference in New Issue