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

Function TestDisableAccessLogWithFilter

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

Source from the content-addressed store, hash-verified

1988}
1989
1990func TestDisableAccessLogWithFilter(t *testing.T) {
1991 for _, ti := range []struct {
1992 msg string
1993 filter string
1994 responseCode int
1995 disabled bool
1996 }{
1997 {
1998 msg: "disable-log-for-all",
1999 filter: "disableAccessLog()",
2000 responseCode: 201,
2001 disabled: true,
2002 },
2003 {
2004 msg: "disable-log-match-exact",
2005 filter: "disableAccessLog(200)",
2006 responseCode: 200,
2007 disabled: true,
2008 },
2009 {
2010 msg: "disable-log-match-prefix",
2011 filter: "disableAccessLog(3)",
2012 responseCode: 302,
2013 disabled: true,
2014 },
2015 {
2016 msg: "disable-log-no-match",
2017 filter: "disableAccessLog(1,20,300)",
2018 responseCode: 500,
2019 disabled: false,
2020 },
2021 } {
2022 t.Run(ti.msg, func(t *testing.T) {
2023 var buf bytes.Buffer
2024 al := logging.NewAccessLogger(logging.Options{
2025 AccessLogOutput: &buf})
2026
2027 response := "7 bytes"
2028
2029 u, _ := url.ParseRequestURI("https://www.example.org/hello")
2030 r := &http.Request{
2031 URL: u,
2032 Method: "GET",
2033 Header: http.Header{"Connection": []string{"token"}}}
2034 w := httptest.NewRecorder()
2035
2036 doc := fmt.Sprintf(`hello: Path("/hello") -> %s -> status(%d) -> inlineContent("%s") -> <shunt>`, ti.filter, ti.responseCode, response)
2037
2038 tp, err := newTestProxyWithParams(doc, Params{
2039 AccessLogDisabled: false,
2040 AccessLogger: al,
2041 })
2042 if err != nil {
2043 t.Fatal(err)
2044 }
2045
2046 defer tp.close()
2047

Callers

nothing calls this directly

Calls 6

NewAccessLoggerFunction · 0.92
newTestProxyWithParamsFunction · 0.85
LenMethod · 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…