Skip to content

Commit 8043fbc

Browse files
silverwindnagoswxiaoguang
authored
Check for valid user token in integration tests (#21520) (#21529)
Backport #21520 Added checks for logged user token. Some builds fail at unrelated tests, due to missing token. Co-authored-by: Vladimir Yakovlev <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 556e2d5 commit 8043fbc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

integrations/integration_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"path/filepath"
2222
"runtime"
2323
"strings"
24+
"sync/atomic"
2425
"testing"
2526
"time"
2627

@@ -430,19 +431,19 @@ var tokenCounter int64
430431

431432
func getTokenForLoggedInUser(t testing.TB, session *TestSession) string {
432433
t.Helper()
433-
tokenCounter++
434434
req := NewRequest(t, "GET", "/user/settings/applications")
435435
resp := session.MakeRequest(t, req, http.StatusOK)
436436
doc := NewHTMLParser(t, resp.Body)
437437
req = NewRequestWithValues(t, "POST", "/user/settings/applications", map[string]string{
438438
"_csrf": doc.GetCSRF(),
439-
"name": fmt.Sprintf("api-testing-token-%d", tokenCounter),
439+
"name": fmt.Sprintf("api-testing-token-%d", atomic.AddInt64(&tokenCounter, 1)),
440440
})
441441
resp = session.MakeRequest(t, req, http.StatusSeeOther)
442442
req = NewRequest(t, "GET", "/user/settings/applications")
443443
resp = session.MakeRequest(t, req, http.StatusOK)
444444
htmlDoc := NewHTMLParser(t, resp.Body)
445445
token := htmlDoc.doc.Find(".ui.info p").Text()
446+
assert.NotEmpty(t, token)
446447
return token
447448
}
448449

0 commit comments

Comments
 (0)