Skip to content

Commit b0943d7

Browse files
committed
support insecure during testing
1 parent 8fc6285 commit b0943d7

File tree

5 files changed

+55
-34
lines changed

5 files changed

+55
-34
lines changed

console/atest-ui/src/locales/en.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"stores": "Stores",
5050
"functionQuery": "Functions Query",
5151
"output": "Output",
52-
"proxy": "Proxy"
52+
"proxy": "Proxy",
53+
"secure": "Secure"
5354
},
5455
"tip": {
5556
"filter": "Filter Keyword",
@@ -73,7 +74,8 @@
7374
"suiteKind": "Suite Kind",
7475
"key": "Key",
7576
"value": "Value",
76-
"proxy": "Proxy"
77+
"proxy": "Proxy",
78+
"insecure": "Insecure"
7779
},
7880
"//see http spec": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403",
7981
"httpCode": {
@@ -98,4 +100,4 @@
98100
"https": "HTTPS Proxy",
99101
"no": "No Proxy"
100102
}
101-
}
103+
}

console/atest-ui/src/locales/zh.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"parameter": "参数",
4545
"functionQuery": "函数查询",
4646
"output": "输出",
47-
"proxy": "代理"
47+
"proxy": "代理",
48+
"secure": "安全"
4849
},
4950
"tip": {
5051
"filter": "过滤",
@@ -67,11 +68,12 @@
6768
"suiteKind": "类型",
6869
"key": "",
6970
"value": "",
70-
"proxy": "代理"
71+
"proxy": "代理",
72+
"insecure": "忽略证书验证"
7173
},
7274
"proxy": {
7375
"http": "HTTP 代理",
7476
"https": "HTTPS 代理",
7577
"no": "跳过代理"
7678
}
77-
}
79+
}

console/atest-ui/src/views/TestSuite.vue

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ const suite = ref({
3232
raw: '',
3333
protofile: '',
3434
serverReflection: false
35-
}
35+
},
36+
secure: {
37+
insecure: true
38+
}
3639
},
3740
proxy: {
3841
http: '',
@@ -62,6 +65,11 @@ function load() {
6265
no: ''
6366
}
6467
}
68+
if (!suite.value.spec.secure) {
69+
suite.value.spec.secure = {
70+
insecure: false
71+
}
72+
}
6573
6674
shareLink.value = `${window.location.href}api/v1/suites/${e.name}/yaml?x-store-name=${store.name}`
6775
},
@@ -322,29 +330,6 @@ const renameTestSuite = (name: string) => {
322330
</tr>
323331
</table>
324332

325-
<div v-if="suite.spec.rpc">
326-
<div>
327-
<span>{{ t('title.refelction') }}</span>
328-
<el-switch v-model="suite.spec.rpc.serverReflection" />
329-
</div>
330-
<div>
331-
<span>{{ t('title.protoContent') }}</span>
332-
<el-input
333-
v-model="suite.spec.rpc.raw"
334-
:autosize="{ minRows: 4, maxRows: 8 }"
335-
type="textarea"
336-
/>
337-
</div>
338-
<div>
339-
<span>{{ t('title.protoImport') }}</span>
340-
<el-input class="mx-1" v-model="suite.spec.rpc.import"></el-input>
341-
</div>
342-
<div>
343-
<span>{{ t('title.protoFile') }}</span>
344-
<el-input class="mx-1" v-model="suite.spec.rpc.protofile"></el-input>
345-
</div>
346-
</div>
347-
348333
<el-collapse>
349334
<el-collapse-item :title="t('title.parameter')">
350335
<el-table :data="suite.param" style="width: 100%">
@@ -362,6 +347,31 @@ const renameTestSuite = (name: string) => {
362347
</el-table-column>
363348
</el-table>
364349
</el-collapse-item>
350+
<el-collapse-item v-if="suite.spec.rpc">
351+
<div>
352+
<span>{{ t('title.refelction') }}</span>
353+
<el-switch v-model="suite.spec.rpc.serverReflection" />
354+
</div>
355+
<div>
356+
<span>{{ t('title.protoContent') }}</span>
357+
<el-input
358+
v-model="suite.spec.rpc.raw"
359+
:autosize="{ minRows: 4, maxRows: 8 }"
360+
type="textarea"
361+
/>
362+
</div>
363+
<div>
364+
<span>{{ t('title.protoImport') }}</span>
365+
<el-input class="mx-1" v-model="suite.spec.rpc.import"></el-input>
366+
</div>
367+
<div>
368+
<span>{{ t('title.protoFile') }}</span>
369+
<el-input class="mx-1" v-model="suite.spec.rpc.protofile"></el-input>
370+
</div>
371+
</el-collapse-item>
372+
<el-collapse-item :title="t('title.secure')">
373+
<el-switch v-model="suite.spec.secure.insecure" active-text="Insecure" inactive-text="Secure" inline-prompt/>
374+
</el-collapse-item>
365375
<el-collapse-item :title="t('title.proxy')">
366376
<div>
367377
<el-form-item :label="t('proxy.http')" prop="proxy.http">

console/atest-ui/src/views/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export interface Suite {
2424
spec: {
2525
kind: string
2626
url: string
27+
secure: {
28+
insecure: boolean
29+
}
2730
}
2831
proxy: {
2932
http: string
@@ -210,4 +213,4 @@ export function FlattenObject(obj: any): any {
210213
acc[pair[0]] = pair[1]
211214
return acc
212215
}, {})
213-
}
216+
}

pkg/runner/http.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,18 @@ func (r *simpleTestCaseRunner) RunTestCase(testcase *testing.TestCase, dataConte
140140
}
141141
}()
142142

143-
client := util.TlsAwareHTTPClient(true) // TODO should have a way to change it
143+
insecure := false
144+
if r.Secure != nil {
145+
insecure = r.Secure.Insecure
146+
}
147+
client := util.TlsAwareHTTPClient(insecure) // TODO should have a way to change it
144148
contextDir := NewContextKeyBuilder().ParentDir().GetContextValueOrEmpty(ctx)
145149
if err = testcase.Request.Render(dataContext, contextDir); err != nil {
146150
return
147151
}
148152

149153
// add proxy setting
150-
if r.proxy != nil {
154+
if r.proxy != nil && r.proxy.HTTP != "" {
151155
var proxyURL *url.URL
152156
if proxyURL, err = url.Parse(r.proxy.HTTP); err == nil {
153157
client.Transport = &http.Transport{
@@ -161,7 +165,7 @@ func (r *simpleTestCaseRunner) RunTestCase(testcase *testing.TestCase, dataConte
161165
r.log.Info("using proxy: %v\n", proxyURL)
162166
return proxyURL, nil
163167
},
164-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
168+
TLSClientConfig: &tls.Config{InsecureSkipVerify: insecure},
165169
}
166170
} else {
167171
err = fmt.Errorf("failed to parse proxy URL: %v", err)

0 commit comments

Comments
 (0)