Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Conversation

guijunchen
Copy link
Contributor

添加支持测试tls单、双证书代码

陈桂军 added 2 commits January 15, 2021 01:10

func main() {
const address = "127.0.0.1:6443"
const caFile = "../asserts/sm2-double-cert/CA.crt"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里和上面用的文件目录名都叫 asserts,是想表达assets的意思么?还是就是断言的意思?

Copy link
Member

@SamYuan1990 SamYuan1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以参考下 https://github.com/guoger/tape/blob/master/e2e/e2e_test.go 结合使用 "github.com/onsi/gomega/gexec"
库和fmt标准输出,优化一下我们的测试代码。(如果可能)

@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果可以,避免在这里上传key

func clientRun(address, caFile, signCertFile, signKeyFile, encCertFile, encKeyFile string) {
signCert, err := tls.LoadX509KeyPair(signCertFile, signKeyFile)
if err != nil {
log.Fatalf("Failed to load LoadX509KeyPair: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接error就报错了吧?

if err != nil {
log.Fatalf("Failed to read num: %v, err:%v", n, err)
}
fmt.Printf("Receive server message: %s\n", string(buf[:n]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这行有必要么?对于测试程序?

log.Println(err)
continue
}
go handleConn(conn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑下一些golang的已经有的库,避免重复造轮子?以及作为示例程序会更好?

log.Println(err)
return
}
fmt.Printf("Receive client message:%s\n", msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt 是否必要?

)

func Test(t *testing.T) {
end = make(chan bool, 64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

试试看 "github.com/onsi/gomega/gexec"

@davidkhala davidkhala marked this pull request as draft May 7, 2021 13:45
SHenry07 pushed a commit to SHenry07/ccs-gm that referenced this pull request Oct 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants