* Utility to clone a proto with redaction. Would be nice to set size of redacted field back into the message, but that does not work for all types. * generated protobuf * Recursive proto redact. * generated protobuf * remove redact_format from TrackInfo name * generated protobuf --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
45 lines
802 B
Go
45 lines
802 B
Go
package utils
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/livekit/protocol/livekit"
|
|
"github.com/stretchr/testify/require"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func TestProtoRedact(t *testing.T) {
|
|
msg := &livekit.ParticipantInfo{
|
|
Identity: "testIdentity",
|
|
Name: "testName",
|
|
Metadata: "testMetadata",
|
|
Attributes: map[string]string{
|
|
"key1": "value1",
|
|
"key2": "value2",
|
|
},
|
|
Tracks: []*livekit.TrackInfo{
|
|
{
|
|
Sid: "TR_AUDIO",
|
|
Name: "Microphone",
|
|
},
|
|
{
|
|
Sid: "TR_VIDEO",
|
|
Name: "Camera",
|
|
},
|
|
},
|
|
}
|
|
cloned := CloneProtoRedacted(msg)
|
|
expectedCloned := &livekit.ParticipantInfo{
|
|
Identity: "testIdentity",
|
|
Tracks: []*livekit.TrackInfo{
|
|
{
|
|
Sid: "TR_AUDIO",
|
|
},
|
|
{
|
|
Sid: "TR_VIDEO",
|
|
},
|
|
},
|
|
}
|
|
require.True(t, proto.Equal(expectedCloned, cloned))
|
|
}
|