(t *testing.T)
| 211 | } |
| 212 | |
| 213 | func 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 | } |
nothing calls this directly
no test coverage detected