forked from TrueCloudLab/frostfs-s3-gw
[#542] Fix object removal
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
88c392d024
commit
fdf0974679
5 changed files with 268 additions and 181 deletions
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-s3-gw/api/resolver"
|
||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
usertest "github.com/nspcc-dev/neofs-sdk-go/user/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -27,8 +28,9 @@ import (
|
|||
)
|
||||
|
||||
type handlerContext struct {
|
||||
h *handler
|
||||
tp *layer.TestNeoFS
|
||||
h *handler
|
||||
tp *layer.TestNeoFS
|
||||
context context.Context
|
||||
}
|
||||
|
||||
func (hc *handlerContext) Handler() *handler {
|
||||
|
@ -43,6 +45,10 @@ func (hc *handlerContext) Layer() layer.Client {
|
|||
return hc.h.obj
|
||||
}
|
||||
|
||||
func (hc *handlerContext) Context() context.Context {
|
||||
return hc.context
|
||||
}
|
||||
|
||||
func prepareHandlerContext(t *testing.T) *handlerContext {
|
||||
key, err := keys.NewPrivateKey()
|
||||
require.NoError(t, err)
|
||||
|
@ -69,8 +75,9 @@ func prepareHandlerContext(t *testing.T) *handlerContext {
|
|||
}
|
||||
|
||||
return &handlerContext{
|
||||
h: h,
|
||||
tp: tp,
|
||||
h: h,
|
||||
tp: tp,
|
||||
context: context.Background(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,3 +174,29 @@ func parseTestResponse(t *testing.T, response *httptest.ResponseRecorder, body i
|
|||
err := xml.NewDecoder(response.Result().Body).Decode(body)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func existInMockedNeoFS(tc *handlerContext, bktInfo *data.BucketInfo, objInfo *data.ObjectInfo) bool {
|
||||
p := &layer.GetObjectParams{
|
||||
BucketInfo: bktInfo,
|
||||
ObjectInfo: objInfo,
|
||||
Writer: io.Discard,
|
||||
}
|
||||
|
||||
return tc.Layer().GetObject(tc.Context(), p) == nil
|
||||
}
|
||||
|
||||
func listOIDsFromMockedNeoFS(t *testing.T, tc *handlerContext, bktName, objectName string) []oid.ID {
|
||||
bktInfo, err := tc.Layer().GetBucketInfo(tc.Context(), bktName)
|
||||
require.NoError(t, err)
|
||||
|
||||
p := layer.PrmObjectSelect{
|
||||
Container: bktInfo.CID,
|
||||
ExactAttribute: [2]string{
|
||||
object.AttributeFileName, objectName,
|
||||
},
|
||||
}
|
||||
ids, err := tc.MockedPool().SelectObjects(tc.Context(), p)
|
||||
require.NoError(t, err)
|
||||
|
||||
return ids
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue