[#295] pkg: Remove usage of deprecated elements

Remove usage of deprecated of `container.ID` and `token.SessionToken` code
elements. Replace using of custom message generators with the ones provided
by packages. Replace string comparison with `Equal` method call.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-31 15:09:04 +03:00 committed by Leonard Lyubich
parent 89be8d3f5a
commit 65080c8b69
22 changed files with 97 additions and 209 deletions

View file

@ -2,7 +2,7 @@ package audit
import (
"github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/container"
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-api-go/v2/audit"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
@ -87,15 +87,15 @@ func (r *Result) SetAuditEpoch(epoch uint64) {
}
// ContainerID returns container under audit.
func (r *Result) ContainerID() *container.ID {
return container.NewIDFromV2(
func (r *Result) ContainerID() *cid.ID {
return cid.NewFromV2(
(*audit.DataAuditResult)(r).
GetContainerID(),
)
}
// SetContainerID sets container under audit.
func (r *Result) SetContainerID(id *container.ID) {
func (r *Result) SetContainerID(id *cid.ID) {
(*audit.DataAuditResult)(r).
SetContainerID(id.ToV2())
}

View file

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/audit"
"github.com/nspcc-dev/neofs-api-go/pkg/container"
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/stretchr/testify/require"
)
@ -17,13 +17,6 @@ func testSHA256() (cs [sha256.Size]byte) {
return
}
func testCID() *container.ID {
cid := container.NewID()
cid.SetSHA256(testSHA256())
return cid
}
func testOID() *object.ID {
id := object.NewID()
id.SetSHA256(testSHA256())
@ -39,7 +32,7 @@ func TestResult(t *testing.T) {
r.SetAuditEpoch(epoch)
require.Equal(t, epoch, r.AuditEpoch())
cid := testCID()
cid := cidtest.Generate()
r.SetContainerID(cid)
require.Equal(t, cid, r.ContainerID())
@ -90,7 +83,7 @@ func TestResult(t *testing.T) {
func TestStorageGroupEncoding(t *testing.T) {
r := audit.NewResult()
r.SetAuditEpoch(13)
r.SetContainerID(testCID())
r.SetContainerID(cidtest.Generate())
r.SetPublicKey([]byte{1, 2, 3})
r.SetPassSG([]*object.ID{testOID(), testOID()})
r.SetFailSG([]*object.ID{testOID(), testOID()})