mirror of
https://github.com/gravitational/teleport.git
synced 2026-08-29 05:27:37 +08:00
423a964eaf
Enable pagination tests for Resource153 cache resources by default and fix resource-specific test setup that previously skipped or bypassed pagination. This also fixes two issues found: UserTask upstream fallback listing honors the requested page size and token. WorkloadIdentity cache listing forwards the page size and token instead of infinitely loading the first page.
53 lines
1.9 KiB
Go
53 lines
1.9 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"
|
|
|
|
usertasksv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/usertasks/v1"
|
|
)
|
|
|
|
// TestUserTasks tests that CRUD operations on user notification resources are
|
|
// replicated from the backend to the cache.
|
|
func TestUserTasks(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
p := newTestPack(t, ForAuth)
|
|
t.Cleanup(p.Close)
|
|
|
|
testResources153(t, p, testFuncs[*usertasksv1.UserTask]{
|
|
newResource: func(name string) (*usertasksv1.UserTask, error) {
|
|
return newUserTasks(t, name), nil
|
|
},
|
|
create: func(ctx context.Context, item *usertasksv1.UserTask) error {
|
|
_, err := p.userTasks.CreateUserTask(ctx, item)
|
|
return trace.Wrap(err)
|
|
},
|
|
list: func(ctx context.Context, pageLimit int, pageToken string) ([]*usertasksv1.UserTask, string, error) {
|
|
return p.userTasks.ListUserTasks(ctx, int64(pageLimit), pageToken, &usertasksv1.ListUserTasksFilters{})
|
|
},
|
|
cacheList: func(ctx context.Context, pageLimit int, pageToken string) ([]*usertasksv1.UserTask, string, error) {
|
|
return p.cache.ListUserTasks(ctx, int64(pageLimit), pageToken, &usertasksv1.ListUserTasksFilters{})
|
|
},
|
|
deleteAll: p.userTasks.DeleteAllUserTasks,
|
|
})
|
|
}
|