compareAuthInfo compares the AuthInfo received on the client side after a successful handshake with the authInfo available on the testServer.
(ctx context.Context, ts *testServer, ai credentials.AuthInfo)
| 242 | // compareAuthInfo compares the AuthInfo received on the client side after a |
| 243 | // successful handshake with the authInfo available on the testServer. |
| 244 | func compareAuthInfo(ctx context.Context, ts *testServer, ai credentials.AuthInfo) error { |
| 245 | if ai.AuthType() != "tls" { |
| 246 | return fmt.Errorf("ClientHandshake returned authType %q, want %q", ai.AuthType(), "tls") |
| 247 | } |
| 248 | info, ok := ai.(credentials.TLSInfo) |
| 249 | if !ok { |
| 250 | return fmt.Errorf("ClientHandshake returned authInfo of type %T, want %T", ai, credentials.TLSInfo{}) |
| 251 | } |
| 252 | gotState := info.State |
| 253 | |
| 254 | // Read the handshake result from the testServer which contains the TLS |
| 255 | // connection state and compare it with the one received on the client-side. |
| 256 | val, err := ts.hsResult.Receive(ctx) |
| 257 | if err != nil { |
| 258 | return fmt.Errorf("testServer failed to return handshake result: %v", err) |
| 259 | } |
| 260 | hsr := val.(handshakeResult) |
| 261 | if hsr.err != nil { |
| 262 | return fmt.Errorf("testServer handshake failure: %v", hsr.err) |
| 263 | } |
| 264 | // AuthInfo contains a variety of information. We only verify a subset here. |
| 265 | // This is the same subset which is verified in TLS credentials tests. |
| 266 | if err := compareConnState(gotState, hsr.connState); err != nil { |
| 267 | return err |
| 268 | } |
| 269 | return nil |
| 270 | } |
| 271 | |
| 272 | func compareConnState(got, want tls.ConnectionState) error { |
| 273 | switch { |
no test coverage detected