Skip to content

Commit

Permalink
Do not use github.com/nspcc-dev/neofs-api-go/v2 module directly (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Apr 12, 2024
2 parents 9ea9b73 + 1084d33 commit f94746b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
3 changes: 1 addition & 2 deletions api/handler/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"strings"

"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl"
"github.com/nspcc-dev/neofs-s3-gw/api"
"github.com/nspcc-dev/neofs-s3-gw/api/data"
"github.com/nspcc-dev/neofs-s3-gw/api/layer"
Expand Down Expand Up @@ -685,7 +684,7 @@ func resInfoFromFilters(bucketName string, filters []eacl.Filter) resourceInfo {
if filter.Matcher() == eacl.MatchStringEqual {
if filter.Key() == object.AttributeFilePath {
resInfo.Object = filter.Value()
} else if filter.Key() == v2acl.FilterObjectID {
} else if filter.Key() == eacl.FilterObjectID {
resInfo.Version = filter.Value()
}
}
Expand Down
16 changes: 11 additions & 5 deletions authmate/session_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import (
"encoding/json"
"fmt"

apisession "github.com/nspcc-dev/neofs-api-go/v2/session"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/session"
)

type (
sessionTokenModel struct {
Verb string `json:"verb"`
ContainerID string `json:"ContainerID"`
ContainerID string `json:"containerID"`
}

sessionTokenContext struct {
Expand All @@ -21,6 +20,13 @@ type (
}
)

// JSON strings for supported container session verbs.
const (
containerSessionVerbPut = "PUT"
containerSessionVerbDelete = "DELETE"
containerSessionVerbSetEACL = "SETEACL"
)

func (c *sessionTokenContext) UnmarshalJSON(data []byte) (err error) {
var m sessionTokenModel

Expand All @@ -29,11 +35,11 @@ func (c *sessionTokenContext) UnmarshalJSON(data []byte) (err error) {
}

switch m.Verb {
case apisession.ContainerVerbPut.String():
case containerSessionVerbPut:
c.verb = session.VerbContainerPut
case apisession.ContainerVerbSetEACL.String():
case containerSessionVerbSetEACL:
c.verb = session.VerbContainerSetEACL
case apisession.ContainerVerbDelete.String():
case containerSessionVerbDelete:
c.verb = session.VerbContainerDelete
default:
return fmt.Errorf("unknown container token verb %s", m.Verb)
Expand Down
7 changes: 6 additions & 1 deletion authmate/session_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@ func TestContainerSessionRules(t *testing.T) {
},
{
"verb": "SETEACL"
},
{
"verb": "DELETE",
"ContainerID": "6CcWg8LkcbfMUC8pt7wiy5zM1fyS3psNoxgfppcCgig1"
}
]`)

sessionContext, err := buildContext(jsonRules)
require.NoError(t, err)

require.Len(t, sessionContext, 3)
require.Len(t, sessionContext, 4)
require.Equal(t, sessionContext[0].verb, session.VerbContainerPut)
require.Zero(t, sessionContext[0].containerID)
require.Equal(t, sessionContext[1].verb, session.VerbContainerDelete)
require.NotNil(t, sessionContext[1].containerID)
require.Equal(t, sessionContext[2].verb, session.VerbContainerSetEACL)
require.Zero(t, sessionContext[2].containerID)
require.Equal(t, sessionContext[1], sessionContext[3])
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ require (
github.com/minio/sio v0.3.0
github.com/nats-io/nats.go v1.31.0
github.com/nspcc-dev/neo-go v0.105.1
github.com/nspcc-dev/neofs-api-go/v2 v2.14.1-0.20240305074711-35bc78d84dc4
github.com/nspcc-dev/neofs-contract v0.19.1
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11.0.20240326133951-7f940dcb37d8
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11.0.20240412074628-830a0ff84256
github.com/nspcc-dev/tzhash v1.8.0
github.com/panjf2000/ants/v2 v2.5.0
github.com/prometheus/client_golang v1.13.0
Expand All @@ -36,6 +35,7 @@ require (
github.com/klauspost/compress v1.17.6 // indirect
github.com/nspcc-dev/go-ordered-json v0.0.0-20240112074137-296698a162ae // indirect
github.com/nspcc-dev/hrw/v2 v2.0.1 // indirect
github.com/nspcc-dev/neofs-api-go/v2 v2.14.1-0.20240305074711-35bc78d84dc4 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ github.com/nspcc-dev/neofs-api-go/v2 v2.14.1-0.20240305074711-35bc78d84dc4 h1:ar
github.com/nspcc-dev/neofs-api-go/v2 v2.14.1-0.20240305074711-35bc78d84dc4/go.mod h1:7Tm1NKEoUVVIUlkVwFrPh7GG5+Lmta2m7EGr4oVpBd8=
github.com/nspcc-dev/neofs-contract v0.19.1 h1:U1Uh+MlzfkalO0kRJ2pADZyHrmAOroC6KLFjdWnTNR0=
github.com/nspcc-dev/neofs-contract v0.19.1/go.mod h1:ZOGouuwuHpgvYkx/LCGufGncIzEUhYEO18LL4cWEbyw=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11.0.20240326133951-7f940dcb37d8 h1:0qr5CEPXp94CRnYyikKu54lJgFLBVJ7Per+zXIBr6tc=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11.0.20240326133951-7f940dcb37d8/go.mod h1:2XHytVt+AFQkwr6vpcYvdm13mA2rZxB+STrxtwSrtx8=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11.0.20240412074628-830a0ff84256 h1:z6bkaWW954KuQjzA5cbjL8YF6xlF7nQtesJXvzg309k=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11.0.20240412074628-830a0ff84256/go.mod h1:2XHytVt+AFQkwr6vpcYvdm13mA2rZxB+STrxtwSrtx8=
github.com/nspcc-dev/rfc6979 v0.2.1 h1:8wWxkamHWFmO790GsewSoKUSJjVnL1fmdRpokU/RgRM=
github.com/nspcc-dev/rfc6979 v0.2.1/go.mod h1:Tk7h5kyUWkhjyO3zUgFFhy1v2vQv3BvQEntakdtqrWc=
github.com/nspcc-dev/tzhash v1.8.0 h1:pJvzME2mZzP/h5rcy/Wb6amT9FJBFeKbJ3HEnWEeUpY=
Expand Down
2 changes: 1 addition & 1 deletion internal/neofs/neofs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func createContainer(ctx context.Context, signer user.Signer, p *pool.Pool) (cid

var pp netmap.PlacementPolicy
pp.SetContainerBackupFactor(1)
pp.AddReplicas(rd)
pp.SetReplicas([]netmap.ReplicaDescriptor{rd})

cnr.SetPlacementPolicy(pp)
cnr.SetBasicACL(acl.PublicRW)
Expand Down

0 comments on commit f94746b

Please sign in to comment.