MCPcopy
hub / github.com/cloudflare/cloudflared / TestUnixSocketOrigin

Function TestUnixSocketOrigin

proxy/proxy_posix_test.go:17–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestUnixSocketOrigin(t *testing.T) {
18 file, err := os.CreateTemp("", "unix.sock")
19 require.NoError(t, err)
20 os.Remove(file.Name()) // remove the file since binding the socket expects to create it
21
22 l, err := net.Listen("unix", file.Name())
23 require.NoError(t, err)
24 defer l.Close()
25 defer os.Remove(file.Name())
26
27 api := &httptest.Server{
28 Listener: l,
29 Config: &http.Server{Handler: mockAPI{}},
30 }
31 api.Start()
32 defer api.Close()
33
34 unvalidatedIngress := []config.UnvalidatedIngressRule{
35 {
36 Hostname: "unix.example.com",
37 Service: "unix:" + file.Name(),
38 },
39 {
40 Hostname: "*",
41 Service: "http_status:404",
42 },
43 }
44
45 tests := []MultipleIngressTest{
46 {
47 url: "http://unix.example.com",
48 expectedStatus: http.StatusCreated,
49 expectedBody: []byte("Created"),
50 },
51 }
52
53 runIngressTestScenarios(t, unvalidatedIngress, tests)
54}

Callers

nothing calls this directly

Calls 6

runIngressTestScenariosFunction · 0.85
RemoveMethod · 0.65
NameMethod · 0.65
ListenMethod · 0.65
CloseMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected