Skip to content

Commit

Permalink
use admin client instead of backend directly
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoandredinis authored and github-actions committed Jan 10, 2025
1 parent 46a4661 commit 57d1799
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/auth/usertasks/usertasksv1/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func (s *Service) updateStatus(ut *usertasksv1.UserTask, existing *usertasksv1.U

if existing != nil {
// Inherit everything from existing UserTask.
ut.Status.LastStateChange = cmp.Or(existing.Status.LastStateChange, ut.Status.LastStateChange)
ut.Status.LastStateChange = cmp.Or(existing.GetStatus().GetLastStateChange(), ut.Status.LastStateChange)

// Update specific values.
if existing.GetSpec().GetState() != ut.GetSpec().GetState() {
Expand Down
5 changes: 4 additions & 1 deletion lib/web/usertasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
usertasksv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/usertasks/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/types/usertasks"
"github.com/gravitational/teleport/lib/auth"
"github.com/gravitational/teleport/lib/services"
"github.com/gravitational/teleport/lib/web/ui"
)
Expand All @@ -53,6 +54,8 @@ func TestUserTask(t *testing.T) {
})
require.NoError(t, err)
pack := env.proxies[0].authPack(t, userWithRW, []types.Role{roleRWUserTask})
adminClient, err := env.server.NewClient(auth.TestAdmin())
require.NoError(t, err)

getAllEndpoint := pack.clt.Endpoint("webapi", "sites", clusterName, "usertask")
singleItemEndpoint := func(name string) string {
Expand Down Expand Up @@ -90,7 +93,7 @@ func TestUserTask(t *testing.T) {
})
require.NoError(t, err)

_, err = env.proxies[0].auth.Auth().CreateUserTask(ctx, userTask)
_, err = adminClient.UserTasksServiceClient().CreateUserTask(ctx, userTask)
require.NoError(t, err)
userTaskForTest = userTask
}
Expand Down

0 comments on commit 57d1799

Please sign in to comment.