Files
opencloud/ocis-pkg/x/path/filepathx/path_test.go
Florian Schade 6814c61506 [full-ci] enhancement: allow ocis to provide custom web applications (#8523)
* 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>
2024-03-05 14:11:18 +01:00

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)
}
})
}
}