forked from TrueCloudLab/frostfs-node
[#821] node: Pass user.ID by value
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
c99157f0b2
commit
c516c7c5f4
12 changed files with 27 additions and 27 deletions
|
@ -39,7 +39,7 @@ var accountingBalanceCmd = &cobra.Command{
|
|||
|
||||
var prm internalclient.BalanceOfPrm
|
||||
prm.SetClient(cli)
|
||||
prm.Account = &idUser
|
||||
prm.Account = idUser
|
||||
|
||||
res, err := internalclient.BalanceOf(cmd.Context(), prm)
|
||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
|
|
@ -47,7 +47,7 @@ var listContainersCmd = &cobra.Command{
|
|||
|
||||
var prm internalclient.ListContainersPrm
|
||||
prm.SetClient(cli)
|
||||
prm.Account = &idUser
|
||||
prm.Account = idUser
|
||||
|
||||
res, err := internalclient.ListContainers(cmd.Context(), prm)
|
||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
|
|
@ -94,7 +94,7 @@ var objectLockCmd = &cobra.Command{
|
|||
|
||||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cnr)
|
||||
obj.SetOwnerID(&idOwner)
|
||||
obj.SetOwnerID(idOwner)
|
||||
obj.SetType(objectSDK.TypeLock)
|
||||
obj.SetAttributes(expirationAttr)
|
||||
obj.SetPayload(lock.Marshal())
|
||||
|
|
|
@ -93,7 +93,7 @@ func putObject(cmd *cobra.Command, _ []string) {
|
|||
attrs := getAllObjectAttributes(cmd)
|
||||
|
||||
obj.SetContainerID(cnr)
|
||||
obj.SetOwnerID(&ownerID)
|
||||
obj.SetOwnerID(ownerID)
|
||||
obj.SetAttributes(attrs...)
|
||||
|
||||
notificationInfo, err := parseObjectNotifications(cmd)
|
||||
|
@ -160,7 +160,7 @@ func readFilePayload(filename string, cmd *cobra.Command) (io.Reader, cid.ID, us
|
|||
commonCmd.ExitOnErr(cmd, "can't unmarshal object from given file: %w", objTemp.Unmarshal(buf))
|
||||
payloadReader := bytes.NewReader(objTemp.Payload())
|
||||
cnr, _ := objTemp.ContainerID()
|
||||
ownerID := *objTemp.OwnerID()
|
||||
ownerID := objTemp.OwnerID()
|
||||
return payloadReader, cnr, ownerID
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ func (v *FormatValidator) validateSignatureKey(obj *objectSDK.Object) error {
|
|||
}
|
||||
|
||||
token := obj.SessionToken()
|
||||
ownerID := *obj.OwnerID()
|
||||
ownerID := obj.OwnerID()
|
||||
|
||||
if token == nil || !token.AssertAuthKey(&key) {
|
||||
return v.checkOwnerKey(ownerID, key)
|
||||
|
@ -412,7 +412,7 @@ func (v *FormatValidator) checkAttributes(obj *objectSDK.Object) error {
|
|||
var errIncorrectOwner = errors.New("incorrect object owner")
|
||||
|
||||
func (v *FormatValidator) checkOwner(obj *objectSDK.Object) error {
|
||||
if idOwner := obj.OwnerID(); idOwner == nil || len(idOwner.WalletBytes()) == 0 {
|
||||
if idOwner := obj.OwnerID(); idOwner.IsEmpty() {
|
||||
return errIncorrectOwner
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ func blankValidObject(key *ecdsa.PrivateKey) *objectSDK.Object {
|
|||
|
||||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cidtest.ID())
|
||||
obj.SetOwnerID(&idOwner)
|
||||
obj.SetOwnerID(idOwner)
|
||||
|
||||
return obj
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cidtest.ID())
|
||||
obj.SetSessionToken(tok)
|
||||
obj.SetOwnerID(&idOwner)
|
||||
obj.SetOwnerID(idOwner)
|
||||
|
||||
require.NoError(t, objectSDK.SetIDWithSignature(ownerKey.PrivateKey, obj))
|
||||
|
||||
|
@ -303,7 +303,7 @@ func TestFormatValidator_ValidateTokenIssuer(t *testing.T) {
|
|||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cidtest.ID())
|
||||
obj.SetSessionToken(tok)
|
||||
obj.SetOwnerID(&owner)
|
||||
obj.SetOwnerID(owner)
|
||||
require.NoError(t, objectSDK.SetIDWithSignature(signer.PrivateKey, obj))
|
||||
|
||||
require.NoError(t, v.Validate(context.Background(), obj, false))
|
||||
|
@ -352,7 +352,7 @@ func TestFormatValidator_ValidateTokenIssuer(t *testing.T) {
|
|||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cnrID)
|
||||
obj.SetSessionToken(tok)
|
||||
obj.SetOwnerID(&owner)
|
||||
obj.SetOwnerID(owner)
|
||||
require.NoError(t, objectSDK.SetIDWithSignature(signer.PrivateKey, obj))
|
||||
|
||||
require.NoError(t, v.Validate(context.Background(), obj, false))
|
||||
|
@ -386,7 +386,7 @@ func TestFormatValidator_ValidateTokenIssuer(t *testing.T) {
|
|||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cnrID)
|
||||
obj.SetSessionToken(tok)
|
||||
obj.SetOwnerID(&owner)
|
||||
obj.SetOwnerID(owner)
|
||||
require.NoError(t, objectSDK.SetIDWithSignature(signer.PrivateKey, obj))
|
||||
|
||||
v := NewFormatValidator(
|
||||
|
@ -459,7 +459,7 @@ func TestFormatValidator_ValidateTokenIssuer(t *testing.T) {
|
|||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cnrID)
|
||||
obj.SetSessionToken(tok)
|
||||
obj.SetOwnerID(&owner)
|
||||
obj.SetOwnerID(owner)
|
||||
require.NoError(t, objectSDK.SetIDWithSignature(signer.PrivateKey, obj))
|
||||
|
||||
v := NewFormatValidator(
|
||||
|
@ -535,7 +535,7 @@ func TestFormatValidator_ValidateTokenIssuer(t *testing.T) {
|
|||
obj := objectSDK.New()
|
||||
obj.SetContainerID(cnrID)
|
||||
obj.SetSessionToken(tok)
|
||||
obj.SetOwnerID(&owner)
|
||||
obj.SetOwnerID(owner)
|
||||
require.NoError(t, objectSDK.SetIDWithSignature(signer.PrivateKey, obj))
|
||||
|
||||
v := NewFormatValidator(
|
||||
|
|
|
@ -39,14 +39,14 @@ func TestStickyCheck(t *testing.T) {
|
|||
info.SetSenderKey(make([]byte, 33)) // any non-empty key
|
||||
info.SetRequestRole(acl.RoleContainer)
|
||||
|
||||
require.True(t, checker.StickyBitCheck(info, *usertest.ID()))
|
||||
require.True(t, checker.StickyBitCheck(info, usertest.ID()))
|
||||
|
||||
var basicACL acl.Basic
|
||||
basicACL.MakeSticky()
|
||||
|
||||
info.SetBasicACL(basicACL)
|
||||
|
||||
require.True(t, checker.StickyBitCheck(info, *usertest.ID()))
|
||||
require.True(t, checker.StickyBitCheck(info, usertest.ID()))
|
||||
})
|
||||
|
||||
t.Run("owner ID and/or public key emptiness", func(t *testing.T) {
|
||||
|
@ -72,7 +72,7 @@ func TestStickyCheck(t *testing.T) {
|
|||
var ownerID user.ID
|
||||
|
||||
if withOwner {
|
||||
ownerID = *usertest.ID()
|
||||
ownerID = usertest.ID()
|
||||
}
|
||||
|
||||
require.Equal(t, expected, checker.StickyBitCheck(info, ownerID))
|
||||
|
|
|
@ -62,8 +62,8 @@ func headersFromObject(obj *objectSDK.Object, cnr cid.ID, oid *oid.ID) []eaclSDK
|
|||
res = append(res, oidHeader(*oid))
|
||||
}
|
||||
|
||||
if idOwner := obj.OwnerID(); idOwner != nil {
|
||||
res = append(res, ownerIDHeader(*idOwner))
|
||||
if idOwner := obj.OwnerID(); !idOwner.IsEmpty() {
|
||||
res = append(res, ownerIDHeader(idOwner))
|
||||
}
|
||||
|
||||
cs, ok := obj.PayloadChecksum()
|
||||
|
|
|
@ -176,11 +176,11 @@ func (exec *execCtx) initTombstoneObject() error {
|
|||
tokenSession := exec.commonParameters().SessionToken()
|
||||
if tokenSession != nil {
|
||||
issuer := tokenSession.Issuer()
|
||||
exec.tombstoneObj.SetOwnerID(&issuer)
|
||||
exec.tombstoneObj.SetOwnerID(issuer)
|
||||
} else {
|
||||
// make local node a tombstone object owner
|
||||
localUser := exec.svc.netInfo.LocalNodeID()
|
||||
exec.tombstoneObj.SetOwnerID(&localUser)
|
||||
exec.tombstoneObj.SetOwnerID(localUser)
|
||||
}
|
||||
|
||||
var a objectSDK.Attribute
|
||||
|
|
|
@ -112,7 +112,7 @@ func (p *Streamer) initTrustedTarget(prm *PutInitPrm) error {
|
|||
// If it isn't owner key, replication attempts will fail, thus this check.
|
||||
if sToken == nil {
|
||||
ownerObj := prm.hdr.OwnerID()
|
||||
if ownerObj == nil {
|
||||
if ownerObj.IsEmpty() {
|
||||
return errors.New("missing object owner")
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestNewKeyStorage(t *testing.T) {
|
|||
tokenStor := tokenStorage.NewTokenStore()
|
||||
stor := util.NewKeyStorage(&nodeKey.PrivateKey, tokenStor, mockedNetworkState{42})
|
||||
|
||||
owner := *usertest.ID()
|
||||
owner := usertest.ID()
|
||||
|
||||
t.Run("node key", func(t *testing.T) {
|
||||
key, err := stor.GetKey(nil)
|
||||
|
@ -36,7 +36,7 @@ func TestNewKeyStorage(t *testing.T) {
|
|||
t.Run("unknown token", func(t *testing.T) {
|
||||
_, err = stor.GetKey(&util.SessionInfo{
|
||||
ID: uuid.New(),
|
||||
Owner: *usertest.ID(),
|
||||
Owner: usertest.ID(),
|
||||
})
|
||||
require.Error(t, err)
|
||||
})
|
||||
|
|
|
@ -22,7 +22,7 @@ func TestTokenStore(t *testing.T) {
|
|||
|
||||
defer ts.Close()
|
||||
|
||||
owner := *usertest.ID()
|
||||
owner := usertest.ID()
|
||||
|
||||
var ownerV2 refs.OwnerID
|
||||
owner.WriteToV2(&ownerV2)
|
||||
|
@ -66,7 +66,7 @@ func TestTokenStore_Persistent(t *testing.T) {
|
|||
ts, err := NewTokenStore(path)
|
||||
require.NoError(t, err)
|
||||
|
||||
idOwner := *usertest.ID()
|
||||
idOwner := usertest.ID()
|
||||
|
||||
var idOwnerV2 refs.OwnerID
|
||||
idOwner.WriteToV2(&idOwnerV2)
|
||||
|
@ -127,7 +127,7 @@ func TestTokenStore_RemoveOld(t *testing.T) {
|
|||
|
||||
defer ts.Close()
|
||||
|
||||
owner := *usertest.ID()
|
||||
owner := usertest.ID()
|
||||
|
||||
var ownerV2 refs.OwnerID
|
||||
owner.WriteToV2(&ownerV2)
|
||||
|
|
Loading…
Reference in a new issue