Commit Graph

57 Commits

Author SHA1 Message Date
Eeshan Garg daea9a543b webhooks/bitbucket2: Account for missing username in PR payloads.
Certain PR payloads do not have a username for the reviewer, in
such cases, we just return the reviewer's nickname or display
name.
2019-06-24 23:19:06 -07:00
Eeshan Garg 0d519ab146 webhooks/bitbucket2: Account for missing username in user data.
Not all payloads contain the user's username. In such cases, we
should use the user's display name or nickname instead.
2019-06-03 20:00:17 -07:00
Eeshan Garg ab8aae6d0c git_webhooks: Use proper punctuation for PR/issue messages. 2019-05-07 16:45:01 -07:00
Hemanth V. Alluri 9ed1dcc4b6 webhooks: Add Bitbucket Server integration.
This commit adds support for all "repo" events.
2019-03-24 22:06:29 -02:30
Anders Kaseorg 39ac378220 webhooks: Remove unused imports.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-02-02 17:05:20 -08:00
Eeshan Garg f9ee393e4f webhooks/common: Allow suppressing exceptions for missing headers.
This is useful in cases where an event type HTTP header isn't
crucial for inferring the payload's type.
2019-02-01 21:19:26 -03:30
Eeshan Garg d999e79a8b webhooks/bitbucket2: Decode improperly encoded stream names and topics. 2018-12-29 14:51:38 -08:00
Eeshan Garg 8bab4ceba4 webhooks/bitbucket2: Update docs, logo and screenshots. 2018-12-29 10:29:16 -08:00
Steve Howell 1fff890b71 webhooks: Change *_SUBJECT_TEMPLATE to *_TOPIC_TEMPLATE. 2018-11-12 15:47:11 -08:00
Steve Howell ea98a44db3 webhooks: Replace SUBJECT_WITH_* with TOPIC_WITH_*. 2018-11-12 15:47:11 -08:00
Steve Howell ced4d81856 Sweep tests for expected_subject -> expected_topic.
This is all in the webhooks tests, including some
docs for how to write those tests.
2018-11-12 15:47:11 -08:00
Steve Howell 6b6001c46c Remove "subject" from test_classes.py.
We now use "topic" lingo.
2018-11-07 10:03:53 -08:00
Eeshan Garg 9e625b881b webhooks/bitbucket2: Improve commit_status_changed type messages.
Instead of just referring to the commit with the raw URL, we
should use the commit ID as the text of the hyperlink.

Note that in commit_status_changed type messages, the name of the
commit isn't available.
2018-10-04 12:16:06 -07:00
Eeshan Garg b22254835e webhooks/bitbucket2: Fix broken commit URL.
The function that generates the body of the commit_status_changed
event messages generated an invalid commit URL.

Most likely, we missed this because this event type is fairly
vague and it is possible it was never tested by users much,
if at all.
2018-10-04 12:16:06 -07:00
Eeshan Garg d8101ca139 webhooks/bitbucket2: Improve test coverage.
The lack of coverage was due to:

* An unused function that was never used anywhere.
* get_commit_status_changed_body was using a regex where it didn't
  really need to use one. And there was an if statement that
  assumed that the payload might NOT contain the URL to the commit.
  However, I checked the payload and there shouldn't be any instances
  where a commit event is generated but there is no URL to the commit.
* get_push_tag_body had an `else` condition that really can't happen
  in any payload. I verified this by checking the BitBucket webhook
  docs.
2018-10-04 12:16:06 -07:00
Eeshan Garg 4a54e8ac17 webhooks/bitbucket2: Include title in message body if not in topic.
This is a follow-up in response to Tim's comments on #9951.

In instances where all messages from a BitBucket integration are
grouped under one user specified topic (specified in the URL), we
should include the title of the PR in the message body, since
the availability of a user-specified topic precludes us from
including it in the topic itself (which was the default behaviour).
2018-07-26 16:35:09 -07:00
Eeshan Garg e0ef831993 webhooks: Migrate to UnexpectedWebhookEventType.
This improves test coverage for a lot of our webhooks that relied
on ad-hoc methods to handle unexpected event types.

Note that I have deliberately skipped github_legacy, it isn't
advertised and is officially deprecated.

Also, I have refrained from making further changes to Trello, I
believe further improvements to test coverage should be covered
in separate per-webhook commits/PRs.
2018-05-22 08:30:19 -07:00
Aditya Bansal a40ae4cae5 zerver/webhooks: Change use of typing.Text to str. 2018-05-12 15:21:24 -07:00
Aditya Bansal 64ddfc6ac0 zerver/webhooks: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
Eeshan Garg 6817232a67 webhooks/bitbucket2: Support events of type "repo:updated". 2018-05-05 15:48:38 -07:00
Eeshan Garg 9fb9c0d901 webhooks: Migrate to validate_extract_webhook_http_header.
This is a part of our efforts to close #6213.
2018-05-05 15:48:38 -07:00
Eeshan Garg 026ff48020 webhooks/bitbucket2: Detect pushes that remove branches correctly.
This was a user-reported bug and a very subtle and painful one
to track down.

Previously, if payload['push']['changes'][i]['closed'] was True,
we assumed that a branch was removed. Looking at whether `closed`
was set to True or not was our way to tell whether a push removed
a branch or not.

However, this is wrong! `closed` being set to True can also mean
that the pull request associated with the branch was approved but
the branch itself was not deleted. According to the BitBucket docs,
the correct way to see if a branch is deleted is to check if `new`
is null.

This bug was leading to KeyErrors about not being able to find
the `commits` key, which shouldn't happen anymore!
2018-04-02 19:30:09 -02:30
Eeshan Garg 93678e89cd webhooks: Migrate 14 webhooks to use check_send_webhook_message.
These are the straightforward ones.

Note that there is a line in zerver.lib.test_classes.build_webhook_url
that lost test coverage. That's because most of our tests test using
stream messages so the webhook URLs being tested always have a query
parameter. So the line that accounts for there being no query
parameters never gets called, which is fine, but we should still
keep it.
2018-03-16 11:34:20 -07:00
neiljp (Neil Pilgrim) 9e1dbde82d mypy: Final small migrations to python3.5 annotations in many files. 2018-03-12 11:23:30 -07:00
Eeshan Garg 1c44a9c4c0 webhooks/bitbucket2: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Rishi Gupta 76898dd4d3 integrations: Make minor wording changes to integrations docs. 2018-02-27 08:23:51 -08:00
Eeshan Garg bd787c12c4 webhooks/bitbucket2: Update text and remove screenshots.
* Remove unnecessary screenshot. It doesn't help very much in this
  case.
* Update text to instruct users to not leave the `Title` field
  empty (it cannot be blank).
* Replace wording such as `Go to Settings` with `Click on Settings`.
* Combine the "fill out the form" and "click 'Save'" steps.
* Replace "Choose X on the left-hand side" with "Choose X".
* Replace "Remember to check the X" with "Check the X".
2018-02-24 06:21:02 -05:00
Rishi Gupta 08efd7828a integrations: Update text for bitbucket2 doc.
With minor fixes by eeshangarg.

Eeshan: I added a screenshot because I thought it would be helpful.
2018-02-13 22:28:48 -03:30
Eeshan Garg 06e86ce50d webhooks/bitbucket2: Reformat documentation steps into numbered list.
This is a part of our efforts to migrate our webhook docs to have
a more structured numbered-list format similar to our /help docs.
2018-02-08 17:45:56 -08:00
fredfishgames ccc3d69f61 mypy: Use Python 3 type syntax in zerver/webhooks/bitbucket2/tests.py. 2017-12-26 08:31:09 -05:00
picapi_ d038e7ea6b mypy: Use Python 3 type syntax in zerver/webhooks/bitbucket2/view.py. 2017-12-11 20:27:55 -08:00
Eeshan Garg 5b8f38f4e3 webhooks/bitbucket2: Ignore push events with no changes.
We now ignore payloads where payload['push']['changes'] is empty,
because an empty push doesn't really convey any useful information.

I couldn't find a way to replicate the action that would generate
such a payload, so I took one of our existing payloads and editted
out payload['push']['changes'] myself, so this payload is not
authentic.
2017-11-26 17:03:07 -08:00
Tim Abbott 73a668e7ae python: Sort imports in webhooks. 2017-11-15 15:43:10 -08:00
rht bafba95eb7 Text-wrap the remaining long lines exceeding 110. 2017-11-15 10:58:03 -08:00
rht 04eaec64f0 zerver/webhooks: Text-wrap long lines exceeding 110. 2017-11-07 17:24:09 -08:00
rht ec5120e807 refactor: Remove six.moves.zip import. 2017-11-07 10:46:42 -08:00
rht 969cc506d2 zerver/webhooks: Use python 3 syntax for typing.
Tweaked by tabbott to fix various line-wrapping issues.
2017-11-04 19:40:32 -07:00
Eeshan Garg aaaed74c3d webhooks: Import REQ, has_request_variables from zerver.lib.request.
We now import REQ and has_request_variables from zerver.lib.request,
which is where these methods are defined.

Fixes #7195.
2017-11-02 14:40:55 -07:00
neiljp (Neil Pilgrim) fc947d92e2 mypy: Improve return type in bitbucket2 webhook function. 2017-10-11 12:16:50 -07:00
Eeshan Garg 86c2c7ad34 webhooks: Migrate to check_send_stream_message.
This commit migrates all webhooks to use check_send_stream_message
instead of check_send_message. The only two webhooks that still
use check_send_message are our yo and teamcity webhooks. They
both use check_send_message for private messages.
2017-09-30 17:48:55 -07:00
rht 7115a29bee zerver/webhooks: Remove absolute_import. 2017-09-27 10:00:39 -07:00
Robert Hönig 18a080cd6c Don't handle json payload key errors inside webhooks.
Fixes first part of #6213.
2017-08-24 11:33:14 -07:00
Jack Zhang 8187b7ab57 bitbucket2/doc.md: Add link to deprecated Enterprise integration. 2017-08-10 10:21:53 -07:00
Eeshan Garg 7cfc592202 webhooks/bitbucket2: Migrate docs to Markdown.
The change to `render_markdown_path` in `app_filters.py` was
required because for bitbucket2, `integrations.name` is
`bitbucket2`, which is substituted for the stream name in our
Markdown macros. It didn't make sense to recommend the name
`bitbucket2` as a default stream name to our users (for them,
it's just bitbucket). However, the URL is still
`api/v1/external/bitbucket2`.
2017-06-05 11:22:05 -07:00
Aditya Bansal 90cdebb04a pep8: Add compliance with rule E261 bitbucket2/view.py. 2017-06-04 09:18:11 -07:00
umkay c1a8fb615c mypy: Fix strict-optional errors in webhooks directory. 2017-05-24 18:57:06 -07:00
Eeshan Garg 597db11a98 webhooks: Rename webhook fixtures to only include event type.
All webhook fixtures have now been renamed from
<webhook_name>/fixtures/<webhook_name>_<event_type>.json to
<webhook_name>/fixtures/<event_type>.json.
2017-05-13 20:07:40 -02:30
Eeshan Garg e87e246fcb zerver/decorator: Set request.client in api_key_only_webhook_view.
Previously, api_key_only_webhook_view passed 3 positional arguments
(request, user_profile, and client) into a function. However, most
of our other auth decorators only pass 2 positional arguments. For
the sake of consistency, we now make api_key_only_webhook_view set
request.client and pass only request and user_profile as positional
arguments.
2017-05-01 23:44:07 -07:00
Eeshan Garg aa12002be7 webhooks: Move all fixtures to zerver/webhooks/<webhook_name>/fixtures.
All webhook fixtures in zerver/fixtures/<webhook_name> have now
been moved to dedicated webhook-specific directories under
zerver/webhooks/<webhook_name>/fixtures, where <webhook_name> is
the name of the webhook.
2017-04-28 11:07:03 -07:00
Eeshan Garg ffdd5d3588 webhooks: Don't display "Commits by" when committer is the only author.
For our Git integrations, we now only display the number of commits
pushed when the pusher also happens to be the only author of the
commits being pushed.

Part of #3968.
Follow-up to #4006.
2017-04-26 18:26:09 -02:30