From 2e471dc89cc969d4ba4434eb423273f349ba0adf Mon Sep 17 00:00:00 2001 From: Dean Karn Date: Fri, 21 Apr 2017 16:11:04 -0400 Subject: [PATCH] Update MergerRequestEvents to MergeRequestEvents --- bitbucket/bitbucket_test.go | 48 +++++++++++++++---------------- github/github_test.go | 56 ++++++++++++++++++------------------- gitlab/gitlab.go | 18 ++++++------ gitlab/gitlab_test.go | 36 ++++++++++++------------ 4 files changed, 79 insertions(+), 79 deletions(-) diff --git a/bitbucket/bitbucket_test.go b/bitbucket/bitbucket_test.go index 88134eb..f0c24fc 100644 --- a/bitbucket/bitbucket_test.go +++ b/bitbucket/bitbucket_test.go @@ -24,7 +24,7 @@ import ( // // const ( - port = 3010 + port = 3009 path = "/webhooks" ) @@ -42,7 +42,7 @@ func TestMain(m *testing.M) { hook.RegisterEvents(HandlePayload, RepoPushEvent, RepoForkEvent, RepoCommitCommentCreatedEvent, RepoCommitStatusCreatedEvent, RepoCommitStatusUpdatedEvent, IssueCreatedEvent, IssueUpdatedEvent, IssueCommentCreatedEvent, PullRequestCreatedEvent, PullRequestUpdatedEvent, PullRequestApprovedEvent, PullRequestApprovalRemovedEvent, PullRequestMergedEvent, PullRequestDeclinedEvent, PullRequestCommentCreatedEvent, PullRequestCommentUpdatedEvent, PullRequestCommentDeletedEvent) go webhooks.Run(hook, "127.0.0.1:"+strconv.Itoa(port), path) - time.Sleep(5000) + time.Sleep(time.Millisecond * 500) os.Exit(m.Run()) @@ -56,7 +56,7 @@ func TestProvider(t *testing.T) { func TestUUIDMissingEvent(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Event-Key", "noneexistant_event") @@ -74,7 +74,7 @@ func TestUUIDMissingEvent(t *testing.T) { func TestUUIDDoesNotMatchEvent(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "THIS_DOES_NOT_MATCH") @@ -92,7 +92,7 @@ func TestUUIDDoesNotMatchEvent(t *testing.T) { func TestBadNoEventHeader(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") @@ -110,7 +110,7 @@ func TestBadNoEventHeader(t *testing.T) { func TestUnsubscribedEvent(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "noneexistant_event") @@ -129,7 +129,7 @@ func TestUnsubscribedEvent(t *testing.T) { func TestBadBody(t *testing.T) { payload := "" - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "repo:push") @@ -355,7 +355,7 @@ func TestRepoPush(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "repo:push") @@ -429,7 +429,7 @@ func TestRepoFork(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "repo:fork") @@ -514,7 +514,7 @@ func TestRepoCommitCommentCreated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "repo:commit_comment_created") @@ -588,7 +588,7 @@ func TestRepoCommitStatusCreated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "repo:commit_status_created") @@ -662,7 +662,7 @@ func TestRepoCommitStatusUpdated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "repo:commit_status_updated") @@ -747,7 +747,7 @@ func TestIssueCreated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "issue:created") @@ -864,7 +864,7 @@ func TestIssueUpdated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "issue:updated") @@ -975,7 +975,7 @@ func TestIssueCommentCreated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "issue:comment_created") @@ -1172,7 +1172,7 @@ func TestPullRequestCreated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "pullrequest:created") @@ -1369,7 +1369,7 @@ func TestPullRequestUpdated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "pullrequest:updated") @@ -1585,7 +1585,7 @@ func TestPullRequestApproved(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "pullrequest:approved") @@ -1801,7 +1801,7 @@ func TestPullRequestApprovalRemoved(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "pullrequest:unapproved") @@ -1998,7 +1998,7 @@ func TestPullRequestMerged(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "pullrequest:fulfilled") @@ -2195,7 +2195,7 @@ func TestPullRequestDeclined(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "pullrequest:rejected") @@ -2418,7 +2418,7 @@ func TestPullRequestCommentCreated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "pullrequest:comment_created") @@ -2641,7 +2641,7 @@ func TestPullRequestCommentUpdated(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "pullrequest:comment_updated") @@ -2864,7 +2864,7 @@ func TestPullRequestCommentDeleted(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Hook-UUID", "MY_UUID") req.Header.Set("X-Event-Key", "pull_request:comment_deleted") diff --git a/github/github_test.go b/github/github_test.go index 2a06816..110e031 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -24,7 +24,7 @@ import ( // const ( - port = 3009 + port = 3010 path = "/webhooks" ) @@ -42,7 +42,7 @@ func TestMain(m *testing.M) { hook.RegisterEvents(HandlePayload, CommitCommentEvent, CreateEvent, CreateEvent, DeleteEvent, DeploymentEvent, DeploymentStatusEvent, ForkEvent, GollumEvent, IssueCommentEvent, IssuesEvent, MemberEvent, MembershipEvent, PageBuildEvent, PublicEvent, PullRequestReviewCommentEvent, PullRequestEvent, PushEvent, RepositoryEvent, ReleaseEvent, StatusEvent, TeamAddEvent, WatchEvent) go webhooks.Run(hook, "127.0.0.1:"+strconv.Itoa(port), path) - time.Sleep(5000) + time.Sleep(time.Millisecond * 500) os.Exit(m.Run()) @@ -56,7 +56,7 @@ func TestProvider(t *testing.T) { func TestBadNoEventHeader(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") Equal(t, err, nil) @@ -73,7 +73,7 @@ func TestBadNoEventHeader(t *testing.T) { func TestUnsubscribedEvent(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "noneexistant_event") @@ -91,7 +91,7 @@ func TestUnsubscribedEvent(t *testing.T) { func TestBadBody(t *testing.T) { payload := "" - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "commit_comment") req.Header.Set("X-Hub-Signature", "sha1=156404ad5f721c53151147f3d3d302329f95a3ab") @@ -110,7 +110,7 @@ func TestBadBody(t *testing.T) { func TestBadSignatureLength(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "commit_comment") req.Header.Set("X-Hub-Signature", "") @@ -129,7 +129,7 @@ func TestBadSignatureLength(t *testing.T) { func TestBadSignatureMatch(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "commit_comment") req.Header.Set("X-Hub-Signature", "sha1=111") @@ -289,7 +289,7 @@ func TestCommitCommentEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "commit_comment") req.Header.Set("X-Hub-Signature", "sha1=156404ad5f721c53151147f3d3d302329f95a3ab") @@ -422,7 +422,7 @@ func TestCreateEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "create") req.Header.Set("X-Hub-Signature", "sha1=77ff16ca116034bbeed77ebfce83b36572a9cbaf") @@ -553,7 +553,7 @@ func TestDeleteEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "delete") req.Header.Set("X-Hub-Signature", "sha1=4ddef04fd05b504c7041e294fca3ad1804bc7be1") @@ -715,7 +715,7 @@ func TestDeploymentEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "deployment") req.Header.Set("X-Hub-Signature", "sha1=bb47dc63ceb764a6b1f14fe123e299e5b814c67c") @@ -907,7 +907,7 @@ func TestDeploymentStatusEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "deployment_status") req.Header.Set("X-Hub-Signature", "sha1=8dc0bd0be97440e282e1b4c9ec8445a8d095dc28") @@ -1123,7 +1123,7 @@ func TestForkEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "fork") req.Header.Set("X-Hub-Signature", "sha1=cec5f8fb7c383514c622d3eb9e121891dfcca848") @@ -1261,7 +1261,7 @@ func TestGollumEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "gollum") req.Header.Set("X-Hub-Signature", "sha1=a375a6dc8ceac7231ee022211f8eb85e2a84a5b9") @@ -1463,7 +1463,7 @@ func TestIssueCommentEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "issue_comment") req.Header.Set("X-Hub-Signature", "sha1=e724c9f811fcf5f511aac32e4251b08ab1a0fd87") @@ -1637,7 +1637,7 @@ func TestIssuesEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "issues") req.Header.Set("X-Hub-Signature", "sha1=266736f9446195ffefd3d0cfcd1e096ab129ccad") @@ -1785,7 +1785,7 @@ func TestMemberEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "member") req.Header.Set("X-Hub-Signature", "sha1=597e7d6627a6636d4c3283e36631983fbd57bdd0") @@ -1866,7 +1866,7 @@ func TestMembershipEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "membership") req.Header.Set("X-Hub-Signature", "sha1=16928c947b3707b0efcf8ceb074a5d5dedc9c76e") @@ -2025,7 +2025,7 @@ func TestPageBuildEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "page_build") req.Header.Set("X-Hub-Signature", "sha1=b3abad8f9c1b3fc0b01c4eb107447800bb5000f9") @@ -2153,7 +2153,7 @@ func TestPublicEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "public") req.Header.Set("X-Hub-Signature", "sha1=73edb2a8c69c1ac35efb797ede3dc2cde618c10c") @@ -2619,7 +2619,7 @@ func TestPullRequestReviewCommentEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "pull_request_review_comment") req.Header.Set("X-Hub-Signature", "sha1=a9ece15dbcbb85fa5f00a0bf409494af2cbc5b60") @@ -3051,7 +3051,7 @@ func TestPullRequestEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "pull_request") req.Header.Set("X-Hub-Signature", "sha1=5b342f365078abd366111158b17a8edf5b41ef2a") @@ -3232,7 +3232,7 @@ func TestPushEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "push") req.Header.Set("X-Hub-Signature", "sha1=d683a72295b08a42a55bf6fbf2598dc7603e0b98") @@ -3371,7 +3371,7 @@ func TestRepositoryEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "repository") req.Header.Set("X-Hub-Signature", "sha1=df442a8af41edd2d42ccdd997938d1d111b0f94e") @@ -3539,7 +3539,7 @@ func TestReleaseEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "release") req.Header.Set("X-Hub-Signature", "sha1=e62bb4c51bc7dde195b9525971c2e3aecb394390") @@ -3765,7 +3765,7 @@ func TestStatusEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "status") req.Header.Set("X-Hub-Signature", "sha1=3caa5f062a2deb7cce1482314bb9b4c99bf0ab45") @@ -3914,7 +3914,7 @@ func TestTeamAddEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "team_add") req.Header.Set("X-Hub-Signature", "sha1=5f3953476e270b79cc6763780346110da880609a") @@ -4043,7 +4043,7 @@ func TestWatchEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Github-Event", "watch") req.Header.Set("X-Hub-Signature", "sha1=a317bcfe69ccb8bece74c20c7378e5413c4772f1") diff --git a/gitlab/gitlab.go b/gitlab/gitlab.go index d76922a..1ed6714 100644 --- a/gitlab/gitlab.go +++ b/gitlab/gitlab.go @@ -25,14 +25,14 @@ type Event string // GitLab hook types const ( - PushEvents Event = "Push Hook" - TagEvents Event = "Tag Push Hook" - IssuesEvents Event = "Issue Hook" - CommentEvents Event = "Note Hook" - MergerRequestEvents Event = "Merge Request Hook" - WikiPageEvents Event = "Wiki Page Hook" - PipelineEvents Event = "Pipeline Hook" - BuildEvents Event = "Build Hook" + PushEvents Event = "Push Hook" + TagEvents Event = "Tag Push Hook" + IssuesEvents Event = "Issue Hook" + CommentEvents Event = "Note Hook" + MergeRequestEvents Event = "Merge Request Hook" + WikiPageEvents Event = "Wiki Page Hook" + PipelineEvents Event = "Pipeline Hook" + BuildEvents Event = "Build Hook" ) // New creates and returns a WebHook instance denoted by the Provider type @@ -115,7 +115,7 @@ func (hook Webhook) ParsePayload(w http.ResponseWriter, r *http.Request) { json.Unmarshal([]byte(payload), &ce) hook.runProcessPayloadFunc(fn, ce, hd) - case MergerRequestEvents: + case MergeRequestEvents: var mre MergeRequestEventPayload json.Unmarshal([]byte(payload), &mre) hook.runProcessPayloadFunc(fn, mre, hd) diff --git a/gitlab/gitlab_test.go b/gitlab/gitlab_test.go index 20e81ff..db99207 100644 --- a/gitlab/gitlab_test.go +++ b/gitlab/gitlab_test.go @@ -24,7 +24,7 @@ import ( // const ( - port = 3009 + port = 3011 path = "/webhooks" ) @@ -44,13 +44,13 @@ func TestMain(m *testing.M) { TagEvents, IssuesEvents, CommentEvents, - MergerRequestEvents, + MergeRequestEvents, WikiPageEvents, PipelineEvents, BuildEvents, ) go webhooks.Run(hook, "127.0.0.1:"+strconv.Itoa(port), path) - time.Sleep(5000) + time.Sleep(time.Millisecond * 500) os.Exit(m.Run()) @@ -64,7 +64,7 @@ func TestProvider(t *testing.T) { func TestBadNoEventHeader(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") Equal(t, err, nil) @@ -81,7 +81,7 @@ func TestBadNoEventHeader(t *testing.T) { func TestUnsubscribedEvent(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "noneexistant_event") @@ -99,7 +99,7 @@ func TestUnsubscribedEvent(t *testing.T) { func TestBadBody(t *testing.T) { payload := "" - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Note Hook") @@ -117,7 +117,7 @@ func TestBadBody(t *testing.T) { func TestTokenMissmatch(t *testing.T) { payload := "{}" - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Note Hook") req.Header.Set("X-Gitlab-Token", "itsnotasampleToken!") @@ -203,7 +203,7 @@ func TestPushEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Push Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -261,7 +261,7 @@ func TestTagEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Tag Push Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -333,7 +333,7 @@ func TestIssueEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Issue Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -419,7 +419,7 @@ func TestCommentCommitEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Note Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -553,7 +553,7 @@ func TestCommentMergeRequestEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Note Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -635,7 +635,7 @@ func TestCommentIssueEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Note Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -715,7 +715,7 @@ func TestCommentSunippetEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Note Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -812,7 +812,7 @@ func TestMergeRequestEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Merge Request Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -872,7 +872,7 @@ func TestWikipageEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Wiki Page Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -1045,7 +1045,7 @@ func TestPipelineEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Pipeline Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!") @@ -1107,7 +1107,7 @@ func TestBuildEvent(t *testing.T) { } ` - req, err := http.NewRequest("POST", "http://127.0.0.1:3009/webhooks", bytes.NewBuffer([]byte(payload))) + req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload))) req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Gitlab-Event", "Build Hook") req.Header.Set("X-Gitlab-Token", "sampleToken!")