MCPcopy
hub / github.com/grpc/grpc-go / TestClientHandshakeReturnsAuthInfo

Method TestClientHandshakeReturnsAuthInfo

credentials/credentials_test.go:134–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

132type serverHandshake func(net.Conn) (AuthInfo, error)
133
134func (s) TestClientHandshakeReturnsAuthInfo(t *testing.T) {
135 tcs := []struct {
136 name string
137 address string
138 }{
139 {
140 name: "localhost",
141 address: "localhost:0",
142 },
143 {
144 name: "ipv4",
145 address: "127.0.0.1:0",
146 },
147 {
148 name: "ipv6",
149 address: "[::1]:0",
150 },
151 }
152
153 for _, tc := range tcs {
154 t.Run(tc.name, func(t *testing.T) {
155 done := make(chan AuthInfo, 1)
156 lis := launchServerOnListenAddress(t, tlsServerHandshake, done, tc.address)
157 defer lis.Close()
158 lisAddr := lis.Addr().String()
159 clientAuthInfo := clientHandle(t, gRPCClientHandshake, lisAddr)
160 // wait until server sends serverAuthInfo or fails.
161 serverAuthInfo, ok := <-done
162 if !ok {
163 t.Fatalf("Error at server-side")
164 }
165 if !compare(clientAuthInfo, serverAuthInfo) {
166 t.Fatalf("c.ClientHandshake(_, %v, _) = %v, want %v.", lisAddr, clientAuthInfo, serverAuthInfo)
167 }
168 })
169 }
170}
171
172func (s) TestServerHandshakeReturnsAuthInfo(t *testing.T) {
173 done := make(chan AuthInfo, 1)

Callers

nothing calls this directly

Calls 7

clientHandleFunction · 0.70
compareFunction · 0.70
CloseMethod · 0.65
StringMethod · 0.65
FatalfMethod · 0.65
AddrMethod · 0.45

Tested by

no test coverage detected