teleport/lib/events/auditwriter_internal_test.go
Zac Bergquist bf52b4f3f5
Export desktop recordings to video (#23253)
* Export desktop recordings to video

Add a new tsh command that will write Windows desktop recordings
to an AVI file for offline playback. Encoding is done client side
to avoid consuming server resources.

This uses the Motion JPEG codec (https://en.wikipedia.org/wiki/Motion_JPEG)
for its simplicity and ease of use. Something like ffmpeg would perform
better in nearly every aspect (run time, compression / file size, video
quality, etc), but that would complicate our build process and add extra
native dependencies. This implementation uses pure Go and works on any
platform where tsh runs today.

Also make sure `tsh recordings ls` shows Windows and SSH recordings.

* Untangle test imports

lib/events/eventstest is allowed to import lib/events
(it needs to in order to implement interfaces and use types)

This means lib/events can not import lib/events/eventstest,
which requires that we move some tests from package events
to package events_test

* tdp: break dependency on lib/srv

The lib/srv package is large and contains Unix-specific code.
Now that tsh needs to understand the TDP protocol, we need to
avoid importing lib/srv so that tsh can still build on Windows.
2023-04-06 23:20:00 +00:00

45 lines
1.1 KiB
Go

/*
Copyright 2022 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package events
import (
"crypto/rand"
"testing"
"github.com/stretchr/testify/require"
apievents "github.com/gravitational/teleport/api/types/events"
)
func TestBytesToSessionPrintEvents(t *testing.T) {
b := make([]byte, MaxProtoMessageSizeBytes+1)
_, err := rand.Read(b)
require.NoError(t, err)
events := bytesToSessionPrintEvents(b)
require.Len(t, events, 2)
event0, ok := events[0].(*apievents.SessionPrint)
require.True(t, ok)
event1, ok := events[1].(*apievents.SessionPrint)
require.True(t, ok)
allBytes := append(event0.Data, event1.Data...)
require.Equal(t, b, allBytes)
}