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

Function TestIDFromCertFileFailures

internal/credentials/spiffe/spiffe_test.go:213–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

211}
212
213func TestIDFromCertFileFailures(t *testing.T) {
214 certWithNoURIs := loadX509Cert(t, testdata.Path("spiffe/client_spiffe.pem"))
215 certWithNoURIs.URIs = nil
216 certWithInvalidSPIFFEID := loadX509Cert(t, testdata.Path("spiffe/client_spiffe.pem"))
217 certWithInvalidSPIFFEID.URIs = []*url.URL{{Path: "non-spiffe.bad"}}
218 tests := []struct {
219 name string
220 cert *x509.Certificate
221 }{
222 {
223 name: "certificate with multiple URIs",
224 cert: loadX509Cert(t, testdata.Path("x509/multiple_uri_cert.pem")),
225 },
226 {
227 name: "certificate with invalidSPIFFE ID",
228 cert: certWithInvalidSPIFFEID,
229 },
230 {
231 name: "nil cert",
232 cert: nil,
233 },
234 {
235 name: "cert with no URIs",
236 cert: certWithNoURIs,
237 },
238 }
239 for _, tt := range tests {
240 t.Run(tt.name, func(t *testing.T) {
241 if _, err := idFromCert(tt.cert); err == nil {
242 t.Fatalf("idFromCert() succeeded but want error")
243 }
244 })
245 }
246}

Callers

nothing calls this directly

Calls 4

PathFunction · 0.92
loadX509CertFunction · 0.85
idFromCertFunction · 0.85
FatalfMethod · 0.65

Tested by

no test coverage detected