diff options
author | Vladimir Yakovlev <nagos@inbox.ru> | 2022-10-20 21:20:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-20 19:20:01 +0100 |
commit | ffa4f4b570c3bb5fb4533db4bab93985ee99e241 (patch) | |
tree | 863d3140863344ca7e3fc914a17af113e3484496 /tests/integration/integration_test.go | |
parent | 6a0330979f74c6947db11aef59c094135aacd29a (diff) | |
download | gitea-ffa4f4b570c3bb5fb4533db4bab93985ee99e241.tar.gz gitea-ffa4f4b570c3bb5fb4533db4bab93985ee99e241.zip |
Check for valid user token in integration tests (#21520)
Added checks for logged user token.
Some builds fail at unrelated tests, due to missing token.
Example:
https://drone.gitea.io/go-gitea/gitea/62011/2/14
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'tests/integration/integration_test.go')
-rw-r--r-- | tests/integration/integration_test.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 8fc8a854a7..416cc126bd 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -18,6 +18,7 @@ import ( "os" "path/filepath" "strings" + "sync/atomic" "testing" "time" @@ -263,19 +264,19 @@ var tokenCounter int64 func getTokenForLoggedInUser(t testing.TB, session *TestSession) string { t.Helper() - tokenCounter++ req := NewRequest(t, "GET", "/user/settings/applications") resp := session.MakeRequest(t, req, http.StatusOK) doc := NewHTMLParser(t, resp.Body) req = NewRequestWithValues(t, "POST", "/user/settings/applications", map[string]string{ "_csrf": doc.GetCSRF(), - "name": fmt.Sprintf("api-testing-token-%d", tokenCounter), + "name": fmt.Sprintf("api-testing-token-%d", atomic.AddInt64(&tokenCounter, 1)), }) session.MakeRequest(t, req, http.StatusSeeOther) req = NewRequest(t, "GET", "/user/settings/applications") resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) token := htmlDoc.doc.Find(".ui.info p").Text() + assert.NotEmpty(t, token) return token } |