mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
711 B
43 lines
711 B
3 years ago
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||
2 years ago
|
// SPDX-License-Identifier: MIT
|
||
3 years ago
|
|
||
|
package repo
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestContainsParentDirectorySeparator(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
v string
|
||
|
b bool
|
||
|
}{
|
||
|
{
|
||
|
v: `user2/repo1/info/refs`,
|
||
|
b: false,
|
||
|
},
|
||
|
{
|
||
|
v: `user2/repo1/HEAD`,
|
||
|
b: false,
|
||
|
},
|
||
|
{
|
||
|
v: `user2/repo1/some.../strange_file...mp3`,
|
||
|
b: false,
|
||
|
},
|
||
|
{
|
||
|
v: `user2/repo1/../../custom/conf/app.ini`,
|
||
|
b: true,
|
||
|
},
|
||
|
{
|
||
|
v: `user2/repo1/objects/info/..\..\..\..\custom\conf\app.ini`,
|
||
|
b: true,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for i := range tests {
|
||
|
assert.EqualValues(t, tests[i].b, containsParentDirectorySeparator(tests[i].v))
|
||
|
}
|
||
|
}
|