From b2a37543d34da7f96d4e3d35c4e8da4bf1f43a00 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Tue, 15 Nov 2022 11:41:28 +0300 Subject: [PATCH] [#362] pool: Don't use default session token for read Signed-off-by: Denis Kirillov --- pool/pool.go | 28 ++++------------------------ pool/pool_test.go | 4 ++-- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/pool/pool.go b/pool/pool.go index 5c60fccf..cf7a01be 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -2151,11 +2151,6 @@ type ResGetObject struct { // // Main return value MUST NOT be processed on an erroneous return. func (p *Pool) GetObject(ctx context.Context, prm PrmObjectGet) (ResGetObject, error) { - var prmCtx prmContext - prmCtx.useDefaultSession() - prmCtx.useVerb(session.VerbObjectGet) - prmCtx.useAddress(prm.addr) - p.fillAppropriateKey(&prm.prmCommon) var cc callContext @@ -2164,7 +2159,7 @@ func (p *Pool) GetObject(ctx context.Context, prm PrmObjectGet) (ResGetObject, e var res ResGetObject - err := p.initCallContext(&cc, prm.prmCommon, prmCtx) + err := p.initCallContext(&cc, prm.prmCommon, prmContext{}) if err != nil { return res, err } @@ -2179,11 +2174,6 @@ func (p *Pool) GetObject(ctx context.Context, prm PrmObjectGet) (ResGetObject, e // // Main return value MUST NOT be processed on an erroneous return. func (p *Pool) HeadObject(ctx context.Context, prm PrmObjectHead) (object.Object, error) { - var prmCtx prmContext - prmCtx.useDefaultSession() - prmCtx.useVerb(session.VerbObjectHead) - prmCtx.useAddress(prm.addr) - p.fillAppropriateKey(&prm.prmCommon) var cc callContext @@ -2193,7 +2183,7 @@ func (p *Pool) HeadObject(ctx context.Context, prm PrmObjectHead) (object.Object var obj object.Object - err := p.initCallContext(&cc, prm.prmCommon, prmCtx) + err := p.initCallContext(&cc, prm.prmCommon, prmContext{}) if err != nil { return obj, err } @@ -2234,11 +2224,6 @@ func (x *ResObjectRange) Close() error { // // Main return value MUST NOT be processed on an erroneous return. func (p *Pool) ObjectRange(ctx context.Context, prm PrmObjectRange) (ResObjectRange, error) { - var prmCtx prmContext - prmCtx.useDefaultSession() - prmCtx.useVerb(session.VerbObjectRange) - prmCtx.useAddress(prm.addr) - p.fillAppropriateKey(&prm.prmCommon) var cc callContext @@ -2247,7 +2232,7 @@ func (p *Pool) ObjectRange(ctx context.Context, prm PrmObjectRange) (ResObjectRa var res ResObjectRange - err := p.initCallContext(&cc, prm.prmCommon, prmCtx) + err := p.initCallContext(&cc, prm.prmCommon, prmContext{}) if err != nil { return res, err } @@ -2301,11 +2286,6 @@ func (x *ResObjectSearch) Close() { // // Main return value MUST NOT be processed on an erroneous return. func (p *Pool) SearchObjects(ctx context.Context, prm PrmObjectSearch) (ResObjectSearch, error) { - var prmCtx prmContext - prmCtx.useDefaultSession() - prmCtx.useVerb(session.VerbObjectSearch) - prmCtx.useContainer(prm.cnrID) - p.fillAppropriateKey(&prm.prmCommon) var cc callContext @@ -2315,7 +2295,7 @@ func (p *Pool) SearchObjects(ctx context.Context, prm PrmObjectSearch) (ResObjec var res ResObjectSearch - err := p.initCallContext(&cc, prm.prmCommon, prmCtx) + err := p.initCallContext(&cc, prm.prmCommon, prmContext{}) if err != nil { return res, err } diff --git a/pool/pool_test.go b/pool/pool_test.go index 29a2cdaf..af28a427 100644 --- a/pool/pool_test.go +++ b/pool/pool_test.go @@ -413,12 +413,12 @@ func TestSessionCacheWithKey(t *testing.T) { st, _ := pool.cache.Get(formCacheKey(cp.address(), pool.key)) require.True(t, st.AssertAuthKey(&expectedAuthKey)) - var prm PrmObjectGet + var prm PrmObjectDelete prm.SetAddress(oid.Address{}) anonKey := newPrivateKey(t) prm.UseKey(anonKey) - _, err = pool.GetObject(ctx, prm) + err = pool.DeleteObject(ctx, prm) require.NoError(t, err) st, _ = pool.cache.Get(formCacheKey(cp.address(), anonKey)) require.True(t, st.AssertAuthKey(&expectedAuthKey))