forked from upstream/filebrowser
+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>
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package settings_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gtsteffaniak/filebrowser/backend/internal/database/users"
|
|
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
|
)
|
|
|
|
func TestNormalizeSourceFilePermissions_explicitDenyAllPreserved(t *testing.T) {
|
|
deny := users.DenyAllSourceFilePermissions()
|
|
got := settings.NormalizeSourceFilePermissions(deny)
|
|
if got.View || got.Download || got.Modify || got.Create || got.Delete {
|
|
t.Fatalf("deny-all should stay false: %+v", got)
|
|
}
|
|
if !got.Configured {
|
|
t.Fatal("expected configured marker on deny-all")
|
|
}
|
|
}
|
|
|
|
func TestApplySourceAccessDefaultsToAllSources(t *testing.T) {
|
|
settings.Config = settings.SetDefaults(true)
|
|
settings.Config.Server.Sources = []*settings.Source{
|
|
{Path: "/a", Name: "a"},
|
|
{Path: "/b", Name: "b"},
|
|
}
|
|
perms := users.SourceFilePermissions{View: true, Modify: true, Configured: true}
|
|
settings.ApplySourceAccessDefaultsToAllSources(perms)
|
|
for _, src := range settings.Config.Server.Sources {
|
|
if !src.Config.DefaultPermissions.View || !src.Config.DefaultPermissions.Modify {
|
|
t.Fatalf("source %s: %+v", src.Name, src.Config.DefaultPermissions)
|
|
}
|
|
}
|
|
}
|