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

Function loadX509Cert

internal/credentials/spiffe/spiffe_test.go:72–85  ·  view source on GitHub ↗
(t *testing.T, filePath string)

Source from the content-addressed store, hash-verified

70}
71
72func loadX509Cert(t *testing.T, filePath string) *x509.Certificate {
73 t.Helper()
74 certFile, _ := os.Open(filePath)
75 certRaw, _ := io.ReadAll(certFile)
76 block, _ := pem.Decode([]byte(certRaw))
77 if block == nil {
78 t.Fatalf("pem.Decode(%v) = nil. Want a value.", certRaw)
79 }
80 cert, err := x509.ParseCertificate(block.Bytes)
81 if err != nil {
82 t.Fatalf("x509.ParseCertificate(%v) failed %v", block.Bytes, err.Error())
83 }
84 return cert
85}
86
87func TestSPIFFEBundleMapFailures(t *testing.T) {
88 filePaths := []string{

Calls 4

OpenMethod · 0.80
DecodeMethod · 0.65
FatalfMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected