mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-02 13:36:42 +02:00
Merge remote-tracking branch 'upstream/main' into limit-repo-size
Resolved Conflicts: models/migrations/migrations.go models/migrations/v1_19/v236.go new file: v237.go
This commit is contained in:
@@ -24,7 +24,7 @@ import (
|
||||
func TestAPITeam(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
teamUser := unittest.AssertExistsAndLoadBean(t, &organization.TeamUser{})
|
||||
teamUser := unittest.AssertExistsAndLoadBean(t, &organization.TeamUser{ID: 1})
|
||||
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: teamUser.TeamID})
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: teamUser.UID})
|
||||
|
||||
|
||||
@@ -264,18 +264,45 @@ var tokenCounter int64
|
||||
|
||||
func getTokenForLoggedInUser(t testing.TB, session *TestSession) string {
|
||||
t.Helper()
|
||||
var token string
|
||||
req := NewRequest(t, "GET", "/user/settings/applications")
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
doc := NewHTMLParser(t, resp.Body)
|
||||
var csrf string
|
||||
for _, cookie := range resp.Result().Cookies() {
|
||||
if cookie.Name != "_csrf" {
|
||||
continue
|
||||
}
|
||||
csrf = cookie.Value
|
||||
break
|
||||
}
|
||||
if csrf == "" {
|
||||
doc := NewHTMLParser(t, resp.Body)
|
||||
csrf = doc.GetCSRF()
|
||||
}
|
||||
assert.NotEmpty(t, csrf)
|
||||
req = NewRequestWithValues(t, "POST", "/user/settings/applications", map[string]string{
|
||||
"_csrf": doc.GetCSRF(),
|
||||
"_csrf": csrf,
|
||||
"name": fmt.Sprintf("api-testing-token-%d", atomic.AddInt64(&tokenCounter, 1)),
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// Log the flash values on failure
|
||||
if !assert.Equal(t, resp.Result().Header["Location"], []string{"/user/settings/applications"}) {
|
||||
for _, cookie := range resp.Result().Cookies() {
|
||||
if cookie.Name != "macaron_flash" {
|
||||
continue
|
||||
}
|
||||
flash, _ := url.ParseQuery(cookie.Value)
|
||||
for key, value := range flash {
|
||||
t.Logf("Flash %q: %q", key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
token = htmlDoc.doc.Find(".ui.info p").Text()
|
||||
assert.NotEmpty(t, token)
|
||||
return token
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user