You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-08-08 22:46:33 +02:00
Move Logging to Middleware Package (#1070)
* Use a specialized ResponseWriter in middleware * Track User & Upstream in RequestScope * Wrap responses in our custom ResponseWriter * Add tests for logging middleware * Inject upstream metadata into request scope * Use custom ResponseWriter only in logging middleware * Assume RequestScope is never nil
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
middlewareapi "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/middleware"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/extensions/table"
|
||||
. "github.com/onsi/gomega"
|
||||
@ -40,10 +41,14 @@ var _ = Describe("Static Response Suite", func() {
|
||||
handler := newStaticResponseHandler(id, code)
|
||||
|
||||
req := httptest.NewRequest("", in.requestPath, nil)
|
||||
req = middlewareapi.AddRequestScope(req, &middlewareapi.RequestScope{})
|
||||
|
||||
rw := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rw, req)
|
||||
|
||||
Expect(rw.Header().Get("GAP-Upstream-Address")).To(Equal(id))
|
||||
scope := middlewareapi.GetRequestScope(req)
|
||||
Expect(scope.Upstream).To(Equal(id))
|
||||
|
||||
Expect(rw.Code).To(Equal(in.expectedCode))
|
||||
Expect(rw.Body.String()).To(Equal(in.expectedBody))
|
||||
},
|
||||
|
Reference in New Issue
Block a user