package web import ( "net/http" "net/http/httptest" "strings" "testing" "adammathes.com/neko/config" ) func TestRouting(t *testing.T) { config.Config.DigestPassword = "secret" router := NewRouter(&config.Config) tests := []struct { name string path string method string cookie *http.Cookie expectedStatus int containsBody string }{ { name: "Root serves V3 UI", path: "/", method: "GET", expectedStatus: http.StatusOK, containsBody: "", // from V3 dist/v3 }, { name: "/v3/ serves v3 UI", path: "/v3/", method: "GET", expectedStatus: http.StatusOK, containsBody: "", }, { name: "/v1/ redirects unauthenticated", path: "/v1/", method: "GET", expectedStatus: http.StatusTemporaryRedirect, }, { name: "/v1/ serves legacy UI when authenticated", path: "/v1/", method: "GET", cookie: authCookie(), expectedStatus: http.StatusOK, containsBody: "