mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-01-08 04:03:58 +02:00
Added tests
Signed-off-by: Josh Michielsen <github@mickey.dev>
This commit is contained in:
parent
aae91b0ad6
commit
271efe776e
29
http_test.go
29
http_test.go
@ -106,3 +106,32 @@ func TestGCPHealthcheckNotIngressPut(t *testing.T) {
|
||||
|
||||
assert.Equal(t, "test", rw.Body.String())
|
||||
}
|
||||
|
||||
func TestRedirectToHTTPSTrue(t *testing.T) {
|
||||
opts := NewOptions()
|
||||
opts.ForceHTTPS = true
|
||||
handler := func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Write([]byte("test"))
|
||||
}
|
||||
|
||||
h := redirectToHTTPS(opts, http.HandlerFunc(handler))
|
||||
rw := httptest.NewRecorder()
|
||||
r, _ := http.NewRequest("GET", "/", nil)
|
||||
h.ServeHTTP(rw, r)
|
||||
|
||||
assert.Equal(t, http.StatusPermanentRedirect, rw.Code, "status code should be %d, got: %d", http.StatusPermanentRedirect, rw.Code)
|
||||
}
|
||||
|
||||
func TestRedirectToHTTPSFalse(t *testing.T) {
|
||||
opts := NewOptions()
|
||||
handler := func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Write([]byte("test"))
|
||||
}
|
||||
|
||||
h := redirectToHTTPS(opts, http.HandlerFunc(handler))
|
||||
rw := httptest.NewRecorder()
|
||||
r, _ := http.NewRequest("GET", "/", nil)
|
||||
h.ServeHTTP(rw, r)
|
||||
|
||||
assert.Equal(t, http.StatusOK, rw.Code, "status code should be %d, got: %d", http.StatusOK, rw.Code)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user