fix: restore symlink behavior as opt-in followExternalSymlinks

This commit is contained in:
Henrique Dias committed 2026-06-23 13:19:51 +02:00
1 parent 64511ce45e
commit a1063925e1
23 files changed
+384 -93

No files matched your search

+13 -5
View File
@@ -269,16 +269,24 @@ func newHTTPRequest(t *testing.T, requestModifiers ...func(*http.Request)) *http
type customFSUser struct {
users.Store
fs afero.Fs
// followExternal mirrors Server.FollowExternalSymlinks: when set, the
// provided fs is used as-is (a bare BasePathFs that follows symlinks);
// otherwise it is wrapped in a symlink-confining ScopedFs.
followExternal bool
}
func (cu *customFSUser) Get(baseScope string, id interface{}) (*users.User, error) {
user, err := cu.Store.Get(baseScope, id)
func (cu *customFSUser) Get(baseScope string, followExternalSymlinks bool, id interface{}) (*users.User, error) {
user, err := cu.Store.Get(baseScope, followExternalSymlinks, id)
if err != nil {
return nil, err
}
// Mirror production (users.User init), where a user's filesystem is always a
// scoped, symlink-confining ScopedFs rather than a bare afero.Fs.
user.Fs = files.NewScopedFs(cu.fs, "/")
// Inject a filesystem rooted at the test's temp scope, standing in for the
// one users.User.Clean would build in production.
if cu.followExternal {
user.Fs = cu.fs
} else {
user.Fs = files.NewScopedFs(cu.fs, "/")
}
return user, nil
}