serverCAPEMPath writes the test server's certificate to a temp file and returns the path.
(t *testing.T, srv *httptest.Server)
| 22 | |
| 23 | // serverCAPEMPath writes the test server's certificate to a temp file and returns the path. |
| 24 | func serverCAPEMPath(t *testing.T, srv *httptest.Server) string { |
| 25 | t.Helper() |
| 26 | data := pem.EncodeToMemory(&pem.Block{ |
| 27 | Type: "CERTIFICATE", |
| 28 | Bytes: srv.Certificate().Raw, |
| 29 | }) |
| 30 | path := filepath.Join(t.TempDir(), "ca.pem") |
| 31 | if err := os.WriteFile(path, data, 0600); err != nil { |
| 32 | t.Fatalf("failed to write CA PEM: %v", err) |
| 33 | } |
| 34 | return path |
| 35 | } |
| 36 | |
| 37 | // get is a helper that makes a GET request and returns the status code. |
| 38 | func get(t *testing.T, client *http.Client, url string) int { |
no test coverage detected