mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-27 00:49:41 -05:00
+10








3c02eedca6
Co-authored-by: Kevin B. <kurami32_kbm@proton.me> Co-authored-by: Gabriel Górski <me@glaeqen.eu> Co-authored-by: Joel Godfrey <82655889+BaccanoMob@users.noreply.github.com> Co-authored-by: Shane Chiu <71911511+pwn2ooown@users.noreply.github.com> Co-authored-by: carloda <35763669+carloda@users.noreply.github.com> Co-authored-by: Taufik Hidayat <taufikdev88@gmail.com> Co-authored-by: Stephan Paternotte <Stephan-P@users.noreply.github.com> Co-authored-by: SIDDHU SINGH <siddhu3116@gmail.com> Co-authored-by: Gaurav Kalal <117557391+Gorupa@users.noreply.github.com> Co-authored-by: Nebula <40148908+nebula-it@users.noreply.github.com> Co-authored-by: Juan Soler <juansoler@gmail.com> Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com> Co-authored-by: Anatolii Prylutskyi <anpryl@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Graham Steffaniak <graham@debian-lake.ghome.net> Co-authored-by: Neil <kylelzzz02@icloud.com> Co-authored-by: Graham <info@quantumx-apps.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
package users
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestFrontendUserContainsOtpEnabled(t *testing.T) {
|
|
structType := reflect.TypeOf(FrontendUser{})
|
|
|
|
otpEnabledField, exists := structType.FieldByName("OtpEnabled")
|
|
if !exists {
|
|
t.Fatal("OtpEnabled field should exist on FrontendUser")
|
|
}
|
|
|
|
expectedTag := "otpEnabled"
|
|
if otpEnabledField.Tag.Get("json") != expectedTag {
|
|
t.Errorf("Expected JSON tag '%s', got '%s'", expectedTag, otpEnabledField.Tag.Get("json"))
|
|
}
|
|
|
|
if otpEnabledField.Type.Kind() != reflect.Bool {
|
|
t.Errorf("Expected OtpEnabled to be bool, got %s", otpEnabledField.Type.Kind())
|
|
}
|
|
}
|
|
|
|
func TestNonAdminEditableDoesNotDuplicateOtpEnabled(t *testing.T) {
|
|
structType := reflect.TypeOf(NonAdminEditable{})
|
|
if _, exists := structType.FieldByName("OtpEnabled"); exists {
|
|
t.Fatal("OtpEnabled should not be duplicated on NonAdminEditable")
|
|
}
|
|
}
|
|
|
|
func TestGetNonAdminEditableFieldNames(t *testing.T) {
|
|
names := getNonAdminEditableFieldNames()
|
|
|
|
for _, name := range names {
|
|
if name == "OtpEnabled" {
|
|
t.Error("OtpEnabled should not be in NonAdminEditable field names")
|
|
}
|
|
}
|
|
|
|
expectedFields := []string{"DarkMode", "Locale", "ViewMode", "SingleClick"}
|
|
for _, expected := range expectedFields {
|
|
found := false
|
|
for _, name := range names {
|
|
if name == expected {
|
|
found = true
|
|
break
|
|
}
|
|
}
|
|
if !found {
|
|
t.Errorf("Expected field %s should be in non-admin editable fields", expected)
|
|
}
|
|
}
|
|
}
|
|
|
|
func getNonAdminEditableFieldNames() []string {
|
|
var names []string
|
|
t := reflect.TypeOf(NonAdminEditable{})
|
|
for i := 0; i < t.NumField(); i++ {
|
|
names = append(names, t.Field(i).Name)
|
|
}
|
|
return names
|
|
}
|