Skip to content

Commit

Permalink
advancedtls: migrate testing to grpctest (grpc#3773)
Browse files Browse the repository at this point in the history
advancedtls: migrate tests to use grpctest
  • Loading branch information
cindyxue authored Jul 30, 2020
1 parent b2e4970 commit b72d07f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion security/advancedtls/advancedtls_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func callAndVerifyWithClientConn(connCtx context.Context, msg string, creds cred
// the factor we modified in stage 1.
// (could be change the client's trust certificate, or change custom
// verification function, etc)
func TestEnd2End(t *testing.T) {
func (s) TestEnd2End(t *testing.T) {
cs := &certStore{}
err := cs.loadCerts()
if err != nil {
Expand Down
21 changes: 15 additions & 6 deletions security/advancedtls/advancedtls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ import (
"testing"

"google.golang.org/grpc/credentials"
"google.golang.org/grpc/internal/grpctest"
"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-------------------
clientTrustPool, err := readTrustCert(testdata.Path("client_trust_cert_1.pem"))
if err != nil {
Expand Down Expand Up @@ -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"
clientTrustPool, err := readTrustCert(testdata.Path("client_trust_cert_1.pem"))
if err != nil {
Expand All @@ -545,7 +554,7 @@ func TestAdvancedTLSOverrideServerName(t *testing.T) {
}
}

func TestTLSClone(t *testing.T) {
func (s) TestTLSClone(t *testing.T) {
expectedServerName := "server.name"
clientTrustPool, err := readTrustCert(testdata.Path("client_trust_cert_1.pem"))
if err != nil {
Expand Down Expand Up @@ -573,7 +582,7 @@ func TestTLSClone(t *testing.T) {

}

func TestAppendH2ToNextProtos(t *testing.T) {
func (s) TestAppendH2ToNextProtos(t *testing.T) {
tests := []struct {
name string
ps []string
Expand Down Expand Up @@ -613,7 +622,7 @@ type nonSyscallConn struct {
net.Conn
}

func TestWrapSyscallConn(t *testing.T) {
func (s) TestWrapSyscallConn(t *testing.T) {
sc := &syscallConn{}
nsc := &nonSyscallConn{}

Expand All @@ -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"),
testdata.Path("server_key_1.pem"))
if err != nil {
Expand Down

0 comments on commit b72d07f

Please sign in to comment.