refactor(api): convert bot accounts through the admin user edit endpoint (#39355)

Follow-up to https://github.com/go-gitea/gitea/pull/38966. Replaces the
unreleased `POST /admin/users/{username}/convert-type` endpoint with a
`type` field on `PATCH /admin/users/{username}`.
This commit is contained in:
silverwind
2026-09-18 17:11:56 +02:00
committed by GitHub
parent 3bec08f998
commit 85eaf5c71c
12 changed files with 57 additions and 203 deletions
+3 -1
View File
@@ -259,7 +259,9 @@ func TestAdminBotUser(t *testing.T) {
}), http.StatusSeeOther)
}
MakeRequest(t, NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user4/convert-type", map[string]string{"user_type": "Bot"}).AddBasicAuth("user1"), http.StatusNoContent)
MakeRequest(t, NewRequestWithJSON(t, "PATCH", "/api/v1/admin/users/org3", map[string]string{"type": "Organization"}).AddBasicAuth("user1"), http.StatusOK)
MakeRequest(t, NewRequestWithJSON(t, "PATCH", "/api/v1/admin/users/user4", map[string]string{"type": "Bot", "password": "Bot-Password-1234"}).AddBasicAuth("user1"), http.StatusBadRequest)
MakeRequest(t, NewRequestWithJSON(t, "PATCH", "/api/v1/admin/users/user4", map[string]string{"type": "Bot"}).AddBasicAuth("user1"), http.StatusOK)
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})
assert.True(t, user4.IsTypeBot())
resp := MakeRequest(t, NewRequest(t, "GET", "/api/v1/users/user4"), http.StatusOK)