Skip to content

Commit

Permalink
Merge "jobs.py: fix components job removal"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul CI authored and Gerrit Code Review committed Dec 6, 2024
2 parents 18fd2c8 + de53fa7 commit 48894f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dci/api/v1/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def remove_component_from_job(user, job_id, cmpt_id):
j = base.get_resource_orm(models2.Job, job_id)
component = base.get_resource_orm(models2.Component, cmpt_id)

if component.team_id and not user.is_in_team(component.team_id):
if user.is_not_in_team(j.team_id):
raise dci_exc.Unauthorized()

try:
Expand Down
9 changes: 9 additions & 0 deletions tests/api/v1/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ def test_attach_component_from_other_team_to_job(
cmpt_found = True
assert cmpt_found

r = user.delete("/api/v1/jobs/%s/components/%s" % (job_user_id, pc_id))
assert r.status_code == 201
cmpts = user.get("/api/v1/jobs/%s/components" % job_user_id).data["components"]
cmpt_found = False
for c in cmpts:
if c["id"] == pc_id:
cmpt_found = True
assert not cmpt_found


def test_add_component_with_no_team_to_job(
user, admin, team_user_id, topic_user_id, job_user_id
Expand Down

0 comments on commit 48894f7

Please sign in to comment.