newTestContextWithHandshakeInfo returns a copy of parent with HandshakeInfo context value added to it.
(parent context.Context, root, identity certprovider.Provider, sanExactMatch, sni string, validateSANUsingSNI bool)
| 221 | // newTestContextWithHandshakeInfo returns a copy of parent with HandshakeInfo |
| 222 | // context value added to it. |
| 223 | func newTestContextWithHandshakeInfo(parent context.Context, root, identity certprovider.Provider, sanExactMatch, sni string, validateSANUsingSNI bool) context.Context { |
| 224 | // Creating the HandshakeInfo and adding it to the attributes is very |
| 225 | // similar to what the CDS balancer would do when it intercepts calls to |
| 226 | // NewSubConn(). |
| 227 | var sms []matcher.StringMatcher |
| 228 | if sanExactMatch != "" { |
| 229 | sms = []matcher.StringMatcher{matcher.NewExactStringMatcher(sanExactMatch, false)} |
| 230 | } |
| 231 | var hiPtr atomic.Pointer[xdsinternal.HandshakeInfo] |
| 232 | info := xdsinternal.NewHandshakeInfo(root, identity, sms, false, sni, validateSANUsingSNI, false) |
| 233 | hiPtr.Store(info) |
| 234 | addr := xdsinternal.SetHandshakeInfo(resolver.Address{}, &hiPtr) |
| 235 | |
| 236 | // Moving the attributes from the resolver.Address to the context passed to |
| 237 | // the handshaker is done in the transport layer. Since we directly call the |
| 238 | // handshaker in these tests, we need to do the same here. |
| 239 | return icredentials.NewClientHandshakeInfoContext(parent, credentials.ClientHandshakeInfo{Attributes: addr.Attributes}) |
| 240 | } |
| 241 | |
| 242 | // compareAuthInfo compares the AuthInfo received on the client side after a |
| 243 | // successful handshake with the authInfo available on the testServer. |
no test coverage detected