重构:移除环境变量管理员初始化

This commit is contained in:
yml2213
2026-08-13 14:21:22 +08:00
parent 538be52636
commit a637101ca8
7 changed files with 0 additions and 87 deletions
-23
View File
@@ -336,26 +336,3 @@ func TestListMerchantAccountGroupsExcludesPlatformAdmins(t *testing.T) {
t.Fatalf("unexpected merchant account group: %+v", groups[0])
}
}
func TestEnsureAdminUsesConfiguredCredentialsOnlyForEmptyDatabase(t *testing.T) {
db := newServiceTestDB(t)
tenant := NewTenantService(db)
auth := NewAuthService(db, nil, tenant)
if err := auth.EnsureAdmin("skin_nh_admin", "secure-password"); err != nil {
t.Fatalf("create configured admin: %v", err)
}
var created model.User
if err := db.Where("username = ?", "skin_nh_admin").First(&created).Error; err != nil {
t.Fatalf("configured admin should exist: %v", err)
}
if err := bcrypt.CompareHashAndPassword([]byte(created.PasswordHash), []byte("secure-password")); err != nil {
t.Fatalf("configured password should match: %v", err)
}
if err := auth.EnsureAdmin("replacement-admin", "another-password"); err != nil {
t.Fatalf("existing admin should not be replaced: %v", err)
}
var count int64
if err := db.Model(&model.User{}).Where("role = ?", model.RoleAdmin).Count(&count).Error; err != nil || count != 1 {
t.Fatalf("existing admin should remain unchanged, count=%d err=%v", count, err)
}
}