[#240] Fix native index page
All checks were successful
/ DCO (pull_request) Successful in 27s
/ Vulncheck (pull_request) Successful in 55s
/ Builds (pull_request) Successful in 1m36s
/ OCI image (pull_request) Successful in 2m22s
/ Lint (pull_request) Successful in 2m12s
/ Tests (pull_request) Successful in 57s
/ Integration tests (pull_request) Successful in 6m59s
All checks were successful
/ DCO (pull_request) Successful in 27s
/ Vulncheck (pull_request) Successful in 55s
/ Builds (pull_request) Successful in 1m36s
/ OCI image (pull_request) Successful in 2m22s
/ Lint (pull_request) Successful in 2m12s
/ Tests (pull_request) Successful in 57s
/ Integration tests (pull_request) Successful in 6m59s
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
39cf4e508e
commit
52481375b0
3 changed files with 76 additions and 30 deletions
|
@ -520,15 +520,23 @@ func TestIndex(t *testing.T) {
|
|||
obj1.SetAttributes(prepareObjectAttributes(object.AttributeFilePath, "prefix/obj1"))
|
||||
hc.frostfs.objects[cnrID.String()+"/"+obj1ID.String()] = obj1
|
||||
|
||||
obj2ID := oidtest.ID()
|
||||
obj2 := object.New()
|
||||
obj2.SetID(obj2ID)
|
||||
obj2.SetPayload([]byte("obj2"))
|
||||
obj2.SetAttributes(prepareObjectAttributes(object.AttributeFilePath, "/dir/.."))
|
||||
hc.frostfs.objects[cnrID.String()+"/"+obj2ID.String()] = obj2
|
||||
|
||||
hc.tree.containers[cnrID.String()] = containerInfo{
|
||||
trees: map[string]map[string]nodeResponse{
|
||||
"system": {"bucket-settings": nodeResponse{nodeID: 1}},
|
||||
"version": {
|
||||
"": nodeResponse{}, //root
|
||||
"<root>": nodeResponse{}, //root
|
||||
"prefix": nodeResponse{
|
||||
nodeID: 1,
|
||||
meta: []nodeMeta{{key: tree.FileNameKey, value: []byte("prefix")}}},
|
||||
"obj1": nodeResponse{
|
||||
meta: []nodeMeta{{key: tree.FileNameKey, value: []byte("prefix")}},
|
||||
},
|
||||
"prefix/obj1": nodeResponse{
|
||||
parentID: 1,
|
||||
nodeID: 2,
|
||||
meta: []nodeMeta{
|
||||
|
@ -536,6 +544,23 @@ func TestIndex(t *testing.T) {
|
|||
{key: "OID", value: []byte(obj1ID.String())},
|
||||
},
|
||||
},
|
||||
"": nodeResponse{
|
||||
nodeID: 3,
|
||||
meta: []nodeMeta{{key: tree.FileNameKey, value: []byte("")}},
|
||||
},
|
||||
"/dir": nodeResponse{
|
||||
parentID: 3,
|
||||
nodeID: 4,
|
||||
meta: []nodeMeta{{key: tree.FileNameKey, value: []byte("dir")}},
|
||||
},
|
||||
"/dir/..": nodeResponse{
|
||||
parentID: 4,
|
||||
nodeID: 5,
|
||||
meta: []nodeMeta{
|
||||
{key: tree.FileNameKey, value: []byte("..")},
|
||||
{key: "OID", value: []byte(obj2ID.String())},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -563,6 +588,21 @@ func TestIndex(t *testing.T) {
|
|||
r = prepareGetRequest(ctx, "bucket", "dummy")
|
||||
hc.Handler().DownloadByAddressOrBucketName(r)
|
||||
require.Contains(t, string(r.Response.Body()), "Index of s3://bucket/dummy")
|
||||
|
||||
r = prepareGetRequest(ctx, "bucket", "")
|
||||
hc.Handler().DownloadByAddressOrBucketName(r)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/bucket/">..</a>`)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/bucket//">/</a>`)
|
||||
|
||||
r = prepareGetRequest(ctx, "bucket", "/")
|
||||
hc.Handler().DownloadByAddressOrBucketName(r)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/bucket/">..</a>`)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/bucket//dir/">dir/</a>`)
|
||||
|
||||
r = prepareGetRequest(ctx, "bucket", "/dir/")
|
||||
hc.Handler().DownloadByAddressOrBucketName(r)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/bucket//">..</a>`)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/bucket//dir%2F..">..</a>`)
|
||||
})
|
||||
|
||||
t.Run("native", func(t *testing.T) {
|
||||
|
@ -575,6 +615,13 @@ func TestIndex(t *testing.T) {
|
|||
obj1.SetAttributes(prepareObjectAttributes(object.AttributeFilePath, "prefix/obj1"))
|
||||
hc.frostfs.objects[cnrID.String()+"/"+obj1ID.String()] = obj1
|
||||
|
||||
obj2ID := oidtest.ID()
|
||||
obj2 := object.New()
|
||||
obj2.SetID(obj2ID)
|
||||
obj2.SetPayload([]byte("obj2"))
|
||||
obj2.SetAttributes(prepareObjectAttributes(object.AttributeFilePath, "/dir/.."))
|
||||
hc.frostfs.objects[cnrID.String()+"/"+obj2ID.String()] = obj2
|
||||
|
||||
r := prepareGetRequest(ctx, cnrID.EncodeToString(), "prefix/")
|
||||
hc.Handler().DownloadByAddressOrBucketName(r)
|
||||
require.Equal(t, fasthttp.StatusNotFound, r.Response.StatusCode())
|
||||
|
@ -598,6 +645,21 @@ func TestIndex(t *testing.T) {
|
|||
r = prepareGetRequest(ctx, cnrID.EncodeToString(), "dummy")
|
||||
hc.Handler().DownloadByAddressOrBucketName(r)
|
||||
require.Contains(t, string(r.Response.Body()), "Index of frostfs://"+cnrID.String()+"/dummy")
|
||||
|
||||
r = prepareGetRequest(ctx, cnrID.EncodeToString(), "")
|
||||
hc.Handler().DownloadByAddressOrBucketName(r)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/`+cnrID.String()+`/">..</a>`)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/`+cnrID.String()+`//">/</a>`)
|
||||
|
||||
r = prepareGetRequest(ctx, cnrID.EncodeToString(), "/")
|
||||
hc.Handler().DownloadByAddressOrBucketName(r)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/`+cnrID.String()+`/">..</a>`)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/`+cnrID.String()+`//dir/">dir/</a>`)
|
||||
|
||||
r = prepareGetRequest(ctx, cnrID.EncodeToString(), "/dir/")
|
||||
hc.Handler().DownloadByAddressOrBucketName(r)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/`+cnrID.String()+`//">..</a>`)
|
||||
require.Contains(t, string(r.Response.Body()), `<a href="/get/`+cnrID.String()+`/`+obj2ID.String()+`">..</a>`)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue