Skip to content

Commit

Permalink
Fix task actions validation (#1871)
Browse files Browse the repository at this point in the history
  • Loading branch information
crspeller authored Sep 26, 2023
1 parent 142d9ed commit a789bf6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/api/graphql_root_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ func (r *RunRootResolver) UpdateRunTaskActions(ctx context.Context, args struct
}
userID := c.r.Header.Get("Mattermost-User-ID")

if err = c.permissions.RunManageProperties(userID, args.RunID); err != nil {
return "", err
}

if err := validateTaskActions(*args.TaskActions); err != nil {
return "", err
}
Expand Down
17 changes: 17 additions & 0 deletions server/api_graphql_runs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ func TestUpdateRun(t *testing.T) {
func TestUpdateRunTaskActions(t *testing.T) {
e := Setup(t)
e.CreateBasic()
e.CreateGuest()

t.Run("task actions mutation create and update", func(t *testing.T) {
createNewRunWithNoChecklists := func(t *testing.T) *client.PlaybookRun {
Expand Down Expand Up @@ -1003,6 +1004,22 @@ func TestUpdateRunTaskActions(t *testing.T) {
// create a new task action
triggerPayload := "{\"keywords\":[\"one\", \"two\"], \"user_ids\":[\"abc\"]}"
actionPayload := "{\"enabled\":false}"

errorResp, err := UpdateRunTaskActions(e.PlaybooksClientGuest, run.ID, 0, 0, &[]app.TaskAction{
{
Trigger: app.Trigger{
Type: app.KeywordsByUsersTriggerType,
Payload: triggerPayload,
},
Actions: []app.Action{{
Type: app.MarkItemAsDoneActionType,
Payload: actionPayload,
}},
},
})
require.NotEmpty(t, errorResp.Errors)
require.NoError(t, err)

response, err := UpdateRunTaskActions(e.PlaybooksClient, run.ID, 0, 0, &[]app.TaskAction{
{
Trigger: app.Trigger{
Expand Down

0 comments on commit a789bf6

Please sign in to comment.