mirror of
https://github.com/openfaas/faas.git
synced 2025-06-19 04:26:35 +00:00
@ -53,12 +53,11 @@ func Test_External_Auth_Wrapper_PassesValidAuth(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test_External_Auth_Wrapper_PassesValidAuthButOnly200IsValid this test exists
|
func Test_External_Auth_Wrapper_TimeoutGivesInternalServerError(t *testing.T) {
|
||||||
// to document the TODO action to consider all "2xx" statuses as valid.
|
|
||||||
func Test_External_Auth_Wrapper_PassesValidAuthButOnly200IsValid(t *testing.T) {
|
|
||||||
|
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusAccepted)
|
time.Sleep(50 * time.Millisecond)
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
}))
|
}))
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -67,22 +66,24 @@ func Test_External_Auth_Wrapper_PassesValidAuthButOnly200IsValid(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
passBody := false
|
passBody := false
|
||||||
handler := MakeExternalAuthHandler(next, time.Second*5, s.URL, passBody)
|
handler := MakeExternalAuthHandler(next, time.Millisecond*10, s.URL, passBody)
|
||||||
|
|
||||||
req := httptest.NewRequest(http.MethodGet, s.URL, nil)
|
req := httptest.NewRequest(http.MethodGet, s.URL, nil)
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
handler(rr, req)
|
handler(rr, req)
|
||||||
want := http.StatusUnauthorized
|
|
||||||
|
want := http.StatusInternalServerError
|
||||||
if rr.Code != want {
|
if rr.Code != want {
|
||||||
t.Errorf("Status incorrect, want: %d, but got %d", want, rr.Code)
|
t.Errorf("Status incorrect, want: %d, but got %d", want, rr.Code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func Test_External_Auth_Wrapper_TimeoutGivesInternalServerError(t *testing.T) {
|
// // Test_External_Auth_Wrapper_PassesValidAuthButOnly200IsValid this test exists
|
||||||
|
// // to document the TODO action to consider all "2xx" statuses as valid.
|
||||||
|
// func Test_External_Auth_Wrapper_PassesValidAuthButOnly200IsValid(t *testing.T) {
|
||||||
|
|
||||||
// s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
// s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
// time.Sleep(50 * time.Millisecond)
|
// w.WriteHeader(http.StatusAccepted)
|
||||||
// w.WriteHeader(http.StatusOK)
|
|
||||||
// }))
|
// }))
|
||||||
// defer s.Close()
|
// defer s.Close()
|
||||||
|
|
||||||
@ -91,13 +92,12 @@ func Test_External_Auth_Wrapper_PassesValidAuthButOnly200IsValid(t *testing.T) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// passBody := false
|
// passBody := false
|
||||||
// handler := MakeExternalAuthHandler(next, time.Millisecond*10, s.URL, passBody)
|
// handler := MakeExternalAuthHandler(next, time.Second*5, s.URL, passBody)
|
||||||
|
|
||||||
// req := httptest.NewRequest(http.MethodGet, s.URL, nil)
|
// req := httptest.NewRequest(http.MethodGet, s.URL, nil)
|
||||||
// rr := httptest.NewRecorder()
|
// rr := httptest.NewRecorder()
|
||||||
// handler(rr, req)
|
// handler(rr, req)
|
||||||
|
// want := http.StatusUnauthorized
|
||||||
// want := http.StatusInternalServerError
|
|
||||||
// if rr.Code != want {
|
// if rr.Code != want {
|
||||||
// t.Errorf("Status incorrect, want: %d, but got %d", want, rr.Code)
|
// t.Errorf("Status incorrect, want: %d, but got %d", want, rr.Code)
|
||||||
// }
|
// }
|
||||||
|
Reference in New Issue
Block a user