Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'logging_test.go')
-rw-r--r--logging_test.go50
1 files changed, 0 insertions, 50 deletions
diff --git a/logging_test.go b/logging_test.go
deleted file mode 100644
index 42831436..00000000
--- a/logging_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package main
-
-import (
- "fmt"
- "net/http"
- "net/http/httptest"
- "testing"
-
- log "github.com/sirupsen/logrus"
- "github.com/stretchr/testify/assert"
-)
-
-func testLogWithStatus(ww http.ResponseWriter, r *http.Request) {
- w := newLoggingResponseWriter(ww, log.WithField("system", "http"))
- defer w.Log(r)
- w.WriteHeader(http.StatusOK)
- fmt.Fprint(&w, "with-status")
-}
-
-func testLogWithoutStatus(ww http.ResponseWriter, r *http.Request) {
- w := newLoggingResponseWriter(ww, log.WithField("system", "http"))
- defer w.Log(r)
- fmt.Fprint(&w, "no-status")
-}
-
-func testLogWithDoubleStatus(ww http.ResponseWriter, r *http.Request) {
- w := newLoggingResponseWriter(ww, log.WithField("system", "http"))
- defer w.Log(r)
- w.WriteHeader(http.StatusOK)
- http.Redirect(&w, r, "/test", 301)
-}
-
-func TestExtractLogFieldsHidesQueryStrings(t *testing.T) {
- w := httptest.NewRecorder()
- r := httptest.NewRequest("GET", "/foo?token=bar", nil)
- r.Header.Set("Referer", "http://invalid.com/bar?token=baz")
-
- l := newLoggingResponseWriter(w, log.WithField("system", "http"))
-
- fields := l.extractLogFields(r)
-
- assert.Equal(t, fields["uri"], "/foo")
- assert.Equal(t, fields["referer"], "http://invalid.com/bar")
-}
-
-func TestLoggingWriter(t *testing.T) {
- assert.HTTPBodyContains(t, testLogWithStatus, "GET", "/test", nil, "with-status")
- assert.HTTPBodyContains(t, testLogWithoutStatus, "GET", "/test", nil, "no-status")
- assert.HTTPSuccess(t, testLogWithDoubleStatus, "GET", "/test", nil)
-}