mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Remove fake secret service in tests (#60488)
This commit is contained in:
parent
9ad45aedcf
commit
92d12fdefa
@ -7,9 +7,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/notify"
|
"github.com/prometheus/alertmanager/notify"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@ -54,8 +51,9 @@ func TestNewAlertmanagerNotifier(t *testing.T) {
|
|||||||
SecureSettings: secureSettings,
|
SecureSettings: secureSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
decryptFn := func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
decryptFn := secretsService.GetDecryptedValue
|
return fallback
|
||||||
|
}
|
||||||
cfg, err := NewAlertmanagerConfig(m, decryptFn)
|
cfg, err := NewAlertmanagerConfig(m, decryptFn)
|
||||||
if c.expectedInitError != "" {
|
if c.expectedInitError != "" {
|
||||||
require.Equal(t, c.expectedInitError, err.Error())
|
require.Equal(t, c.expectedInitError, err.Error())
|
||||||
@ -151,8 +149,9 @@ func TestAlertmanagerNotifier_Notify(t *testing.T) {
|
|||||||
SecureSettings: secureSettings,
|
SecureSettings: secureSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
decryptFn := func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
decryptFn := secretsService.GetDecryptedValue
|
return fallback
|
||||||
|
}
|
||||||
cfg, err := NewAlertmanagerConfig(m, decryptFn)
|
cfg, err := NewAlertmanagerConfig(m, decryptFn)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
sn := NewAlertmanagerNotifier(cfg, &FakeLogger{}, images, tmpl, decryptFn)
|
sn := NewAlertmanagerNotifier(cfg, &FakeLogger{}, images, tmpl, decryptFn)
|
||||||
|
@ -10,9 +10,6 @@ import (
|
|||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLineNotifier(t *testing.T) {
|
func TestLineNotifier(t *testing.T) {
|
||||||
@ -99,8 +96,6 @@ func TestLineNotifier(t *testing.T) {
|
|||||||
settingsJSON := json.RawMessage(c.settings)
|
settingsJSON := json.RawMessage(c.settings)
|
||||||
secureSettings := make(map[string][]byte)
|
secureSettings := make(map[string][]byte)
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
decryptFn := secretsService.GetDecryptedValue
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: &NotificationChannelConfig{
|
Config: &NotificationChannelConfig{
|
||||||
@ -111,9 +106,11 @@ func TestLineNotifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
// TODO: allow changing the associated values for different tests.
|
// TODO: allow changing the associated values for different tests.
|
||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
DecryptFunc: decryptFn,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
Template: tmpl,
|
return fallback
|
||||||
Logger: &FakeLogger{},
|
},
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
pn, err := newLineNotifier(fc)
|
pn, err := newLineNotifier(fc)
|
||||||
if c.expInitError != "" {
|
if c.expInitError != "" {
|
||||||
|
@ -7,9 +7,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/notify"
|
"github.com/prometheus/alertmanager/notify"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@ -235,8 +232,6 @@ func TestOpsgenieNotifier(t *testing.T) {
|
|||||||
|
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
webhookSender.Webhook.Body = "<not-sent>"
|
webhookSender.Webhook.Body = "<not-sent>"
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
decryptFn := secretsService.GetDecryptedValue
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: &NotificationChannelConfig{
|
Config: &NotificationChannelConfig{
|
||||||
@ -246,10 +241,12 @@ func TestOpsgenieNotifier(t *testing.T) {
|
|||||||
SecureSettings: secureSettings,
|
SecureSettings: secureSettings,
|
||||||
},
|
},
|
||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
DecryptFunc: decryptFn,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
ImageStore: &UnavailableImageStore{},
|
return fallback
|
||||||
Template: tmpl,
|
},
|
||||||
Logger: &FakeLogger{},
|
ImageStore: &UnavailableImageStore{},
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := notify.WithGroupKey(context.Background(), "alertname")
|
ctx := notify.WithGroupKey(context.Background(), "alertname")
|
||||||
|
@ -14,9 +14,6 @@ import (
|
|||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPagerdutyNotifier(t *testing.T) {
|
func TestPagerdutyNotifier(t *testing.T) {
|
||||||
@ -278,9 +275,6 @@ func TestPagerdutyNotifier(t *testing.T) {
|
|||||||
settingsJSON := json.RawMessage(c.settings)
|
settingsJSON := json.RawMessage(c.settings)
|
||||||
secureSettings := make(map[string][]byte)
|
secureSettings := make(map[string][]byte)
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
decryptFn := secretsService.GetDecryptedValue
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: &NotificationChannelConfig{
|
Config: &NotificationChannelConfig{
|
||||||
Name: "pageduty_testing",
|
Name: "pageduty_testing",
|
||||||
@ -289,9 +283,11 @@ func TestPagerdutyNotifier(t *testing.T) {
|
|||||||
SecureSettings: secureSettings,
|
SecureSettings: secureSettings,
|
||||||
},
|
},
|
||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
DecryptFunc: decryptFn,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
Template: tmpl,
|
return fallback
|
||||||
Logger: &FakeLogger{},
|
},
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
pn, err := newPagerdutyNotifier(fc)
|
pn, err := newPagerdutyNotifier(fc)
|
||||||
if c.expInitError != "" {
|
if c.expInitError != "" {
|
||||||
|
@ -12,9 +12,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/notify"
|
"github.com/prometheus/alertmanager/notify"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@ -214,8 +211,6 @@ func TestPushoverNotifier(t *testing.T) {
|
|||||||
secureSettings := make(map[string][]byte)
|
secureSettings := make(map[string][]byte)
|
||||||
|
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
decryptFn := secretsService.GetDecryptedValue
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: &NotificationChannelConfig{
|
Config: &NotificationChannelConfig{
|
||||||
@ -226,9 +221,11 @@ func TestPushoverNotifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
ImageStore: images,
|
ImageStore: images,
|
||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
DecryptFunc: decryptFn,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
Template: tmpl,
|
return fallback
|
||||||
Logger: &FakeLogger{},
|
},
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
pn, err := NewPushoverNotifier(fc)
|
pn, err := NewPushoverNotifier(fc)
|
||||||
|
@ -7,9 +7,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/notify"
|
"github.com/prometheus/alertmanager/notify"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@ -147,16 +144,16 @@ func TestSensuGoNotifier(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
decryptFn := secretsService.GetDecryptedValue
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: m,
|
Config: m,
|
||||||
ImageStore: images,
|
ImageStore: images,
|
||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
Template: tmpl,
|
Template: tmpl,
|
||||||
DecryptFunc: decryptFn,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
Logger: &FakeLogger{},
|
return fallback
|
||||||
|
},
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
sn, err := NewSensuGoNotifier(fc)
|
sn, err := NewSensuGoNotifier(fc)
|
||||||
|
@ -19,8 +19,6 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -421,7 +419,6 @@ func setupSlackForTests(t *testing.T, settings string) (*SlackNotifier, *slackRe
|
|||||||
URL: "https://www.example.com/test.png",
|
URL: "https://www.example.com/test.png",
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
notificationService := mockNotificationService()
|
notificationService := mockNotificationService()
|
||||||
|
|
||||||
c := FactoryConfig{
|
c := FactoryConfig{
|
||||||
@ -433,9 +430,11 @@ func setupSlackForTests(t *testing.T, settings string) (*SlackNotifier, *slackRe
|
|||||||
},
|
},
|
||||||
ImageStore: images,
|
ImageStore: images,
|
||||||
NotificationService: notificationService,
|
NotificationService: notificationService,
|
||||||
DecryptFunc: secretsService.GetDecryptedValue,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
Template: tmpl,
|
return fallback
|
||||||
Logger: &FakeLogger{},
|
},
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
sn, err := buildSlackNotifier(c)
|
sn, err := buildSlackNotifier(c)
|
||||||
|
@ -7,9 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/notify"
|
"github.com/prometheus/alertmanager/notify"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@ -120,8 +117,6 @@ func TestTelegramNotifier(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
secureSettings := make(map[string][]byte)
|
secureSettings := make(map[string][]byte)
|
||||||
|
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
decryptFn := secretsService.GetDecryptedValue
|
|
||||||
notificationService := mockNotificationService()
|
notificationService := mockNotificationService()
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
@ -133,9 +128,11 @@ func TestTelegramNotifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
ImageStore: images,
|
ImageStore: images,
|
||||||
NotificationService: notificationService,
|
NotificationService: notificationService,
|
||||||
DecryptFunc: decryptFn,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
Template: tmpl,
|
return fallback
|
||||||
Logger: &FakeLogger{},
|
},
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := NewTelegramNotifier(fc)
|
n, err := NewTelegramNotifier(fc)
|
||||||
|
@ -6,9 +6,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/notify"
|
"github.com/prometheus/alertmanager/notify"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@ -121,7 +118,6 @@ func TestThreemaNotifier(t *testing.T) {
|
|||||||
settingsJSON := json.RawMessage(c.settings)
|
settingsJSON := json.RawMessage(c.settings)
|
||||||
secureSettings := make(map[string][]byte)
|
secureSettings := make(map[string][]byte)
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: &NotificationChannelConfig{
|
Config: &NotificationChannelConfig{
|
||||||
@ -133,8 +129,10 @@ func TestThreemaNotifier(t *testing.T) {
|
|||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
ImageStore: images,
|
ImageStore: images,
|
||||||
Template: tmpl,
|
Template: tmpl,
|
||||||
DecryptFunc: secretsService.GetDecryptedValue,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
Logger: &FakeLogger{},
|
return fallback
|
||||||
|
},
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
pn, err := NewThreemaNotifier(fc)
|
pn, err := NewThreemaNotifier(fc)
|
||||||
|
@ -8,9 +8,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/notify"
|
"github.com/prometheus/alertmanager/notify"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@ -108,8 +105,6 @@ func TestWebexNotifier(t *testing.T) {
|
|||||||
settingsJSON := json.RawMessage(c.settings)
|
settingsJSON := json.RawMessage(c.settings)
|
||||||
secureSettings := make(map[string][]byte)
|
secureSettings := make(map[string][]byte)
|
||||||
|
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
decryptFn := secretsService.GetDecryptedValue
|
|
||||||
notificationService := mockNotificationService()
|
notificationService := mockNotificationService()
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
@ -121,9 +116,11 @@ func TestWebexNotifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
ImageStore: images,
|
ImageStore: images,
|
||||||
NotificationService: notificationService,
|
NotificationService: notificationService,
|
||||||
DecryptFunc: decryptFn,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
Template: tmpl,
|
return fallback
|
||||||
Logger: &FakeLogger{},
|
},
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := buildWebexNotifier(fc)
|
n, err := buildWebexNotifier(fc)
|
||||||
|
@ -7,9 +7,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/notify"
|
"github.com/prometheus/alertmanager/notify"
|
||||||
"github.com/prometheus/alertmanager/template"
|
"github.com/prometheus/alertmanager/template"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
@ -348,15 +345,16 @@ func TestWebhookNotifier(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: m,
|
Config: m,
|
||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
DecryptFunc: secretsService.GetDecryptedValue,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
ImageStore: &UnavailableImageStore{},
|
return fallback
|
||||||
Template: tmpl,
|
},
|
||||||
Logger: &FakeLogger{},
|
ImageStore: &UnavailableImageStore{},
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
pn, err := buildWebhookNotifier(fc)
|
pn, err := buildWebhookNotifier(fc)
|
||||||
|
@ -11,9 +11,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/services/secrets/fakes"
|
|
||||||
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
||||||
|
|
||||||
"github.com/prometheus/alertmanager/notify"
|
"github.com/prometheus/alertmanager/notify"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@ -166,15 +163,16 @@ func TestWeComNotifier(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: m,
|
Config: m,
|
||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
DecryptFunc: secretsService.GetDecryptedValue,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
ImageStore: nil,
|
return fallback
|
||||||
Template: tmpl,
|
},
|
||||||
Logger: &FakeLogger{},
|
ImageStore: nil,
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
pn, err := buildWecomNotifier(fc)
|
pn, err := buildWecomNotifier(fc)
|
||||||
@ -349,15 +347,16 @@ func TestWeComNotifierAPIAPP(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: m,
|
Config: m,
|
||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
DecryptFunc: secretsService.GetDecryptedValue,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
ImageStore: nil,
|
return fallback
|
||||||
Template: tmpl,
|
},
|
||||||
Logger: &FakeLogger{},
|
ImageStore: nil,
|
||||||
|
Template: tmpl,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
pn, err := buildWecomNotifier(fc)
|
pn, err := buildWecomNotifier(fc)
|
||||||
@ -533,14 +532,15 @@ func TestWeComFactory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
webhookSender := mockNotificationService()
|
webhookSender := mockNotificationService()
|
||||||
secretsService := secretsManager.SetupTestService(t, fakes.NewFakeSecretsStore())
|
|
||||||
|
|
||||||
fc := FactoryConfig{
|
fc := FactoryConfig{
|
||||||
Config: m,
|
Config: m,
|
||||||
NotificationService: webhookSender,
|
NotificationService: webhookSender,
|
||||||
DecryptFunc: secretsService.GetDecryptedValue,
|
DecryptFunc: func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string {
|
||||||
ImageStore: nil,
|
return fallback
|
||||||
Logger: &FakeLogger{},
|
},
|
||||||
|
ImageStore: nil,
|
||||||
|
Logger: &FakeLogger{},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := WeComFactory(fc)
|
_, err := WeComFactory(fc)
|
||||||
|
Loading…
Reference in New Issue
Block a user