Skip to content

Commit cc5a6d7

Browse files
committed
tests: ensure all forwarded headers are set on tests
1 parent b2e3a85 commit cc5a6d7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/controller/proxy_controller_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ func TestProxyHandler(t *testing.T) {
136136
// Test logged out user (nginx)
137137
recorder = httptest.NewRecorder()
138138
req = httptest.NewRequest("GET", "/api/auth/nginx", nil)
139+
req.Header.Set("X-Forwarded-Proto", "https")
140+
req.Header.Set("X-Forwarded-Host", "example.com")
141+
req.Header.Set("X-Forwarded-Uri", "/somepath")
139142
router.ServeHTTP(recorder, req)
140143

141144
assert.Equal(t, 401, recorder.Code)
@@ -175,6 +178,9 @@ func TestProxyHandler(t *testing.T) {
175178

176179
req = httptest.NewRequest("GET", "/api/auth/traefik", nil)
177180
req.Header.Set("Cookie", cookie)
181+
req.Header.Set("X-Forwarded-Proto", "https")
182+
req.Header.Set("X-Forwarded-Host", "example.com")
183+
req.Header.Set("X-Forwarded-Uri", "/somepath")
178184
req.Header.Set("Accept", "text/html")
179185
router.ServeHTTP(recorder, req)
180186

@@ -204,6 +210,9 @@ func TestProxyHandler(t *testing.T) {
204210
})
205211

206212
req = httptest.NewRequest("GET", "/api/auth/traefik", nil)
213+
req.Header.Set("X-Forwarded-Proto", "https")
214+
req.Header.Set("X-Forwarded-Host", "example.com")
215+
req.Header.Set("X-Forwarded-Uri", "/somepath")
207216
req.SetBasicAuth("testuser", "test")
208217
router.ServeHTTP(recorder, req)
209218

0 commit comments

Comments
 (0)