Merge branch 'origin/main' into session-management

Conflict resolutions:
- models/migrations/v1_26/v328.go: kept origin/main's TokenPermissions
  migration; moved AddUserSessionTable to v1_27/v332.go (1.26.0 closed
  at migration 330; 1.27 starts at 331).
- models/migrations/migrations.go: registered session migration as 332
  using v1_27.AddUserSessionTable.
- tests/integration/api_admin_test.go: adopted new DecodeJSON return
  style; cron count is 30 (added cleanup_user_sessions task).

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
This commit is contained in:
silverwind
2026-05-08 08:48:32 +02:00
co-authored by Claude
1841 changed files with 83555 additions and 29241 deletions
+6 -12
View File
@@ -36,8 +36,7 @@ func TestAPIAdminCreateAndDeleteSSHKey(t *testing.T) {
}).AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusCreated)
var newPublicKey api.PublicKey
DecodeJSON(t, resp, &newPublicKey)
newPublicKey := DecodeJSON(t, resp, &api.PublicKey{})
unittest.AssertExistsAndLoadBean(t, &asymkey_model.PublicKey{
ID: newPublicKey.ID,
Name: newPublicKey.Title,
@@ -73,8 +72,7 @@ func TestAPIAdminDeleteUnauthorizedKey(t *testing.T) {
"title": "test-key",
}).AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusCreated)
var newPublicKey api.PublicKey
DecodeJSON(t, resp, &newPublicKey)
newPublicKey := DecodeJSON(t, resp, &api.PublicKey{})
token = getUserToken(t, normalUsername, auth_model.AccessTokenScopeAll)
req = NewRequestf(t, "DELETE", "/api/v1/admin/users/%s/keys/%d", adminUsername, newPublicKey.ID).
@@ -91,8 +89,7 @@ func TestAPISudoUser(t *testing.T) {
req := NewRequest(t, "GET", "/api/v1/user?sudo="+normalUsername).
AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusOK)
var user api.User
DecodeJSON(t, resp, &user)
user := DecodeJSON(t, resp, &api.User{})
assert.Equal(t, normalUsername, user.UserName)
}
@@ -116,8 +113,7 @@ func TestAPIListUsers(t *testing.T) {
req := NewRequest(t, "GET", "/api/v1/admin/users").
AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusOK)
var users []api.User
DecodeJSON(t, resp, &users)
users := DecodeJSON(t, resp, []api.User{})
found := false
for _, user := range users {
@@ -306,8 +302,7 @@ func TestAPICron(t *testing.T) {
assert.Equal(t, "30", resp.Header().Get("X-Total-Count"))
var crons []api.Cron
DecodeJSON(t, resp, &crons)
crons := DecodeJSON(t, resp, []api.Cron{})
assert.Len(t, crons, 30)
})
@@ -328,8 +323,7 @@ func TestAPICron(t *testing.T) {
AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusOK)
var crons []api.Cron
DecodeJSON(t, resp, &crons)
crons := DecodeJSON(t, resp, []api.Cron{})
for _, cron := range crons {
if cron.Name == "archive_cleanup" {