mirror of
https://github.com/gravitational/teleport.git
synced 2026-09-24 16:17:11 +08:00
68 lines
2.4 KiB
Go
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())
|
|
}
|