diff --git a/server/events/event_parser.go b/server/events/event_parser.go index cc34929240..eeccd15292 100644 --- a/server/events/event_parser.go +++ b/server/events/event_parser.go @@ -288,7 +288,7 @@ func (e *EventParser) parseCommonBitbucketCloudEventData(event bitbucketcloud.Co prState = models.ClosedPullState case "SUPERSEDED": prState = models.ClosedPullState - case "DECLINE": + case "DECLINED": prState = models.ClosedPullState default: err = fmt.Errorf("unable to determine pull request state from %q–this is a bug", *event.PullRequest.State) diff --git a/server/events/event_parser_test.go b/server/events/event_parser_test.go index 059b176937..a2af742c72 100644 --- a/server/events/event_parser_test.go +++ b/server/events/event_parser_test.go @@ -765,7 +765,7 @@ func TestParseBitbucketCloudCommentEvent_MultipleStates(t *testing.T) { models.ClosedPullState, }, { - "DECLINE", + "DECLINED", models.ClosedPullState, }, } @@ -781,7 +781,7 @@ func TestParseBitbucketCloudCommentEvent_MultipleStates(t *testing.T) { } func TestParseBitbucketCloudPullEvent_ValidEvent(t *testing.T) { - path := filepath.Join("testdata", "bitbucket-cloud-pull-event-fulfilled.json") + path := filepath.Join("testdata", "bitbucket-cloud-pull-event-created.json") bytes, err := ioutil.ReadFile(path) if err != nil { Ok(t, err) @@ -801,13 +801,13 @@ func TestParseBitbucketCloudPullEvent_ValidEvent(t *testing.T) { } Equals(t, expBaseRepo, baseRepo) Equals(t, models.PullRequest{ - Num: 2, - HeadCommit: "e0624da46d3a", - URL: "https://bitbucket.org/lkysow/atlantis-example/pull-requests/2", - HeadBranch: "lkysow/maintf-edited-online-with-bitbucket-1532029690581", + Num: 16, + HeadCommit: "1e69a602caef", + URL: "https://bitbucket.org/lkysow/atlantis-example/pull-requests/16", + HeadBranch: "Luke/maintf-edited-online-with-bitbucket-1560433073473", BaseBranch: "master", - Author: "lkysow", - State: models.ClosedPullState, + Author: "Luke", + State: models.OpenPullState, BaseRepo: expBaseRepo, }, pull) Equals(t, models.Repo{ @@ -822,10 +822,39 @@ func TestParseBitbucketCloudPullEvent_ValidEvent(t *testing.T) { }, }, headRepo) Equals(t, models.User{ - Username: "lkysow", + Username: "Luke", }, user) } +func TestParseBitbucketCloudPullEvent_States(t *testing.T) { + for _, c := range []struct { + JSON string + ExpState models.PullRequestState + }{ + { + JSON: "bitbucket-cloud-pull-event-created.json", + ExpState: models.OpenPullState, + }, + { + JSON: "bitbucket-cloud-pull-event-fulfilled.json", + ExpState: models.ClosedPullState, + }, + { + JSON: "bitbucket-cloud-pull-event-rejected.json", + ExpState: models.ClosedPullState, + }, + } { + path := filepath.Join("testdata", c.JSON) + bytes, err := ioutil.ReadFile(path) + if err != nil { + Ok(t, err) + } + pull, _, _, _, err := parser.ParseBitbucketCloudPullEvent(bytes) + Ok(t, err) + Equals(t, c.ExpState, pull.State) + } +} + func TestGetBitbucketCloudEventType(t *testing.T) { cases := []struct { header string diff --git a/server/events/testdata/bitbucket-cloud-pull-event-created.json b/server/events/testdata/bitbucket-cloud-pull-event-created.json index 93735745e1..f8de61cc43 100644 --- a/server/events/testdata/bitbucket-cloud-pull-event-created.json +++ b/server/events/testdata/bitbucket-cloud-pull-event-created.json @@ -1,59 +1,71 @@ { "pullrequest": { + "rendered": { + "description": { + "raw": "main.tf edited online with Bitbucket", + "markup": "markdown", + "html": "
main.tf edited online with Bitbucket
", + "type": "rendered" + }, + "title": { + "raw": "main.tf edited online with Bitbucket", + "markup": "markdown", + "html": "main.tf edited online with Bitbucket
", + "type": "rendered" + } + }, "type": "pullrequest", "description": "main.tf edited online with Bitbucket", "links": { "decline": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/decline" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/decline" }, "commits": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/commits" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/commits" }, "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16" }, "comments": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/comments" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/comments" }, "merge": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/merge" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/merge" }, "html": { - "href": "https://bitbucket.org/lkysow/atlantis-example/pull-requests/2" + "href": "https://bitbucket.org/lkysow/atlantis-example/pull-requests/16" }, "activity": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/activity" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/activity" }, "diff": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/diff" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/diff" }, "approve": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/approve" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/approve" }, "statuses": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/statuses" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/statuses" } }, "title": "main.tf edited online with Bitbucket", "close_source_branch": true, "reviewers": [], - "id": 2, + "id": 16, "destination": { "commit": { - "hash": "1ed8205eec00", + "hash": "1d1f6d3216f1", + "type": "commit", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/1ed8205eec00" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/1d1f6d3216f1" + }, + "html": { + "href": "https://bitbucket.org/lkysow/atlantis-example/commits/1d1f6d3216f1" } } }, - "branch": { - "name": "master" - }, "repository": { - "full_name": "lkysow/atlantis-example", - "type": "repository", - "name": "atlantis-example", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example" @@ -65,10 +77,16 @@ "href": "https://bytebucket.org/ravatar/%7B94189367-116b-436a-9f77-2314b97a6067%7D?ts=default" } }, + "type": "repository", + "name": "atlantis-example", + "full_name": "lkysow/atlantis-example", "uuid": "{94189367-116b-436a-9f77-2314b97a6067}" + }, + "branch": { + "name": "master" } }, - "comment_count": 0, + "created_on": "2019-06-13T13:37:58.036928+00:00", "summary": { "raw": "main.tf edited online with Bitbucket", "markup": "markdown", @@ -77,78 +95,64 @@ }, "source": { "commit": { - "hash": "e0624da46d3a", + "hash": "1e69a602caef", + "type": "commit", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/e0624da46d3a" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow-fork/atlantis-example/commit/1e69a602caef" + }, + "html": { + "href": "https://bitbucket.org/lkysow-fork/atlantis-example/commits/1e69a602caef" } } }, - "branch": { - "name": "lkysow/maintf-edited-online-with-bitbucket-1532029690581" - }, "repository": { - "full_name": "lkysow/atlantis-example", - "type": "repository", - "name": "atlantis-example", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow-fork/atlantis-example" }, "html": { - "href": "https://bitbucket.org/lkysow/atlantis-example" + "href": "https://bitbucket.org/lkysow-fork/atlantis-example" }, "avatar": { "href": "https://bytebucket.org/ravatar/%7B94189367-116b-436a-9f77-2314b97a6067%7D?ts=default" } }, + "type": "repository", + "name": "atlantis-example", + "full_name": "lkysow-fork/atlantis-example", "uuid": "{94189367-116b-436a-9f77-2314b97a6067}" + }, + "branch": { + "name": "Luke/maintf-edited-online-with-bitbucket-1560433073473" } }, + "comment_count": 0, "state": "OPEN", + "task_count": 0, + "participants": [], + "reason": "", + "updated_on": "2019-06-13T13:37:58.128400+00:00", "author": { - "username": "lkysow", "display_name": "Luke", "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" }, "html": { - "href": "https://bitbucket.org/lkysow/" + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" }, "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" } }, + "nickname": "Luke", "type": "user", "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" }, - "created_on": "2018-07-19T19:48:14.228611+00:00", - "participants": [], - "reason": "", - "updated_on": "2018-07-19T19:48:14.283739+00:00", "merge_commit": null, - "closed_by": null, - "task_count": 0 - }, - "actor": { - "username": "lkysow", - "display_name": "Luke", - "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", - "links": { - "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" - }, - "html": { - "href": "https://bitbucket.org/lkysow/" - }, - "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" - } - }, - "type": "user", - "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" + "closed_by": null }, "repository": { "scm": "git", @@ -167,25 +171,43 @@ }, "full_name": "lkysow/atlantis-example", "owner": { - "username": "lkysow", "display_name": "Luke", "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" }, "html": { - "href": "https://bitbucket.org/lkysow/" + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" }, "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" } }, + "nickname": "Luke", "type": "user", "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" }, "type": "repository", "is_private": false, "uuid": "{94189367-116b-436a-9f77-2314b97a6067}" + }, + "actor": { + "display_name": "Luke", + "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" + }, + "avatar": { + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" + } + }, + "nickname": "Luke", + "type": "user", + "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" } -} \ No newline at end of file +} diff --git a/server/events/testdata/bitbucket-cloud-pull-event-fulfilled.json b/server/events/testdata/bitbucket-cloud-pull-event-fulfilled.json index 79244a4076..aac36ec2a1 100644 --- a/server/events/testdata/bitbucket-cloud-pull-event-fulfilled.json +++ b/server/events/testdata/bitbucket-cloud-pull-event-fulfilled.json @@ -1,59 +1,71 @@ { "pullrequest": { + "rendered": { + "description": { + "raw": "main.tf edited online with Bitbucket", + "markup": "markdown", + "html": "main.tf edited online with Bitbucket
", + "type": "rendered" + }, + "title": { + "raw": "main.tf edited online with Bitbucket", + "markup": "markdown", + "html": "main.tf edited online with Bitbucket
", + "type": "rendered" + } + }, "type": "pullrequest", "description": "main.tf edited online with Bitbucket", "links": { "decline": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/decline" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/decline" }, "commits": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/commits" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/commits" }, "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16" }, "comments": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/comments" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/comments" }, "merge": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/merge" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/merge" }, "html": { - "href": "https://bitbucket.org/lkysow/atlantis-example/pull-requests/2" + "href": "https://bitbucket.org/lkysow/atlantis-example/pull-requests/16" }, "activity": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/activity" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/activity" }, "diff": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/diff" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/diff" }, "approve": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/approve" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/approve" }, "statuses": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/2/statuses" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/16/statuses" } }, "title": "main.tf edited online with Bitbucket", "close_source_branch": true, "reviewers": [], - "id": 2, + "id": 16, "destination": { "commit": { - "hash": "1ed8205eec00", + "hash": "1d1f6d3216f1", + "type": "commit", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/1ed8205eec00" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/1d1f6d3216f1" + }, + "html": { + "href": "https://bitbucket.org/lkysow/atlantis-example/commits/1d1f6d3216f1" } } }, - "branch": { - "name": "master" - }, "repository": { - "full_name": "lkysow/atlantis-example", - "type": "repository", - "name": "atlantis-example", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example" @@ -65,10 +77,16 @@ "href": "https://bytebucket.org/ravatar/%7B94189367-116b-436a-9f77-2314b97a6067%7D?ts=default" } }, + "type": "repository", + "name": "atlantis-example", + "full_name": "lkysow/atlantis-example", "uuid": "{94189367-116b-436a-9f77-2314b97a6067}" + }, + "branch": { + "name": "master" } }, - "comment_count": 9, + "created_on": "2019-06-13T13:37:58.036928+00:00", "summary": { "raw": "main.tf edited online with Bitbucket", "markup": "markdown", @@ -77,128 +95,92 @@ }, "source": { "commit": { - "hash": "e0624da46d3a", + "hash": "1e69a602caef", + "type": "commit", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow-fork/atlantis-example/commit/e0624da46d3a" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/1e69a602caef" + }, + "html": { + "href": "https://bitbucket.org/lkysow/atlantis-example/commits/1e69a602caef" } } }, - "branch": { - "name": "lkysow/maintf-edited-online-with-bitbucket-1532029690581" - }, "repository": { - "full_name": "lkysow-fork/atlantis-example", - "type": "repository", - "name": "atlantis-example", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow-fork/atlantis-example" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example" }, "html": { - "href": "https://bitbucket.org/lkysow-fork/atlantis-example" + "href": "https://bitbucket.org/lkysow/atlantis-example" }, "avatar": { "href": "https://bytebucket.org/ravatar/%7B94189367-116b-436a-9f77-2314b97a6067%7D?ts=default" } }, + "type": "repository", + "name": "atlantis-example", + "full_name": "lkysow/atlantis-example", "uuid": "{94189367-116b-436a-9f77-2314b97a6067}" + }, + "branch": { + "name": "Luke/maintf-edited-online-with-bitbucket-1560433073473" } }, + "comment_count": 0, "state": "MERGED", + "task_count": 0, + "participants": [], + "reason": "", + "updated_on": "2019-06-13T13:38:38.142188+00:00", "author": { - "username": "lkysow", "display_name": "Luke", "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" }, "html": { - "href": "https://bitbucket.org/lkysow/" + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" }, "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" } }, + "nickname": "Luke", "type": "user", "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" }, - "created_on": "2018-07-19T19:48:14.228611+00:00", - "participants": [ - { - "type": "participant", - "user": { - "username": "lkysow", - "display_name": "Luke", - "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", - "links": { - "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" - }, - "html": { - "href": "https://bitbucket.org/lkysow/" - }, - "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" - } - }, - "type": "user", - "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" - }, - "role": "PARTICIPANT", - "approved": true, - "participated_on": "2018-07-19T19:51:24.190902+00:00" - } - ], - "reason": "", - "updated_on": "2018-07-19T19:51:49.774941+00:00", "merge_commit": { - "hash": "c21506eeea5f", + "hash": "981c4a02003b", + "type": "commit", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/c21506eeea5f" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/981c4a02003b" + }, + "html": { + "href": "https://bitbucket.org/lkysow/atlantis-example/commits/981c4a02003b" } } }, "closed_by": { - "username": "lkysow", "display_name": "Luke", "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" }, "html": { - "href": "https://bitbucket.org/lkysow/" + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" }, "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" } }, + "nickname": "Luke", "type": "user", "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" - }, - "task_count": 0 - }, - "actor": { - "username": "lkysow", - "nickname": "lkysow", - "display_name": "Luke", - "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", - "links": { - "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" - }, - "html": { - "href": "https://bitbucket.org/lkysow/" - }, - "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" - } - }, - "type": "user", - "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" + } }, "repository": { "scm": "git", @@ -217,25 +199,43 @@ }, "full_name": "lkysow/atlantis-example", "owner": { - "username": "lkysow", "display_name": "Luke", "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" }, "html": { - "href": "https://bitbucket.org/lkysow/" + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" }, "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" } }, + "nickname": "Luke", "type": "user", "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" }, "type": "repository", "is_private": false, "uuid": "{94189367-116b-436a-9f77-2314b97a6067}" + }, + "actor": { + "display_name": "Luke", + "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" + }, + "avatar": { + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" + } + }, + "nickname": "Luke", + "type": "user", + "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" } } diff --git a/server/events/testdata/bitbucket-cloud-pull-event-rejected.json b/server/events/testdata/bitbucket-cloud-pull-event-rejected.json index 5ee1c603e2..23399af6df 100644 --- a/server/events/testdata/bitbucket-cloud-pull-event-rejected.json +++ b/server/events/testdata/bitbucket-cloud-pull-event-rejected.json @@ -1,58 +1,71 @@ { "pullrequest": { - "merge_commit": null, - "description": "main.tf edited online with Bitbucket", + "rendered": { + "description": { + "raw": "", + "markup": "markdown", + "html": "", + "type": "rendered" + }, + "title": { + "raw": "testtest", + "markup": "markdown", + "html": "testtest
", + "type": "rendered" + } + }, + "type": "pullrequest", + "description": "", "links": { "decline": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/3/decline" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/13/decline" }, "commits": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/3/commits" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/13/commits" }, "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/3" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/13" }, "comments": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/3/comments" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/13/comments" }, "merge": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/3/merge" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/13/merge" }, "html": { - "href": "https://bitbucket.org/lkysow/atlantis-example/pull-requests/3" + "href": "https://bitbucket.org/lkysow/atlantis-example/pull-requests/13" }, "activity": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/3/activity" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/13/activity" }, "diff": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/3/diff" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/13/diff" }, "approve": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/3/approve" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/13/approve" }, "statuses": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/3/statuses" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/pullrequests/13/statuses" } }, - "title": "main.tf edited online with Bitbucket", + "title": "testtest", "close_source_branch": false, "reviewers": [], + "id": 13, "destination": { "commit": { - "hash": "c21506eeea5f", + "hash": "1d1f6d3216f1", + "type": "commit", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/c21506eeea5f" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/1d1f6d3216f1" + }, + "html": { + "href": "https://bitbucket.org/lkysow/atlantis-example/commits/1d1f6d3216f1" } } }, - "branch": { - "name": "master" - }, "repository": { - "full_name": "lkysow/atlantis-example", - "type": "repository", - "name": "atlantis-example", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example" @@ -64,50 +77,36 @@ "href": "https://bytebucket.org/ravatar/%7B94189367-116b-436a-9f77-2314b97a6067%7D?ts=default" } }, + "type": "repository", + "name": "atlantis-example", + "full_name": "lkysow/atlantis-example", "uuid": "{94189367-116b-436a-9f77-2314b97a6067}" - } - }, - "comment_count": 1, - "closed_by": { - "username": "lkysow", - "display_name": "Luke", - "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", - "links": { - "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" - }, - "html": { - "href": "https://bitbucket.org/lkysow/" - }, - "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" - } }, - "type": "user", - "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" + "branch": { + "name": "master" + } }, + "created_on": "2019-02-12T16:54:45.891127+00:00", "summary": { - "raw": "main.tf edited online with Bitbucket", + "raw": "", "markup": "markdown", - "html": "main.tf edited online with Bitbucket
", + "html": "", "type": "rendered" }, "source": { "commit": { - "hash": "ff06f4002ff8", + "hash": "0adf41d7f4cc", + "type": "commit", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/ff06f4002ff8" + "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/commit/0adf41d7f4cc" + }, + "html": { + "href": "https://bitbucket.org/lkysow/atlantis-example/commits/0adf41d7f4cc" } } }, - "branch": { - "name": "lkysow/maintf-edited-online-with-bitbucket-1532029760658" - }, "repository": { - "full_name": "lkysow/atlantis-example", - "type": "repository", - "name": "atlantis-example", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example" @@ -119,78 +118,107 @@ "href": "https://bytebucket.org/ravatar/%7B94189367-116b-436a-9f77-2314b97a6067%7D?ts=default" } }, + "type": "repository", + "name": "atlantis-example", + "full_name": "lkysow/atlantis-example", "uuid": "{94189367-116b-436a-9f77-2314b97a6067}" + }, + "branch": { + "name": "test" } }, - "created_on": "2018-07-19T19:49:24.172710+00:00", + "comment_count": 4, "state": "DECLINED", "task_count": 0, "participants": [ { + "role": "PARTICIPANT", + "participated_on": "2019-06-12T11:10:44.054840+00:00", "type": "participant", "user": { - "username": "lkysow", "display_name": "Luke", "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" }, "html": { - "href": "https://bitbucket.org/lkysow/" + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" }, "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" } }, + "nickname": "Luke", "type": "user", "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" }, + "approved": false + }, + { "role": "PARTICIPANT", - "approved": false, - "participated_on": "2018-07-19T19:49:29.565800+00:00" + "participated_on": "2019-06-12T11:10:47.208597+00:00", + "type": "participant", + "user": { + "display_name": "Atlantisbot", + "account_id": "5b5097035488b9140c078f7f", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/%7B73686412-4495-426f-89a7-c69ff1c8d7b8%7D" + }, + "html": { + "href": "https://bitbucket.org/%7B73686412-4495-426f-89a7-c69ff1c8d7b8%7D/" + }, + "avatar": { + "href": "https://avatar-cdn.atlassian.com/5b5097035488b9140c078f7f?by=id&sg=vyisLdHfYH10sFOuFCvPgHKn6ds%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FA-1.png" + } + }, + "nickname": "atlantis-bot", + "type": "user", + "uuid": "{73686412-4495-426f-89a7-c69ff1c8d7b8}" + }, + "approved": false } ], - "reason": "Declined", - "updated_on": "2018-07-21T21:06:38.096401+00:00", + "reason": "", + "updated_on": "2019-06-13T13:29:24.538120+00:00", "author": { - "username": "lkysow", "display_name": "Luke", "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" }, "html": { - "href": "https://bitbucket.org/lkysow/" + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" }, "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" } }, + "nickname": "Luke", "type": "user", "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" }, - "type": "pullrequest", - "id": 3 - }, - "actor": { - "username": "lkysow", - "display_name": "Luke", - "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", - "links": { - "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" - }, - "html": { - "href": "https://bitbucket.org/lkysow/" + "merge_commit": null, + "closed_by": { + "display_name": "Luke", + "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" + }, + "avatar": { + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" + } }, - "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" - } - }, - "type": "user", - "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" + "nickname": "Luke", + "type": "user", + "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" + } }, "repository": { "scm": "git", @@ -209,25 +237,43 @@ }, "full_name": "lkysow/atlantis-example", "owner": { - "username": "lkysow", "display_name": "Luke", "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", "links": { "self": { - "href": "https://api.bitbucket.org/2.0/users/lkysow" + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" }, "html": { - "href": "https://bitbucket.org/lkysow/" + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" }, "avatar": { - "href": "https://bitbucket.org/account/lkysow/avatar/" + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" } }, + "nickname": "Luke", "type": "user", "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" }, "type": "repository", "is_private": false, "uuid": "{94189367-116b-436a-9f77-2314b97a6067}" + }, + "actor": { + "display_name": "Luke", + "account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Bbf34a99b-8a11-452c-8fbc-bdffc340e584%7D/" + }, + "avatar": { + "href": "https://avatar-cdn.atlassian.com/557058%3Adc3817de-68b5-45cd-b81c-5c39d2560090?by=id&sg=TUDovBcAEFksW8FiPnLjf1IV73Y%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FL-1.svg" + } + }, + "nickname": "Luke", + "type": "user", + "uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}" } -} \ No newline at end of file +}