forked from forgejo/forgejo
Fix object storage path handling (#27024)
Object storage path rules: * No single `/` or `.`, use empty string for root path * Need to use trailing `/` for a list prefix to distinguish a "dir/"
This commit is contained in:
parent
7d56459c6c
commit
8ecdc93f8b
2 changed files with 48 additions and 14 deletions
|
@ -31,6 +31,40 @@ func TestMinioStorageIterator(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestMinioStoragePath(t *testing.T) {
|
||||
m := &MinioStorage{basePath: ""}
|
||||
assert.Equal(t, "", m.buildMinioPath("/"))
|
||||
assert.Equal(t, "", m.buildMinioPath("."))
|
||||
assert.Equal(t, "a", m.buildMinioPath("/a"))
|
||||
assert.Equal(t, "a/b", m.buildMinioPath("/a/b/"))
|
||||
assert.Equal(t, "", m.buildMinioDirPrefix(""))
|
||||
assert.Equal(t, "a/", m.buildMinioDirPrefix("/a/"))
|
||||
|
||||
m = &MinioStorage{basePath: "/"}
|
||||
assert.Equal(t, "", m.buildMinioPath("/"))
|
||||
assert.Equal(t, "", m.buildMinioPath("."))
|
||||
assert.Equal(t, "a", m.buildMinioPath("/a"))
|
||||
assert.Equal(t, "a/b", m.buildMinioPath("/a/b/"))
|
||||
assert.Equal(t, "", m.buildMinioDirPrefix(""))
|
||||
assert.Equal(t, "a/", m.buildMinioDirPrefix("/a/"))
|
||||
|
||||
m = &MinioStorage{basePath: "/base"}
|
||||
assert.Equal(t, "base", m.buildMinioPath("/"))
|
||||
assert.Equal(t, "base", m.buildMinioPath("."))
|
||||
assert.Equal(t, "base/a", m.buildMinioPath("/a"))
|
||||
assert.Equal(t, "base/a/b", m.buildMinioPath("/a/b/"))
|
||||
assert.Equal(t, "base/", m.buildMinioDirPrefix(""))
|
||||
assert.Equal(t, "base/a/", m.buildMinioDirPrefix("/a/"))
|
||||
|
||||
m = &MinioStorage{basePath: "/base/"}
|
||||
assert.Equal(t, "base", m.buildMinioPath("/"))
|
||||
assert.Equal(t, "base", m.buildMinioPath("."))
|
||||
assert.Equal(t, "base/a", m.buildMinioPath("/a"))
|
||||
assert.Equal(t, "base/a/b", m.buildMinioPath("/a/b/"))
|
||||
assert.Equal(t, "base/", m.buildMinioDirPrefix(""))
|
||||
assert.Equal(t, "base/a/", m.buildMinioDirPrefix("/a/"))
|
||||
}
|
||||
|
||||
func TestS3StorageBadRequest(t *testing.T) {
|
||||
if os.Getenv("CI") == "" {
|
||||
t.Skip("S3Storage not present outside of CI")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue