From e9cc74ad957fba03eb5317249cc486326668c6ea Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 7 Sep 2023 20:08:10 +0400 Subject: [PATCH] object: Use new constant key to the expiration attribute The constant is now declared in the NeoFS SDK and has same value, so NeoFS API Go usage is not needed anymore for this. After this change `github.com/nspcc-dev/neofs-api-go/v2` module is no longer used by the repository. --- go.mod | 2 +- uploader/filter.go | 8 ++++---- uploader/filter_test.go | 44 ++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index bc9b3e8..dcd93e5 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/docker/docker v24.0.5+incompatible github.com/fasthttp/router v1.4.1 github.com/nspcc-dev/neo-go v0.101.0 - github.com/nspcc-dev/neofs-api-go/v2 v2.14.0 github.com/nspcc-dev/neofs-contract v0.17.1-0.20230804121740-84ff5d244f69 github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11 github.com/prometheus/client_golang v1.14.0 @@ -54,6 +53,7 @@ require ( github.com/mr-tron/base58 v1.2.0 // indirect github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 // indirect github.com/nspcc-dev/hrw v1.0.9 // indirect + github.com/nspcc-dev/neofs-api-go/v2 v2.14.0 // indirect github.com/nspcc-dev/neofs-crypto v0.4.0 // indirect github.com/nspcc-dev/rfc6979 v0.2.0 // indirect github.com/nspcc-dev/tzhash v1.7.0 // indirect diff --git a/uploader/filter.go b/uploader/filter.go index c7349c7..529f595 100644 --- a/uploader/filter.go +++ b/uploader/filter.go @@ -7,8 +7,8 @@ import ( "strconv" "time" - "github.com/nspcc-dev/neofs-api-go/v2/object" "github.com/nspcc-dev/neofs-http-gw/utils" + "github.com/nspcc-dev/neofs-sdk-go/object" "github.com/valyala/fasthttp" "go.uber.org/zap" ) @@ -79,7 +79,7 @@ func filterHeaders(l *zap.Logger, header *fasthttp.RequestHeader) (map[string]st } func prepareExpirationHeader(headers map[string]string, epochDurations *epochDurations, now time.Time) error { - expirationInEpoch := headers[object.SysAttributeExpEpoch] + expirationInEpoch := headers[object.AttributeExpirationEpoch] if timeRFC3339, ok := headers[utils.ExpirationRFC3339Attr]; ok { expTime, err := time.Parse(time.RFC3339, timeRFC3339) @@ -121,7 +121,7 @@ func prepareExpirationHeader(headers map[string]string, epochDurations *epochDur } if expirationInEpoch != "" { - headers[object.SysAttributeExpEpoch] = expirationInEpoch + headers[object.AttributeExpirationEpoch] = expirationInEpoch } return nil @@ -141,5 +141,5 @@ func updateExpirationHeader(headers map[string]string, durations *epochDurations expirationEpoch = currentEpoch + numEpoch } - headers[object.SysAttributeExpEpoch] = strconv.FormatUint(expirationEpoch, 10) + headers[object.AttributeExpirationEpoch] = strconv.FormatUint(expirationEpoch, 10) } diff --git a/uploader/filter_test.go b/uploader/filter_test.go index de4c541..d8cd0cf 100644 --- a/uploader/filter_test.go +++ b/uploader/filter_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/nspcc-dev/neofs-api-go/v2/object" "github.com/nspcc-dev/neofs-http-gw/utils" + "github.com/nspcc-dev/neofs-sdk-go/object" "github.com/stretchr/testify/require" "github.com/valyala/fasthttp" "go.uber.org/zap" @@ -90,71 +90,71 @@ func TestPrepareExpirationHeader(t *testing.T) { }{ { name: "valid epoch", - headers: map[string]string{object.SysAttributeExpEpoch: epoch}, - expected: map[string]string{object.SysAttributeExpEpoch: epoch}, + headers: map[string]string{object.AttributeExpirationEpoch: epoch}, + expected: map[string]string{object.AttributeExpirationEpoch: epoch}, }, { name: "valid epoch, valid duration", headers: map[string]string{ - object.SysAttributeExpEpoch: epoch, - utils.ExpirationDurationAttr: duration, + object.AttributeExpirationEpoch: epoch, + utils.ExpirationDurationAttr: duration, }, durations: defaultDurations, - expected: map[string]string{object.SysAttributeExpEpoch: epoch}, + expected: map[string]string{object.AttributeExpirationEpoch: epoch}, }, { name: "valid epoch, valid rfc3339", headers: map[string]string{ - object.SysAttributeExpEpoch: epoch, - utils.ExpirationRFC3339Attr: tomorrow.Format(time.RFC3339), + object.AttributeExpirationEpoch: epoch, + utils.ExpirationRFC3339Attr: tomorrow.Format(time.RFC3339), }, durations: defaultDurations, - expected: map[string]string{object.SysAttributeExpEpoch: epoch}, + expected: map[string]string{object.AttributeExpirationEpoch: epoch}, }, { name: "valid epoch, valid timestamp sec", headers: map[string]string{ - object.SysAttributeExpEpoch: epoch, - utils.ExpirationTimestampAttr: timestampSec, + object.AttributeExpirationEpoch: epoch, + utils.ExpirationTimestampAttr: timestampSec, }, durations: defaultDurations, - expected: map[string]string{object.SysAttributeExpEpoch: epoch}, + expected: map[string]string{object.AttributeExpirationEpoch: epoch}, }, { name: "valid epoch, valid timestamp milli", headers: map[string]string{ - object.SysAttributeExpEpoch: epoch, - utils.ExpirationTimestampAttr: timestampMilli, + object.AttributeExpirationEpoch: epoch, + utils.ExpirationTimestampAttr: timestampMilli, }, durations: defaultDurations, - expected: map[string]string{object.SysAttributeExpEpoch: epoch}, + expected: map[string]string{object.AttributeExpirationEpoch: epoch}, }, { name: "valid epoch, valid timestamp nano", headers: map[string]string{ - object.SysAttributeExpEpoch: epoch, - utils.ExpirationTimestampAttr: timestampNano, + object.AttributeExpirationEpoch: epoch, + utils.ExpirationTimestampAttr: timestampNano, }, durations: defaultDurations, - expected: map[string]string{object.SysAttributeExpEpoch: epoch}, + expected: map[string]string{object.AttributeExpirationEpoch: epoch}, }, { name: "valid timestamp sec", headers: map[string]string{utils.ExpirationTimestampAttr: timestampSec}, durations: defaultDurations, - expected: map[string]string{object.SysAttributeExpEpoch: defaultExpEpoch}, + expected: map[string]string{object.AttributeExpirationEpoch: defaultExpEpoch}, }, { name: "valid duration", headers: map[string]string{utils.ExpirationDurationAttr: duration}, durations: defaultDurations, - expected: map[string]string{object.SysAttributeExpEpoch: defaultExpEpoch}, + expected: map[string]string{object.AttributeExpirationEpoch: defaultExpEpoch}, }, { name: "valid rfc3339", headers: map[string]string{utils.ExpirationRFC3339Attr: tomorrow.Format(time.RFC3339)}, durations: defaultDurations, - expected: map[string]string{object.SysAttributeExpEpoch: defaultExpEpoch}, + expected: map[string]string{object.AttributeExpirationEpoch: defaultExpEpoch}, }, { name: "valid max uint 64", @@ -164,7 +164,7 @@ func TestPrepareExpirationHeader(t *testing.T) { msPerBlock: defaultDurations.msPerBlock, blockPerEpoch: defaultDurations.blockPerEpoch, }, - expected: map[string]string{object.SysAttributeExpEpoch: strconv.FormatUint(uint64(math.MaxUint64), 10)}, + expected: map[string]string{object.AttributeExpirationEpoch: strconv.FormatUint(uint64(math.MaxUint64), 10)}, }, { name: "invalid timestamp sec",