Public Dashboards: Adds template variable validation for pubdash on the backend (#52566)

Validates template variables for pubdash on the backend when saving a public dashboard
This commit is contained in:
owensmallwood
2022-07-21 13:56:20 -06:00
committed by GitHub
parent 9ef29bb5c3
commit cf86c696e0
11 changed files with 258 additions and 46 deletions
@@ -24,6 +24,29 @@ var DefaultTimeSettings, _ = simplejson.NewJson([]byte(`{}`))
// Default time to pass in with seconds rounded
var DefaultTime = time.Now().UTC().Round(time.Second)
func TestIntegrationGetDashboard(t *testing.T) {
var sqlStore *sqlstore.SQLStore
var dashboardStore *dashboardsDB.DashboardStore
var publicdashboardStore *PublicDashboardStoreImpl
var savedDashboard *models.Dashboard
setup := func() {
sqlStore = sqlstore.InitTestDB(t)
dashboardStore = dashboardsDB.ProvideDashboardStore(sqlStore)
publicdashboardStore = ProvideStore(sqlStore)
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, 0, true)
}
t.Run("GetDashboard can get original dashboard by uid", func(t *testing.T) {
setup()
dashboard, err := publicdashboardStore.GetDashboard(context.Background(), savedDashboard.Uid)
require.NoError(t, err)
require.Equal(t, savedDashboard.Uid, dashboard.Uid)
})
}
// GetPublicDashboard
func TestIntegrationGetPublicDashboard(t *testing.T) {
var sqlStore *sqlstore.SQLStore