fix(接口测试): 接口用例在请求内容选no auth 报错

【接口用例在请求内容选no auth报错】
https://www.tapd.cn/33805590/bugtrace/bugs/view?bug_id=1133805590001008973
This commit is contained in:
wxg0103 2021-12-20 14:06:19 +08:00 committed by shiziyuan9527
parent 16af01bfee
commit b2f307ce4a

View File

@ -8,10 +8,10 @@
<el-select v-model="authConfig.verification" @change="change" <el-select v-model="authConfig.verification" @change="change"
:placeholder="$t('api_test.definition.request.verification_method')" filterable size="small"> :placeholder="$t('api_test.definition.request.verification_method')" filterable size="small">
<el-option <el-option
v-for="item in options" v-for="item in options"
:key="item.name" :key="item.name"
:label="item.name" :label="item.name"
:value="item.name"> :value="item.name">
</el-option> </el-option>
</el-select> </el-select>
@ -24,7 +24,8 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('commons.password')" prop="password" v-if=" authConfig.verification!=undefined && authConfig.verification !='No Auth'"> <el-form-item :label="$t('commons.password')" prop="password"
v-if=" authConfig.verification!=undefined && authConfig.verification !='No Auth'">
<el-input v-model="authConfig.password" :placeholder="$t('commons.password')" show-password autocomplete="off" <el-input v-model="authConfig.password" :placeholder="$t('commons.password')" show-password autocomplete="off"
maxlength="50" show-word-limit/> maxlength="50" show-word-limit/>
</el-form-item> </el-form-item>
@ -42,10 +43,10 @@
<el-select v-model="authConfig.encrypt" <el-select v-model="authConfig.encrypt"
:placeholder="$t('api_test.definition.request.verification_method')" filterable size="small"> :placeholder="$t('api_test.definition.request.verification_method')" filterable size="small">
<el-option <el-option
v-for="item in encryptOptions" v-for="item in encryptOptions"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.id"> :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -90,25 +91,28 @@ export default {
let authManager = createComponent("AuthManager"); let authManager = createComponent("AuthManager");
authManager.verification = "Basic Auth"; authManager.verification = "Basic Auth";
authManager.environment = this.request.useEnvironment; authManager.environment = this.request.useEnvironment;
if(this.request.hashTree == undefined){ if (this.request.hashTree == undefined) {
this.request.hashTree = []; this.request.hashTree = [];
} }
this.request.hashTree.push(authManager); this.request.hashTree.push(authManager);
// //
if(this.authConfig.username == undefined && this.authConfig.password == undefined){ if (this.authConfig.username == undefined && this.authConfig.password == undefined) {
this.authConfig = authManager; this.authConfig = authManager;
} }
} else { } else {
for (let index in this.request.hashTree) { if (this.request.hashTree) {
if (this.request.hashTree[index].type === "AuthManager") { for (let index in this.request.hashTree) {
this.request.hashTree.splice(index, 1); if (this.request.hashTree[index].type === "AuthManager") {
this.request.hashTree.splice(index, 1);
}
} }
} }
this.request.authManager = {}; this.request.authManager = {};
} }
this.request.authManager = this.authConfig; this.request.authManager = this.authConfig;
}, },
initData(){ initData() {
if (this.request.hashTree) { if (this.request.hashTree) {
for (let index in this.request.hashTree) { for (let index in this.request.hashTree) {
if (this.request.hashTree[index].type == 'AuthManager') { if (this.request.hashTree[index].type == 'AuthManager') {