Improve the maintainblity of the reserved username list (#32229)

(cherry picked from commit 6029d78ab5006e8fb4f42adb5a8c491f19fa7b0a)

Conflicts:
  models/user/user.go
	services/user/user_test.go
    trivial context conflict
	tests/integration/user_test.go
    discarded entirely because dot may be allowed in Forgejo under
    some conditions
This commit is contained in:
Earl Warren 2024-10-13 10:13:04 +03:00
parent eff28911d3
commit 7855e4bb56
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 39 additions and 46 deletions

View file

@ -114,12 +114,10 @@ func TestRenameUser(t *testing.T) {
})
t.Run("Non usable username", func(t *testing.T) {
usernames := []string{"--diff", "aa.png", ".well-known", "search", "aaa.atom"}
usernames := []string{"--diff", ".well-known", "gitea-actions", "aaa.atom", "aa.png"}
for _, username := range usernames {
t.Run(username, func(t *testing.T) {
require.Error(t, user_model.IsUsableUsername(username))
require.Error(t, RenameUser(db.DefaultContext, user, username))
})
require.Error(t, user_model.IsUsableUsername(username), "non-usable username: %s", username)
require.Error(t, RenameUser(db.DefaultContext, user, username), "non-usable username: %s", username)
}
})