Plugins: Requests validator (#30445)
* Introduce PluginRequestValidator abstraction with a NoOp implementation * Update PluginRequestValidator abstraction to use the dsURL instead * Inject PluginRequestValidator into the HTTPServer and validate requests going through data source proxy * Inject PluginRequestValidator into the BackendPluginManager and validate requests going through it * Validate requests going through QueryMetrics & QueryMetricsV2 * Validate BackendPluginManager health requests * Fix backend plugins manager tests * Validate requests going through alerting service * Fix tests * fix tests * goimports Co-authored-by: Leonard Gram <leo@xlson.com>
This commit is contained in:
co-authored by
Leonard Gram
parent
4a324e3d74
commit
6415d2802e
@@ -6,6 +6,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/validations"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
@@ -13,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestStateIsUpdatedWhenNeeded(t *testing.T) {
|
||||
ctx := NewEvalContext(context.TODO(), &Rule{Conditions: []Condition{&conditionStub{firing: true}}})
|
||||
ctx := NewEvalContext(context.TODO(), &Rule{Conditions: []Condition{&conditionStub{firing: true}}}, &validations.OSSPluginRequestValidator{})
|
||||
|
||||
t.Run("ok -> alerting", func(t *testing.T) {
|
||||
ctx.PrevAlertState = models.AlertStateOK
|
||||
@@ -198,7 +200,7 @@ func TestGetStateFromEvalContext(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
evalContext := NewEvalContext(context.Background(), &Rule{Conditions: []Condition{&conditionStub{firing: true}}})
|
||||
evalContext := NewEvalContext(context.Background(), &Rule{Conditions: []Condition{&conditionStub{firing: true}}}, &validations.OSSPluginRequestValidator{})
|
||||
|
||||
tc.applyFn(evalContext)
|
||||
newState := evalContext.GetNewState()
|
||||
|
||||
Reference in New Issue
Block a user