Handle slash-suffixed web root
All checks were successful
release / create-release (push) Successful in 9s
release / build-and-upload (pia-qbt-autoport-linux-amd64, amd64, linux, pia-qbt-autoport-linux-amd64) (push) Successful in 1m25s
release / build-and-upload (pia-qbt-autoport-macos-amd64, amd64, darwin, pia-qbt-autoport-macos-amd64) (push) Successful in 1m21s
release / build-and-upload (pia-qbt-autoport-macos-arm64, arm64, darwin, pia-qbt-autoport-macos-arm64) (push) Successful in 1m13s
release / build-and-upload (pia-qbt-autoport-windows-amd64.exe, amd64, windows, pia-qbt-autoport-windows-amd64.exe) (push) Successful in 1m14s
All checks were successful
release / create-release (push) Successful in 9s
release / build-and-upload (pia-qbt-autoport-linux-amd64, amd64, linux, pia-qbt-autoport-linux-amd64) (push) Successful in 1m25s
release / build-and-upload (pia-qbt-autoport-macos-amd64, amd64, darwin, pia-qbt-autoport-macos-amd64) (push) Successful in 1m21s
release / build-and-upload (pia-qbt-autoport-macos-arm64, arm64, darwin, pia-qbt-autoport-macos-arm64) (push) Successful in 1m13s
release / build-and-upload (pia-qbt-autoport-windows-amd64.exe, amd64, windows, pia-qbt-autoport-windows-amd64.exe) (push) Successful in 1m14s
This commit is contained in:
@@ -57,6 +57,7 @@ func (a *App) Router() http.Handler {
|
||||
mux.HandleFunc("/status", a.handleStatus)
|
||||
mux.HandleFunc("/pia", a.handlePIA)
|
||||
mux.HandleFunc("/_", a.handleWebRoot)
|
||||
mux.HandleFunc("/_/", a.handleWebRoot)
|
||||
mux.HandleFunc("/_/login", a.handleWebLogin)
|
||||
mux.HandleFunc("/_/chart.js", a.handleWebChartJS)
|
||||
mux.HandleFunc("/_/app.js", a.handleWebAppJS)
|
||||
|
||||
@@ -64,6 +64,22 @@ func TestWebLoginPageSetsNoStoreHeaders(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebRootSlashRedirects(t *testing.T) {
|
||||
app := NewApp(Config{APIKey: "super-secret"}, BuildInfo{}, "")
|
||||
req := httptest.NewRequest(http.MethodGet, "/_/", nil)
|
||||
rr := httptest.NewRecorder()
|
||||
|
||||
app.Router().ServeHTTP(rr, req)
|
||||
|
||||
res := rr.Result()
|
||||
if res.StatusCode != http.StatusSeeOther {
|
||||
t.Fatalf("status = %d, want %d", res.StatusCode, http.StatusSeeOther)
|
||||
}
|
||||
if got := res.Header.Get("Location"); got != "/_/login" {
|
||||
t.Fatalf("Location = %q, want /_/login", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebConfigTogglePersistsToFile(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
configPath := filepath.Join(dir, "config.json")
|
||||
|
||||
Reference in New Issue
Block a user