From 11a1f1d72b920521c5be9aec4b7783471125d078 Mon Sep 17 00:00:00 2001 From: Tomasz Kolek Date: Mon, 30 Jan 2017 19:26:48 +0100 Subject: [PATCH] Add support for old Jira API's version to Jira integration. --- .../fixtures/jira/jira_change_status_v1.json | 154 ++++++++++ .../fixtures/jira/jira_change_status_v2.json | 186 ++++++++++++ ...eted.json => jira_comment_deleted_v2.json} | 0 ...dited.json => jira_comment_edited_v2.json} | 0 .../jira/jira_commented_markup_v1.json | 275 ++++++++++++++++++ ...kup.json => jira_commented_markup_v2.json} | 0 zerver/fixtures/jira/jira_commented_v1.json | 189 ++++++++++++ ..._commented.json => jira_commented_v2.json} | 0 .../jira/jira_created_assignee_v1.json | 154 ++++++++++ ...nee.json => jira_created_assignee_v2.json} | 0 zerver/fixtures/jira/jira_created_v1.json | 120 ++++++++ ...jira_created.json => jira_created_v2.json} | 0 zerver/fixtures/jira/jira_deleted_v1.json | 160 ++++++++++ ...jira_deleted.json => jira_deleted_v2.json} | 0 zerver/fixtures/jira/jira_reassigned_v1.json | 143 +++++++++ ...eassigned.json => jira_reassigned_v2.json} | 0 zerver/fixtures/jira/jira_unknown_v1.json | 189 ++++++++++++ ...jira_unknown.json => jira_unknown_v2.json} | 0 .../jira/jira_updated_priority_v1.json | 221 ++++++++++++++ ...ity.json => jira_updated_priority_v2.json} | 0 zerver/tests/test_decorators.py | 4 +- zerver/webhooks/jira/tests.py | 48 ++- zerver/webhooks/jira/view.py | 44 ++- 23 files changed, 1867 insertions(+), 20 deletions(-) create mode 100644 zerver/fixtures/jira/jira_change_status_v1.json create mode 100644 zerver/fixtures/jira/jira_change_status_v2.json rename zerver/fixtures/jira/{jira_comment_deleted.json => jira_comment_deleted_v2.json} (100%) rename zerver/fixtures/jira/{jira_comment_edited.json => jira_comment_edited_v2.json} (100%) create mode 100644 zerver/fixtures/jira/jira_commented_markup_v1.json rename zerver/fixtures/jira/{jira_commented_markup.json => jira_commented_markup_v2.json} (100%) create mode 100644 zerver/fixtures/jira/jira_commented_v1.json rename zerver/fixtures/jira/{jira_commented.json => jira_commented_v2.json} (100%) create mode 100644 zerver/fixtures/jira/jira_created_assignee_v1.json rename zerver/fixtures/jira/{jira_created_assignee.json => jira_created_assignee_v2.json} (100%) create mode 100644 zerver/fixtures/jira/jira_created_v1.json rename zerver/fixtures/jira/{jira_created.json => jira_created_v2.json} (100%) create mode 100644 zerver/fixtures/jira/jira_deleted_v1.json rename zerver/fixtures/jira/{jira_deleted.json => jira_deleted_v2.json} (100%) create mode 100644 zerver/fixtures/jira/jira_reassigned_v1.json rename zerver/fixtures/jira/{jira_reassigned.json => jira_reassigned_v2.json} (100%) create mode 100644 zerver/fixtures/jira/jira_unknown_v1.json rename zerver/fixtures/jira/{jira_unknown.json => jira_unknown_v2.json} (100%) create mode 100644 zerver/fixtures/jira/jira_updated_priority_v1.json rename zerver/fixtures/jira/{jira_updated_priority.json => jira_updated_priority_v2.json} (100%) diff --git a/zerver/fixtures/jira/jira_change_status_v1.json b/zerver/fixtures/jira/jira_change_status_v1.json new file mode 100644 index 0000000000..7646cece0d --- /dev/null +++ b/zerver/fixtures/jira/jira_change_status_v1.json @@ -0,0 +1,154 @@ +{ + "transition": { + "workflowId": 10200, + "workflowName": "TestProj Workflow", + "transitionId": 3, + "transitionName": "Reopen Issue", + "from_status": "To Do", + "to_status": "In Progress" + }, + "comment": "", + "user": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "issue": { + "id": "10200", + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10200", + "key": "TEST-1", + "fields": { + "summary": "Fix That", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "https://zulipp.atlassian.net/rest/api/2/issuetype/1", + "id": "1", + "description": "A problem which impairs or prevents the functions of the product.", + "iconUrl": "https://zulipp.atlassian.net/images/icons/issuetypes/bug.png", + "name": "Bug", + "subtask": false + }, + "timespent": null, + "reporter": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2013-05-23T11:04:49.965-0400", + "updated": "2013-05-23T11:07:13.541-0400", + "priority": { + "self": "https://zulipp.atlassian.net/rest/api/2/priority/3", + "iconUrl": "https://zulipp.atlassian.net/images/icons/priorities/major.png", + "name": "Major", + "id": "3" + }, + "description": null, + "customfield_10001": null, + "customfield_10002": null, + "customfield_10003": null, + "issuelinks": [], + "customfield_10000": "1_*:*_1_*:*_19188_*|*_5_*:*_2_*:*_86333_*|*_4_*:*_2_*:*_9853", + "subtasks": [], + "customfield_10008": null, + "customfield_10007": null, + "status": { + "self": "https://zulipp.atlassian.net/rest/api/2/status/5", + "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", + "iconUrl": "https://zulipp.atlassian.net/images/icons/statuses/resolved.png", + "name": "Resolved", + "id": "5" + }, + "customfield_10006": "5", + "labels": [], + "workratio": -1, + "project": { + "self": "https://zulipp.atlassian.net/rest/api/2/project/TEST", + "id": "10000", + "key": "TEST", + "name": "TestProj", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", + "24x24": "https://zulipp.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "32x32": "https://zulipp.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011", + "48x48": "https://zulipp.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "environment": null, + "customfield_10014": null, + "customfield_10015": null, + "lastViewed": "2013-05-23T11:07:38.760-0400", + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "customfield_10012": null, + "components": [], + "customfield_10013": null, + "comment": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "comments": [] + }, + "timeoriginalestimate": null, + "customfield_10017": null, + "customfield_10016": null, + "customfield_10019": null, + "customfield_10018": null, + "votes": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-1/votes", + "votes": 0, + "hasVoted": false + }, + "fixVersions": [], + "resolution": { + "self": "https://zulipp.atlassian.net/rest/api/2/resolution/1", + "id": "1", + "description": "A fix for this issue is checked into the tree and tested.", + "name": "Fixed" + }, + "resolutiondate": "2013-05-23T11:07:13.474-0400", + "aggregatetimeoriginalestimate": null, + "duedate": null, + "customfield_10020": null, + "customfield_10021": "Not Started", + "watches": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-1/watchers", + "watchCount": 1, + "isWatching": true + }, + "worklog": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "worklogs": [] + }, + "attachment": [], + "aggregatetimeestimate": null, + "versions": [], + "timeestimate": null, + "aggregatetimespent": null + } + }, + "timestamp": 1369321658777 +} diff --git a/zerver/fixtures/jira/jira_change_status_v2.json b/zerver/fixtures/jira/jira_change_status_v2.json new file mode 100644 index 0000000000..24e4a0deb1 --- /dev/null +++ b/zerver/fixtures/jira/jira_change_status_v2.json @@ -0,0 +1,186 @@ +{ + "timestamp": 1485797534721, + "webhookEvent": "jira:issue_updated", + "issue_event_type_name": "issue_generic", + "user": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=admin", + "name": "admin", + "key": "admin", + "emailAddress": "kolaszek@tlen.pl", + "avatarUrls": { + "48x48": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=48", + "24x24": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=24", + "16x16": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=16", + "32x32": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=32" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true, + "timeZone": "Europe/Berlin" + }, + "issue": { + "id": "10000", + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10000", + "key": "TEST-1", + "fields": { + "issuetype": { + "self": "https://zulipp.atlassian.net/rest/api/2/issuetype/10101", + "id": "10101", + "description": "A task that needs to be done.", + "iconUrl": "https://zulipp.atlassian.net/secure/viewavatar?size=xsmall&avatarId=10318&avatarType=issuetype", + "name": "Task", + "subtask": false, + "avatarId": 10318 + }, + "timespent": null, + "project": { + "self": "https://zulipp.atlassian.net/rest/api/2/project/10000", + "id": "10000", + "key": "ABC", + "name": "Fix That", + "avatarUrls": { + "48x48": "https://zulipp.atlassian.net/secure/projectavatar?avatarId=10324", + "24x24": "https://zulipp.atlassian.net/secure/projectavatar?size=small&avatarId=10324", + "16x16": "https://zulipp.atlassian.net/secure/projectavatar?size=xsmall&avatarId=10324", + "32x32": "https://zulipp.atlassian.net/secure/projectavatar?size=medium&avatarId=10324" + } + }, + "fixVersions": [], + "customfield_10110": null, + "customfield_10111": null, + "aggregatetimespent": null, + "resolution": null, + "customfield_10112": "Not started", + "customfield_10113": null, + "customfield_10114": null, + "customfield_10104": null, + "customfield_10105": null, + "customfield_10106": null, + "customfield_10107": null, + "customfield_10108": null, + "customfield_10109": null, + "resolutiondate": null, + "workratio": -1, + "lastViewed": "2017-01-30T18:32:14.694+0100", + "watches": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-1/watchers", + "watchCount": 1, + "isWatching": true + }, + "created": "2017-01-30T18:30:41.962+0100", + "priority": { + "self": "https://zulipp.atlassian.net/rest/api/2/priority/3", + "iconUrl": "https://zulipp.atlassian.net/images/icons/priorities/medium.svg", + "name": "Medium", + "id": "3" + }, + "customfield_10100": null, + "customfield_10101": null, + "customfield_10102": null, + "labels": [], + "customfield_10103": null, + "timeestimate": null, + "aggregatetimeoriginalestimate": null, + "versions": [], + "issuelinks": [], + "assignee": null, + "updated": "2017-01-30T18:32:14.716+0100", + "status": { + "self": "https://zulipp.atlassian.net/rest/api/2/status/3", + "description": "This issue is being actively worked on at the moment by the assignee.", + "iconUrl": "https://zulipp.atlassian.net/images/icons/statuses/inprogress.png", + "name": "In Progress", + "id": "3", + "statusCategory": { + "self": "https://zulipp.atlassian.net/rest/api/2/statuscategory/4", + "id": 4, + "key": "indeterminate", + "colorName": "yellow", + "name": "In Progress" + } + }, + "components": [], + "timeoriginalestimate": null, + "description": "Fix That", + "timetracking": {}, + "customfield_10005": null, + "attachment": [], + "aggregatetimeestimate": null, + "summary": "Fix That", + "creator": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=admin", + "name": "admin", + "key": "admin", + "emailAddress": "kolaszek@tlen.pl", + "avatarUrls": { + "48x48": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=48", + "24x24": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=24", + "16x16": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=16", + "32x32": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=32" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true, + "timeZone": "Europe/Berlin" + }, + "subtasks": [], + "reporter": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=admin", + "name": "admin", + "key": "admin", + "emailAddress": "kolaszek@tlen.pl", + "avatarUrls": { + "48x48": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=48", + "24x24": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=24", + "16x16": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=16", + "32x32": "https://secure.gravatar.com/avatar/d832c4f48fb6bc323411fbbcd25079ad?d=mm&s=32" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true, + "timeZone": "Europe/Berlin" + }, + "customfield_10000": "{}", + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "customfield_10001": null, + "customfield_10115": null, + "customfield_10116": "0|hzzzzz:", + "environment": null, + "duedate": null, + "progress": { + "progress": 0, + "total": 0 + }, + "comment": { + "comments": [], + "maxResults": 0, + "total": 0, + "startAt": 0 + }, + "votes": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-1/votes", + "votes": 0, + "hasVoted": false + }, + "worklog": { + "startAt": 0, + "maxResults": 20, + "total": 0, + "worklogs": [] + } + } + }, + "changelog": { + "id": "10000", + "items": [ + { + "field": "status", + "fieldtype": "jira", + "from": "10000", + "fromString": "To Do", + "to": "3", + "toString": "In Progress" + } + ] + } +} diff --git a/zerver/fixtures/jira/jira_comment_deleted.json b/zerver/fixtures/jira/jira_comment_deleted_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_comment_deleted.json rename to zerver/fixtures/jira/jira_comment_deleted_v2.json diff --git a/zerver/fixtures/jira/jira_comment_edited.json b/zerver/fixtures/jira/jira_comment_edited_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_comment_edited.json rename to zerver/fixtures/jira/jira_comment_edited_v2.json diff --git a/zerver/fixtures/jira/jira_commented_markup_v1.json b/zerver/fixtures/jira/jira_commented_markup_v1.json new file mode 100644 index 0000000000..b5bc23950a --- /dev/null +++ b/zerver/fixtures/jira/jira_commented_markup_v1.json @@ -0,0 +1,275 @@ +{ + "webhookEvent": "jira:issue_updated", + "user": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "issue": { + "id": "10100", + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10100", + "key": "TEST-7", + "fields": { + "summary": "Testing of rich text", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "https://zulipp.atlassian.net/rest/api/2/issuetype/2", + "id": "2", + "description": "A new feature of the product, which has yet to be developed.", + "iconUrl": "https://zulipp.atlassian.net/images/icons/issuetypes/newfeature.png", + "name": "New Feature", + "subtask": false + }, + "timespent": null, + "reporter": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2013-10-01T16:08:48.446-0400", + "updated": "2013-10-01T16:16:47.821-0400", + "priority": { + "self": "https://zulipp.atlassian.net/rest/api/2/priority/3", + "iconUrl": "https://zulipp.atlassian.net/images/icons/priorities/major.png", + "name": "Major", + "id": "3" + }, + "description": "h1. So this is a heading\r\n\r\nAnd some *bold* **and _bold_?\r\n\r\n{quote}\r\nsome stuff goes here\r\n{quote}", + "customfield_10001": null, + "customfield_10002": null, + "customfield_10003": null, + "issuelinks": [], + "customfield_10000": null, + "subtasks": [], + "customfield_10008": null, + "customfield_10007": null, + "status": { + "self": "https://zulipp.atlassian.net/rest/api/2/status/10001", + "description": "", + "iconUrl": "https://zulipp.atlassian.net/images/icons/statuses/open.png", + "name": "To Do", + "id": "10001" + }, + "customfield_10006": "7", + "labels": [], + "workratio": -1, + "project": { + "self": "https://zulipp.atlassian.net/rest/api/2/project/10000", + "id": "10000", + "key": "TEST", + "name": "TestProject", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", + "24x24": "https://zulipp.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "32x32": "https://zulipp.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011", + "48x48": "https://zulipp.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "environment": null, + "customfield_10014": null, + "customfield_10015": null, + "lastViewed": "2013-10-01T16:16:48.075-0400", + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "customfield_10012": null, + "components": [], + "customfield_10013": null, + "comment": { + "startAt": 0, + "maxResults": 3, + "total": 3, + "comments": [ + { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10100/comment/10000", + "id": "10000", + "author": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "body": "Commenting that *this is important* and also _please italicize me_\r\n\r\nh2. Heading this all the way\r\n\r\nsome quote:\r\n\r\n{quote}\r\noh say can you see...\r\n{quote}", + "updateAuthor": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2013-10-01T16:11:07.615-0400", + "updated": "2013-10-01T16:11:07.615-0400" + }, + { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10100/comment/10001", + "id": "10001", + "author": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "body": "*Rich Text* comment, with _italicized_ text,\r\n\r\nand including some\r\n\r\n{quote}\r\nquotations by yours truly\r\n{quote}", + "updateAuthor": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2013-10-01T16:16:47.821-0400", + "updated": "2013-10-01T16:16:47.821-0400" + }, + { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10100/comment/10002", + "id": "10002", + "author": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "body": "This is a comment that likes to *exercise* a lot of _different_ {{conventions}} that {{jira uses}}.\r\n\r\n{noformat}\r\nthis code is not highlighted, but monospaced\r\n{noformat}\r\n\r\n{code:python}\r\ndef python():\r\n print \"likes to be formatted\"\r\n{code}\r\n\r\n[http://www.google.com] is a bare link, and [Google|http://www.google.com] is given a title.\r\n\r\nThanks!\r\n\r\n{quote}\r\nSomeone said somewhere\r\n{quote}", + "updateAuthor": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2013-10-01T17:03:00.964-0400", + "updated": "2013-10-01T17:03:00.964-0400" + } + ] + }, + "timeoriginalestimate": null, + "customfield_10017": null, + "customfield_10016": null, + "customfield_10019": null, + "customfield_10018": null, + "votes": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-7/votes", + "votes": 0, + "hasVoted": false + }, + "fixVersions": [], + "resolution": null, + "resolutiondate": null, + "aggregatetimeoriginalestimate": null, + "duedate": null, + "customfield_10020": null, + "customfield_10021": "Not Started", + "watches": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-7/watchers", + "watchCount": 1, + "isWatching": true + }, + "worklog": { + "startAt": 0, + "maxResults": 20, + "total": 0, + "worklogs": [] + }, + "assignee": null, + "attachment": [], + "aggregatetimeestimate": null, + "versions": [], + "timeestimate": null, + "aggregatetimespent": null + } + }, + "comment": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10100/comment/10002", + "id": "10002", + "author": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "body": "This is a comment that likes to *exercise* a lot of _different_ {{conventions}} that {{jira uses}}.\r\n\r\n{noformat}\r\nthis code is not highlighted, but monospaced\r\n{noformat}\r\n\r\n{code:python}\r\ndef python():\r\n print \"likes to be formatted\"\r\n{code}\r\n\r\n[http://www.google.com] is a bare link, and [Google|http://www.google.com] is given a title.\r\n\r\nThanks!\r\n\r\n{quote}\r\nSomeone said somewhere\r\n{quote}", + "updateAuthor": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2013-10-01T17:03:00.964-0400", + "updated": "2013-10-01T17:03:00.964-0400" + }, + "timestamp": 1380661380969 +} diff --git a/zerver/fixtures/jira/jira_commented_markup.json b/zerver/fixtures/jira/jira_commented_markup_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_commented_markup.json rename to zerver/fixtures/jira/jira_commented_markup_v2.json diff --git a/zerver/fixtures/jira/jira_commented_v1.json b/zerver/fixtures/jira/jira_commented_v1.json new file mode 100644 index 0000000000..9e5fa82733 --- /dev/null +++ b/zerver/fixtures/jira/jira_commented_v1.json @@ -0,0 +1,189 @@ +{ + "webhookEvent": "jira:issue_updated", + "timestamp": 1364403934253, + "user": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "issue": { + "id": "10400", + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400", + "key": "BUG-15", + "fields": { + "summary": "New bug with hook", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "http://lfranchi.com:8080/rest/api/2/issuetype/1", + "id": "1", + "description": "A problem which impairs or prevents the functions of the product.", + "iconUrl": "http://lfranchi.com:8080/images/icons/bug.gif", + "name": "Bug", + "subtask": false + }, + "votes": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/votes", + "votes": 0, + "hasVoted": false + }, + "resolution": null, + "fixVersions": [], + "resolutiondate": null, + "timespent": null, + "reporter": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "aggregatetimeoriginalestimate": null, + "created": "2013-03-27T16:53:58.301+0000", + "updated": "2013-03-27T16:57:45.287+0000", + "description": "Fix me please", + "priority": { + "self": "http://lfranchi.com:8080/rest/api/2/priority/3", + "iconUrl": "http://lfranchi.com:8080/images/icons/priority_major.gif", + "name": "Major", + "id": "3" + }, + "duedate": null, + "issuelinks": [], + "watches": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/watchers", + "watchCount": 1, + "isWatching": true + }, + "worklog": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "worklogs": [] + }, + "customfield_10000": null, + "subtasks": [], + "status": { + "self": "http://lfranchi.com:8080/rest/api/2/status/1", + "description": "The issue is open and ready for the assignee to start work on it.", + "iconUrl": "http://lfranchi.com:8080/images/icons/status_open.gif", + "name": "Open", + "id": "1" + }, + "labels": [], + "workratio": -1, + "assignee": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "attachment": [], + "aggregatetimeestimate": null, + "project": { + "self": "http://lfranchi.com:8080/rest/api/2/project/BUG", + "id": "10000", + "key": "BUG", + "name": "buggery-test", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "48x48": "http://lfranchi.com:8080/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "versions": [], + "environment": null, + "timeestimate": null, + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "lastViewed": "2013-03-27T16:57:45.258+0000", + "components": [], + "comment": { + "startAt": 0, + "maxResults": 1, + "total": 1, + "comments": [ + { + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400/comment/10400", + "id": "10400", + "author": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "body": "Adding a comment. Oh, what a comment it is!", + "updateAuthor": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "created": "2013-03-27T17:05:34.250+0000", + "updated": "2013-03-27T17:05:34.250+0000" + } + ] + }, + "timeoriginalestimate": null, + "aggregatetimespent": null + } + }, + "comment": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400/comment/10400", + "id": "10400", + "author": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "body": "Adding a comment. Oh, what a comment it is!", + "updateAuthor": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "created": "2013-03-27T17:05:34.250+0000", + "updated": "2013-03-27T17:05:34.250+0000" + } +} diff --git a/zerver/fixtures/jira/jira_commented.json b/zerver/fixtures/jira/jira_commented_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_commented.json rename to zerver/fixtures/jira/jira_commented_v2.json diff --git a/zerver/fixtures/jira/jira_created_assignee_v1.json b/zerver/fixtures/jira/jira_created_assignee_v1.json new file mode 100644 index 0000000000..5314c89c1d --- /dev/null +++ b/zerver/fixtures/jira/jira_created_assignee_v1.json @@ -0,0 +1,154 @@ +{ + "webhookEvent": "jira:issue_created", + "user": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "issue": { + "id": "10003", + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10003", + "key": "TEST-4", + "fields": { + "summary": "Test Created Assignee", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "https://zulipp.atlassian.net/rest/api/2/issuetype/2", + "id": "2", + "description": "A new feature of the product, which has yet to be developed.", + "iconUrl": "https://zulipp.atlassian.net/images/icons/issuetypes/newfeature.png", + "name": "New Feature", + "subtask": false + }, + "timespent": null, + "reporter": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2013-09-06T11:20:24.101-0400", + "updated": "2013-09-06T11:20:24.101-0400", + "priority": { + "self": "https://zulipp.atlassian.net/rest/api/2/priority/3", + "iconUrl": "https://zulipp.atlassian.net/images/icons/priorities/major.png", + "name": "Major", + "id": "3" + }, + "description": "This is the description, so descriptive it is", + "customfield_10001": null, + "customfield_10002": null, + "customfield_10003": null, + "issuelinks": [], + "customfield_10000": null, + "subtasks": [], + "customfield_10008": null, + "customfield_10007": null, + "status": { + "self": "https://zulipp.atlassian.net/rest/api/2/status/10001", + "description": "", + "iconUrl": "https://zulipp.atlassian.net/images/icons/statuses/open.png", + "name": "To Do", + "id": "10001" + }, + "customfield_10006": "4", + "labels": [], + "workratio": -1, + "project": { + "self": "https://zulipp.atlassian.net/rest/api/2/project/10000", + "id": "10000", + "key": "TEST", + "name": "TestProject", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", + "24x24": "https://zulipp.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "32x32": "https://zulipp.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011", + "48x48": "https://zulipp.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "environment": null, + "customfield_10014": null, + "customfield_10015": null, + "lastViewed": null, + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "customfield_10012": null, + "components": [], + "customfield_10013": null, + "comment": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "comments": [] + }, + "timeoriginalestimate": null, + "customfield_10017": null, + "customfield_10016": null, + "customfield_10019": null, + "customfield_10018": null, + "votes": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-4/votes", + "votes": 0, + "hasVoted": false + }, + "fixVersions": [], + "resolution": null, + "resolutiondate": null, + "aggregatetimeoriginalestimate": null, + "duedate": null, + "customfield_10020": null, + "customfield_10021": "Not Started", + "watches": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-4/watchers", + "watchCount": 0, + "isWatching": false + }, + "worklog": { + "startAt": 0, + "maxResults": 20, + "total": 0, + "worklogs": [] + }, + "assignee": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "attachment": [], + "aggregatetimeestimate": null, + "versions": [], + "timeestimate": null, + "aggregatetimespent": null + } + }, + "timestamp": 1378480824183 +} diff --git a/zerver/fixtures/jira/jira_created_assignee.json b/zerver/fixtures/jira/jira_created_assignee_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_created_assignee.json rename to zerver/fixtures/jira/jira_created_assignee_v2.json diff --git a/zerver/fixtures/jira/jira_created_v1.json b/zerver/fixtures/jira/jira_created_v1.json new file mode 100644 index 0000000000..9c7e9b1898 --- /dev/null +++ b/zerver/fixtures/jira/jira_created_v1.json @@ -0,0 +1,120 @@ +{ + "webhookEvent": "jira:issue_created", + "timestamp": 1364403238369, + "user": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "issue": { + "id": "10400", + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400", + "key": "BUG-15", + "fields": { + "summary": "New bug with hook", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "http://lfranchi.com:8080/rest/api/2/issuetype/1", + "id": "1", + "description": "A problem which impairs or prevents the functions of the product.", + "iconUrl": "http://lfranchi.com:8080/images/icons/bug.gif", + "name": "Bug", + "subtask": false + }, + "votes": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/votes", + "votes": 0, + "hasVoted": false + }, + "resolution": null, + "fixVersions": [], + "resolutiondate": null, + "timespent": null, + "reporter": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "aggregatetimeoriginalestimate": null, + "created": "2013-03-27T16:53:58.301+0000", + "updated": "2013-03-27T16:53:58.301+0000", + "description": "Fix me please", + "priority": { + "self": "http://lfranchi.com:8080/rest/api/2/priority/3", + "iconUrl": "http://lfranchi.com:8080/images/icons/priority_major.gif", + "name": "Major", + "id": "3" + }, + "duedate": null, + "issuelinks": [], + "watches": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/watchers", + "watchCount": 0, + "isWatching": false + }, + "worklog": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "worklogs": [] + }, + "customfield_10000": null, + "subtasks": [], + "status": { + "self": "http://lfranchi.com:8080/rest/api/2/status/1", + "description": "The issue is open and ready for the assignee to start work on it.", + "iconUrl": "http://lfranchi.com:8080/images/icons/status_open.gif", + "name": "Open", + "id": "1" + }, + "labels": [], + "workratio": -1, + "assignee": null, + "attachment": [], + "aggregatetimeestimate": null, + "project": { + "self": "http://lfranchi.com:8080/rest/api/2/project/BUG", + "id": "10000", + "key": "BUG", + "name": "buggery-test", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "48x48": "http://lfranchi.com:8080/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "versions": [], + "environment": null, + "timeestimate": null, + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "lastViewed": null, + "components": [], + "comment": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "comments": [] + }, + "timeoriginalestimate": null, + "aggregatetimespent": null + } + } +} diff --git a/zerver/fixtures/jira/jira_created.json b/zerver/fixtures/jira/jira_created_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_created.json rename to zerver/fixtures/jira/jira_created_v2.json diff --git a/zerver/fixtures/jira/jira_deleted_v1.json b/zerver/fixtures/jira/jira_deleted_v1.json new file mode 100644 index 0000000000..42479c64fc --- /dev/null +++ b/zerver/fixtures/jira/jira_deleted_v1.json @@ -0,0 +1,160 @@ +{ + "webhookEvent": "jira:issue_deleted", + "timestamp": 1364403969102, + "user": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "issue": { + "id": "10400", + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400", + "key": "BUG-15", + "fields": { + "summary": "New bug with hook", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "http://lfranchi.com:8080/rest/api/2/issuetype/1", + "id": "1", + "description": "A problem which impairs or prevents the functions of the product.", + "iconUrl": "http://lfranchi.com:8080/images/icons/bug.gif", + "name": "Bug", + "subtask": false + }, + "votes": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/votes", + "votes": 0, + "hasVoted": false + }, + "resolution": null, + "fixVersions": [], + "resolutiondate": null, + "timespent": null, + "reporter": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "aggregatetimeoriginalestimate": null, + "created": "2013-03-27T16:53:58.301+0000", + "updated": "2013-03-27T17:05:34.250+0000", + "description": "Fix me please", + "priority": { + "self": "http://lfranchi.com:8080/rest/api/2/priority/3", + "iconUrl": "http://lfranchi.com:8080/images/icons/priority_major.gif", + "name": "Major", + "id": "3" + }, + "duedate": null, + "issuelinks": [], + "watches": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/watchers", + "watchCount": 1, + "isWatching": true + }, + "worklog": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "worklogs": [] + }, + "customfield_10000": null, + "subtasks": [], + "status": { + "self": "http://lfranchi.com:8080/rest/api/2/status/1", + "description": "The issue is open and ready for the assignee to start work on it.", + "iconUrl": "http://lfranchi.com:8080/images/icons/status_open.gif", + "name": "Open", + "id": "1" + }, + "labels": [], + "workratio": -1, + "assignee": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "attachment": [], + "aggregatetimeestimate": null, + "project": { + "self": "http://lfranchi.com:8080/rest/api/2/project/BUG", + "id": "10000", + "key": "BUG", + "name": "buggery-test", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "48x48": "http://lfranchi.com:8080/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "versions": [], + "environment": null, + "timeestimate": null, + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "lastViewed": "2013-03-27T17:06:09.088+0000", + "components": [], + "comment": { + "startAt": 0, + "maxResults": 1, + "total": 1, + "comments": [ + { + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400/comment/10400", + "id": "10400", + "author": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "body": "Adding a comment. Oh, what a comment it is!", + "updateAuthor": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "created": "2013-03-27T17:05:34.250+0000", + "updated": "2013-03-27T17:05:34.250+0000" + } + ] + }, + "timeoriginalestimate": null, + "aggregatetimespent": null + } + } +} diff --git a/zerver/fixtures/jira/jira_deleted.json b/zerver/fixtures/jira/jira_deleted_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_deleted.json rename to zerver/fixtures/jira/jira_deleted_v2.json diff --git a/zerver/fixtures/jira/jira_reassigned_v1.json b/zerver/fixtures/jira/jira_reassigned_v1.json new file mode 100644 index 0000000000..cde2352d17 --- /dev/null +++ b/zerver/fixtures/jira/jira_reassigned_v1.json @@ -0,0 +1,143 @@ +{ + "webhookEvent": "jira:issue_updated", + "timestamp": 1364403465325, + "user": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "issue": { + "id": "10400", + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400", + "key": "BUG-15", + "fields": { + "summary": "New bug with hook", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "http://lfranchi.com:8080/rest/api/2/issuetype/1", + "id": "1", + "description": "A problem which impairs or prevents the functions of the product.", + "iconUrl": "http://lfranchi.com:8080/images/icons/bug.gif", + "name": "Bug", + "subtask": false + }, + "votes": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/votes", + "votes": 0, + "hasVoted": false + }, + "resolution": null, + "fixVersions": [], + "resolutiondate": null, + "timespent": null, + "reporter": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "aggregatetimeoriginalestimate": null, + "created": "2013-03-27T16:53:58.301+0000", + "updated": "2013-03-27T16:57:45.287+0000", + "description": "Fix me please", + "priority": { + "self": "http://lfranchi.com:8080/rest/api/2/priority/3", + "iconUrl": "http://lfranchi.com:8080/images/icons/priority_major.gif", + "name": "Major", + "id": "3" + }, + "duedate": null, + "issuelinks": [], + "watches": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/watchers", + "watchCount": 1, + "isWatching": true + }, + "worklog": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "worklogs": [] + }, + "customfield_10000": null, + "subtasks": [], + "status": { + "self": "http://lfranchi.com:8080/rest/api/2/status/1", + "description": "The issue is open and ready for the assignee to start work on it.", + "iconUrl": "http://lfranchi.com:8080/images/icons/status_open.gif", + "name": "Open", + "id": "1" + }, + "labels": [], + "workratio": -1, + "assignee": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "attachment": [], + "aggregatetimeestimate": null, + "project": { + "self": "http://lfranchi.com:8080/rest/api/2/project/BUG", + "id": "10000", + "key": "BUG", + "name": "buggery-test", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "48x48": "http://lfranchi.com:8080/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "versions": [], + "environment": null, + "timeestimate": null, + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "lastViewed": "2013-03-27T16:57:45.258+0000", + "components": [], + "comment": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "comments": [] + }, + "timeoriginalestimate": null, + "aggregatetimespent": null + } + }, + "changelog": { + "id": "10600", + "items": [ + { + "field": "assignee", + "fieldtype": "jira", + "from": null, + "fromString": null, + "to": "lfranchi", + "toString": "Leo Franchi" + } + ] + } +} diff --git a/zerver/fixtures/jira/jira_reassigned.json b/zerver/fixtures/jira/jira_reassigned_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_reassigned.json rename to zerver/fixtures/jira/jira_reassigned_v2.json diff --git a/zerver/fixtures/jira/jira_unknown_v1.json b/zerver/fixtures/jira/jira_unknown_v1.json new file mode 100644 index 0000000000..dc3cd83998 --- /dev/null +++ b/zerver/fixtures/jira/jira_unknown_v1.json @@ -0,0 +1,189 @@ +{ + "webhookEvent": "jira:issue_unknown", + "timestamp": 1364403934253, + "user": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "issue": { + "id": "10400", + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400", + "key": "BUG-15", + "fields": { + "summary": "New bug with hook", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "http://lfranchi.com:8080/rest/api/2/issuetype/1", + "id": "1", + "description": "A problem which impairs or prevents the functions of the product.", + "iconUrl": "http://lfranchi.com:8080/images/icons/bug.gif", + "name": "Bug", + "subtask": false + }, + "votes": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/votes", + "votes": 0, + "hasVoted": false + }, + "resolution": null, + "fixVersions": [], + "resolutiondate": null, + "timespent": null, + "reporter": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "aggregatetimeoriginalestimate": null, + "created": "2013-03-27T16:53:58.301+0000", + "updated": "2013-03-27T16:57:45.287+0000", + "description": "Fix me please", + "priority": { + "self": "http://lfranchi.com:8080/rest/api/2/priority/3", + "iconUrl": "http://lfranchi.com:8080/images/icons/priority_major.gif", + "name": "Major", + "id": "3" + }, + "duedate": null, + "issuelinks": [], + "watches": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-15/watchers", + "watchCount": 1, + "isWatching": true + }, + "worklog": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "worklogs": [] + }, + "customfield_10000": null, + "subtasks": [], + "status": { + "self": "http://lfranchi.com:8080/rest/api/2/status/1", + "description": "The issue is open and ready for the assignee to start work on it.", + "iconUrl": "http://lfranchi.com:8080/images/icons/status_open.gif", + "name": "Open", + "id": "1" + }, + "labels": [], + "workratio": -1, + "assignee": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "attachment": [], + "aggregatetimeestimate": null, + "project": { + "self": "http://lfranchi.com:8080/rest/api/2/project/BUG", + "id": "10000", + "key": "BUG", + "name": "buggery-test", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "48x48": "http://lfranchi.com:8080/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "versions": [], + "environment": null, + "timeestimate": null, + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "lastViewed": "2013-03-27T16:57:45.258+0000", + "components": [], + "comment": { + "startAt": 0, + "maxResults": 1, + "total": 1, + "comments": [ + { + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400/comment/10400", + "id": "10400", + "author": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "body": "Adding a comment. Oh, what a comment it is!", + "updateAuthor": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "created": "2013-03-27T17:05:34.250+0000", + "updated": "2013-03-27T17:05:34.250+0000" + } + ] + }, + "timeoriginalestimate": null, + "aggregatetimespent": null + } + }, + "comment": { + "self": "http://lfranchi.com:8080/rest/api/2/issue/10400/comment/10400", + "id": "10400", + "author": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "body": "Adding a comment. Oh, what a comment it is!", + "updateAuthor": { + "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", + "name": "lfranchi", + "emailAddress": "othello@zulip.com", + "avatarUrls": { + "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", + "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" + }, + "displayName": "Leo Franchi", + "active": true + }, + "created": "2013-03-27T17:05:34.250+0000", + "updated": "2013-03-27T17:05:34.250+0000" + } +} diff --git a/zerver/fixtures/jira/jira_unknown.json b/zerver/fixtures/jira/jira_unknown_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_unknown.json rename to zerver/fixtures/jira/jira_unknown_v2.json diff --git a/zerver/fixtures/jira/jira_updated_priority_v1.json b/zerver/fixtures/jira/jira_updated_priority_v1.json new file mode 100644 index 0000000000..8263065d4a --- /dev/null +++ b/zerver/fixtures/jira/jira_updated_priority_v1.json @@ -0,0 +1,221 @@ +{ + "webhookEvent": "jira:issue_updated", + "user": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "issue": { + "id": "10000", + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10000", + "key": "TEST-1", + "fields": { + "summary": "Fix That", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "https://zulipp.atlassian.net/rest/api/2/issuetype/2", + "id": "2", + "description": "A new feature of the product, which has yet to be developed.", + "iconUrl": "https://zulipp.atlassian.net/images/icons/issuetypes/newfeature.png", + "name": "New Feature", + "subtask": false + }, + "timespent": null, + "reporter": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2013-09-06T11:07:19.972-0400", + "updated": "2014-02-26T14:57:13.139-0500", + "priority": { + "self": "https://zulipp.atlassian.net/rest/api/2/priority/3", + "iconUrl": "https://zulipp.atlassian.net/images/icons/priorities/major.png", + "name": "Major", + "id": "3" + }, + "description": "Please", + "customfield_10001": null, + "customfield_10002": null, + "customfield_10003": null, + "issuelinks": [], + "customfield_10000": null, + "subtasks": [], + "customfield_10008": null, + "customfield_10007": null, + "status": { + "self": "https://zulipp.atlassian.net/rest/api/2/status/10001", + "description": "", + "iconUrl": "https://zulipp.atlassian.net/images/icons/statuses/open.png", + "name": "To Do", + "id": "10001", + "statusCategory": { + "self": "https://zulipp.atlassian.net/rest/api/2/statuscategory/2", + "id": 2, + "key": "new", + "colorName": "blue-gray", + "name": "New" + } + }, + "customfield_10006": "1", + "labels": [], + "workratio": -1, + "project": { + "self": "https://zulipp.atlassian.net/rest/api/2/project/10000", + "id": "10000", + "key": "TEST", + "name": "TestProject", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", + "24x24": "https://zulipp.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "32x32": "https://zulipp.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011", + "48x48": "https://zulipp.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "environment": null, + "customfield_10014": null, + "customfield_10015": null, + "lastViewed": "2014-02-26T14:56:59.145-0500", + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "customfield_10012": null, + "components": [], + "customfield_10013": null, + "comment": { + "startAt": 0, + "maxResults": 1, + "total": 1, + "comments": [ + { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10000/comment/10100", + "id": "10100", + "author": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "body": "test", + "updateAuthor": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2014-02-26T14:55:10.416-0500", + "updated": "2014-02-26T14:55:10.416-0500" + } + ] + }, + "timeoriginalestimate": null, + "customfield_10017": null, + "customfield_10016": null, + "customfield_10019": null, + "customfield_10018": null, + "votes": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-1/votes", + "votes": 0, + "hasVoted": false + }, + "fixVersions": [], + "resolution": null, + "resolutiondate": null, + "creator": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "aggregatetimeoriginalestimate": null, + "duedate": null, + "customfield_10020": null, + "customfield_10021": "Not Started", + "watches": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-1/watchers", + "watchCount": 1, + "isWatching": true + }, + "worklog": { + "startAt": 0, + "maxResults": 20, + "total": 0, + "worklogs": [] + }, + "assignee": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "attachment": [], + "aggregatetimeestimate": null, + "versions": [], + "timeestimate": null, + "aggregatetimespent": null + } + }, + "changelog": { + "id": "10102", + "items": [ + { + "field": "priority", + "fieldtype": "jira", + "from": "2", + "fromString": "Critical", + "to": "3", + "toString": "Major" + } + ] + }, + "timestamp": 1393444633145 +} diff --git a/zerver/fixtures/jira/jira_updated_priority.json b/zerver/fixtures/jira/jira_updated_priority_v2.json similarity index 100% rename from zerver/fixtures/jira/jira_updated_priority.json rename to zerver/fixtures/jira/jira_updated_priority_v2.json diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index 684befff2b..db0d05132d 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -551,7 +551,7 @@ class DeactivatedRealmTest(ZulipTestCase): email = "hamlet@zulip.com" api_key = self.get_api_key(email) url = "/api/v1/external/jira?api_key=%s&stream=jira_custom" % (api_key,) - data = self.fixture_data('jira', "created") + data = self.fixture_data('jira', "created_v2") result = self.client_post(url, data, content_type="application/json") self.assert_json_error_contains(result, "has been deactivated", status_code=400) @@ -689,7 +689,7 @@ class InactiveUserTest(ZulipTestCase): api_key = self.get_api_key(email) url = "/api/v1/external/jira?api_key=%s&stream=jira_custom" % (api_key,) - data = self.fixture_data('jira', "created") + data = self.fixture_data('jira', "created_v2") result = self.client_post(url, data, content_type="application/json") self.assert_json_error_contains(result, "Account not active", status_code=400) diff --git a/zerver/webhooks/jira/tests.py b/zerver/webhooks/jira/tests.py index bb5905f0f0..b8bd74d9ed 100644 --- a/zerver/webhooks/jira/tests.py +++ b/zerver/webhooks/jira/tests.py @@ -11,7 +11,14 @@ class JiraHookTests(WebhookTestCase): url = self.build_webhook_url() result = self.client_post(url, - self.get_body('unknown'), + self.get_body('unknown_v1'), + stream_name="jira", + content_type="application/json") + + self.assert_json_error(result, "Got JIRA event type we don't support: jira:issue_unknown") + + result = self.client_post(url, + self.get_body('unknown_v2'), stream_name="jira", content_type="application/json") @@ -23,7 +30,7 @@ class JiraHookTests(WebhookTestCase): url = "/api/v1/external/jira?api_key=%s&stream=jira_custom" % (api_key,) msg = self.send_json_payload(self.TEST_USER_EMAIL, url, - self.get_body('created'), + self.get_body('created_v2'), stream_name="jira_custom", content_type="application/json") self.assertEqual(msg.topic_name(), "BUG-15: New bug with hook") @@ -37,7 +44,8 @@ class JiraHookTests(WebhookTestCase): expected_message = """Leo Franchi **created** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) priority Major, assigned to **no one**: > New bug with hook""" - self.send_and_test_stream_message('created', expected_subject, expected_message) + self.send_and_test_stream_message('created_v1', expected_subject, expected_message) + self.send_and_test_stream_message('created_v2', expected_subject, expected_message) def test_created_assignee(self): # type: () -> None @@ -45,7 +53,8 @@ class JiraHookTests(WebhookTestCase): expected_message = """Leonardo Franchi [Administrator] **created** [TEST-4](https://zulipp.atlassian.net/browse/TEST-4) priority Major, assigned to **Leonardo Franchi [Administrator]**: > Test Created Assignee""" - self.send_and_test_stream_message('created_assignee', expected_subject, expected_message) + self.send_and_test_stream_message('created_assignee_v1', expected_subject, expected_message) + self.send_and_test_stream_message('created_assignee_v2', expected_subject, expected_message) def test_commented(self): # type: () -> None @@ -55,7 +64,8 @@ class JiraHookTests(WebhookTestCase): Adding a comment. Oh, what a comment it is! """ - self.send_and_test_stream_message('commented', expected_subject, expected_message) + self.send_and_test_stream_message('commented_v1', expected_subject, expected_message) + self.send_and_test_stream_message('commented_v2', expected_subject, expected_message) def test_comment_edited(self): # type: () -> None @@ -65,34 +75,37 @@ Adding a comment. Oh, what a comment it is! Adding a comment. Oh, what a comment it is! """ - self.send_and_test_stream_message('comment_edited', expected_subject, expected_message) + self.send_and_test_stream_message('comment_edited_v2', expected_subject, expected_message) def test_comment_deleted(self): # type: () -> None expected_subject = "TOM-1: New Issue" expected_message = "Tomasz Kolek **deleted comment from** [TOM-1](https://zuliptomek.atlassian.net/browse/TOM-1) (assigned to **kolaszek@go2.pl**)" - self.send_and_test_stream_message('comment_deleted', expected_subject, expected_message) + self.send_and_test_stream_message('comment_deleted_v2', expected_subject, expected_message) def test_commented_markup(self): # type: () -> None expected_subject = "TEST-7: Testing of rich text" expected_message = """Leonardo Franchi [Administrator] **added comment to** [TEST-7](https://zulipp.atlassian.net/browse/TEST-7):\n\n\nThis is a comment that likes to **exercise** a lot of _different_ `conventions` that `jira uses`.\r\n\r\n~~~\n\r\nthis code is not highlighted, but monospaced\r\n\n~~~\r\n\r\n~~~\n\r\ndef python():\r\n print "likes to be formatted"\r\n\n~~~\r\n\r\n[http://www.google.com](http://www.google.com) is a bare link, and [Google](http://www.google.com) is given a title.\r\n\r\nThanks!\r\n\r\n~~~ quote\n\r\nSomeone said somewhere\r\n\n~~~\n""" - self.send_and_test_stream_message('commented_markup', expected_subject, expected_message) + self.send_and_test_stream_message('commented_markup_v1', expected_subject, expected_message) + self.send_and_test_stream_message('commented_markup_v2', expected_subject, expected_message) def test_deleted(self): # type: () -> None expected_subject = "BUG-15: New bug with hook" expected_message = "Leo Franchi **deleted** [BUG-15](http://lfranchi.com:8080/browse/BUG-15)!" - self.send_and_test_stream_message('deleted', expected_subject, expected_message) + self.send_and_test_stream_message('deleted_v1', expected_subject, expected_message) + self.send_and_test_stream_message('deleted_v2', expected_subject, expected_message) def test_reassigned(self): # type: () -> None expected_subject = "BUG-15: New bug with hook" expected_message = """Leo Franchi **updated** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) (assigned to **Othello, the Moor of Venice**): -* Changed assignee from **None** to **Othello, the Moor of Venice** +* Changed assignee to **Othello, the Moor of Venice** """ - self.send_and_test_stream_message('reassigned', expected_subject, expected_message) + self.send_and_test_stream_message('reassigned_v1', expected_subject, expected_message) + self.send_and_test_stream_message('reassigned_v2', expected_subject, expected_message) def test_priority_updated(self): # type: () -> None @@ -101,7 +114,18 @@ Adding a comment. Oh, what a comment it is! * Changed priority from **Critical** to **Major** """ - self.send_and_test_stream_message('updated_priority', expected_subject, expected_message) + self.send_and_test_stream_message('updated_priority_v1', expected_subject, expected_message) + self.send_and_test_stream_message('updated_priority_v2', expected_subject, expected_message) + + def test_status_changed(self): + # type: () -> None + expected_subject = "TEST-1: Fix That" + expected_message = """Leonardo Franchi [Administrator] **updated** [TEST-1](https://zulipp.atlassian.net/browse/TEST-1): + +* Changed status from **To Do** to **In Progress** +""" + self.send_and_test_stream_message('change_status_v1', expected_subject, expected_message) + self.send_and_test_stream_message('change_status_v2', expected_subject, expected_message) def get_body(self, fixture_name): # type: (Text) -> Text diff --git a/zerver/webhooks/jira/view.py b/zerver/webhooks/jira/view.py index 2ac497fb2a..bf6c599910 100644 --- a/zerver/webhooks/jira/view.py +++ b/zerver/webhooks/jira/view.py @@ -140,6 +140,32 @@ def get_issue_subject(payload): # type: (Dict[str, Any]) -> Text return "{}: {}".format(get_issue_id(payload), get_issue_title(payload)) +def get_sub_event_for_update_issue(payload): + # type: (Dict[str, Any]) -> Text + sub_event = payload.get('issue_event_type_name', '') + if sub_event == '': + if payload.get('comment'): + return 'issue_commented' + elif payload.get('transition'): + return 'issue_transited' + return sub_event + +def get_event_type(payload): + # type: (Dict[str, Any]) -> Text + event = payload.get('webhookEvent') + if event is None and payload.get('transition'): + event = 'jira:issue_updated' + return event + +def add_change_info(content, field, from_field, to_field): + # type: (Text, Text, Text, Text) -> Text + content += "* Changed {}".format(field) + if from_field: + content += " from **{}**".format(from_field) + if to_field: + content += " to {}\n".format(to_field) + return content + def handle_updated_issue_event(payload, user_profile): # Reassigned, commented, reopened, and resolved events are all bundled # into this one 'updated' event type, so we try to extract the meaningful @@ -156,7 +182,7 @@ def handle_updated_issue_event(payload, user_profile): else: assignee_blurb = '' - sub_event = payload.get('issue_event_type_name') + sub_event = get_sub_event_for_update_issue(payload) if 'comment' in sub_event: if sub_event == 'issue_commented': verb = 'added comment to' @@ -164,13 +190,13 @@ def handle_updated_issue_event(payload, user_profile): verb = 'edited comment on' else: verb = 'deleted comment from' - content = "{} **{}** {}{}".format(get_issue_author(payload), verb, issue, assignee_blurb) + content = u"{} **{}** {}{}".format(get_issue_author(payload), verb, issue, assignee_blurb) comment = get_in(payload, ['comment', 'body']) if comment: comment = convert_jira_markup(comment, user_profile.realm) - content = "{}:\n\n\n{}\n".format(content, comment) + content = u"{}:\n\n\n{}\n".format(content, comment) else: - content = "{} **updated** {}{}:\n\n".format(get_issue_author(payload), issue, assignee_blurb) + content = u"{} **updated** {}{}:\n\n".format(get_issue_author(payload), issue, assignee_blurb) changelog = get_in(payload, ['changelog']) if changelog != '': @@ -187,7 +213,13 @@ def handle_updated_issue_event(payload, user_profile): from_field_string = item.get('fromString') if target_field_string or from_field_string: - content += "* Changed {} from **{}** to {}\n".format(field, from_field_string, target_field_string) + content = add_change_info(content, field, from_field_string, target_field_string) + + elif sub_event == 'issue_transited': + from_field_string = get_in(payload, ['transition', 'from_status']) + target_field_string = '**{}**'.format(get_in(payload, ['transition', 'to_status'])) + if target_field_string or from_field_string: + content = add_change_info(content, 'status', from_field_string, target_field_string) return content @@ -212,7 +244,7 @@ def api_jira_webhook(request, user_profile, client, stream=REQ(default='jira')): # type: (HttpRequest, UserProfile, Client, Dict[str, Any], Text) -> HttpResponse - event = payload.get('webhookEvent') + event = get_event_type(payload) if event == 'jira:issue_created': subject = get_issue_subject(payload) content = handle_created_issue_event(payload)