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

Method TestNewProvider

credentials/tls/certprovider/pemfile/watcher_test.go:78–145  ·  view source on GitHub ↗

TestNewProvider tests the NewProvider() function with different inputs.

(t *testing.T)

Source from the content-addressed store, hash-verified

76
77// TestNewProvider tests the NewProvider() function with different inputs.
78func (s) TestNewProvider(t *testing.T) {
79 tests := []struct {
80 desc string
81 options Options
82 wantError bool
83 }{
84 {
85 desc: "No credential files specified",
86 options: Options{},
87 wantError: true,
88 },
89 {
90 desc: "Only identity cert is specified",
91 options: Options{
92 CertFile: testdata.Path("x509/client1_cert.pem"),
93 },
94 wantError: true,
95 },
96 {
97 desc: "Only identity key is specified",
98 options: Options{
99 KeyFile: testdata.Path("x509/client1_key.pem"),
100 },
101 wantError: true,
102 },
103 {
104 desc: "Identity cert/key pair is specified",
105 options: Options{
106 KeyFile: testdata.Path("x509/client1_key.pem"),
107 CertFile: testdata.Path("x509/client1_cert.pem"),
108 },
109 },
110 {
111 desc: "Only root certs are specified",
112 options: Options{
113 RootFile: testdata.Path("x509/client_ca_cert.pem"),
114 },
115 },
116 {
117 desc: "Only spiffe bundle map specified",
118 options: Options{
119 SPIFFEBundleMapFile: testdata.Path("spiffe/spiffebundle.json"),
120 },
121 },
122 {
123 desc: "Everything is specified",
124 options: Options{
125 KeyFile: testdata.Path("x509/client1_key.pem"),
126 CertFile: testdata.Path("x509/client1_cert.pem"),
127 RootFile: testdata.Path("x509/client_ca_cert.pem"),
128 SPIFFEBundleMapFile: testdata.Path("spiffe/spiffebundle.json"),
129 },
130 wantError: false,
131 },
132 }
133 for _, test := range tests {
134 t.Run(test.desc, func(t *testing.T) {
135 provider, err := NewProvider(test.options)

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
PathFunction · 0.92
NewProviderFunction · 0.85
FatalfMethod · 0.65

Tested by

no test coverage detected