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

Function makeTLSCreds

balancer/rls/control_channel_test.go:213–230  ·  view source on GitHub ↗

makeTLSCreds is a test helper which creates a TLS based transport credentials from files specified in the arguments.

(t *testing.T, certPath, keyPath, rootsPath string)

Source from the content-addressed store, hash-verified

211// makeTLSCreds is a test helper which creates a TLS based transport credentials
212// from files specified in the arguments.
213func makeTLSCreds(t *testing.T, certPath, keyPath, rootsPath string) credentials.TransportCredentials {
214 cert, err := tls.LoadX509KeyPair(testdata.Path(certPath), testdata.Path(keyPath))
215 if err != nil {
216 t.Fatalf("tls.LoadX509KeyPair(%q, %q) failed: %v", certPath, keyPath, err)
217 }
218 b, err := os.ReadFile(testdata.Path(rootsPath))
219 if err != nil {
220 t.Fatalf("os.ReadFile(%q) failed: %v", rootsPath, err)
221 }
222 roots := x509.NewCertPool()
223 if !roots.AppendCertsFromPEM(b) {
224 t.Fatal("failed to append certificates")
225 }
226 return credentials.NewTLS(&tls.Config{
227 Certificates: []tls.Certificate{cert},
228 RootCAs: roots,
229 })
230}
231
232const (
233 wantHeaderData = "headerData"

Calls 4

PathFunction · 0.92
NewTLSFunction · 0.92
FatalfMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected