Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
object: Use new constant key to the expiration attribute
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cthulhu-rider committed Sep 7, 2023
1 parent 2b8d00e commit e9cc74a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions uploader/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -121,7 +121,7 @@ func prepareExpirationHeader(headers map[string]string, epochDurations *epochDur
}

if expirationInEpoch != "" {
headers[object.SysAttributeExpEpoch] = expirationInEpoch
headers[object.AttributeExpirationEpoch] = expirationInEpoch
}

return nil
Expand All @@ -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)
}
44 changes: 22 additions & 22 deletions uploader/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit e9cc74a

Please sign in to comment.