MCPcopy Create free account
hub / github.com/cli/cli / TestGatewayRecordsUpstreamFailures

Function TestGatewayRecordsUpstreamFailures

script/api-host-gateway/gateway/main_test.go:84–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestGatewayRecordsUpstreamFailures(t *testing.T) {
85 logPath := filepath.Join(t.TempDir(), "gateway.jsonl")
86 rec, err := newRecorder(logPath)
87 require.NoError(t, err)
88 defer rec.Close()
89
90 // 127.0.0.1:1 is not listening, standing in for an unreachable upstream.
91 proxy := newProxy("gh-gateway.internal", &url.URL{Scheme: "http", Host: "api.github.com"}, "127.0.0.1:1", rec)
92
93 gateway := httptest.NewServer(recordingHandler(proxy, rec))
94 defer gateway.Close()
95
96 resp, err := http.Get(gateway.URL + "/user")
97 require.NoError(t, err)
98 defer resp.Body.Close()
99
100 assert.Equal(t, http.StatusBadGateway, resp.StatusCode)
101
102 entries := readLog(t, logPath)
103 require.Len(t, entries, 1)
104 assert.Equal(t, "/user", entries[0].Path)
105 assert.False(t, entries[0].AuthHeader)
106 assert.NotEmpty(t, entries[0].Error)
107}
108
109func TestGeneratedServerCertificateChainsToTheCA(t *testing.T) {
110 caPEM, serverCert, err := generateCertificates("gh-gateway.internal")

Callers

nothing calls this directly

Calls 9

newRecorderFunction · 0.85
newProxyFunction · 0.85
recordingHandlerFunction · 0.85
readLogFunction · 0.85
JoinMethod · 0.80
EqualMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected