Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#362] pool: Don't use default session token for read #363

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2074,11 +2074,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
Expand All @@ -2087,7 +2082,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
}
Expand All @@ -2102,11 +2097,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
Expand All @@ -2116,7 +2106,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
}
Expand Down Expand Up @@ -2157,11 +2147,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
Expand All @@ -2170,7 +2155,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
}
Expand Down Expand Up @@ -2224,11 +2209,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
Expand All @@ -2238,7 +2218,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
}
Expand Down
4 changes: 2 additions & 2 deletions pool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down