mirror of
https://github.com/zulip/zulip.git
synced 2025-10-22 20:42:14 +00:00
webhooks_gitea: Add tests and fixture for correct actor on PR close.
Previously, closing a pull request by someone other than its creator could result in Zulip notifications attributing the action to the wrong user. This change adds a focused test and a fixture capturing the case where the webhook sender differs from pull_request.user, ensuring the correct actor is mentioned for pull_request close events. Follow-up to #36184.
This commit is contained in:
@@ -0,0 +1,479 @@
|
||||
{
|
||||
"action": "closed",
|
||||
"number": 1,
|
||||
"pull_request": {
|
||||
"id": 126085,
|
||||
"url": "https://gitea.com/Aneesh-Hegde/test-repo/pulls/1",
|
||||
"number": 1,
|
||||
"user": {
|
||||
"id": 116733,
|
||||
"login": "Celebi",
|
||||
"login_name": "",
|
||||
"source_id": 0,
|
||||
"full_name": "",
|
||||
"email": "celebi_datatransfer@noreply.gitea.com",
|
||||
"avatar_url": "https://seccdn.libravatar.org/avatar/7acebc2b09409dc06796dc2cbd80c08a?d=identicon",
|
||||
"html_url": "https://gitea.com/Celebi",
|
||||
"language": "",
|
||||
"is_admin": false,
|
||||
"last_login": "0001-01-01T00:00:00Z",
|
||||
"created": "2025-03-29T17:56:48Z",
|
||||
"restricted": false,
|
||||
"active": false,
|
||||
"prohibit_login": false,
|
||||
"location": "",
|
||||
"website": "",
|
||||
"description": "",
|
||||
"visibility": "public",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"starred_repos_count": 0,
|
||||
"username": "Celebi"
|
||||
},
|
||||
"title": "PR closed",
|
||||
"body": "",
|
||||
"labels": [],
|
||||
"milestone": null,
|
||||
"assignee": null,
|
||||
"assignees": [],
|
||||
"requested_reviewers": [],
|
||||
"requested_reviewers_teams": [],
|
||||
"state": "closed",
|
||||
"draft": true,
|
||||
"is_locked": false,
|
||||
"comments": 10,
|
||||
"additions": 3,
|
||||
"deletions": 1,
|
||||
"changed_files": 3,
|
||||
"html_url": "https://gitea.com/Aneesh-Hegde/test-repo/pulls/1",
|
||||
"diff_url": "https://gitea.com/Aneesh-Hegde/test-repo/pulls/1.diff",
|
||||
"patch_url": "https://gitea.com/Aneesh-Hegde/test-repo/pulls/1.patch",
|
||||
"mergeable": false,
|
||||
"merged": false,
|
||||
"merged_at": null,
|
||||
"merge_commit_sha": null,
|
||||
"merged_by": null,
|
||||
"allow_maintainer_edit": false,
|
||||
"base": {
|
||||
"label": "main",
|
||||
"ref": "main",
|
||||
"sha": "aef25c08146a31ac1d9941edd8c306132194978f",
|
||||
"repo_id": 95379,
|
||||
"repo": {
|
||||
"id": 95379,
|
||||
"owner": {
|
||||
"id": 116728,
|
||||
"login": "Aneesh-Hegde",
|
||||
"login_name": "",
|
||||
"source_id": 0,
|
||||
"full_name": "CELEBI",
|
||||
"email": "aneesh-hegde@noreply.gitea.com",
|
||||
"avatar_url": "https://seccdn.libravatar.org/avatar/3629fd95adff086774218f58a8d33c7c?d=identicon",
|
||||
"html_url": "https://gitea.com/Aneesh-Hegde",
|
||||
"language": "",
|
||||
"is_admin": false,
|
||||
"last_login": "0001-01-01T00:00:00Z",
|
||||
"created": "2025-03-29T17:41:12Z",
|
||||
"restricted": false,
|
||||
"active": false,
|
||||
"prohibit_login": false,
|
||||
"location": "",
|
||||
"website": "",
|
||||
"description": "",
|
||||
"visibility": "public",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"starred_repos_count": 0,
|
||||
"username": "Aneesh-Hegde"
|
||||
},
|
||||
"name": "test",
|
||||
"full_name": "Aneesh-Hegde/test-repo",
|
||||
"description": "",
|
||||
"empty": false,
|
||||
"private": false,
|
||||
"fork": false,
|
||||
"template": false,
|
||||
"mirror": false,
|
||||
"size": 30,
|
||||
"language": "",
|
||||
"languages_url": "https://gitea.com/api/v1/repos/Aneesh-Hegde/test-repo/languages",
|
||||
"html_url": "https://gitea.com/Aneesh-Hegde/test-repo",
|
||||
"url": "https://gitea.com/api/v1/repos/Aneesh-Hegde/test-repo",
|
||||
"link": "",
|
||||
"ssh_url": "git@gitea.com:Aneesh-Hegde/test-repo.git",
|
||||
"clone_url": "https://gitea.com/Aneesh-Hegde/test-repo.git",
|
||||
"original_url": "",
|
||||
"website": "",
|
||||
"stars_count": 0,
|
||||
"forks_count": 1,
|
||||
"watchers_count": 1,
|
||||
"open_issues_count": 1,
|
||||
"open_pr_counter": 2,
|
||||
"release_counter": 1,
|
||||
"default_branch": "main",
|
||||
"archived": false,
|
||||
"created_at": "2025-03-29T18:00:25Z",
|
||||
"updated_at": "2025-10-02T11:23:27Z",
|
||||
"archived_at": "1970-01-01T00:00:00Z",
|
||||
"permissions": {
|
||||
"admin": false,
|
||||
"push": true,
|
||||
"pull": true
|
||||
},
|
||||
"has_code": false,
|
||||
"has_issues": true,
|
||||
"internal_tracker": {
|
||||
"enable_time_tracker": true,
|
||||
"allow_only_contributors_to_track_time": true,
|
||||
"enable_issue_dependencies": true
|
||||
},
|
||||
"has_wiki": true,
|
||||
"has_pull_requests": true,
|
||||
"has_projects": true,
|
||||
"projects_mode": "all",
|
||||
"has_releases": true,
|
||||
"has_packages": false,
|
||||
"has_actions": true,
|
||||
"ignore_whitespace_conflicts": false,
|
||||
"allow_merge_commits": true,
|
||||
"allow_rebase": true,
|
||||
"allow_rebase_explicit": true,
|
||||
"allow_squash_merge": true,
|
||||
"allow_fast_forward_only_merge": true,
|
||||
"allow_rebase_update": true,
|
||||
"allow_manual_merge": false,
|
||||
"autodetect_manual_merge": false,
|
||||
"default_delete_branch_after_merge": false,
|
||||
"default_merge_style": "merge",
|
||||
"default_allow_maintainer_edit": false,
|
||||
"avatar_url": "",
|
||||
"internal": false,
|
||||
"mirror_interval": "",
|
||||
"object_format_name": "sha1",
|
||||
"mirror_updated": "0001-01-01T00:00:00Z",
|
||||
"topics": [],
|
||||
"licenses": []
|
||||
}
|
||||
},
|
||||
"head": {
|
||||
"label": "main",
|
||||
"ref": "main",
|
||||
"sha": "cabcb9513308844c015a6b3dd804c5618875b447",
|
||||
"repo_id": 95380,
|
||||
"repo": {
|
||||
"id": 95380,
|
||||
"owner": {
|
||||
"id": 116733,
|
||||
"login": "Celebi",
|
||||
"login_name": "",
|
||||
"source_id": 0,
|
||||
"full_name": "",
|
||||
"email": "celebi_datatransfer@noreply.gitea.com",
|
||||
"avatar_url": "https://seccdn.libravatar.org/avatar/7acebc2b09409dc06796dc2cbd80c08a?d=identicon",
|
||||
"html_url": "https://gitea.com/Celebi",
|
||||
"language": "",
|
||||
"is_admin": false,
|
||||
"last_login": "0001-01-01T00:00:00Z",
|
||||
"created": "2025-03-29T17:56:48Z",
|
||||
"restricted": false,
|
||||
"active": false,
|
||||
"prohibit_login": false,
|
||||
"location": "",
|
||||
"website": "",
|
||||
"description": "",
|
||||
"visibility": "public",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"starred_repos_count": 0,
|
||||
"username": "Celebi"
|
||||
},
|
||||
"name": "test",
|
||||
"full_name": "Celebi/test-repo",
|
||||
"description": "",
|
||||
"empty": false,
|
||||
"private": false,
|
||||
"fork": true,
|
||||
"template": false,
|
||||
"parent": {
|
||||
"id": 95379,
|
||||
"owner": {
|
||||
"id": 116728,
|
||||
"login": "Aneesh-Hegde",
|
||||
"login_name": "",
|
||||
"source_id": 0,
|
||||
"full_name": "CELEBI",
|
||||
"email": "aneesh-hegde@noreply.gitea.com",
|
||||
"avatar_url": "https://seccdn.libravatar.org/avatar/3629fd95adff086774218f58a8d33c7c?d=identicon",
|
||||
"html_url": "https://gitea.com/Aneesh-Hegde",
|
||||
"language": "",
|
||||
"is_admin": false,
|
||||
"last_login": "0001-01-01T00:00:00Z",
|
||||
"created": "2025-03-29T17:41:12Z",
|
||||
"restricted": false,
|
||||
"active": false,
|
||||
"prohibit_login": false,
|
||||
"location": "",
|
||||
"website": "",
|
||||
"description": "",
|
||||
"visibility": "public",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"starred_repos_count": 0,
|
||||
"username": "Aneesh-Hegde"
|
||||
},
|
||||
"name": "test",
|
||||
"full_name": "Aneesh-Hegde/test-repo",
|
||||
"description": "",
|
||||
"empty": false,
|
||||
"private": false,
|
||||
"fork": false,
|
||||
"template": false,
|
||||
"mirror": false,
|
||||
"size": 30,
|
||||
"language": "",
|
||||
"languages_url": "https://gitea.com/api/v1/repos/Aneesh-Hegde/test-repo/languages",
|
||||
"html_url": "https://gitea.com/Aneesh-Hegde/test-repo",
|
||||
"url": "https://gitea.com/api/v1/repos/Aneesh-Hegde/test-repo",
|
||||
"link": "",
|
||||
"ssh_url": "git@gitea.com:Aneesh-Hegde/test-repo.git",
|
||||
"clone_url": "https://gitea.com/Aneesh-Hegde/test-repo.git",
|
||||
"original_url": "",
|
||||
"website": "",
|
||||
"stars_count": 0,
|
||||
"forks_count": 1,
|
||||
"watchers_count": 1,
|
||||
"open_issues_count": 1,
|
||||
"open_pr_counter": 1,
|
||||
"release_counter": 1,
|
||||
"default_branch": "main",
|
||||
"archived": false,
|
||||
"created_at": "2025-03-29T18:00:25Z",
|
||||
"updated_at": "2025-10-02T11:23:27Z",
|
||||
"archived_at": "1970-01-01T00:00:00Z",
|
||||
"permissions": {
|
||||
"admin": false,
|
||||
"push": false,
|
||||
"pull": true
|
||||
},
|
||||
"has_code": false,
|
||||
"has_issues": true,
|
||||
"internal_tracker": {
|
||||
"enable_time_tracker": true,
|
||||
"allow_only_contributors_to_track_time": true,
|
||||
"enable_issue_dependencies": true
|
||||
},
|
||||
"has_wiki": true,
|
||||
"has_pull_requests": true,
|
||||
"has_projects": true,
|
||||
"projects_mode": "all",
|
||||
"has_releases": true,
|
||||
"has_packages": false,
|
||||
"has_actions": true,
|
||||
"ignore_whitespace_conflicts": false,
|
||||
"allow_merge_commits": true,
|
||||
"allow_rebase": true,
|
||||
"allow_rebase_explicit": true,
|
||||
"allow_squash_merge": true,
|
||||
"allow_fast_forward_only_merge": true,
|
||||
"allow_rebase_update": true,
|
||||
"allow_manual_merge": false,
|
||||
"autodetect_manual_merge": false,
|
||||
"default_delete_branch_after_merge": false,
|
||||
"default_merge_style": "merge",
|
||||
"default_allow_maintainer_edit": false,
|
||||
"avatar_url": "",
|
||||
"internal": false,
|
||||
"mirror_interval": "",
|
||||
"object_format_name": "sha1",
|
||||
"mirror_updated": "0001-01-01T00:00:00Z",
|
||||
"topics": [],
|
||||
"licenses": []
|
||||
},
|
||||
"mirror": false,
|
||||
"size": 30,
|
||||
"language": "",
|
||||
"languages_url": "https://gitea.com/api/v1/repos/Celebi/test-repo/languages",
|
||||
"html_url": "https://gitea.com/Celebi/test-repo",
|
||||
"url": "https://gitea.com/api/v1/repos/Celebi/test-repo",
|
||||
"link": "",
|
||||
"ssh_url": "git@gitea.com:Celebi/test-repo.git",
|
||||
"clone_url": "https://gitea.com/Celebi/test-repo.git",
|
||||
"original_url": "",
|
||||
"website": "",
|
||||
"stars_count": 0,
|
||||
"forks_count": 0,
|
||||
"watchers_count": 1,
|
||||
"open_issues_count": 0,
|
||||
"open_pr_counter": 0,
|
||||
"release_counter": 0,
|
||||
"default_branch": "main",
|
||||
"archived": false,
|
||||
"created_at": "2025-03-29T18:04:25Z",
|
||||
"updated_at": "2025-03-31T10:07:23Z",
|
||||
"archived_at": "1970-01-01T00:00:00Z",
|
||||
"permissions": {
|
||||
"admin": false,
|
||||
"push": false,
|
||||
"pull": true
|
||||
},
|
||||
"has_code": false,
|
||||
"has_issues": false,
|
||||
"has_wiki": false,
|
||||
"has_pull_requests": true,
|
||||
"has_projects": false,
|
||||
"projects_mode": "all",
|
||||
"has_releases": false,
|
||||
"has_packages": false,
|
||||
"has_actions": false,
|
||||
"ignore_whitespace_conflicts": false,
|
||||
"allow_merge_commits": true,
|
||||
"allow_rebase": true,
|
||||
"allow_rebase_explicit": true,
|
||||
"allow_squash_merge": true,
|
||||
"allow_fast_forward_only_merge": true,
|
||||
"allow_rebase_update": true,
|
||||
"allow_manual_merge": false,
|
||||
"autodetect_manual_merge": false,
|
||||
"default_delete_branch_after_merge": false,
|
||||
"default_merge_style": "merge",
|
||||
"default_allow_maintainer_edit": false,
|
||||
"avatar_url": "",
|
||||
"internal": false,
|
||||
"mirror_interval": "",
|
||||
"object_format_name": "sha1",
|
||||
"mirror_updated": "0001-01-01T00:00:00Z",
|
||||
"topics": [],
|
||||
"licenses": []
|
||||
}
|
||||
},
|
||||
"merge_base": "3d1aa2535f5433f56e252fee2311039c3afb0cb6",
|
||||
"due_date": null,
|
||||
"created_at": "2025-03-29T18:04:51Z",
|
||||
"updated_at": "2025-10-10T19:45:22Z",
|
||||
"closed_at": "2025-10-10T19:45:22Z",
|
||||
"pin_order": 0
|
||||
},
|
||||
"requested_reviewer": null,
|
||||
"repository": {
|
||||
"id": 95379,
|
||||
"owner": {
|
||||
"id": 116728,
|
||||
"login": "Aneesh-Hegde",
|
||||
"login_name": "",
|
||||
"source_id": 0,
|
||||
"full_name": "CELEBI",
|
||||
"email": "aneesh-hegde@noreply.gitea.com",
|
||||
"avatar_url": "https://seccdn.libravatar.org/avatar/3629fd95adff086774218f58a8d33c7c?d=identicon",
|
||||
"html_url": "https://gitea.com/Aneesh-Hegde",
|
||||
"language": "",
|
||||
"is_admin": false,
|
||||
"last_login": "0001-01-01T00:00:00Z",
|
||||
"created": "2025-03-29T17:41:12Z",
|
||||
"restricted": false,
|
||||
"active": false,
|
||||
"prohibit_login": false,
|
||||
"location": "",
|
||||
"website": "",
|
||||
"description": "",
|
||||
"visibility": "public",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"starred_repos_count": 0,
|
||||
"username": "Aneesh-Hegde"
|
||||
},
|
||||
"name": "test",
|
||||
"full_name": "Aneesh-Hegde/test-repo",
|
||||
"description": "",
|
||||
"empty": false,
|
||||
"private": false,
|
||||
"fork": false,
|
||||
"template": false,
|
||||
"mirror": false,
|
||||
"size": 30,
|
||||
"language": "",
|
||||
"languages_url": "https://gitea.com/api/v1/repos/Aneesh-Hegde/test-repo/languages",
|
||||
"html_url": "https://gitea.com/Aneesh-Hegde/test-repo",
|
||||
"url": "https://gitea.com/api/v1/repos/Aneesh-Hegde/test-repo",
|
||||
"link": "",
|
||||
"ssh_url": "git@gitea.com:Aneesh-Hegde/test-repo.git",
|
||||
"clone_url": "https://gitea.com/Aneesh-Hegde/test-repo.git",
|
||||
"original_url": "",
|
||||
"website": "",
|
||||
"stars_count": 0,
|
||||
"forks_count": 1,
|
||||
"watchers_count": 1,
|
||||
"open_issues_count": 1,
|
||||
"open_pr_counter": 2,
|
||||
"release_counter": 1,
|
||||
"default_branch": "main",
|
||||
"archived": false,
|
||||
"created_at": "2025-03-29T18:00:25Z",
|
||||
"updated_at": "2025-10-02T11:23:27Z",
|
||||
"archived_at": "1970-01-01T00:00:00Z",
|
||||
"permissions": {
|
||||
"admin": false,
|
||||
"push": false,
|
||||
"pull": true
|
||||
},
|
||||
"has_code": false,
|
||||
"has_issues": true,
|
||||
"internal_tracker": {
|
||||
"enable_time_tracker": true,
|
||||
"allow_only_contributors_to_track_time": true,
|
||||
"enable_issue_dependencies": true
|
||||
},
|
||||
"has_wiki": true,
|
||||
"has_pull_requests": true,
|
||||
"has_projects": true,
|
||||
"projects_mode": "all",
|
||||
"has_releases": true,
|
||||
"has_packages": false,
|
||||
"has_actions": true,
|
||||
"ignore_whitespace_conflicts": false,
|
||||
"allow_merge_commits": true,
|
||||
"allow_rebase": true,
|
||||
"allow_rebase_explicit": true,
|
||||
"allow_squash_merge": true,
|
||||
"allow_fast_forward_only_merge": true,
|
||||
"allow_rebase_update": true,
|
||||
"allow_manual_merge": false,
|
||||
"autodetect_manual_merge": false,
|
||||
"default_delete_branch_after_merge": false,
|
||||
"default_merge_style": "merge",
|
||||
"default_allow_maintainer_edit": false,
|
||||
"avatar_url": "",
|
||||
"internal": false,
|
||||
"mirror_interval": "",
|
||||
"object_format_name": "sha1",
|
||||
"mirror_updated": "0001-01-01T00:00:00Z",
|
||||
"topics": [],
|
||||
"licenses": []
|
||||
},
|
||||
"sender": {
|
||||
"id": 150382,
|
||||
"login": "Aneesh-Hegde",
|
||||
"login_name": "",
|
||||
"source_id": 0,
|
||||
"full_name": "",
|
||||
"email": "Aneesh-Hegde@noreply.gitea.com",
|
||||
"avatar_url": "https://seccdn.libravatar.org/avatar/466f1c45cb91f690a119741a0ffbb418?d=identicon",
|
||||
"html_url": "https://gitea.com/Aneesh-Hegde",
|
||||
"language": "",
|
||||
"is_admin": false,
|
||||
"last_login": "0001-01-01T00:00:00Z",
|
||||
"created": "2025-10-10T19:39:18Z",
|
||||
"restricted": false,
|
||||
"active": false,
|
||||
"prohibit_login": false,
|
||||
"location": "",
|
||||
"website": "",
|
||||
"description": "",
|
||||
"visibility": "public",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"starred_repos_count": 0,
|
||||
"username": "Aneesh-Hegde"
|
||||
},
|
||||
"commit_id": "",
|
||||
"review": null
|
||||
}
|
@@ -51,6 +51,11 @@ class GiteaHookTests(WebhookTestCase):
|
||||
expected_message = """kostekIV closed [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`."""
|
||||
self.check_webhook("pull_request__closed", expected_topic_name, expected_message)
|
||||
|
||||
def test_pull_request_closed_different_user(self) -> None:
|
||||
expected_topic_name = "test / PR #126085 PR closed"
|
||||
expected_message = """Aneesh-Hegde closed [PR #1](https://gitea.com/Aneesh-Hegde/test-repo/pulls/1) from `main` to `main`."""
|
||||
self.check_webhook("pull_request__closed_diff_user", expected_topic_name, expected_message)
|
||||
|
||||
def test_pull_request_assigned(self) -> None:
|
||||
expected_topic_name = "test / PR #1906 test 2"
|
||||
expected_message = """kostekIV assigned kostekIV to [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master` (assigned to kostekIV)."""
|
||||
|
Reference in New Issue
Block a user