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

Method TestCredsBundleBoth

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

Source from the content-addressed store, hash-verified

79}
80
81func (s) TestCredsBundleBoth(t *testing.T) {
82 te := newTest(t, env{name: "creds-bundle", network: "tcp", security: "empty"})
83 te.tapHandle = authHandle
84 te.customDialOptions = []grpc.DialOption{
85 grpc.WithCredentialsBundle(&testCredsBundle{t: t}),
86 grpc.WithAuthority("x.test.example.com"),
87 }
88 creds, err := credentials.NewServerTLSFromFile(testdata.Path("x509/server1_cert.pem"), testdata.Path("x509/server1_key.pem"))
89 if err != nil {
90 t.Fatalf("Failed to generate credentials %v", err)
91 }
92 te.customServerOptions = []grpc.ServerOption{
93 grpc.Creds(creds),
94 }
95 te.startServer(&testServer{})
96 defer te.tearDown()
97
98 cc := te.clientConn()
99 tc := testgrpc.NewTestServiceClient(cc)
100 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
101 defer cancel()
102 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); err != nil {
103 t.Fatalf("Test failed. Reason: %v", err)
104 }
105}
106
107func (s) TestCredsBundleTransportCredentials(t *testing.T) {
108 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