(t *testing.T)
| 132 | type serverHandshake func(net.Conn) (AuthInfo, error) |
| 133 | |
| 134 | func (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 | |
| 172 | func (s) TestServerHandshakeReturnsAuthInfo(t *testing.T) { |
| 173 | done := make(chan AuthInfo, 1) |
nothing calls this directly
no test coverage detected