forked from TrueCloudLab/frostfs-node
[#1100] *: Adopt new SDK's owner.ID
API
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
4b5404047c
commit
fee2f5a330
21 changed files with 32 additions and 134 deletions
|
@ -122,14 +122,7 @@ func (v *FormatValidator) checkOwnerKey(id *owner.ID, key []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
wallet, err := owner.NEO3WalletFromPublicKey((*ecdsa.PublicKey)(pub))
|
||||
if err != nil {
|
||||
// TODO: check via NeoFSID
|
||||
return err
|
||||
}
|
||||
|
||||
id2 := owner.NewID()
|
||||
id2.SetNeo3Wallet(wallet)
|
||||
id2 := owner.NewIDFromPublicKey((*ecdsa.PublicKey)(pub))
|
||||
|
||||
if !id.Equal(id2) {
|
||||
return fmt.Errorf("(%T) different owner identifiers %s/%s", v, id, id2)
|
||||
|
|
|
@ -34,16 +34,10 @@ func testObjectID(t *testing.T) *object.ID {
|
|||
return id
|
||||
}
|
||||
|
||||
func blankValidObject(t *testing.T, key *ecdsa.PrivateKey) *RawObject {
|
||||
wallet, err := owner.NEO3WalletFromPublicKey(&key.PublicKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
ownerID := owner.NewID()
|
||||
ownerID.SetNeo3Wallet(wallet)
|
||||
|
||||
func blankValidObject(key *ecdsa.PrivateKey) *RawObject {
|
||||
obj := NewRaw()
|
||||
obj.SetContainerID(cidtest.ID())
|
||||
obj.SetOwnerID(ownerID)
|
||||
obj.SetOwnerID(owner.NewIDFromPublicKey(&key.PublicKey))
|
||||
|
||||
return obj
|
||||
}
|
||||
|
@ -94,11 +88,10 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("correct w/ session token", func(t *testing.T) {
|
||||
w, err := owner.NEO3WalletFromPublicKey((*ecdsa.PublicKey)(ownerKey.PublicKey()))
|
||||
require.NoError(t, err)
|
||||
oid := owner.NewIDFromPublicKey((*ecdsa.PublicKey)(ownerKey.PublicKey()))
|
||||
|
||||
tok := sessiontest.Token()
|
||||
tok.SetOwnerID(owner.NewIDFromNeo3Wallet(w))
|
||||
tok.SetOwnerID(oid)
|
||||
|
||||
obj := NewRaw()
|
||||
obj.SetContainerID(cidtest.ID())
|
||||
|
@ -111,7 +104,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("correct w/o session token", func(t *testing.T) {
|
||||
obj := blankValidObject(t, &ownerKey.PrivateKey)
|
||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||
|
||||
require.NoError(t, object.SetIDWithSignature(&ownerKey.PrivateKey, obj.SDK()))
|
||||
|
||||
|
@ -188,7 +181,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
|
||||
t.Run("expiration", func(t *testing.T) {
|
||||
fn := func(val string) *Object {
|
||||
obj := blankValidObject(t, &ownerKey.PrivateKey)
|
||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||
|
||||
a := object.NewAttribute()
|
||||
a.SetKey(objectV2.SysAttributeExpEpoch)
|
||||
|
@ -222,7 +215,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
|
||||
t.Run("attributes", func(t *testing.T) {
|
||||
t.Run("duplication", func(t *testing.T) {
|
||||
obj := blankValidObject(t, &ownerKey.PrivateKey)
|
||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||
|
||||
a1 := object.NewAttribute()
|
||||
a1.SetKey("key1")
|
||||
|
@ -244,7 +237,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("empty value", func(t *testing.T) {
|
||||
obj := blankValidObject(t, &ownerKey.PrivateKey)
|
||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||
|
||||
a := object.NewAttribute()
|
||||
a.SetKey("key")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue