Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Dev testtls #16

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

guijunchen
Copy link
Member

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

陈桂军 added 2 commits January 15, 2021 01:10
Signed-off-by: 陈桂军 <chengj16@bngrp.com>
Signed-off-by: 陈桂军 <chengj16@bngrp.com>

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"

…S handshake

Signed-off-by: 陈桂军 <chengj16@bngrp.com>
@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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants