package ape_test import ( "testing" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape" "github.com/stretchr/testify/require" apeV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape" ) 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 ape.Chain b := []byte(encoded) c.Raw = b v2, ok := c.ToV2().GetKind().(*apeV2.ChainRaw) require.True(t, ok) require.Equal(t, b, v2.Raw) }) } func TestChainMessageV2(t *testing.T) { b := []byte(encoded) v2Raw := &apeV2.ChainRaw{} v2Raw.SetRaw(b) v2 := &apeV2.Chain{} v2.SetKind(v2Raw) var c ape.Chain c.ReadFromV2(v2) require.NotNil(t, c.Raw) require.Equal(t, b, c.Raw) }