mirror of
https://github.com/ZizzyDizzyMC/linx-server.git
synced 2026-01-23 02:14:33 +00:00
improve auth tests and rename auth struct
This commit is contained in:
parent
aa7dad3a03
commit
3c9e260926
2 changed files with 21 additions and 13 deletions
|
|
@ -52,21 +52,29 @@ func TestIndex(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestIndexAuthKeys(t *testing.T) {
|
||||
func TestAuthKeysRedirects(t *testing.T) {
|
||||
Config.authFile = "/dev/null"
|
||||
|
||||
mux := setup()
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
req, err := http.NewRequest("GET", "/", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
redirects := []string{
|
||||
"/",
|
||||
"/paste/",
|
||||
}
|
||||
|
||||
mux.ServeHTTP(w, req)
|
||||
mux := setup()
|
||||
|
||||
if w.Code != 303 {
|
||||
t.Fatalf("Status code is not 301, but %d", w.Code)
|
||||
for _, v := range redirects {
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
req, err := http.NewRequest("GET", v, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mux.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != 303 {
|
||||
t.Fatalf("Status code is not 303, but %d", w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
Config.authFile = ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue