From f2267082d9e33172663a0e0f8cfca52c19d004ae Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Sat, 17 Aug 2024 23:29:00 +0200 Subject: [PATCH] chore: debug playwright shutdown errors (#15456) --- server/http_auth.go | 3 +++ tests/evcc.js | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/server/http_auth.go b/server/http_auth.go index 160bd2ebd..06ccdc12a 100644 --- a/server/http_auth.go +++ b/server/http_auth.go @@ -2,6 +2,7 @@ package server import ( "encoding/json" + "fmt" "net/http" "strings" "time" @@ -97,6 +98,7 @@ func loginHandler(auth auth.Auth) http.HandlerFunc { } if !auth.IsAdminPasswordValid(req.Password) { + fmt.Println("auth: invalid password", req.Password) http.Error(w, "Invalid password", http.StatusUnauthorized) return } @@ -133,6 +135,7 @@ func ensureAuthHandler(auth auth.Auth) mux.MiddlewareFunc { // check jwt token ok, err := auth.ValidateJwtToken(jwtFromRequest(r)) if !ok || err != nil { + fmt.Println("auth: invalid auth token", jwtFromRequest(r)) http.Error(w, "Unauthorized", http.StatusUnauthorized) return } diff --git a/tests/evcc.js b/tests/evcc.js index d36e53063..07fb94046 100644 --- a/tests/evcc.js +++ b/tests/evcc.js @@ -88,10 +88,14 @@ async function _stop(instance) { } const port = workerPort(); console.log("shutting down evcc", { port }); - const res = await axios.post(`${baseUrl()}/api/auth/login`, { password: "secret" }); - console.log(res.status, res.statusText); - const cookie = res.headers["set-cookie"]; - await axios.post(`${baseUrl()}/api/system/shutdown`, {}, { headers: { cookie } }); + try { + const res = await axios.post(`${baseUrl()}/api/auth/login`, { password: "secret" }); + console.log(res.status, res.statusText); + const cookie = res.headers["set-cookie"]; + await axios.post(`${baseUrl()}/api/system/shutdown`, {}, { headers: { cookie } }); + } catch (err) { + console.error(err); + } console.log(`wait until port ${port} is closed`); await waitOn({ resources: [`tcp:localhost:${port}`], reverse: true }); console.log("evcc is down", { port });