You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nginx-ui/internal/helper/directory_test.go

14 lines
482 B
Go

package helper
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestIsUnderDirectory(t *testing.T) {
assert.Equal(t, true, IsUnderDirectory("/etc/nginx/nginx.conf", "/etc/nginx"))
assert.Equal(t, false, IsUnderDirectory("../../root/nginx.conf", "/etc/nginx"))
assert.Equal(t, false, IsUnderDirectory("/etc/nginx/../../root/nginx.conf", "/etc/nginx"))
assert.Equal(t, false, IsUnderDirectory("/etc/nginx/../../etc/nginx/../../root/nginx.conf", "/etc/nginx"))
}