Files
teleport/lib/cache/recording_encryption_test.go
T
Luke Okraszewski 24d3a3447d [cache] update test harness to support paginated APIs by default (#58927)
Fixes WindowsDesktop list not respecting pagination limits.
2025-09-17 14:31:32 +00:00

68 lines
2.4 KiB
Go

// Teleport
// Copyright (C) 2025 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package cache
import (
"context"
"testing"
"github.com/gravitational/trace"
headerv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1"
recordingencryptionv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/recordingencryption/v1"
"github.com/gravitational/teleport/api/types"
)
func newRecordingEncryption() *recordingencryptionv1.RecordingEncryption {
return &recordingencryptionv1.RecordingEncryption{
Kind: types.KindRecordingEncryption,
Version: types.V1,
Metadata: &headerv1.Metadata{
Name: types.MetaNameRecordingEncryption,
},
Spec: &recordingencryptionv1.RecordingEncryptionSpec{
ActiveKeyPairs: nil,
},
}
}
// TestRecordingEncryption tests that CRUD operations on the RecordingEncryption resource are
// replicated from the backend to the cache.
func TestRecordingEncryption(t *testing.T) {
t.Parallel()
p := newTestPack(t, ForAuth)
t.Cleanup(p.Close)
testResources153(t, p, testFuncs[*recordingencryptionv1.RecordingEncryption]{
newResource: func(name string) (*recordingencryptionv1.RecordingEncryption, error) {
return newRecordingEncryption(), nil
},
create: func(ctx context.Context, item *recordingencryptionv1.RecordingEncryption) error {
_, err := p.recordingEncryption.CreateRecordingEncryption(ctx, item)
return trace.Wrap(err)
},
update: func(ctx context.Context, item *recordingencryptionv1.RecordingEncryption) error {
_, err := p.recordingEncryption.UpdateRecordingEncryption(ctx, item)
return trace.Wrap(err)
},
list: singletonListAdapter(p.recordingEncryption.GetRecordingEncryption),
cacheList: singletonListAdapter(p.cache.GetRecordingEncryption),
deleteAll: p.recordingEncryption.DeleteRecordingEncryption,
}, withSkipPaginationTest())
}