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

Method TestCredsBundleTransportCredentials

test/creds_test.go:107–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func (s) TestCredsBundleTransportCredentials(t *testing.T) {
108 te := newTest(t, env{name: "creds-bundle", network: "tcp", security: "empty"})
109 te.customDialOptions = []grpc.DialOption{
110 grpc.WithCredentialsBundle(&testCredsBundle{t: t, mode: bundleTLSOnly}),
111 grpc.WithAuthority("x.test.example.com"),
112 }
113 creds, err := credentials.NewServerTLSFromFile(testdata.Path("x509/server1_cert.pem"), testdata.Path("x509/server1_key.pem"))
114 if err != nil {
115 t.Fatalf("Failed to generate credentials %v", err)
116 }
117 te.customServerOptions = []grpc.ServerOption{
118 grpc.Creds(creds),
119 }
120 te.startServer(&testServer{})
121 defer te.tearDown()
122
123 cc := te.clientConn()
124 tc := testgrpc.NewTestServiceClient(cc)
125 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
126 defer cancel()
127 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); err != nil {
128 t.Fatalf("Test failed. Reason: %v", err)
129 }
130}
131
132func (s) TestCredsBundlePerRPCCredentials(t *testing.T) {
133 te := newTest(t, env{name: "creds-bundle", network: "tcp", security: "empty"})

Callers

nothing calls this directly

Calls 11

EmptyCallMethod · 0.95
WithCredentialsBundleFunction · 0.92
WithAuthorityFunction · 0.92
NewServerTLSFromFileFunction · 0.92
PathFunction · 0.92
CredsFunction · 0.92
newTestFunction · 0.70
FatalfMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected