Skip to content

Commit

Permalink
fix: bitbucket server failing diagnostics:ping (argoproj#6029) (argop…
Browse files Browse the repository at this point in the history
…roj#6034)

Signed-off-by: Marcel Hoyer <[email protected]>

Co-authored-by: Marcel Hoyer <[email protected]>
  • Loading branch information
mhoyer and mhoyer authored Apr 14, 2021
1 parent 8f53bd5 commit 5bc7297
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion util/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func (a *ArgoCDWebhookHandler) Handler(w http.ResponseWriter, r *http.Request) {
case r.Header.Get("X-Hook-UUID") != "":
payload, err = a.bitbucket.Parse(r, bitbucket.RepoPushEvent)
case r.Header.Get("X-Event-Key") != "":
payload, err = a.bitbucketserver.Parse(r, bitbucketserver.RepositoryReferenceChangedEvent)
payload, err = a.bitbucketserver.Parse(r, bitbucketserver.RepositoryReferenceChangedEvent, bitbucketserver.DiagnosticsPingEvent)
default:
log.Debug("Ignoring unknown webhook event")
http.Error(w, "Unknown webhook event", http.StatusBadRequest)
Expand Down
14 changes: 14 additions & 0 deletions util/webhook/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ func TestBitbucketServerRepositoryReferenceChangedEvent(t *testing.T) {
hook.Reset()
}

func TestBitbucketServerRepositoryDiagnosticPingEvent(t *testing.T) {
hook := test.NewGlobal()
h := NewMockHandler()
eventJSON := "{\"test\": true}"
req := httptest.NewRequest("POST", "/api/webhook", bytes.NewBufferString(eventJSON))
req.Header.Set("X-Event-Key", "diagnostics:ping")
w := httptest.NewRecorder()
h.Handler(w, req)
assert.Equal(t, w.Code, http.StatusOK)
expectedLogResult := "Ignoring webhook event"
assert.Equal(t, expectedLogResult, hook.LastEntry().Message)
hook.Reset()
}

func TestGogsPushEvent(t *testing.T) {
hook := test.NewGlobal()
h := NewMockHandler()
Expand Down

0 comments on commit 5bc7297

Please sign in to comment.