Skip to content

Commit bf6131f

Browse files
committed
FIX
1 parent 04fb637 commit bf6131f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

routers/api/v1/repo/action.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,10 @@ func DeleteActionRun(ctx *context.APIContext) {
11031103
ctx.APIErrorInternal(err)
11041104
return
11051105
}
1106+
if run.RepoID != ctx.Repo.Repository.ID {
1107+
ctx.APIError(http.StatusNotFound, fmt.Errorf("run with id %d: %w", runID, util.ErrNotExist))
1108+
return
1109+
}
11061110
if !run.Status.IsDone() {
11071111
ctx.APIError(http.StatusBadRequest, "this workflow run is not done")
11081112
return

tests/integration/api_actions_delete_run_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ import (
1818
"github.com/stretchr/testify/assert"
1919
)
2020

21+
func TestAPIActionsDeleteRunCheckPermission(t *testing.T) {
22+
defer prepareTestEnvActionsArtifacts(t)()
23+
24+
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
25+
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
26+
session := loginUser(t, user.Name)
27+
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository)
28+
testAPIActionsDeleteRun(t, repo, token, http.StatusNotFound)
29+
}
30+
2131
func TestAPIActionsDeleteRun(t *testing.T) {
2232
defer prepareTestEnvActionsArtifacts(t)()
2333

0 commit comments

Comments
 (0)