From f075b833e290f9e38a7186dc0f4f2a59b1d2586c Mon Sep 17 00:00:00 2001 From: Sebastian Czoch Date: Wed, 10 Jan 2018 20:32:03 +0100 Subject: [PATCH] Change default token-prefix to proper one for the Alerta service --- CHANGELOG.md | 5 +++++ etc/kapacitor/kapacitor.conf | 3 +-- integrations/streamer_test.go | 4 ++-- server/server_test.go | 4 ++-- services/alerta/config.go | 2 +- services/alerta/service.go | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3a551f89b..aaca62bb8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,11 @@ alert will auto-recover. ### Bugfixes - [#1834](https://github.com/influxdata/kapacitor/issues/1834): Fix bug where task type was invalid when using var for stream/batch +## Unreleased + +### Bugfixes + +- [#1165]((https://github.com/influxdata/kapacitor/issues/1165): Fix wrong default "token-prefix" value for the alerta service. ## v1.4.0 [2017-12-08] diff --git a/etc/kapacitor/kapacitor.conf b/etc/kapacitor/kapacitor.conf index 0f6f1fc04e..a074ea2d46 100644 --- a/etc/kapacitor/kapacitor.conf +++ b/etc/kapacitor/kapacitor.conf @@ -484,8 +484,7 @@ default-retention-policy = "" # Default authentication token. token = "" # Default token prefix - # If you are on older versions of alerta you may need to change this to "Key" - token-prefix = "Bearer" + token-prefix = "Key" # Default environment. environment = "" # Default origin. diff --git a/integrations/streamer_test.go b/integrations/streamer_test.go index 10df5684d8..2c528d4124 100644 --- a/integrations/streamer_test.go +++ b/integrations/streamer_test.go @@ -8864,7 +8864,7 @@ stream exp := []interface{}{ alertatest.Request{ URL: "/alert", - Authorization: "Bearer testtoken1234567", + Authorization: "Key testtoken1234567", PostData: alertatest.PostData{ Resource: "cpu", Event: "serverA", @@ -8878,7 +8878,7 @@ stream }, alertatest.Request{ URL: "/alert", - Authorization: "Bearer anothertesttoken", + Authorization: "Key anothertesttoken", PostData: alertatest.PostData{ Resource: "resource: serverA", Event: "event: TestStream_Alert", diff --git a/server/server_test.go b/server/server_test.go index 712150ab28..6c5f62d33f 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -9474,7 +9474,7 @@ func TestServer_AlertHandlers(t *testing.T) { Kind: "alerta", Options: map[string]interface{}{ "token": "testtoken1234567", - "token-prefix": "Bearer", + "token-prefix": "Key", "origin": "kapacitor", "group": "test", "environment": "env", @@ -9495,7 +9495,7 @@ func TestServer_AlertHandlers(t *testing.T) { got := ts.Requests() exp := []alertatest.Request{{ URL: "/alert", - Authorization: "Bearer testtoken1234567", + Authorization: "Key testtoken1234567", PostData: alertatest.PostData{ Resource: "alert", Event: "id", diff --git a/services/alerta/config.go b/services/alerta/config.go index 839afb855f..98c3d6871e 100644 --- a/services/alerta/config.go +++ b/services/alerta/config.go @@ -17,7 +17,7 @@ type Config struct { // The authentication token for this notification, can be overridden per alert. Token string `toml:"token" override:"token,redact"` // The prefix for the Authentication field where the token is stored - // This defaults to Bearer but you may need to set this to "Key" for older versions of alerta + // This defaults to Key TokenPrefix string `toml:"token-prefix" override:"token-prefix"` // The environment in which to raise the alert. Environment string `toml:"environment" override:"environment"` diff --git a/services/alerta/service.go b/services/alerta/service.go index cea6d1c1c1..e8baacebba 100644 --- a/services/alerta/service.go +++ b/services/alerta/service.go @@ -24,7 +24,7 @@ const ( defaultEvent = "{{ .ID }}" defaultGroup = "{{ .Group }}" defaultTimeout = time.Duration(24 * time.Hour) - defaultTokenPrefix = "Bearer" + defaultTokenPrefix = "Key" ) type Diagnostic interface {