Skip to content

Commit

Permalink
update test to be comparing the channelz cipher suite with all avaial…
Browse files Browse the repository at this point in the history
…ble cipher suites
  • Loading branch information
lyuxuan authored and Yuxuan Li committed Nov 20, 2018
1 parent 15f2136 commit 1f4532d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions test/channelz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1232,19 +1232,16 @@ func TestCZSocketGetSecurityValueTLS(t *testing.T) {
}
skt := channelz.GetSocket(id)
cert, _ := tls.LoadX509KeyPair(testdata.Path("server1.pem"), testdata.Path("server1.key"))
conn, err := tls.Dial("tcp", te.srvAddr, &tls.Config{Certificates: []tls.Certificate{cert}})
if err != nil {
return false, fmt.Errorf("tls.Dial failed due to err: %v", err)
}
securityVal := skt.SocketData.Security.(*credentials.TLSChannelzSecurityValue)
if credentials.CipherSuiteLookup[conn.ConnectionState().CipherSuite] != securityVal.StandardName {
return false, fmt.Errorf("SocketData.Security.StandardName got: %v, want: %v", securityVal.StandardName, credentials.CipherSuiteLookup[conn.ConnectionState().CipherSuite])
}
if !reflect.DeepEqual(securityVal.RemoteCertificate, cert.Certificate[0]) {
return false, fmt.Errorf("SocketData.Security.RemoteCertificate got: %v, want: %v", securityVal.RemoteCertificate, cert.Certificate[0])
}

return true, nil
for _, v := range credentials.CipherSuiteLookup {
if v == securityVal.StandardName {
return true, nil
}
}
return false, fmt.Errorf("SocketData.Security.StandardName got: %v, want it to be one of %v ", securityVal.StandardName, credentials.CipherSuiteLookup)
}); err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 1f4532d

Please sign in to comment.