advancedtls: migrate testing to grpctest (#3773)
advancedtls: migrate tests to use grpctest
This commit is contained in:
@ -181,7 +181,7 @@ func callAndVerifyWithClientConn(connCtx context.Context, msg string, creds cred
|
|||||||
// the factor we modified in stage 1.
|
// the factor we modified in stage 1.
|
||||||
// (could be change the client's trust certificate, or change custom
|
// (could be change the client's trust certificate, or change custom
|
||||||
// verification function, etc)
|
// verification function, etc)
|
||||||
func TestEnd2End(t *testing.T) {
|
func (s) TestEnd2End(t *testing.T) {
|
||||||
cs := &certStore{}
|
cs := &certStore{}
|
||||||
err := cs.loadCerts()
|
err := cs.loadCerts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -32,10 +32,19 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
"google.golang.org/grpc/internal/grpctest"
|
||||||
"google.golang.org/grpc/security/advancedtls/testdata"
|
"google.golang.org/grpc/security/advancedtls/testdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestClientServerHandshake(t *testing.T) {
|
type s struct {
|
||||||
|
grpctest.Tester
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test(t *testing.T) {
|
||||||
|
grpctest.RunSubTests(t, s{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s) TestClientServerHandshake(t *testing.T) {
|
||||||
// ------------------Load Client Trust Cert and Peer Cert-------------------
|
// ------------------Load Client Trust Cert and Peer Cert-------------------
|
||||||
clientTrustPool, err := readTrustCert(testdata.Path("client_trust_cert_1.pem"))
|
clientTrustPool, err := readTrustCert(testdata.Path("client_trust_cert_1.pem"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -523,7 +532,7 @@ func compare(a1, a2 credentials.AuthInfo) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAdvancedTLSOverrideServerName(t *testing.T) {
|
func (s) TestAdvancedTLSOverrideServerName(t *testing.T) {
|
||||||
expectedServerName := "server.name"
|
expectedServerName := "server.name"
|
||||||
clientTrustPool, err := readTrustCert(testdata.Path("client_trust_cert_1.pem"))
|
clientTrustPool, err := readTrustCert(testdata.Path("client_trust_cert_1.pem"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -545,7 +554,7 @@ func TestAdvancedTLSOverrideServerName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTLSClone(t *testing.T) {
|
func (s) TestTLSClone(t *testing.T) {
|
||||||
expectedServerName := "server.name"
|
expectedServerName := "server.name"
|
||||||
clientTrustPool, err := readTrustCert(testdata.Path("client_trust_cert_1.pem"))
|
clientTrustPool, err := readTrustCert(testdata.Path("client_trust_cert_1.pem"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -573,7 +582,7 @@ func TestTLSClone(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAppendH2ToNextProtos(t *testing.T) {
|
func (s) TestAppendH2ToNextProtos(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
ps []string
|
ps []string
|
||||||
@ -613,7 +622,7 @@ type nonSyscallConn struct {
|
|||||||
net.Conn
|
net.Conn
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrapSyscallConn(t *testing.T) {
|
func (s) TestWrapSyscallConn(t *testing.T) {
|
||||||
sc := &syscallConn{}
|
sc := &syscallConn{}
|
||||||
nsc := &nonSyscallConn{}
|
nsc := &nonSyscallConn{}
|
||||||
|
|
||||||
@ -624,7 +633,7 @@ func TestWrapSyscallConn(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOptionsConfig(t *testing.T) {
|
func (s) TestOptionsConfig(t *testing.T) {
|
||||||
serverPeerCert, err := tls.LoadX509KeyPair(testdata.Path("server_cert_1.pem"),
|
serverPeerCert, err := tls.LoadX509KeyPair(testdata.Path("server_cert_1.pem"),
|
||||||
testdata.Path("server_key_1.pem"))
|
testdata.Path("server_key_1.pem"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user