mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: add database constraint to enforce minimum username length (#19453)
Username length and format, via regex, are already enforced at the application layer, but we have some code paths with database queries where we could optimize away many of the DB query calls if we could be sure at the database level that the username is never an empty string. For example: https://github.com/coder/coder/pull/19395 --------- Signed-off-by: Callum Styan <callumstyan@gmail.com>
This commit is contained in:
@@ -1552,8 +1552,11 @@ func TestUpdateSystemUser(t *testing.T) {
|
||||
|
||||
// When: attempting to update a system user's name.
|
||||
_, err = db.UpdateUserProfile(ctx, database.UpdateUserProfileParams{
|
||||
ID: systemUser.ID,
|
||||
Name: "not prebuilds",
|
||||
ID: systemUser.ID,
|
||||
Email: systemUser.Email,
|
||||
Username: systemUser.Username,
|
||||
AvatarURL: systemUser.AvatarURL,
|
||||
Name: "not prebuilds",
|
||||
})
|
||||
// Then: the attempt is rejected by a postgres trigger.
|
||||
// require.ErrorContains(t, err, "Cannot modify or delete system users")
|
||||
|
||||
Reference in New Issue
Block a user