fix(旧版本接口测试): 兼容新版本定义的环境
This commit is contained in:
parent
7220882d7d
commit
9b110273bc
|
@ -9,7 +9,7 @@
|
||||||
<el-select :disabled="isReadOnly" v-model="scenario.environmentId" class="environment-select"
|
<el-select :disabled="isReadOnly" v-model="scenario.environmentId" class="environment-select"
|
||||||
@change="environmentChange" clearable>
|
@change="environmentChange" clearable>
|
||||||
<el-option v-for="(environment, index) in environments" :key="index"
|
<el-option v-for="(environment, index) in environments" :key="index"
|
||||||
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
:label="environment.name"
|
||||||
:value="environment.id"/>
|
:value="environment.id"/>
|
||||||
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
|
|
|
@ -193,10 +193,25 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
displayUrl() {
|
displayUrl() {
|
||||||
return (this.scenario.environment && this.scenario.environment.config.httpConfig.socket) ?
|
let url = null;
|
||||||
|
if(this.scenario.environment && this.scenario.environment.config.httpConfig
|
||||||
|
&& this.scenario.environment.config.httpConfig.conditions && this.scenario.environment.config.httpConfig.conditions.length > 0){
|
||||||
|
for(let i in this.scenario.environment.config.httpConfig.conditions) {
|
||||||
|
if (this.scenario.environment.config.httpConfig.conditions[i]) {
|
||||||
|
let item = this.scenario.environment.config.httpConfig.conditions[i];
|
||||||
|
if (item && item.type === 'NONE') {
|
||||||
|
url = item.protocol + '://' + item.socket + (this.request.path ? this.request.path : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(url === null) {
|
||||||
|
url = (this.scenario.environment && this.scenario.environment.config.httpConfig.socket) ?
|
||||||
this.scenario.environment.config.httpConfig.protocol + '://' + this.scenario.environment.config.httpConfig.socket + (this.request.path ? this.request.path : '')
|
this.scenario.environment.config.httpConfig.protocol + '://' + this.scenario.environment.config.httpConfig.socket + (this.request.path ? this.request.path : '')
|
||||||
: '';
|
: '';
|
||||||
}
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -379,7 +379,20 @@ export class HttpRequest extends Request {
|
||||||
info: 'api_test.request.please_configure_environment_in_scenario'
|
info: 'api_test.request.please_configure_environment_in_scenario'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!environment.config.httpConfig.socket) {
|
let url = null;
|
||||||
|
if (environment && this.environment.config.httpConfig
|
||||||
|
&& environment.config.httpConfig.conditions && environment.config.httpConfig.conditions.length > 0) {
|
||||||
|
environment.config.httpConfig.conditions.forEach(item => {
|
||||||
|
if (item.type === 'NONE') {
|
||||||
|
url = item.protocol + '://' + item.socket;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (url === null) {
|
||||||
|
url = (environment && environment.config.httpConfig.socket) ?
|
||||||
|
environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket : null;
|
||||||
|
}
|
||||||
|
if (url === null) {
|
||||||
return {
|
return {
|
||||||
isValid: false,
|
isValid: false,
|
||||||
info: 'api_test.request.please_configure_socket_in_environment'
|
info: 'api_test.request.please_configure_socket_in_environment'
|
||||||
|
@ -1031,6 +1044,22 @@ class JMXHttpRequest {
|
||||||
this.protocol = url.protocol.split(":")[0];
|
this.protocol = url.protocol.split(":")[0];
|
||||||
this.path = this.getPostQueryParameters(request, decodeURIComponent(url.pathname));
|
this.path = this.getPostQueryParameters(request, decodeURIComponent(url.pathname));
|
||||||
} else {
|
} else {
|
||||||
|
let isNewEnv = false;
|
||||||
|
if (environment && environment.config.httpConfig
|
||||||
|
&& environment.config.httpConfig.conditions && environment.config.httpConfig.conditions.length > 0) {
|
||||||
|
environment.config.httpConfig.conditions.forEach(item => {
|
||||||
|
if (item.type === 'NONE') {
|
||||||
|
isNewEnv = true;
|
||||||
|
this.domain = item.domain;
|
||||||
|
this.port = item.port;
|
||||||
|
this.protocol = item.protocol;
|
||||||
|
let url = new URL(item.protocol + "://" + item.socket);
|
||||||
|
let envPath = url.pathname === '/' ? '' : url.pathname;
|
||||||
|
this.path = this.getPostQueryParameters(request, decodeURIComponent(envPath + (request.path ? request.path : '')));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!isNewEnv) {
|
||||||
this.domain = environment.config.httpConfig.domain;
|
this.domain = environment.config.httpConfig.domain;
|
||||||
this.port = environment.config.httpConfig.port;
|
this.port = environment.config.httpConfig.port;
|
||||||
this.protocol = environment.config.httpConfig.protocol;
|
this.protocol = environment.config.httpConfig.protocol;
|
||||||
|
@ -1038,6 +1067,7 @@ class JMXHttpRequest {
|
||||||
let envPath = url.pathname === '/' ? '' : url.pathname;
|
let envPath = url.pathname === '/' ? '' : url.pathname;
|
||||||
this.path = this.getPostQueryParameters(request, decodeURIComponent(envPath + (request.path ? request.path : '')));
|
this.path = this.getPostQueryParameters(request, decodeURIComponent(envPath + (request.path ? request.path : '')));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.connectTimeout = request.connectTimeout;
|
this.connectTimeout = request.connectTimeout;
|
||||||
this.responseTimeout = request.responseTimeout;
|
this.responseTimeout = request.responseTimeout;
|
||||||
this.followRedirects = request.followRedirects;
|
this.followRedirects = request.followRedirects;
|
||||||
|
|
Loading…
Reference in New Issue