package apemanager_test import ( "testing" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apemanager" "github.com/stretchr/testify/require" apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" ) const ( encoded = `{"ID":"","Rules":[{"Status":"Allow","Actions":{"Inverted":false,"Names":["GetObject"]},"Resources":{"Inverted":false,"Names":["native:object/*"]},"Any":false,"Condition":[{"Op":"StringEquals","Object":"Resource","Key":"Department","Value":"HR"}]}],"MatchType":"DenyPriority"}` ) func TestChainData(t *testing.T) { t.Run("raw chain", func(t *testing.T) { var c apemanager.Chain b := []byte(encoded) c.Raw = b v2, ok := c.ToV2().GetKind().(*apemanager_v2.ChainRaw) require.True(t, ok) require.Equal(t, b, v2.Raw) }) } func TestChainMessageV2(t *testing.T) { b := []byte(encoded) v2Raw := &apemanager_v2.ChainRaw{} v2Raw.SetRaw(b) v2 := &apemanager_v2.Chain{} v2.SetKind(v2Raw) var c apemanager.Chain c.ReadFromV2(v2) require.NotNil(t, c.Raw) require.Equal(t, b, c.Raw) }