Skip to content

Commit

Permalink
chore: debug playwright shutdown errors (evcc-io#15456)
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis authored Aug 17, 2024
1 parent f73072d commit f226708
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions server/http_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"encoding/json"
"fmt"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 8 additions & 4 deletions tests/evcc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit f226708

Please sign in to comment.