mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
fix tests
This commit is contained in:
parent
0d339c8ab6
commit
46a2420ed1
@ -78,7 +78,7 @@ func TestAPIEndpoint_Metrics_QueryMetricsV2(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}, &fakeDatasources.FakeDataSourceService{}, pluginSettings.ProvideService(dbtest.NewFakeDB(),
|
||||
secretstest.NewFakeSecretsService()), pluginFakes.NewFakeLicensingService(), &config.Cfg{}),
|
||||
secretstest.NewFakeSecretsService()), pluginFakes.NewFakeLicensingService(), &config.Cfg{}, featuremgmt.WithFeatures()),
|
||||
)
|
||||
serverFeatureEnabled := SetupAPITestServer(t, func(hs *HTTPServer) {
|
||||
hs.queryDataService = qds
|
||||
@ -124,7 +124,7 @@ func TestAPIEndpoint_Metrics_PluginDecryptionFailure(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
ds, pluginSettings.ProvideService(db, secretstest.NewFakeSecretsService()), pluginFakes.NewFakeLicensingService(), &config.Cfg{},
|
||||
ds, pluginSettings.ProvideService(db, secretstest.NewFakeSecretsService()), pluginFakes.NewFakeLicensingService(), &config.Cfg{}, featuremgmt.WithFeatures(),
|
||||
)
|
||||
qds := query.ProvideService(
|
||||
cfg,
|
||||
@ -301,7 +301,7 @@ func TestDataSourceQueryError(t *testing.T) {
|
||||
PluginList: []pluginstore.Plugin{pluginstore.ToGrafanaDTO(p)},
|
||||
},
|
||||
ds, pluginSettings.ProvideService(dbtest.NewFakeDB(),
|
||||
secretstest.NewFakeSecretsService()), pluginFakes.NewFakeLicensingService(), &config.Cfg{}),
|
||||
secretstest.NewFakeSecretsService()), pluginFakes.NewFakeLicensingService(), &config.Cfg{}, featuremgmt.WithFeatures()),
|
||||
)
|
||||
hs.QuotaService = quotatest.New(false, nil)
|
||||
})
|
||||
|
@ -56,7 +56,7 @@ func TestCallResource(t *testing.T) {
|
||||
textCtx := pluginsintegration.CreateIntegrationTestCtx(t, cfg, coreRegistry)
|
||||
|
||||
pcp := plugincontext.ProvideService(cfg, localcache.ProvideService(), textCtx.PluginStore, &datasources.FakeDataSourceService{},
|
||||
pluginSettings.ProvideService(db.InitTestDB(t), fakeSecrets.NewFakeSecretsService()), nil, &pCfg)
|
||||
pluginSettings.ProvideService(db.InitTestDB(t), fakeSecrets.NewFakeSecretsService()), nil, &pCfg, featuremgmt.WithFeatures())
|
||||
|
||||
srv := SetupAPITestServer(t, func(hs *HTTPServer) {
|
||||
hs.Cfg = cfg
|
||||
|
@ -61,7 +61,7 @@ func framesPassThroughService(t *testing.T, frames data.Frames) (data.Frames, er
|
||||
PluginList: []pluginstore.Plugin{
|
||||
{JSONData: plugins.JSONData{ID: "test"}},
|
||||
}},
|
||||
&datafakes.FakeDataSourceService{}, nil, pluginFakes.NewFakeLicensingService(), &config.Cfg{}),
|
||||
&datafakes.FakeDataSourceService{}, nil, pluginFakes.NewFakeLicensingService(), &config.Cfg{}, featuremgmt.WithFeatures()),
|
||||
tracer: tracing.InitializeTracerForTest(),
|
||||
metrics: newMetrics(nil),
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func TestService(t *testing.T) {
|
||||
PluginList: []pluginstore.Plugin{
|
||||
{JSONData: plugins.JSONData{ID: "test"}},
|
||||
},
|
||||
}, &datafakes.FakeDataSourceService{}, nil, fakes.NewFakeLicensingService(), &config.Cfg{})
|
||||
}, &datafakes.FakeDataSourceService{}, nil, fakes.NewFakeLicensingService(), &config.Cfg{}, featuremgmt.WithFeatures())
|
||||
|
||||
s := Service{
|
||||
cfg: setting.NewCfg(),
|
||||
@ -128,7 +128,7 @@ func TestDSQueryError(t *testing.T) {
|
||||
PluginList: []pluginstore.Plugin{
|
||||
{JSONData: plugins.JSONData{ID: "test"}},
|
||||
},
|
||||
}, &datafakes.FakeDataSourceService{}, nil, nil, &config.Cfg{})
|
||||
}, &datafakes.FakeDataSourceService{}, nil, nil, &config.Cfg{}, featuremgmt.WithFeatures())
|
||||
|
||||
s := Service{
|
||||
cfg: setting.NewCfg(),
|
||||
|
@ -39,7 +39,7 @@ func TestInitializer_envVars(t *testing.T) {
|
||||
"custom_env_var": "customVal",
|
||||
},
|
||||
},
|
||||
}, licensing)
|
||||
}, licensing, featuremgmt.WithFeatures())
|
||||
|
||||
envVars := envVarsProvider.Get(context.Background(), p)
|
||||
assert.Len(t, envVars, 6)
|
||||
@ -67,7 +67,7 @@ func TestInitializer_skipHostEnvVars(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("without FlagPluginsSkipHostEnvVars should not populate host env vars", func(t *testing.T) {
|
||||
envVarsProvider := NewProvider(&config.Cfg{Features: featuremgmt.WithFeatures()}, nil)
|
||||
envVarsProvider := NewProvider(&config.Cfg{Features: featuremgmt.WithFeatures()}, nil, featuremgmt.WithFeatures())
|
||||
envVars := envVarsProvider.Get(context.Background(), p)
|
||||
|
||||
// We want to test that the envvars.Provider does not add any of the host env vars.
|
||||
@ -82,7 +82,7 @@ func TestInitializer_skipHostEnvVars(t *testing.T) {
|
||||
JSONData: plugins.JSONData{ID: "test"},
|
||||
SkipHostEnvVars: true,
|
||||
}
|
||||
envVarsProvider := NewProvider(&config.Cfg{}, nil)
|
||||
envVarsProvider := NewProvider(&config.Cfg{}, nil, featuremgmt.WithFeatures())
|
||||
|
||||
t.Run("should populate allowed host env vars", func(t *testing.T) {
|
||||
// Set all allowed variables
|
||||
@ -493,7 +493,7 @@ func TestInitializer_tracingEnvironmentVariables(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
envVarsProvider := NewProvider(tc.cfg, nil)
|
||||
envVarsProvider := NewProvider(tc.cfg, nil, featuremgmt.WithFeatures())
|
||||
envVars := envVarsProvider.Get(context.Background(), tc.plugin)
|
||||
tc.exp(t, envVars)
|
||||
})
|
||||
@ -542,7 +542,7 @@ func TestInitializer_authEnvVars(t *testing.T) {
|
||||
|
||||
envVarsProvider := NewProvider(&config.Cfg{
|
||||
GrafanaAppURL: "https://myorg.com/",
|
||||
}, nil)
|
||||
}, nil, featuremgmt.WithFeatures())
|
||||
envVars := envVarsProvider.Get(context.Background(), p)
|
||||
assert.Equal(t, "GF_VERSION=", envVars[0])
|
||||
assert.Equal(t, "GF_APP_URL=https://myorg.com/", envVars[1])
|
||||
@ -559,7 +559,7 @@ func TestInitalizer_awsEnvVars(t *testing.T) {
|
||||
AWSAssumeRoleEnabled: true,
|
||||
AWSAllowedAuthProviders: []string{"grafana_assume_role", "keys"},
|
||||
AWSExternalId: "mock_external_id",
|
||||
}, nil)
|
||||
}, nil, featuremgmt.WithFeatures())
|
||||
envVars := envVarsProvider.Get(context.Background(), p)
|
||||
assert.ElementsMatch(t, []string{"GF_VERSION=", "AWS_AUTH_AssumeRoleEnabled=true", "AWS_AUTH_AllowedAuthProviders=grafana_assume_role,keys", "AWS_AUTH_EXTERNAL_ID=mock_external_id"}, envVars)
|
||||
})
|
||||
@ -576,7 +576,7 @@ func TestInitializer_featureToggleEnvVar(t *testing.T) {
|
||||
p := &plugins.Plugin{}
|
||||
envVarsProvider := NewProvider(&config.Cfg{
|
||||
Features: featuremgmt.WithFeatures(expectedFeatures[0], true, expectedFeatures[1], true),
|
||||
}, nil)
|
||||
}, nil, featuremgmt.WithFeatures())
|
||||
envVars := envVarsProvider.Get(context.Background(), p)
|
||||
|
||||
assert.Equal(t, 2, len(envVars))
|
||||
@ -621,7 +621,7 @@ func TestInitalizer_azureEnvVars(t *testing.T) {
|
||||
UsernameAssertion: true,
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
}, nil, featuremgmt.WithFeatures())
|
||||
envVars := envVarsProvider.Get(context.Background(), p)
|
||||
assert.ElementsMatch(t, []string{"GF_VERSION=", "GFAZPL_AZURE_CLOUD=AzureCloud", "GFAZPL_MANAGED_IDENTITY_ENABLED=true",
|
||||
"GFAZPL_MANAGED_IDENTITY_CLIENT_ID=mock_managed_identity_client_id",
|
||||
|
@ -1623,7 +1623,7 @@ func newLoader(t *testing.T, cfg *config.Cfg, reg registry.Service, proc process
|
||||
finder.NewLocalFinder(false, featuremgmt.WithFeatures()), reg),
|
||||
pipeline.ProvideBootstrapStage(cfg, signature.DefaultCalculator(cfg), assets),
|
||||
pipeline.ProvideValidationStage(cfg, signature.NewValidator(signature.NewUnsignedAuthorizer(cfg)), angularInspector, sigErrTracker),
|
||||
pipeline.ProvideInitializationStage(cfg, reg, lic, backendFactory, proc, &fakes.FakeAuthService{}, fakes.NewFakeRoleRegistry()),
|
||||
pipeline.ProvideInitializationStage(cfg, reg, lic, backendFactory, proc, &fakes.FakeAuthService{}, fakes.NewFakeRoleRegistry(), featuremgmt.WithFeatures()),
|
||||
terminate)
|
||||
}
|
||||
|
||||
@ -1656,7 +1656,7 @@ func newLoaderWithOpts(t *testing.T, cfg *config.Cfg, opts loaderDepOpts) *Loade
|
||||
finder.NewLocalFinder(false, featuremgmt.WithFeatures()), reg),
|
||||
pipeline.ProvideBootstrapStage(cfg, signature.DefaultCalculator(cfg), assets),
|
||||
pipeline.ProvideValidationStage(cfg, signature.NewValidator(signature.NewUnsignedAuthorizer(cfg)), angularInspector, sigErrTracker),
|
||||
pipeline.ProvideInitializationStage(cfg, reg, lic, backendFactoryProvider, proc, authServiceRegistry, fakes.NewFakeRoleRegistry()),
|
||||
pipeline.ProvideInitializationStage(cfg, reg, lic, backendFactoryProvider, proc, authServiceRegistry, fakes.NewFakeRoleRegistry(), featuremgmt.WithFeatures()),
|
||||
terminate)
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
fakeDatasources "github.com/grafana/grafana/pkg/services/datasources/fakes"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
||||
@ -43,7 +44,7 @@ func TestGet(t *testing.T) {
|
||||
db := &dbtest.FakeDB{ExpectedError: pluginsettings.ErrPluginSettingNotFound}
|
||||
pcp := plugincontext.ProvideService(cfg, localcache.ProvideService(),
|
||||
pluginstore.New(preg, &pluginFakes.FakeLoader{}),
|
||||
ds, pluginSettings.ProvideService(db, secretstest.NewFakeSecretsService()), pluginFakes.NewFakeLicensingService(), &config.Cfg{},
|
||||
ds, pluginSettings.ProvideService(db, secretstest.NewFakeSecretsService()), pluginFakes.NewFakeLicensingService(), &config.Cfg{}, featuremgmt.WithFeatures(),
|
||||
)
|
||||
identity := &user.SignedInUser{OrgID: int64(1), Login: "admin"}
|
||||
|
||||
|
@ -141,7 +141,7 @@ func buildQueryDataService(t *testing.T, cs datasources.CacheService, fpc *fakeP
|
||||
},
|
||||
},
|
||||
}, ds, pluginSettings.ProvideService(store, fakeSecrets.NewFakeSecretsService()), fakes.NewFakeLicensingService(),
|
||||
&config.Cfg{})
|
||||
&config.Cfg{}, featuremgmt.WithFeatures())
|
||||
|
||||
return query.ProvideService(
|
||||
setting.NewCfg(),
|
||||
|
@ -477,7 +477,7 @@ func setup(t *testing.T) *testContext {
|
||||
{JSONData: plugins.JSONData{ID: "mysql"}},
|
||||
},
|
||||
}, fakeDatasourceService,
|
||||
pluginSettings.ProvideService(sqlStore, secretsService), pluginFakes.NewFakeLicensingService(), &config.Cfg{},
|
||||
pluginSettings.ProvideService(sqlStore, secretsService), pluginFakes.NewFakeLicensingService(), &config.Cfg{}, featuremgmt.WithFeatures(),
|
||||
)
|
||||
exprService := expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, pc, pCtxProvider,
|
||||
&featuremgmt.FeatureManager{}, nil, tracing.InitializeTracerForTest())
|
||||
|
@ -47,7 +47,7 @@ func TestHandleRequest(t *testing.T) {
|
||||
|
||||
pCtxProvider := plugincontext.ProvideService(sqlStore.Cfg, localcache.ProvideService(), &pluginstore.FakePluginStore{
|
||||
PluginList: []pluginstore.Plugin{{JSONData: plugins.JSONData{ID: "test"}}},
|
||||
}, dsService, pluginSettings.ProvideService(sqlStore, secretsService), pluginFakes.NewFakeLicensingService(), &config.Cfg{})
|
||||
}, dsService, pluginSettings.ProvideService(sqlStore, secretsService), pluginFakes.NewFakeLicensingService(), &config.Cfg{}, featuremgmt.WithFeatures())
|
||||
s := ProvideService(client, nil, dsService, pCtxProvider)
|
||||
|
||||
ds := &datasources.DataSource{ID: 12, Type: "test", JsonData: simplejson.New()}
|
||||
|
Loading…
Reference in New Issue
Block a user