mirror of https://github.com/statping/statping
Merge pull request #80 from ryanoolala/fix-webhook-apikey
Fix: issue with api_key in webhookpull/94/head
commit
9498e86b54
|
@ -130,8 +130,8 @@ func (w *webhooker) run(body string) (*http.Response, error) {
|
|||
req.Header.Add(split[0], split[1])
|
||||
}
|
||||
}
|
||||
if w.ApiSecret != "" {
|
||||
req.Header.Add("Content-Type", w.ApiSecret)
|
||||
if w.ApiKey != "" {
|
||||
req.Header.Add("Content-Type", w.ApiKey)
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
var (
|
||||
WEBHOOK_URL = "https://jsonplaceholder.typicode.com/posts"
|
||||
webhookMessage = `{ "title": "%service.Id", "body": "%service.Name", "online": %service.Online, "userId": 19999 }`
|
||||
apiKey = "application/json"
|
||||
fullMsg string
|
||||
)
|
||||
|
||||
|
@ -41,10 +42,12 @@ func TestWebhookNotifier(t *testing.T) {
|
|||
t.Run("Load webhooker", func(t *testing.T) {
|
||||
webhook.Host = WEBHOOK_URL
|
||||
webhook.Delay = time.Duration(100 * time.Millisecond)
|
||||
webhook.ApiKey = apiKey
|
||||
err := notifier.AddNotifier(webhook)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Hunter Long", webhook.Author)
|
||||
assert.Equal(t, WEBHOOK_URL, webhook.Host)
|
||||
assert.Equal(t, apiKey, webhook.ApiKey)
|
||||
})
|
||||
|
||||
t.Run("Load webhooker Notifier", func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue