forked from TrueCloudLab/frostfs-node
975ab0dff7
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
36 lines
1 KiB
Go
36 lines
1 KiB
Go
package acl
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/acl"
|
|
acltest "github.com/nspcc-dev/neofs-api-go/v2/acl/test"
|
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
|
sessiontest "github.com/nspcc-dev/neofs-api-go/v2/session/test"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestOriginalTokens(t *testing.T) {
|
|
sToken := sessiontest.GenerateSessionToken(false)
|
|
bToken := acltest.GenerateBearerToken(false)
|
|
|
|
for i := 0; i < 10; i++ {
|
|
metaHeaders := testGenerateMetaHeader(uint32(i), bToken, sToken)
|
|
require.Equal(t, sToken, originalSessionToken(metaHeaders), i)
|
|
require.Equal(t, bToken, originalBearerToken(metaHeaders), i)
|
|
}
|
|
}
|
|
|
|
func testGenerateMetaHeader(depth uint32, b *acl.BearerToken, s *session.SessionToken) *session.RequestMetaHeader {
|
|
metaHeader := new(session.RequestMetaHeader)
|
|
metaHeader.SetBearerToken(b)
|
|
metaHeader.SetSessionToken(s)
|
|
|
|
for i := uint32(0); i < depth; i++ {
|
|
link := metaHeader
|
|
metaHeader = new(session.RequestMetaHeader)
|
|
metaHeader.SetOrigin(link)
|
|
}
|
|
|
|
return metaHeader
|
|
}
|