MCPcopy Create free account
hub / github.com/zalando/skipper / TestLogsAccess

Function TestLogsAccess

proxy/proxy_test.go:1929–1956  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1927}
1928
1929func TestLogsAccess(t *testing.T) {
1930 var accessLog bytes.Buffer
1931 al := logging.NewAccessLogger(logging.Options{AccessLogOutput: &accessLog})
1932
1933 response := "7 bytes"
1934
1935 u, _ := url.ParseRequestURI("https://www.example.org/hello")
1936 r := &http.Request{
1937 URL: u,
1938 Method: "GET",
1939 Header: http.Header{"Connection": []string{"token"}}}
1940 w := httptest.NewRecorder()
1941
1942 doc := fmt.Sprintf(`hello: Path("/hello") -> status(%d) -> inlineContent("%s") -> <shunt>`, http.StatusTeapot, response)
1943
1944 tp, err := newTestProxyWithParams(doc, Params{Flags: FlagsNone, AccessLogger: al})
1945 if err != nil {
1946 t.Fatal(err)
1947 }
1948 defer tp.close()
1949
1950 tp.proxy.ServeHTTP(w, r)
1951
1952 output := accessLog.String()
1953 if !strings.Contains(output, fmt.Sprintf(`"%s - -" %d %d "-" "-"`, r.Method, http.StatusTeapot, len(response))) {
1954 t.Error("failed to log access", output)
1955 }
1956}
1957
1958func TestDisableAccessLog(t *testing.T) {
1959 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 6

NewAccessLoggerFunction · 0.92
newTestProxyWithParamsFunction · 0.85
StringMethod · 0.65
ErrorMethod · 0.65
closeMethod · 0.45
ServeHTTPMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…