fix audit log prefix for public dashboards (#53070)

This commit is contained in:
Jeff Levin
2022-08-01 14:46:48 -08:00
committed by GitHub
parent cc20f04860
commit b3f7deebda
4 changed files with 14 additions and 2 deletions

View File

@@ -21,6 +21,8 @@ type PublicDashboardStoreImpl struct {
dialect migrator.Dialect
}
var LogPrefix = "publicdashboards.store"
// Gives us a compile time error if our database does not adhere to contract of
// the interface
var _ publicdashboards.Store = (*PublicDashboardStoreImpl)(nil)
@@ -29,7 +31,7 @@ var _ publicdashboards.Store = (*PublicDashboardStoreImpl)(nil)
func ProvideStore(sqlStore *sqlstore.SQLStore) *PublicDashboardStoreImpl {
return &PublicDashboardStoreImpl{
sqlStore: sqlStore,
log: log.New("publicdashboards.store"),
log: log.New(LogPrefix),
dialect: sqlStore.Dialect,
}
}

View File

@@ -24,6 +24,10 @@ var DefaultTimeSettings, _ = simplejson.NewJson([]byte(`{}`))
// Default time to pass in with seconds rounded
var DefaultTime = time.Now().UTC().Round(time.Second)
func TestLogPrefix(t *testing.T) {
assert.Equal(t, LogPrefix, "publicdashboards.store")
}
func TestIntegrationGetDashboard(t *testing.T) {
var sqlStore *sqlstore.SQLStore
var dashboardStore *dashboardsDB.DashboardStore

View File

@@ -25,6 +25,8 @@ type PublicDashboardServiceImpl struct {
store publicdashboards.Store
}
var LogPrefix = "publicdashboards.service"
// Gives us compile time error if the service does not adhere to the contract of
// the interface
var _ publicdashboards.Service = (*PublicDashboardServiceImpl)(nil)
@@ -36,7 +38,7 @@ func ProvideService(
store publicdashboards.Store,
) *PublicDashboardServiceImpl {
return &PublicDashboardServiceImpl{
log: log.New("publicdashboards"),
log: log.New(LogPrefix),
cfg: cfg,
store: store,
}

View File

@@ -27,6 +27,10 @@ var defaultPubdashTimeSettings, _ = simplejson.NewJson([]byte(`{}`))
var dashboardData = simplejson.NewFromAny(map[string]interface{}{"time": map[string]interface{}{"from": "now-8", "to": "now"}})
var mergedDashboardData = simplejson.NewFromAny(map[string]interface{}{"time": map[string]interface{}{"from": "now-12", "to": "now"}})
func TestLogPrefix(t *testing.T) {
assert.Equal(t, LogPrefix, "publicdashboards.service")
}
func TestGetPublicDashboard(t *testing.T) {
type storeResp struct {
pd *PublicDashboard