mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-17 18:14:42 -06:00
* enhancement: allow ocis to provide custom web applications * enhancement: add an option to disable web apps * test: add default logger tests * test: add app loading tests * test: add asset server tests * enhancement: make use of dedicated app conf file and app asset paths * enhancement: adjust asset locations and deprecate WEB_ASSET_PATH * enhancement: get rid of default logger and use the service level logger instead * Apply suggestions from code review Co-authored-by: Benedikt Kulmann <benedikt@kulmann.biz> Co-authored-by: kobergj <juliankoberg@googlemail.com> * enhancement: use basename as app id * Apply suggestions from code review Co-authored-by: Martin <github@diemattels.at> * enhancement: use afero as fs abstraction * enhancement: simplify logo upload * enhancement: make use of introductionVersion field annotations --------- Co-authored-by: Benedikt Kulmann <benedikt@kulmann.biz> Co-authored-by: kobergj <juliankoberg@googlemail.com> Co-authored-by: Martin <github@diemattels.at>
66 lines
1.1 KiB
Go
66 lines
1.1 KiB
Go
package filepathx_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/x/path/filepathx"
|
|
)
|
|
|
|
func TestJailJoin(t *testing.T) {
|
|
type args struct {
|
|
jail string
|
|
elem []string
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want string
|
|
}{
|
|
{
|
|
name: "regular use case",
|
|
args: args{
|
|
jail: "/",
|
|
elem: []string{"a", "b", "c"},
|
|
},
|
|
want: "/a/b/c",
|
|
},
|
|
{
|
|
name: "access parent directory",
|
|
args: args{
|
|
jail: "/",
|
|
elem: []string{"a", "b", "c", ".."},
|
|
},
|
|
want: "/a/b",
|
|
},
|
|
{
|
|
name: "restrict breaking out of jail",
|
|
args: args{
|
|
jail: "/",
|
|
elem: []string{"a", "b", "c", "..", "..", "..", "..", "..", "..", ".."},
|
|
},
|
|
want: "/",
|
|
},
|
|
{
|
|
name: "restrict to child of jail",
|
|
args: args{
|
|
jail: "/a/b",
|
|
elem: []string{"a", "b", "c", "..", "..", "..", "..", "..", "..", ".."},
|
|
},
|
|
want: "/a/b",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
tt := tt
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if got := filepathx.JailJoin(tt.args.jail, tt.args.elem...); got != tt.want {
|
|
t.Errorf("JailJoin() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|