MCPcopy
hub / github.com/kagent-dev/kagent / serverCAPEMPath

Function serverCAPEMPath

go/adk/pkg/models/tls_test.go:24–35  ·  view source on GitHub ↗

serverCAPEMPath writes the test server's certificate to a temp file and returns the path.

(t *testing.T, srv *httptest.Server)

Source from the content-addressed store, hash-verified

22
23// serverCAPEMPath writes the test server's certificate to a temp file and returns the path.
24func 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.
38func get(t *testing.T, client *http.Client, url string) int {

Calls 2

WriteFileMethod · 0.80
JoinMethod · 0.45

Tested by

no test coverage detected