Files
filebrowser/backend/pkg/settings/auth_admin_password_test.go
T
+11 45a14bf2f2 Beta/v2.1.0 (#3046)
Signed-off-by: MichaIng <micha@dietpi.com>
Co-authored-by: Kevin B. <kurami32_kbm@proton.me>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Mattijs Bliek <mattijs@mattijsbliek.com>
Co-authored-by: GammelSami <39372285+GammelSami@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: yzxcj797 <54314860+yzxcj797@users.noreply.github.com>
Co-authored-by: yzxcj797 <yzxcj797@users.noreply.github.com>
Co-authored-by: DireMunchkin <dire.munchkin@proton.me>
Co-authored-by: Chris <39135018+Chri6s@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Aditya Raj Singh <github@adityaraj.com>
Co-authored-by: tbsagdic <86909795+tbsagdic@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Ethan Lee Qi Yang <pluscompanyhqDEPT@gmail.com>
Co-authored-by: Aditya Raj Singh <aditya@bncw.in>
Co-authored-by: MichaIng <micha@dietpi.com>
Co-authored-by: FandacqkaCorp <david@davidyloreto.com>
Co-authored-by: FandacqkaCorp <275647464+FandacqkaCorp@users.noreply.github.com>
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: connorjfarrell <connorjfarrell@users.noreply.github.com>
2026-09-30 13:04:20 -05:00

35 lines
1.1 KiB
Go

package settings
import "testing"
func TestConfigTriggersAdminPasswordReset(t *testing.T) {
origNested := Config.Auth.Methods.PasswordAuth.AdminPassword
origLegacy := Config.Auth.AdminPassword
defer func() {
Config.Auth.Methods.PasswordAuth.AdminPassword = origNested
Config.Auth.AdminPassword = origLegacy
}()
Config.Auth.Methods.PasswordAuth.AdminPassword = ""
Config.Auth.AdminPassword = ""
if ConfigTriggersAdminPasswordReset() {
t.Fatal("empty adminPassword should not trigger reset")
}
Config.Auth.AdminPassword = "admin"
if ConfigTriggersAdminPasswordReset() {
t.Fatal("admin adminPassword should not trigger reset")
}
Config.Auth.AdminPassword = "s3cret"
if !ConfigTriggersAdminPasswordReset() {
t.Fatal("non-default top-level adminPassword should trigger reset")
}
Config.Auth.Methods.PasswordAuth.AdminPassword = "nested-secret"
Config.Auth.AdminPassword = "legacy-secret"
if !ConfigTriggersAdminPasswordReset() {
t.Fatal("nested adminPassword should trigger reset")
}
if got := PasswordAdminPassword(); got != "nested-secret" {
t.Fatalf("PasswordAdminPassword() = %q, want nested-secret", got)
}
}