forked from TrueCloudLab/frostfs-s3-gw
[#243] Fix list object versions marker param
According to https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectVersions.html we have to use `key-marker` Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
7e91f62c28
commit
8d6aa0d40a
4 changed files with 52 additions and 8 deletions
|
@ -15,6 +15,7 @@ This document outlines major changes between releases.
|
||||||
- Fix parsing signed headers in presigned urls (#182)
|
- Fix parsing signed headers in presigned urls (#182)
|
||||||
- Fix url escaping (#188)
|
- Fix url escaping (#188)
|
||||||
- Use correct keys in `list-multipart-uploads` response (#185)
|
- Use correct keys in `list-multipart-uploads` response (#185)
|
||||||
|
- Fix parsing `key-marker` for object list versions (#243)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Add `trace_id` value into log record when tracing is enabled (#142)
|
- Add `trace_id` value into log record when tracing is enabled (#142)
|
||||||
|
|
|
@ -456,13 +456,8 @@ func headObjectBase(hc *handlerContext, bktName, objName, version string) *httpt
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
func listVersions(t *testing.T, tc *handlerContext, bktName string) *ListObjectsVersionsResponse {
|
func listVersions(_ *testing.T, tc *handlerContext, bktName string) *ListObjectsVersionsResponse {
|
||||||
w, r := prepareTestRequest(tc, bktName, "", nil)
|
return listObjectsVersions(tc, bktName, "", "", "", "", -1)
|
||||||
tc.Handler().ListBucketObjectVersionsHandler(w, r)
|
|
||||||
assertStatus(t, w, http.StatusOK)
|
|
||||||
res := &ListObjectsVersionsResponse{}
|
|
||||||
parseTestResponse(t, w, res)
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVersion(resp *ListObjectsVersionsResponse, objName string) []*ObjectVersionResponse {
|
func getVersion(resp *ListObjectsVersionsResponse, objName string) []*ObjectVersionResponse {
|
||||||
|
|
|
@ -253,7 +253,7 @@ func parseListObjectVersionsRequest(reqInfo *middleware.ReqInfo) (*layer.ListObj
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Prefix = queryValues.Get("prefix")
|
res.Prefix = queryValues.Get("prefix")
|
||||||
res.KeyMarker = queryValues.Get("marker")
|
res.KeyMarker = queryValues.Get("key-marker")
|
||||||
res.Delimiter = queryValues.Get("delimiter")
|
res.Delimiter = queryValues.Get("delimiter")
|
||||||
res.Encode = queryValues.Get("encoding-type")
|
res.Encode = queryValues.Get("encoding-type")
|
||||||
res.VersionIDMarker = queryValues.Get("version-id-marker")
|
res.VersionIDMarker = queryValues.Get("version-id-marker")
|
||||||
|
|
|
@ -3,6 +3,7 @@ package handler
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -56,6 +57,36 @@ func TestListObjectNullVersions(t *testing.T) {
|
||||||
require.Equal(t, data.UnversionedObjectVersionID, result.Version[1].VersionID)
|
require.Equal(t, data.UnversionedObjectVersionID, result.Version[1].VersionID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestListObjectsPaging(t *testing.T) {
|
||||||
|
hc := prepareHandlerContext(t)
|
||||||
|
|
||||||
|
bktName := "bucket-versioning-enabled"
|
||||||
|
createTestBucket(hc, bktName)
|
||||||
|
|
||||||
|
n := 10
|
||||||
|
|
||||||
|
var objects []string
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
objects = append(objects, "objects"+strconv.Itoa(i))
|
||||||
|
putObjectContent(hc, bktName, objects[i], "content")
|
||||||
|
}
|
||||||
|
sort.Strings(objects)
|
||||||
|
|
||||||
|
result := &ListObjectsVersionsResponse{IsTruncated: true}
|
||||||
|
for result.IsTruncated {
|
||||||
|
result = listObjectsVersions(hc, bktName, "", "", result.NextKeyMarker, result.NextVersionIDMarker, n/3)
|
||||||
|
|
||||||
|
for i, version := range result.Version {
|
||||||
|
if objects[i] != version.Key {
|
||||||
|
t.Errorf("expected: '%s', got: '%s'", objects[i], version.Key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
objects = objects[len(result.Version):]
|
||||||
|
}
|
||||||
|
|
||||||
|
require.Empty(t, objects)
|
||||||
|
}
|
||||||
|
|
||||||
func TestS3CompatibilityBucketListV2BothContinuationTokenStartAfter(t *testing.T) {
|
func TestS3CompatibilityBucketListV2BothContinuationTokenStartAfter(t *testing.T) {
|
||||||
tc := prepareHandlerContext(t)
|
tc := prepareHandlerContext(t)
|
||||||
|
|
||||||
|
@ -215,3 +246,20 @@ func listObjectsV1(hc *handlerContext, bktName, prefix, delimiter, marker string
|
||||||
parseTestResponse(hc.t, w, res)
|
parseTestResponse(hc.t, w, res)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func listObjectsVersions(hc *handlerContext, bktName, prefix, delimiter, keyMarker, versionIDMarker string, maxKeys int) *ListObjectsVersionsResponse {
|
||||||
|
query := prepareCommonListObjectsQuery(prefix, delimiter, maxKeys)
|
||||||
|
if len(keyMarker) != 0 {
|
||||||
|
query.Add("key-marker", keyMarker)
|
||||||
|
}
|
||||||
|
if len(versionIDMarker) != 0 {
|
||||||
|
query.Add("version-id-marker", versionIDMarker)
|
||||||
|
}
|
||||||
|
|
||||||
|
w, r := prepareTestFullRequest(hc, bktName, "", query, nil)
|
||||||
|
hc.Handler().ListBucketObjectVersionsHandler(w, r)
|
||||||
|
assertStatus(hc.t, w, http.StatusOK)
|
||||||
|
res := &ListObjectsVersionsResponse{}
|
||||||
|
parseTestResponse(hc.t, w, res)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue