MCPcopy Index your code
hub / github.com/go-task/task / TestBuildHTTPClient_CACert

Function TestBuildHTTPClient_CACert

taskfile/node_http_test.go:86–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func TestBuildHTTPClient_CACert(t *testing.T) {
87 t.Parallel()
88
89 // Create a temporary CA cert file
90 tempDir := t.TempDir()
91 caCertPath := filepath.Join(tempDir, "ca.crt")
92
93 // Generate a valid CA certificate
94 caCertPEM := generateTestCACert(t)
95 err := os.WriteFile(caCertPath, caCertPEM, 0o600)
96 require.NoError(t, err)
97
98 client, err := buildHTTPClient(false, caCertPath, "", "")
99 require.NoError(t, err)
100 require.NotNil(t, client)
101 assert.NotEqual(t, http.DefaultClient, client)
102
103 // Check that custom RootCAs is set
104 transport, ok := client.Transport.(*http.Transport)
105 require.True(t, ok)
106 require.NotNil(t, transport.TLSClientConfig)
107 assert.NotNil(t, transport.TLSClientConfig.RootCAs)
108}
109
110func TestBuildHTTPClient_CACertNotFound(t *testing.T) {
111 t.Parallel()

Callers

nothing calls this directly

Calls 2

generateTestCACertFunction · 0.85
buildHTTPClientFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…