From 97fb67788797ff42ea3c99b54124cd58fa5b2807 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 24 Apr 2026 15:07:16 +0200 Subject: [PATCH] chore(api): deflake TestHTTPLogin on Windows (#10667) Hopefully deflakes TestHTTPLogin on Windows, where it currently often times out, presumably in the config saving stage after already having started a shutdown of the API and being CPU constrained due to password hashing. --------- Signed-off-by: Jakob Borg --- lib/api/api_test.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/api/api_test.go b/lib/api/api_test.go index 389f30c44..2637f2395 100644 --- a/lib/api/api_test.go +++ b/lib/api/api_test.go @@ -571,7 +571,7 @@ func httpPost(url string, body map[string]string, cookies []*http.Cookie, t *tes } func TestHTTPLogin(t *testing.T) { - t.Parallel() + // This test intentionally does not use t.Parallel() httpGetBasicAuth := func(url string, username string, password string) *http.Response { t.Helper() @@ -602,7 +602,6 @@ func TestHTTPLogin(t *testing.T) { t.Run(fmt.Sprintf("%d path", expectedOkStatus), func(t *testing.T) { t.Run("no auth is rejected", func(t *testing.T) { - t.Parallel() resp := httpGetBasicAuth(url, "", "") if resp.StatusCode != expectedFailStatus { t.Errorf("Unexpected non-%d return code %d for unauthed request", expectedFailStatus, resp.StatusCode) @@ -613,7 +612,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("incorrect password is rejected", func(t *testing.T) { - t.Parallel() resp := httpGetBasicAuth(url, "üser", "rksmrgs") if resp.StatusCode != expectedFailStatus { t.Errorf("Unexpected non-%d return code %d for incorrect password", expectedFailStatus, resp.StatusCode) @@ -624,7 +622,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("incorrect username is rejected", func(t *testing.T) { - t.Parallel() resp := httpGetBasicAuth(url, "user", "räksmörgås") // string literals in Go source code are in UTF-8 if resp.StatusCode != expectedFailStatus { t.Errorf("Unexpected non-%d return code %d for incorrect username", expectedFailStatus, resp.StatusCode) @@ -635,7 +632,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("UTF-8 auth works", func(t *testing.T) { - t.Parallel() resp := httpGetBasicAuth(url, "üser", "räksmörgås") // string literals in Go source code are in UTF-8 if resp.StatusCode != expectedOkStatus { t.Errorf("Unexpected non-%d return code %d for authed request (UTF-8)", expectedOkStatus, resp.StatusCode) @@ -646,7 +642,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("Logout removes the session cookie", func(t *testing.T) { - t.Parallel() resp := httpGetBasicAuth(url, "üser", "räksmörgås") // string literals in Go source code are in UTF-8 if resp.StatusCode != expectedOkStatus { t.Errorf("Unexpected non-%d return code %d for authed request (UTF-8)", expectedOkStatus, resp.StatusCode) @@ -661,7 +656,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("Session cookie is invalid after logout", func(t *testing.T) { - t.Parallel() loginResp := httpGetBasicAuth(url, "üser", "räksmörgås") // string literals in Go source code are in UTF-8 if loginResp.StatusCode != expectedOkStatus { t.Errorf("Unexpected non-%d return code %d for authed request (UTF-8)", expectedOkStatus, loginResp.StatusCode) @@ -683,7 +677,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("ISO-8859-1 auth works", func(t *testing.T) { - t.Parallel() resp := httpGetBasicAuth(url, "\xfcser", "r\xe4ksm\xf6rg\xe5s") // escaped ISO-8859-1 if resp.StatusCode != expectedOkStatus { t.Errorf("Unexpected non-%d return code %d for authed request (ISO-8859-1)", expectedOkStatus, resp.StatusCode) @@ -694,7 +687,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("bad X-API-Key is rejected", func(t *testing.T) { - t.Parallel() resp := httpGetXapikey(url, testAPIKey+"X") if resp.StatusCode != expectedFailStatus { t.Errorf("Unexpected non-%d return code %d for bad API key", expectedFailStatus, resp.StatusCode) @@ -705,7 +697,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("good X-API-Key is accepted", func(t *testing.T) { - t.Parallel() resp := httpGetXapikey(url, testAPIKey) if resp.StatusCode != expectedOkStatus { t.Errorf("Unexpected non-%d return code %d for API key", expectedOkStatus, resp.StatusCode) @@ -716,7 +707,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("bad Bearer is rejected", func(t *testing.T) { - t.Parallel() resp := httpGetAuthorizationBearer(url, testAPIKey+"X") if resp.StatusCode != expectedFailStatus { t.Errorf("Unexpected non-%d return code %d for bad Authorization: Bearer", expectedFailStatus, resp.StatusCode) @@ -727,7 +717,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("good Bearer is accepted", func(t *testing.T) { - t.Parallel() resp := httpGetAuthorizationBearer(url, testAPIKey) if resp.StatusCode != expectedOkStatus { t.Errorf("Unexpected non-%d return code %d for Authorization: Bearer", expectedOkStatus, resp.StatusCode) @@ -748,8 +737,6 @@ func TestHTTPLogin(t *testing.T) { testWith(false, http.StatusNotFound, http.StatusForbidden, "/any-path/that/does/nooooooot/match-any/noauth-pattern") t.Run("Password change invalidates old and enables new password", func(t *testing.T) { - t.Parallel() - // This test needs a longer-than-default shutdown timeout to finish saving // config changes when running on GitHub Actions shutdownTimeout := time.Second @@ -786,8 +773,6 @@ func TestHTTPLogin(t *testing.T) { newPassword := "123!asdF" t.Run("when done via /rest/config", func(t *testing.T) { - t.Parallel() - w := initConfig(initialPassword, t) { baseURL := startHTTPWithShutdownTimeout(t, w, shutdownTimeout) @@ -820,8 +805,6 @@ func TestHTTPLogin(t *testing.T) { }) t.Run("when done via /rest/config/gui", func(t *testing.T) { - t.Parallel() - w := initConfig(initialPassword, t) { baseURL := startHTTPWithShutdownTimeout(t, w, shutdownTimeout)