mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +00:00
webhooks/gitlab: Add support for confidential issues and notes.
With some minor changes by Eeshan Garg. Fixes #10478.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"object_kind": "issue",
|
||||
"event_type": "confidential_issue",
|
||||
"user": {
|
||||
"name": "Joe Bloggs",
|
||||
"username": "joe.bloggs",
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/ca4538511817d50e4c64a354537f1135?s=80&d=identicon"
|
||||
},
|
||||
"project": {
|
||||
"id": 5,
|
||||
"name": "testing",
|
||||
"description": "",
|
||||
"web_url": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"avatar_url": null,
|
||||
"git_ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"git_http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"namespace": "joe.bloggs",
|
||||
"visibility_level": 0,
|
||||
"path_with_namespace": "joe.bloggs/testing",
|
||||
"default_branch": null,
|
||||
"ci_config_path": null,
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git"
|
||||
},
|
||||
"object_attributes": {
|
||||
"author_id": 2,
|
||||
"closed_at": "2018-09-15 19:05:12 UTC",
|
||||
"confidential": true,
|
||||
"created_at": "2018-09-14 17:48:36 UTC",
|
||||
"description": "Testing Test",
|
||||
"due_date": null,
|
||||
"id": 1,
|
||||
"iid": 1,
|
||||
"last_edited_at": "2018-09-15 19:04:31 UTC",
|
||||
"last_edited_by_id": 2,
|
||||
"milestone_id": null,
|
||||
"moved_to_id": null,
|
||||
"project_id": 5,
|
||||
"relative_position": 1073742323,
|
||||
"state": "closed",
|
||||
"time_estimate": 0,
|
||||
"title": "Testing Test",
|
||||
"updated_at": "2018-09-15 19:05:12 UTC",
|
||||
"updated_by_id": 2,
|
||||
"url": "https://gitlab.example.co.uk/joe.bloggs/testing/issues/1",
|
||||
"total_time_spent": 0,
|
||||
"human_total_time_spent": null,
|
||||
"human_time_estimate": null,
|
||||
"assignee_ids": [],
|
||||
"assignee_id": null,
|
||||
"action": "close"
|
||||
},
|
||||
"labels": [],
|
||||
"changes": {
|
||||
"updated_at": {
|
||||
"previous": "2018-09-15 19:05:12 UTC",
|
||||
"current": "2018-09-15 19:05:12 UTC"
|
||||
},
|
||||
"total_time_spent": {
|
||||
"previous": null,
|
||||
"current": 0
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"name": "testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"description": "",
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"object_kind": "issue",
|
||||
"event_type": "confidential_issue",
|
||||
"user": {
|
||||
"name": "Joe Bloggs",
|
||||
"username": "joe.bloggs",
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/ca4538511817d50e4c64a354537f1135?s=80&d=identicon"
|
||||
},
|
||||
"project": {
|
||||
"id": 5,
|
||||
"name": "testing",
|
||||
"description": "",
|
||||
"web_url": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"avatar_url": null,
|
||||
"git_ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"git_http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"namespace": "joe.bloggs",
|
||||
"visibility_level": 0,
|
||||
"path_with_namespace": "joe.bloggs/testing",
|
||||
"default_branch": null,
|
||||
"ci_config_path": null,
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git"
|
||||
},
|
||||
"object_attributes": {
|
||||
"author_id": 2,
|
||||
"closed_at": null,
|
||||
"confidential": true,
|
||||
"created_at": "2018-09-15 19:33:44 UTC",
|
||||
"description": "Testing",
|
||||
"due_date": null,
|
||||
"id": 2,
|
||||
"iid": 2,
|
||||
"last_edited_at": null,
|
||||
"last_edited_by_id": null,
|
||||
"milestone_id": null,
|
||||
"moved_to_id": null,
|
||||
"project_id": 5,
|
||||
"relative_position": 1073742823,
|
||||
"state": "opened",
|
||||
"time_estimate": 0,
|
||||
"title": "Testing",
|
||||
"updated_at": "2018-09-15 19:33:44 UTC",
|
||||
"updated_by_id": null,
|
||||
"url": "https://gitlab.example.co.uk/joe.bloggs/testing/issues/2",
|
||||
"total_time_spent": 0,
|
||||
"human_total_time_spent": null,
|
||||
"human_time_estimate": null,
|
||||
"assignee_ids": [
|
||||
2
|
||||
],
|
||||
"assignee_id": 2,
|
||||
"action": "open"
|
||||
},
|
||||
"labels": [],
|
||||
"changes": {
|
||||
"assignees": {
|
||||
"previous": [],
|
||||
"current": [
|
||||
{
|
||||
"name": "Joe Bloggs",
|
||||
"username": "joe.bloggs",
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/ca4538511817d50e4c64a354537f1135?s=80&d=identicon"
|
||||
}
|
||||
]
|
||||
},
|
||||
"total_time_spent": {
|
||||
"previous": null,
|
||||
"current": 0
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"name": "testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"description": "",
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing"
|
||||
},
|
||||
"assignees": [
|
||||
{
|
||||
"name": "Joe Bloggs",
|
||||
"username": "joe.bloggs",
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/ca4538511817d50e4c64a354537f1135?s=80&d=identicon"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"object_kind": "issue",
|
||||
"event_type": "confidential_issue",
|
||||
"user": {
|
||||
"name": "Joe Bloggs",
|
||||
"username": "joe.bloggs",
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/ca4538511817d50e4c64a354537f1135?s=80&d=identicon"
|
||||
},
|
||||
"project": {
|
||||
"id": 5,
|
||||
"name": "testing",
|
||||
"description": "",
|
||||
"web_url": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"avatar_url": null,
|
||||
"git_ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"git_http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"namespace": "joe.bloggs",
|
||||
"visibility_level": 0,
|
||||
"path_with_namespace": "joe.bloggs/testing",
|
||||
"default_branch": null,
|
||||
"ci_config_path": null,
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git"
|
||||
},
|
||||
"object_attributes": {
|
||||
"author_id": 2,
|
||||
"closed_at": null,
|
||||
"confidential": true,
|
||||
"created_at": "2018-09-14 17:48:36 UTC",
|
||||
"description": "This description actually has a hidden comment in it!\n\n<!-- This is\na multiline\ncomment -->\n\n<!-- one line comment -->\n\n<!--\nanother\nmultiline\ncomment\n-->",
|
||||
"due_date": null,
|
||||
"id": 1,
|
||||
"iid": 1,
|
||||
"last_edited_at": null,
|
||||
"last_edited_by_id": null,
|
||||
"milestone_id": null,
|
||||
"moved_to_id": null,
|
||||
"project_id": 5,
|
||||
"relative_position": 1073742323,
|
||||
"state": "opened",
|
||||
"time_estimate": 0,
|
||||
"title": "Testing",
|
||||
"updated_at": "2018-09-14 17:48:36 UTC",
|
||||
"updated_by_id": null,
|
||||
"url": "https://gitlab.example.co.uk/joe.bloggs/testing/issues/1",
|
||||
"total_time_spent": 0,
|
||||
"human_total_time_spent": null,
|
||||
"human_time_estimate": null,
|
||||
"assignee_ids": [],
|
||||
"assignee_id": null,
|
||||
"action": "open"
|
||||
},
|
||||
"labels": [],
|
||||
"changes": {
|
||||
"total_time_spent": {
|
||||
"previous": null,
|
||||
"current": 0
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"name": "testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"description": "",
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"object_kind": "issue",
|
||||
"event_type": "confidential_issue",
|
||||
"user": {
|
||||
"name": "Joe Bloggs",
|
||||
"username": "joe.bloggs",
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/ca4538511817d50e4c64a354537f1135?s=80&d=identicon"
|
||||
},
|
||||
"project": {
|
||||
"id": 5,
|
||||
"name": "testing",
|
||||
"description": "",
|
||||
"web_url": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"avatar_url": null,
|
||||
"git_ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"git_http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"namespace": "joe.bloggs",
|
||||
"visibility_level": 0,
|
||||
"path_with_namespace": "joe.bloggs/testing",
|
||||
"default_branch": null,
|
||||
"ci_config_path": null,
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git"
|
||||
},
|
||||
"object_attributes": {
|
||||
"author_id": 2,
|
||||
"closed_at": null,
|
||||
"confidential": true,
|
||||
"created_at": "2018-09-14 17:48:36 UTC",
|
||||
"description": "Testing",
|
||||
"due_date": null,
|
||||
"id": 1,
|
||||
"iid": 1,
|
||||
"last_edited_at": null,
|
||||
"last_edited_by_id": null,
|
||||
"milestone_id": null,
|
||||
"moved_to_id": null,
|
||||
"project_id": 5,
|
||||
"relative_position": 1073742323,
|
||||
"state": "opened",
|
||||
"time_estimate": 0,
|
||||
"title": "Testing",
|
||||
"updated_at": "2018-09-14 17:48:36 UTC",
|
||||
"updated_by_id": null,
|
||||
"url": "https://gitlab.example.co.uk/joe.bloggs/testing/issues/1",
|
||||
"total_time_spent": 0,
|
||||
"human_total_time_spent": null,
|
||||
"human_time_estimate": null,
|
||||
"assignee_ids": [],
|
||||
"assignee_id": null,
|
||||
"action": "open"
|
||||
},
|
||||
"labels": [],
|
||||
"changes": {
|
||||
"total_time_spent": {
|
||||
"previous": null,
|
||||
"current": 0
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"name": "testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"description": "",
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing"
|
||||
}
|
||||
}
|
||||
88
zerver/webhooks/gitlab/fixtures/confidential_issue_note.json
Normal file
88
zerver/webhooks/gitlab/fixtures/confidential_issue_note.json
Normal file
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"object_kind": "note",
|
||||
"event_type": "confidential_note",
|
||||
"user": {
|
||||
"name": "Joe Bloggs",
|
||||
"username": "joebloggs",
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/1e00d93acdfdddc06304143a1dfcd0b4?s=80&d=identicon"
|
||||
},
|
||||
"project_id": 8385998,
|
||||
"project": {
|
||||
"id": 8385998,
|
||||
"name": "Test",
|
||||
"description": "",
|
||||
"web_url": "https://gitlab.com/joebloggs/test",
|
||||
"avatar_url": null,
|
||||
"git_ssh_url": "git@gitlab.com:joebloggs/test.git",
|
||||
"git_http_url": "https://gitlab.com/joebloggs/test.git",
|
||||
"namespace": "joebloggs",
|
||||
"visibility_level": 20,
|
||||
"path_with_namespace": "joebloggs/test",
|
||||
"default_branch": null,
|
||||
"ci_config_path": null,
|
||||
"homepage": "https://gitlab.com/joebloggs/test",
|
||||
"url": "git@gitlab.com:joebloggs/test.git",
|
||||
"ssh_url": "git@gitlab.com:joebloggs/test.git",
|
||||
"http_url": "https://gitlab.com/joebloggs/test.git"
|
||||
},
|
||||
"object_attributes": {
|
||||
"attachment": null,
|
||||
"author_id": 1102929,
|
||||
"change_position": null,
|
||||
"commit_id": null,
|
||||
"created_at": "2018-09-15 21:01:07 UTC",
|
||||
"discussion_id": "0be9d1a81a3841710ae99c237f781b4209e6c23f",
|
||||
"id": 101638770,
|
||||
"line_code": null,
|
||||
"note": "Test",
|
||||
"noteable_id": 14177506,
|
||||
"noteable_type": "Issue",
|
||||
"original_position": null,
|
||||
"position": null,
|
||||
"project_id": 8385998,
|
||||
"resolved_at": null,
|
||||
"resolved_by_id": null,
|
||||
"resolved_by_push": null,
|
||||
"st_diff": null,
|
||||
"system": false,
|
||||
"type": null,
|
||||
"updated_at": "2018-09-15 21:01:07 UTC",
|
||||
"updated_by_id": null,
|
||||
"description": "Test",
|
||||
"url": "https://gitlab.com/joebloggs/test/issues/3#note_101638770"
|
||||
},
|
||||
"repository": {
|
||||
"name": "Test",
|
||||
"url": "git@gitlab.com:joebloggs/test.git",
|
||||
"description": "",
|
||||
"homepage": "https://gitlab.com/joebloggs/test"
|
||||
},
|
||||
"issue": {
|
||||
"author_id": 1102929,
|
||||
"closed_at": null,
|
||||
"confidential": true,
|
||||
"created_at": "2018-09-15 21:01:03 UTC",
|
||||
"description": "Test",
|
||||
"due_date": null,
|
||||
"id": 14177506,
|
||||
"iid": 3,
|
||||
"last_edited_at": null,
|
||||
"last_edited_by_id": null,
|
||||
"milestone_id": null,
|
||||
"moved_to_id": null,
|
||||
"project_id": 8385998,
|
||||
"relative_position": 1073743323,
|
||||
"state": "opened",
|
||||
"time_estimate": 0,
|
||||
"title": "Test",
|
||||
"updated_at": "2018-09-15 21:01:03 UTC",
|
||||
"updated_by_id": null,
|
||||
"weight": null,
|
||||
"url": "https://gitlab.com/joebloggs/test/issues/3",
|
||||
"total_time_spent": 0,
|
||||
"human_total_time_spent": null,
|
||||
"human_time_estimate": null,
|
||||
"assignee_ids": [],
|
||||
"assignee_id": null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"object_kind": "issue",
|
||||
"event_type": "confidential_issue",
|
||||
"user": {
|
||||
"name": "Joe Bloggs",
|
||||
"username": "joe.bloggs",
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/ca4538511817d50e4c64a354537f1135?s=80&d=identicon"
|
||||
},
|
||||
"project": {
|
||||
"id": 5,
|
||||
"name": "testing",
|
||||
"description": "",
|
||||
"web_url": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"avatar_url": null,
|
||||
"git_ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"git_http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"namespace": "joe.bloggs",
|
||||
"visibility_level": 0,
|
||||
"path_with_namespace": "joe.bloggs/testing",
|
||||
"default_branch": null,
|
||||
"ci_config_path": null,
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"ssh_url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git"
|
||||
},
|
||||
"object_attributes": {
|
||||
"author_id": 2,
|
||||
"closed_at": null,
|
||||
"confidential": true,
|
||||
"created_at": "2018-09-14 17:48:36 UTC",
|
||||
"description": "Testing Test",
|
||||
"due_date": null,
|
||||
"id": 1,
|
||||
"iid": 1,
|
||||
"last_edited_at": "2018-09-15 19:04:31 UTC",
|
||||
"last_edited_by_id": 2,
|
||||
"milestone_id": null,
|
||||
"moved_to_id": null,
|
||||
"project_id": 5,
|
||||
"relative_position": 1073742323,
|
||||
"state": "opened",
|
||||
"time_estimate": 0,
|
||||
"title": "Testing Test",
|
||||
"updated_at": "2018-09-15 19:05:15 UTC",
|
||||
"updated_by_id": 2,
|
||||
"url": "https://gitlab.example.co.uk/joe.bloggs/testing/issues/1",
|
||||
"total_time_spent": 0,
|
||||
"human_total_time_spent": null,
|
||||
"human_time_estimate": null,
|
||||
"assignee_ids": [],
|
||||
"assignee_id": null,
|
||||
"action": "reopen"
|
||||
},
|
||||
"labels": [],
|
||||
"changes": {
|
||||
"closed_at": {
|
||||
"previous": "2018-09-15 19:05:12 UTC",
|
||||
"current": null
|
||||
},
|
||||
"state": {
|
||||
"previous": "closed",
|
||||
"current": "opened"
|
||||
},
|
||||
"updated_at": {
|
||||
"previous": "2018-09-15 19:05:12 UTC",
|
||||
"current": "2018-09-15 19:05:15 UTC"
|
||||
},
|
||||
"total_time_spent": {
|
||||
"previous": null,
|
||||
"current": 0
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"name": "testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"description": "",
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"object_kind": "issue",
|
||||
"event_type": "confidential_issue",
|
||||
"user": {
|
||||
"name": "Joe Bloggs",
|
||||
"username": "joe.bloggs",
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/ca4538511817d50e4c64a354537f1135?s=80&d=identicon"
|
||||
},
|
||||
"project": {
|
||||
"id": 5,
|
||||
"name": "testing",
|
||||
"description": "",
|
||||
"web_url": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"avatar_url": null,
|
||||
"git_ssh_url": "ssh://git@gitlab.example.co.uk:1999/joe.bloggs/testing.git",
|
||||
"git_http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git",
|
||||
"namespace": "joe.bloggs",
|
||||
"visibility_level": 0,
|
||||
"path_with_namespace": "joe.bloggs/testing",
|
||||
"default_branch": null,
|
||||
"ci_config_path": null,
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk:1999/joe.bloggs/testing.git",
|
||||
"ssh_url": "ssh://git@gitlab.example.co.uk:1999/joe.bloggs/testing.git",
|
||||
"http_url": "https://gitlab.example.co.uk/joe.bloggs/testing.git"
|
||||
},
|
||||
"object_attributes": {
|
||||
"author_id": 2,
|
||||
"closed_at": null,
|
||||
"confidential": true,
|
||||
"created_at": "2018-09-14 17:48:36 UTC",
|
||||
"description": "Testing",
|
||||
"due_date": null,
|
||||
"id": 1,
|
||||
"iid": 1,
|
||||
"last_edited_at": "2018-09-15 19:08:43 UTC",
|
||||
"last_edited_by_id": 2,
|
||||
"milestone_id": null,
|
||||
"moved_to_id": null,
|
||||
"project_id": 5,
|
||||
"relative_position": 1073742323,
|
||||
"state": "opened",
|
||||
"time_estimate": 0,
|
||||
"title": "Testing",
|
||||
"updated_at": "2018-09-15 19:08:43 UTC",
|
||||
"updated_by_id": 2,
|
||||
"url": "https://gitlab.example.co.uk/joe.bloggs/testing/issues/1",
|
||||
"total_time_spent": 0,
|
||||
"human_total_time_spent": null,
|
||||
"human_time_estimate": null,
|
||||
"assignee_ids": [],
|
||||
"assignee_id": null,
|
||||
"action": "update"
|
||||
},
|
||||
"labels": [],
|
||||
"changes": {
|
||||
"description": {
|
||||
"previous": "Testing Test",
|
||||
"current": "Testing"
|
||||
},
|
||||
"last_edited_at": {
|
||||
"previous": "2018-09-15 19:04:31 UTC",
|
||||
"current": "2018-09-15 19:08:43 UTC"
|
||||
},
|
||||
"title": {
|
||||
"previous": "Testing Test",
|
||||
"current": "Testing"
|
||||
},
|
||||
"updated_at": {
|
||||
"previous": "2018-09-15 19:05:15 UTC",
|
||||
"current": "2018-09-15 19:08:43 UTC"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"name": "testing",
|
||||
"url": "ssh://git@gitlab.example.co.uk:1999/joe.bloggs/testing.git",
|
||||
"description": "",
|
||||
"homepage": "https://gitlab.example.co.uk/joe.bloggs/testing"
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,17 @@ class GitlabHookTests(WebhookTestCase):
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_create_confidential_issue_without_assignee_event_message(self) -> None:
|
||||
expected_subject = u"testing / Issue #1 Testing"
|
||||
expected_message = u"Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)\n\n~~~ quote\nTesting\n~~~"
|
||||
|
||||
self.send_and_test_stream_message(
|
||||
'confidential_issue_created_without_assignee',
|
||||
expected_subject,
|
||||
expected_message,
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_create_issue_with_custom_topic_in_url(self) -> None:
|
||||
self.url = self.build_webhook_url(topic='notifications')
|
||||
expected_topic = u"notifications"
|
||||
@@ -125,6 +136,17 @@ class GitlabHookTests(WebhookTestCase):
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_create_confidential_issue_with_assignee_event_message(self) -> None:
|
||||
expected_subject = u"testing / Issue #2 Testing"
|
||||
expected_message = u"Joe Bloggs created [Issue #2](https://gitlab.example.co.uk/joe.bloggs/testing/issues/2)(assigned to Joe Bloggs)\n\n~~~ quote\nTesting\n~~~"
|
||||
|
||||
self.send_and_test_stream_message(
|
||||
'confidential_issue_created_with_assignee',
|
||||
expected_subject,
|
||||
expected_message,
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_create_issue_with_hidden_comment_in_description(self) -> None:
|
||||
expected_topic = u"public-repo / Issue #3 New Issue with hidden comment"
|
||||
expected_message = u"Eeshan Garg created [Issue #3](https://gitlab.com/eeshangarg/public-repo/issues/3)\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~"
|
||||
@@ -136,6 +158,17 @@ class GitlabHookTests(WebhookTestCase):
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_create_confidential_issue_with_hidden_comment_in_description(self) -> None:
|
||||
expected_subject = u"testing / Issue #1 Testing"
|
||||
expected_message = u"Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~"
|
||||
|
||||
self.send_and_test_stream_message(
|
||||
'confidential_issue_created_with_hidden_comment_in_description',
|
||||
expected_subject,
|
||||
expected_message,
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_create_issue_with_null_description(self) -> None:
|
||||
expected_topic = u"my-awesome-project / Issue #7 Issue without description"
|
||||
expected_message = u"Eeshan Garg created [Issue #7](https://gitlab.com/eeshangarg/my-awesome-project/issues/7)"
|
||||
@@ -157,6 +190,17 @@ class GitlabHookTests(WebhookTestCase):
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_update_confidential_issue_event_message(self) -> None:
|
||||
expected_subject = u"testing / Issue #1 Testing"
|
||||
expected_message = u"Joe Bloggs updated [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)"
|
||||
|
||||
self.send_and_test_stream_message(
|
||||
'confidential_issue_updated',
|
||||
expected_subject,
|
||||
expected_message,
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_update_issue_with_custom_topic_in_url(self) -> None:
|
||||
self.url = self.build_webhook_url(topic='notifications')
|
||||
expected_topic = u"notifications"
|
||||
@@ -180,6 +224,17 @@ class GitlabHookTests(WebhookTestCase):
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_close_confidential_issue_event_message(self) -> None:
|
||||
expected_subject = u"testing / Issue #1 Testing Test"
|
||||
expected_message = u"Joe Bloggs closed [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)"
|
||||
|
||||
self.send_and_test_stream_message(
|
||||
'confidential_issue_closed',
|
||||
expected_subject,
|
||||
expected_message,
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_reopen_issue_event_message(self) -> None:
|
||||
expected_topic = u"my-awesome-project / Issue #1 Issue title_new"
|
||||
expected_message = u"Tomasz Kolek reopened [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)"
|
||||
@@ -191,6 +246,17 @@ class GitlabHookTests(WebhookTestCase):
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_reopen_confidential_issue_event_message(self) -> None:
|
||||
expected_subject = u"testing / Issue #1 Testing Test"
|
||||
expected_message = u"Joe Bloggs reopened [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)"
|
||||
|
||||
self.send_and_test_stream_message(
|
||||
'confidential_issue_reopened',
|
||||
expected_subject,
|
||||
expected_message,
|
||||
HTTP_X_GITLAB_EVENT="Issue Hook"
|
||||
)
|
||||
|
||||
def test_note_commit_event_message(self) -> None:
|
||||
expected_topic = u"my-awesome-project"
|
||||
expected_message = u"Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7#note_14169211) on [66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7)\n~~~ quote\nnice commit\n~~~"
|
||||
@@ -236,6 +302,17 @@ class GitlabHookTests(WebhookTestCase):
|
||||
HTTP_X_GITLAB_EVENT="Note Hook"
|
||||
)
|
||||
|
||||
def test_note_confidential_issue_event_message(self) -> None:
|
||||
expected_subject = u"Test / Issue #3 Test"
|
||||
expected_message = u"Joe Bloggs [commented](https://gitlab.com/joebloggs/test/issues/3#note_101638770) on [Issue #3](https://gitlab.com/joebloggs/test/issues/3)\n\n~~~ quote\nTest\n~~~"
|
||||
|
||||
self.send_and_test_stream_message(
|
||||
'confidential_issue_note',
|
||||
expected_subject,
|
||||
expected_message,
|
||||
HTTP_X_GITLAB_EVENT="Confidential Note Hook"
|
||||
)
|
||||
|
||||
def test_note_issue_with_custom_topic_in_url(self) -> None:
|
||||
self.url = self.build_webhook_url(topic='notifications')
|
||||
expected_topic = u"notifications"
|
||||
|
||||
@@ -133,6 +133,12 @@ def get_objects_assignee(payload: Dict[str, Any]) -> Optional[str]:
|
||||
assignee_object = payload.get('assignee')
|
||||
if assignee_object:
|
||||
return assignee_object.get('name')
|
||||
else:
|
||||
assignee_object = payload.get('assignees')
|
||||
if assignee_object:
|
||||
for assignee in payload.get('assignees'):
|
||||
return assignee['name']
|
||||
|
||||
return None
|
||||
|
||||
def get_commented_commit_event_body(payload: Dict[str, Any]) -> str:
|
||||
@@ -272,9 +278,14 @@ EVENT_FUNCTION_MAPPER = {
|
||||
'Issue Hook close': partial(get_issue_event_body, action='closed'),
|
||||
'Issue Hook reopen': partial(get_issue_event_body, action='reopened'),
|
||||
'Issue Hook update': partial(get_issue_event_body, action='updated'),
|
||||
'Confidential Issue Hook open': get_issue_created_event_body,
|
||||
'Confidential Issue Hook close': partial(get_issue_event_body, action='closed'),
|
||||
'Confidential Issue Hook reopen': partial(get_issue_event_body, action='reopened'),
|
||||
'Confidential Issue Hook update': partial(get_issue_event_body, action='updated'),
|
||||
'Note Hook Commit': get_commented_commit_event_body,
|
||||
'Note Hook MergeRequest': get_commented_merge_request_event_body,
|
||||
'Note Hook Issue': get_commented_issue_event_body,
|
||||
'Confidential Note Hook Issue': get_commented_issue_event_body,
|
||||
'Note Hook Snippet': get_commented_snippet_event_body,
|
||||
'Merge Request Hook approved': partial(get_merge_request_event_body, action='approved'),
|
||||
'Merge Request Hook open': partial(get_merge_request_open_or_updated_body, action='created'),
|
||||
@@ -329,14 +340,14 @@ def get_subject_based_on_event(event: str, payload: Dict[str, Any]) -> str:
|
||||
id=payload['object_attributes'].get('iid'),
|
||||
title=payload['object_attributes'].get('title')
|
||||
)
|
||||
elif event.startswith('Issue Hook'):
|
||||
elif event.startswith('Issue Hook') or event.startswith('Confidential Issue Hook'):
|
||||
return TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
||||
repo=get_repo_name(payload),
|
||||
type='Issue',
|
||||
id=payload['object_attributes'].get('iid'),
|
||||
title=payload['object_attributes'].get('title')
|
||||
)
|
||||
elif event == 'Note Hook Issue':
|
||||
elif event == 'Note Hook Issue' or event == 'Confidential Note Hook Issue':
|
||||
return TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
||||
repo=get_repo_name(payload),
|
||||
type='Issue',
|
||||
@@ -362,10 +373,10 @@ def get_subject_based_on_event(event: str, payload: Dict[str, Any]) -> str:
|
||||
|
||||
def get_event(request: HttpRequest, payload: Dict[str, Any], branches: Optional[str]) -> Optional[str]:
|
||||
event = validate_extract_webhook_http_header(request, 'X_GITLAB_EVENT', 'GitLab')
|
||||
if event in ['Issue Hook', 'Merge Request Hook', 'Wiki Page Hook']:
|
||||
if event in ['Confidential Issue Hook', 'Issue Hook', 'Merge Request Hook', 'Wiki Page Hook']:
|
||||
action = payload['object_attributes'].get('action')
|
||||
event = "{} {}".format(event, action)
|
||||
elif event == 'Note Hook':
|
||||
elif event in ['Confidential Note Hook', 'Note Hook']:
|
||||
action = payload['object_attributes'].get('noteable_type')
|
||||
event = "{} {}".format(event, action)
|
||||
elif event == 'Push Hook':
|
||||
|
||||
Reference in New Issue
Block a user