webhooks/gitlab: Add support for confidential issues and notes.

With some minor changes by Eeshan Garg.

Fixes #10478.
This commit is contained in:
Eeshan Garg
2018-12-18 19:07:44 -03:30
committed by Tim Abbott
parent 124cb9cca3
commit 6d51c065d3
9 changed files with 635 additions and 4 deletions

View File

@@ -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"