Skip to content

Commit

Permalink
*: fix deprecated code
Browse files Browse the repository at this point in the history
Use:
- `eacl.Target.RawSubjects` instead of `eacl.Target.BinaryKeys`
- `eacl.NewTargetByRole` with `eacl.Target.SetRawSubjects` for targets with
public keys
- `eacl.ConstructTable` instead of `eacl.NewTable`
- `eacl.ConstructRecord` instead of `eacl.NewRecord`
- `*.Get*ID` instead of `*.*ID`
- comparing with == instead of `ID.Equals`
- `cid.NewFromMarshalledContainer(cnr.Marshal())` instead of
`cid.ID.CalculateID`
- `user.NewFromECDSAPublicKey` instead of `user.ResolveFromECDSAPublicKey`
- direct copy instead of `ID.Encode`
- direct assign instead of `ID.SetSHA256`

Signed-off-by: Andrey Butusov <[email protected]>
  • Loading branch information
End-rey committed Sep 23, 2024
1 parent 7510720 commit b721910
Show file tree
Hide file tree
Showing 122 changed files with 434 additions and 450 deletions.
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/morph/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func restoreContainers(cmd *cobra.Command, _ []string) error {
var id cid.ID
b := smartcontract.NewBuilder()
for _, cnt := range containers {
id.FromBinary(cnt.Value)
id = cid.NewFromMarshalledContainer(cnt.Value)

Check warning on line 192 in cmd/neofs-adm/internal/modules/morph/container.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-adm/internal/modules/morph/container.go#L192

Added line #L192 was not covered by tests
if _, ok := requested[id]; !ok {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/morph/estimation.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func estimationsFunc(cmd *cobra.Command, _ []string) error {
}

cIDBytes := make([]byte, sha256.Size)
cID.Encode(cIDBytes)
copy(cIDBytes, cID[:])

Check warning on line 79 in cmd/neofs-adm/internal/modules/morph/estimation.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-adm/internal/modules/morph/estimation.go#L79

Added line #L79 was not covered by tests

sID, iter, err := unwrap.SessionIterator(inv.Call(cnrHash, "iterateContainerSizes", epoch, cIDBytes))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/accounting/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var accountingBalanceCmd = &cobra.Command{

balanceOwner, _ := cmd.Flags().GetString(ownerFlag)
if balanceOwner == "" {
idUser = user.ResolveFromECDSAPublicKey(pk.PublicKey)
idUser = user.NewFromECDSAPublicKey(pk.PublicKey)

Check warning on line 37 in cmd/neofs-cli/modules/accounting/balance.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/accounting/balance.go#L37

Added line #L37 was not covered by tests
} else {
common.ExitOnErr(cmd, "can't decode owner ID wallet address: %w", idUser.DecodeString(balanceOwner))
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/neofs-cli/modules/acl/extended/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ func TestParseTable(t *testing.T) {
},
}

eaclTable := eacl.NewTable()
eaclTable := eacl.ConstructTable(nil)

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
err := util.ParseEACLRule(eaclTable, test.rule)
err := util.ParseEACLRule(&eaclTable, test.rule)
ok := len(test.jsonRecord) > 0
require.Equal(t, ok, err == nil, err)
if ok {
expectedRecord := eacl.NewRecord()
expectedRecord := eacl.ConstructRecord(eacl.ActionUnspecified, eacl.OperationUnspecified, nil, eacl.Filter{})
err = expectedRecord.UnmarshalJSON([]byte(test.jsonRecord))
require.NoError(t, err)

actualRecord := eaclTable.Records()[len(eaclTable.Records())-1]

equalRecords(t, expectedRecord, &actualRecord)
equalRecords(t, &expectedRecord, &actualRecord)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/container/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
issuer := tok.Issuer()
cnr.SetOwner(issuer)
} else {
cnr.SetOwner(user.ResolveFromECDSAPublicKey(key.PublicKey))
cnr.SetOwner(user.NewFromECDSAPublicKey(key.PublicKey))

Check warning on line 87 in cmd/neofs-cli/modules/container/create.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/create.go#L87

Added line #L87 was not covered by tests
}

cnr.SetPlacementPolicy(*placementPolicy)
Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-cli/modules/container/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ Only owner of the container has a permission to remove container.`,
if tok != nil {
common.PrintVerbose(cmd, "Checking session issuer...")

if !tok.Issuer().Equals(owner) {
if tok.Issuer() != owner {

Check warning on line 48 in cmd/neofs-cli/modules/container/delete.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/delete.go#L48

Added line #L48 was not covered by tests
common.ExitOnErr(cmd, "", fmt.Errorf("session issuer differs with the container owner: expected %s, has %s", owner, tok.Issuer()))
}
} else {
common.PrintVerbose(cmd, "Checking provided account...")

acc := user.ResolveFromECDSAPublicKey(pk.PublicKey)
acc := user.NewFromECDSAPublicKey(pk.PublicKey)

Check warning on line 54 in cmd/neofs-cli/modules/container/delete.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/delete.go#L54

Added line #L54 was not covered by tests

if !acc.Equals(owner) {
if acc != owner {

Check warning on line 56 in cmd/neofs-cli/modules/container/delete.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/delete.go#L56

Added line #L56 was not covered by tests
common.ExitOnErr(cmd, "", fmt.Errorf("provided account differs with the container owner: expected %s, has %s", owner, acc))
}
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/neofs-cli/modules/container/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ func prettyPrintContainer(cmd *cobra.Command, cnr container.Container, jsonEncod
return
}

var id cid.ID
cnr.CalculateID(&id)
id := cid.NewFromMarshalledContainer(cnr.Marshal())

Check warning on line 85 in cmd/neofs-cli/modules/container/get.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/get.go#L85

Added line #L85 was not covered by tests
cmd.Println("container ID:", id)

cmd.Println("owner ID:", cnr.Owner())
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/container/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var listContainersCmd = &cobra.Command{
key := key.GetOrGenerate(cmd)

if flagVarListContainerOwner == "" {
idUser = user.ResolveFromECDSAPublicKey(key.PublicKey)
idUser = user.NewFromECDSAPublicKey(key.PublicKey)

Check warning on line 38 in cmd/neofs-cli/modules/container/list.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/list.go#L38

Added line #L38 was not covered by tests
} else {
err := idUser.DecodeString(flagVarListContainerOwner)
common.ExitOnErr(cmd, "invalid user ID: %w", err)
Expand Down
3 changes: 1 addition & 2 deletions cmd/neofs-cli/modules/container/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ var containerNodesCmd = &cobra.Command{
resmap, err := internalclient.NetMapSnapshot(ctx, prm)
common.ExitOnErr(cmd, "unable to get netmap snapshot", err)

var id cid.ID
cnr.CalculateID(&id)
id := cid.NewFromMarshalledContainer(cnr.Marshal())

Check warning on line 34 in cmd/neofs-cli/modules/container/nodes.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/nodes.go#L34

Added line #L34 was not covered by tests

policy := cnr.PlacementPolicy()

Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-cli/modules/container/set_eacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
if tok != nil {
common.PrintVerbose(cmd, "Checking session issuer...")

if !tok.Issuer().Equals(owner) {
if tok.Issuer() != owner {

Check warning on line 63 in cmd/neofs-cli/modules/container/set_eacl.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/set_eacl.go#L63

Added line #L63 was not covered by tests
common.ExitOnErr(cmd, "", fmt.Errorf("session issuer differs with the container owner: expected %s, has %s", owner, tok.Issuer()))
}
} else {
common.PrintVerbose(cmd, "Checking provided account...")

acc := user.ResolveFromECDSAPublicKey(pk.PublicKey)
acc := user.NewFromECDSAPublicKey(pk.PublicKey)

Check warning on line 69 in cmd/neofs-cli/modules/container/set_eacl.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/set_eacl.go#L69

Added line #L69 was not covered by tests

if !acc.Equals(owner) {
if acc != owner {

Check warning on line 71 in cmd/neofs-cli/modules/container/set_eacl.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/set_eacl.go#L71

Added line #L71 was not covered by tests
common.ExitOnErr(cmd, "", fmt.Errorf("provided account differs with the container owner: expected %s, has %s", owner, acc))
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/control/synchronize_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func synchronizeTree(cmd *cobra.Command, _ []string) {
height, _ := cmd.Flags().GetUint64("height")

rawCID := make([]byte, sha256.Size)
cnr.Encode(rawCID)
copy(rawCID, cnr[:])

Check warning on line 57 in cmd/neofs-cli/modules/control/synchronize_tree.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/synchronize_tree.go#L57

Added line #L57 was not covered by tests

req := &control.SynchronizeTreeRequest{
Body: &control.SynchronizeTreeRequest_Body{
Expand Down
22 changes: 11 additions & 11 deletions cmd/neofs-cli/modules/object/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ func marshalHeader(cmd *cobra.Command, hdr *object.Object) ([]byte, error) {
}
}

func printObjectID(cmd *cobra.Command, recv func() (oid.ID, bool)) {
func printObjectID(cmd *cobra.Command, recv func() oid.ID) {

Check warning on line 118 in cmd/neofs-cli/modules/object/head.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/head.go#L118

Added line #L118 was not covered by tests
var strID string

id, ok := recv()
if ok {
id := recv()
if !id.IsZero() {

Check warning on line 122 in cmd/neofs-cli/modules/object/head.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/head.go#L121-L122

Added lines #L121 - L122 were not covered by tests
strID = id.String()
} else {
strID = "<empty>"
Expand All @@ -128,11 +128,11 @@ func printObjectID(cmd *cobra.Command, recv func() (oid.ID, bool)) {
cmd.Printf("ID: %s\n", strID)
}

func printContainerID(cmd *cobra.Command, recv func() (cid.ID, bool)) {
func printContainerID(cmd *cobra.Command, recv func() cid.ID) {

Check warning on line 131 in cmd/neofs-cli/modules/object/head.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/head.go#L131

Added line #L131 was not covered by tests
var strID string

id, ok := recv()
if ok {
id := recv()
if !id.IsZero() {

Check warning on line 135 in cmd/neofs-cli/modules/object/head.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/head.go#L134-L135

Added lines #L134 - L135 were not covered by tests
strID = id.String()
} else {
strID = "<empty>"
Expand All @@ -142,8 +142,8 @@ func printContainerID(cmd *cobra.Command, recv func() (cid.ID, bool)) {
}

func printHeader(cmd *cobra.Command, obj *object.Object) error {
printObjectID(cmd, obj.ID)
printContainerID(cmd, obj.ContainerID)
printObjectID(cmd, obj.GetID)
printContainerID(cmd, obj.GetContainerID)

Check warning on line 146 in cmd/neofs-cli/modules/object/head.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/head.go#L145-L146

Added lines #L145 - L146 were not covered by tests
cmd.Printf("Owner: %s\n", obj.OwnerID())
cmd.Printf("CreatedAt: %d\n", obj.CreationEpoch())
cmd.Printf("Size: %d\n", obj.PayloadSize())
Expand Down Expand Up @@ -177,11 +177,11 @@ func printSplitHeader(cmd *cobra.Command, obj *object.Object) error {
cmd.Printf("Split ID: %s\n", splitID)
}

if oid, ok := obj.ParentID(); ok {
cmd.Printf("Split ParentID: %s\n", oid)
if oID := obj.GetParentID(); !oID.IsZero() {
cmd.Printf("Split ParentID: %s\n", oID)

Check warning on line 181 in cmd/neofs-cli/modules/object/head.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/head.go#L180-L181

Added lines #L180 - L181 were not covered by tests
}

if prev, ok := obj.PreviousID(); ok {
if prev := obj.GetPreviousID(); !prev.IsZero() {

Check warning on line 184 in cmd/neofs-cli/modules/object/head.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/head.go#L184

Added line #L184 was not covered by tests
cmd.Printf("Split PreviousID: %s\n", prev)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/object/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var objectLockCmd = &cobra.Command{

key := key.GetOrGenerate(cmd)

idOwner := user.ResolveFromECDSAPublicKey(key.PublicKey)
idOwner := user.NewFromECDSAPublicKey(key.PublicKey)

Check warning on line 47 in cmd/neofs-cli/modules/object/lock.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/lock.go#L47

Added line #L47 was not covered by tests

var lock objectSDK.Lock
lock.WriteMembers(lockList)
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-cli/modules/object/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func putObject(cmd *cobra.Command, _ []string) {
//TODO(@acid-ant): #1932 Use streams to marshal/unmarshal payload
common.ExitOnErr(cmd, "can't unmarshal object from given file: %w", objTemp.Unmarshal(buf))
payloadReader = bytes.NewReader(objTemp.Payload())
cnr, _ = objTemp.ContainerID()
cnr = objTemp.GetContainerID()

Check warning on line 91 in cmd/neofs-cli/modules/object/put.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/put.go#L91

Added line #L91 was not covered by tests
ownerID = *objTemp.OwnerID()
} else {
fi, err := f.Stat()
Expand All @@ -97,7 +97,7 @@ func putObject(cmd *cobra.Command, _ []string) {
obj.SetPayloadSize(uint64(fi.Size()))

readCID(cmd, &cnr)
ownerID = user.ResolveFromECDSAPublicKey(pk.PublicKey)
ownerID = user.NewFromECDSAPublicKey(pk.PublicKey)

Check warning on line 100 in cmd/neofs-cli/modules/object/put.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/put.go#L100

Added line #L100 was not covered by tests
}

attrs, err := parseObjectAttrs(cmd)
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-cli/modules/object/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ func marshalSplitInfo(cmd *cobra.Command, info *object.SplitInfo) ([]byte, error
if splitID := info.SplitID(); splitID != nil {
b.WriteString("Split ID: " + splitID.String() + "\n")
}
if link, ok := info.Link(); ok {
if link := info.GetLink(); !link.IsZero() {

Check warning on line 144 in cmd/neofs-cli/modules/object/range.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/range.go#L144

Added line #L144 was not covered by tests
b.WriteString("Linking object: " + link.String() + "\n")
}
if last, ok := info.LastPart(); ok {
if last := info.GetLastPart(); !last.IsZero() {

Check warning on line 147 in cmd/neofs-cli/modules/object/range.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/range.go#L147

Added line #L147 was not covered by tests
b.WriteString("Last object: " + last.String() + "\n")
}
return b.Bytes(), nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-cli/modules/object/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func readObjectAddressBin(cmd *cobra.Command, cnr *cid.ID, obj *oid.ID, filename
common.ExitOnErr(cmd, "can't unmarshal object from given file: %w", objTemp.Unmarshal(buf))

var addr oid.Address
*cnr, _ = objTemp.ContainerID()
*obj, _ = objTemp.ID()
*cnr = objTemp.GetContainerID()
*obj = objTemp.GetID()

Check warning on line 96 in cmd/neofs-cli/modules/object/util.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/util.go#L95-L96

Added lines #L95 - L96 were not covered by tests
addr.SetContainer(*cnr)
addr.SetObject(*obj)
return addr
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/storagegroup/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func putSG(cmd *cobra.Command, _ []string) {

pk := key.GetOrGenerate(cmd)

ownerID := user.ResolveFromECDSAPublicKey(pk.PublicKey)
ownerID := user.NewFromECDSAPublicKey(pk.PublicKey)

Check warning on line 61 in cmd/neofs-cli/modules/storagegroup/put.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/storagegroup/put.go#L61

Added line #L61 was not covered by tests

var cnr cid.ID
readCID(cmd, &cnr)
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/tree/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func add(cmd *cobra.Command, _ []string) {
common.ExitOnErr(cmd, "client: %w", err)

rawCID := make([]byte, sha256.Size)
cnr.Encode(rawCID)
copy(rawCID, cnr[:])

Check warning on line 57 in cmd/neofs-cli/modules/tree/add.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/tree/add.go#L57

Added line #L57 was not covered by tests

req := new(tree.AddRequest)
req.Body = &tree.AddRequest_Body{
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/tree/add_by_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func addByPath(cmd *cobra.Command, _ []string) {
common.ExitOnErr(cmd, "client: %w", err)

rawCID := make([]byte, sha256.Size)
cnr.Encode(rawCID)
copy(rawCID, cnr[:])

Check warning on line 61 in cmd/neofs-cli/modules/tree/add_by_path.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/tree/add_by_path.go#L61

Added line #L61 was not covered by tests

meta, err := parseMeta(cmd)
common.ExitOnErr(cmd, "meta data parsing: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/tree/get_by_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func getByPath(cmd *cobra.Command, _ []string) {
common.ExitOnErr(cmd, "client: %w", err)

rawCID := make([]byte, sha256.Size)
cnr.Encode(rawCID)
copy(rawCID, cnr[:])

Check warning on line 61 in cmd/neofs-cli/modules/tree/get_by_path.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/tree/get_by_path.go#L61

Added line #L61 was not covered by tests

latestOnly, _ := cmd.Flags().GetBool(latestOnlyFlagKey)
path, _ := cmd.Flags().GetString(pathFlagKey)
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/tree/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func list(cmd *cobra.Command, _ []string) {
common.ExitOnErr(cmd, "client: %w", err)

rawCID := make([]byte, sha256.Size)
cnr.Encode(rawCID)
copy(rawCID, cnr[:])

Check warning on line 49 in cmd/neofs-cli/modules/tree/list.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/tree/list.go#L49

Added line #L49 was not covered by tests

req := &tree.TreeListRequest{
Body: &tree.TreeListRequest_Body{
Expand Down
10 changes: 6 additions & 4 deletions cmd/neofs-cli/modules/util/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func PrettyPrintTableEACL(cmd *cobra.Command, table *eacl.Table) {
func eaclTargetsToString(ts []eacl.Target) string {
b := bytes.NewBuffer(nil)
for _, t := range ts {
keysExists := len(t.BinaryKeys()) > 0
keysExists := len(t.RawSubjects()) > 0

Check warning on line 86 in cmd/neofs-cli/modules/util/acl.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/util/acl.go#L86

Added line #L86 was not covered by tests
switch t.Role() {
case eacl.RoleUser:
b.WriteString("User")
Expand All @@ -107,7 +107,7 @@ func eaclTargetsToString(ts []eacl.Target) string {
}
}

for i, pub := range t.BinaryKeys() {
for i, pub := range t.RawSubjects() {

Check warning on line 110 in cmd/neofs-cli/modules/util/acl.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/util/acl.go#L110

Added line #L110 was not covered by tests
if i != 0 {
b.WriteString(" ")
}
Expand Down Expand Up @@ -286,8 +286,10 @@ func parseEACLRecord(args []string) (eacl.Record, error) {
continue
}

var target eacl.Target
eacl.SetTargetECDSAKeys(&target, pubs...)
target := eacl.NewTargetByRole(eacl.RoleUnspecified)
for _, pub := range pubs {
target.SetRawSubjects(append(target.RawSubjects(), (*keys.PublicKey)(pub).Bytes()))

Check warning on line 291 in cmd/neofs-cli/modules/util/acl.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/util/acl.go#L289-L291

Added lines #L289 - L291 were not covered by tests
}
targets = append(targets, target)
case "address": // targets
var (
Expand Down
18 changes: 9 additions & 9 deletions cmd/neofs-cli/modules/util/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ func anyValidEACL() eacl.Table {

func TestValidateEACL(t *testing.T) {
t.Run("absence matcher", func(t *testing.T) {
var r eacl.Record
r.AddObjectAttributeFilter(eacl.MatchNotPresent, "any_key", "any_value")
r := eacl.ConstructRecord(eacl.ActionUnspecified, eacl.OperationUnspecified, []eacl.Target{},
eacl.NewObjectPropertyFilter("any_key", eacl.MatchNotPresent, "any_value"))
tb := anyValidEACL()
tb.AddRecord(&r)
tb.SetRecords([]eacl.Record{r})

err := ValidateEACLTable(tb)
require.ErrorContains(t, err, "non-empty value in absence filter")

r = eacl.Record{}
r.AddObjectAttributeFilter(eacl.MatchNotPresent, "any_key", "")
r = eacl.ConstructRecord(eacl.ActionUnspecified, eacl.OperationUnspecified, []eacl.Target{},
eacl.NewObjectPropertyFilter("any_key", eacl.MatchNotPresent, ""))
tb = anyValidEACL()
tb.AddRecord(&r)
tb.SetRecords([]eacl.Record{r})

err = ValidateEACLTable(tb)
require.NoError(t, err)
Expand All @@ -119,10 +119,10 @@ func TestValidateEACL(t *testing.T) {
{true, "-1111111111111111111111111111111111111111111111"},
} {
for _, m := range allNumMatchers {
var r eacl.Record
r.AddObjectAttributeFilter(m, "any_key", tc.v)
r := eacl.ConstructRecord(eacl.ActionUnspecified, eacl.OperationUnspecified, []eacl.Target{},
eacl.NewObjectPropertyFilter("any_key", m, tc.v))
tb := anyValidEACL()
tb.AddRecord(&r)
tb.SetRecords([]eacl.Record{r})

err := ValidateEACLTable(tb)
if tc.ok {
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/util/sign_bearer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func signBearerToken(cmd *cobra.Command, _ []string) {

signer := user.NewAutoIDSignerRFC6979(*pk)
var zeroUsr user.ID
if issuer := btok.Issuer(); !issuer.Equals(zeroUsr) {
if issuer := btok.Issuer(); issuer != zeroUsr {

Check warning on line 43 in cmd/neofs-cli/modules/util/sign_bearer.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/util/sign_bearer.go#L43

Added line #L43 was not covered by tests
// issuer is already set, don't corrupt it
signer = user.NewSigner(signer, issuer)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/neofs-lens/internal/meta/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ func getFunc(cmd *cobra.Command, _ []string) {

res, err := db.Get(prm)
if errors.As(err, &siErr) {
link, linkSet := siErr.SplitInfo().Link()
last, lastSet := siErr.SplitInfo().LastPart()
link := siErr.SplitInfo().GetLink()
last := siErr.SplitInfo().GetLastPart()

Check warning on line 57 in cmd/neofs-lens/internal/meta/get.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-lens/internal/meta/get.go#L56-L57

Added lines #L56 - L57 were not covered by tests

fmt.Println("Object is split")
cmd.Println("\tSplitID:", siErr.SplitInfo().SplitID().String())

if linkSet {
if !link.IsZero() {

Check warning on line 62 in cmd/neofs-lens/internal/meta/get.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-lens/internal/meta/get.go#L62

Added line #L62 was not covered by tests
cmd.Println("\tLink:", link)
}
if lastSet {
if !last.IsZero() {

Check warning on line 65 in cmd/neofs-lens/internal/meta/get.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-lens/internal/meta/get.go#L65

Added line #L65 was not covered by tests
cmd.Println("\tLast:", last)
}

Expand Down
Loading

0 comments on commit b721910

Please sign in to comment.