mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Enable whitespace linter (#25903)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
42295898b8
commit
41d432b5ae
@ -826,7 +826,7 @@ jobs:
|
|||||||
command: |
|
command: |
|
||||||
# To save memory, run in two batches
|
# To save memory, run in two batches
|
||||||
golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E deadcode -E depguard -E dogsled \
|
golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E deadcode -E depguard -E dogsled \
|
||||||
-E errcheck -E goconst -E golint -E gosec -E gosimple -E govet -E scopelint ./pkg/...
|
-E errcheck -E goconst -E golint -E gosec -E gosimple -E govet -E scopelint -E whitespace ./pkg/...
|
||||||
golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E ineffassign \
|
golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E ineffassign \
|
||||||
-E rowserrcheck -E staticcheck -E structcheck -E typecheck -E unconvert -E unused -E varcheck ./pkg/...
|
-E rowserrcheck -E staticcheck -E structcheck -E typecheck -E unconvert -E unused -E varcheck ./pkg/...
|
||||||
./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive.toml ./pkg/...
|
./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive.toml ./pkg/...
|
||||||
|
@ -39,7 +39,6 @@ func AdminGetSettings(c *models.ReqContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func AdminGetStats(c *models.ReqContext) {
|
func AdminGetStats(c *models.ReqContext) {
|
||||||
|
|
||||||
statsQuery := models.GetAdminStatsQuery{}
|
statsQuery := models.GetAdminStatsQuery{}
|
||||||
|
|
||||||
if err := bus.Dispatch(&statsQuery); err != nil {
|
if err := bus.Dispatch(&statsQuery); err != nil {
|
||||||
|
@ -21,7 +21,6 @@ const (
|
|||||||
func TestAdminApiEndpoint(t *testing.T) {
|
func TestAdminApiEndpoint(t *testing.T) {
|
||||||
role := models.ROLE_ADMIN
|
role := models.ROLE_ADMIN
|
||||||
Convey("Given a server admin attempts to remove themself as an admin", t, func() {
|
Convey("Given a server admin attempts to remove themself as an admin", t, func() {
|
||||||
|
|
||||||
updateCmd := dtos.AdminUpdateUserPermissionsForm{
|
updateCmd := dtos.AdminUpdateUserPermissionsForm{
|
||||||
IsGrafanaAdmin: false,
|
IsGrafanaAdmin: false,
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
|
|
||||||
func TestAlertingApiEndpoint(t *testing.T) {
|
func TestAlertingApiEndpoint(t *testing.T) {
|
||||||
Convey("Given an alert in a dashboard with an acl", t, func() {
|
Convey("Given an alert in a dashboard with an acl", t, func() {
|
||||||
|
|
||||||
singleAlert := &models.Alert{Id: 1, DashboardId: 1, Name: "singlealert"}
|
singleAlert := &models.Alert{Id: 1, DashboardId: 1, Name: "singlealert"}
|
||||||
|
|
||||||
bus.AddHandler("test", func(query *models.GetAlertByIdQuery) error {
|
bus.AddHandler("test", func(query *models.GetAlertByIdQuery) error {
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GetAnnotations(c *models.ReqContext) Response {
|
func GetAnnotations(c *models.ReqContext) Response {
|
||||||
|
|
||||||
query := &annotations.ItemQuery{
|
query := &annotations.ItemQuery{
|
||||||
From: c.QueryInt64("from"),
|
From: c.QueryInt64("from"),
|
||||||
To: c.QueryInt64("to"),
|
To: c.QueryInt64("to"),
|
||||||
|
@ -112,7 +112,6 @@ func (hs *HTTPServer) registerRoutes() {
|
|||||||
|
|
||||||
// authed api
|
// authed api
|
||||||
r.Group("/api", func(apiRoute routing.RouteRegister) {
|
r.Group("/api", func(apiRoute routing.RouteRegister) {
|
||||||
|
|
||||||
// user (signed in)
|
// user (signed in)
|
||||||
apiRoute.Group("/user", func(userRoute routing.RouteRegister) {
|
apiRoute.Group("/user", func(userRoute routing.RouteRegister) {
|
||||||
userRoute.Get("/", Wrap(GetSignedInUser))
|
userRoute.Get("/", Wrap(GetSignedInUser))
|
||||||
@ -383,7 +382,6 @@ func (hs *HTTPServer) registerRoutes() {
|
|||||||
|
|
||||||
// error test
|
// error test
|
||||||
r.Get("/metrics/error", Wrap(GenerateError))
|
r.Get("/metrics/error", Wrap(GenerateError))
|
||||||
|
|
||||||
}, reqSignedIn)
|
}, reqSignedIn)
|
||||||
|
|
||||||
// admin api
|
// admin api
|
||||||
|
@ -31,7 +31,6 @@ type NormalResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Wrap(action interface{}) macaron.Handler {
|
func Wrap(action interface{}) macaron.Handler {
|
||||||
|
|
||||||
return func(c *models.ReqContext) {
|
return func(c *models.ReqContext) {
|
||||||
var res Response
|
var res Response
|
||||||
val, err := c.Invoke(action)
|
val, err := c.Invoke(action)
|
||||||
@ -48,7 +47,6 @@ func Wrap(action interface{}) macaron.Handler {
|
|||||||
func (r *NormalResponse) WriteTo(ctx *models.ReqContext) {
|
func (r *NormalResponse) WriteTo(ctx *models.ReqContext) {
|
||||||
if r.err != nil {
|
if r.err != nil {
|
||||||
ctx.Logger.Error(r.errMessage, "error", r.err, "remote_addr", ctx.RemoteAddr())
|
ctx.Logger.Error(r.errMessage, "error", r.err, "remote_addr", ctx.RemoteAddr())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header := ctx.Resp.Header()
|
header := ctx.Resp.Header()
|
||||||
|
@ -458,7 +458,6 @@ func GetDashboardVersion(c *models.ReqContext) Response {
|
|||||||
|
|
||||||
// POST /api/dashboards/calculate-diff performs diffs on two dashboards
|
// POST /api/dashboards/calculate-diff performs diffs on two dashboards
|
||||||
func CalculateDashboardDiff(c *models.ReqContext, apiOptions dtos.CalculateDiffOptions) Response {
|
func CalculateDashboardDiff(c *models.ReqContext, apiOptions dtos.CalculateDiffOptions) Response {
|
||||||
|
|
||||||
guardianBase := guardian.New(apiOptions.Base.DashboardId, c.OrgId, c.SignedInUser)
|
guardianBase := guardian.New(apiOptions.Base.DashboardId, c.OrgId, c.SignedInUser)
|
||||||
if canSave, err := guardianBase.CanSave(); err != nil || !canSave {
|
if canSave, err := guardianBase.CanSave(); err != nil || !canSave {
|
||||||
return dashboardGuardianResponse(err)
|
return dashboardGuardianResponse(err)
|
||||||
|
@ -716,7 +716,6 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("Post dashboard response tests", t, func() {
|
Convey("Post dashboard response tests", t, func() {
|
||||||
|
|
||||||
// This tests that a valid request returns correct response
|
// This tests that a valid request returns correct response
|
||||||
|
|
||||||
Convey("Given a correct request for creating a dashboard", func() {
|
Convey("Given a correct request for creating a dashboard", func() {
|
||||||
@ -953,7 +952,6 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("Given provisioned dashboard", t, func() {
|
Convey("Given provisioned dashboard", t, func() {
|
||||||
|
|
||||||
bus.AddHandler("test", func(query *models.GetDashboardsBySlugQuery) error {
|
bus.AddHandler("test", func(query *models.GetDashboardsBySlugQuery) error {
|
||||||
query.Result = []*models.Dashboard{{}}
|
query.Result = []*models.Dashboard{{}}
|
||||||
return nil
|
return nil
|
||||||
@ -1062,7 +1060,6 @@ func GetDashboardShouldReturn200(sc *scenarioContext) dtos.DashboardFullWithMeta
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CallGetDashboard(sc *scenarioContext, hs *HTTPServer) {
|
func CallGetDashboard(sc *scenarioContext, hs *HTTPServer) {
|
||||||
|
|
||||||
sc.handlerFunc = hs.GetDashboard
|
sc.handlerFunc = hs.GetDashboard
|
||||||
sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
|
sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,6 @@ func fillWithSecureJSONData(cmd *models.UpdateDataSourceCommand) error {
|
|||||||
|
|
||||||
secureJSONData := ds.SecureJsonData.Decrypt()
|
secureJSONData := ds.SecureJsonData.Decrypt()
|
||||||
for k, v := range secureJSONData {
|
for k, v := range secureJSONData {
|
||||||
|
|
||||||
if _, ok := cmd.SecureJsonData[k]; !ok {
|
if _, ok := cmd.SecureJsonData[k]; !ok {
|
||||||
cmd.SecureJsonData[k] = v
|
cmd.SecureJsonData[k] = v
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ const (
|
|||||||
func TestDataSourcesProxy(t *testing.T) {
|
func TestDataSourcesProxy(t *testing.T) {
|
||||||
Convey("Given a user is logged in", t, func() {
|
Convey("Given a user is logged in", t, func() {
|
||||||
loggedInUserScenario("When calling GET on", "/api/datasources/", func(sc *scenarioContext) {
|
loggedInUserScenario("When calling GET on", "/api/datasources/", func(sc *scenarioContext) {
|
||||||
|
|
||||||
// Stubs the database query
|
// Stubs the database query
|
||||||
bus.AddHandler("test", func(query *models.GetDataSourcesQuery) error {
|
bus.AddHandler("test", func(query *models.GetDataSourcesQuery) error {
|
||||||
So(query.OrgId, ShouldEqual, TestOrgID)
|
So(query.OrgId, ShouldEqual, TestOrgID)
|
||||||
|
@ -93,7 +93,6 @@ func (c *connection) handleMessage(message []byte) {
|
|||||||
case "unsubscribe":
|
case "unsubscribe":
|
||||||
c.hub.subChannel <- &streamSubscription{name: streamName, conn: c, remove: true}
|
c.hub.subChannel <- &streamSubscription{name: streamName, conn: c, remove: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *connection) write(mt int, payload []byte) error {
|
func (c *connection) write(mt int, payload []byte) error {
|
||||||
|
@ -88,7 +88,6 @@ func NewStream(name string) *Stream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stream) Push(packet *models.StreamPacket) {
|
func (s *Stream) Push(packet *models.StreamPacket) {
|
||||||
|
|
||||||
messageBytes, _ := simplejson.NewFromAny(packet).Encode()
|
messageBytes, _ := simplejson.NewFromAny(packet).Encode()
|
||||||
|
|
||||||
for _, sub := range s.subscribers {
|
for _, sub := range s.subscribers {
|
||||||
|
@ -30,7 +30,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestDSRouteRule(t *testing.T) {
|
func TestDSRouteRule(t *testing.T) {
|
||||||
|
|
||||||
Convey("DataSourceProxy", t, func() {
|
Convey("DataSourceProxy", t, func() {
|
||||||
Convey("Plugin with routes", func() {
|
Convey("Plugin with routes", func() {
|
||||||
plugin := &plugins.DataSourcePlugin{
|
plugin := &plugins.DataSourcePlugin{
|
||||||
|
@ -60,7 +60,6 @@ func NewApiPluginProxy(ctx *models.ReqContext, proxyPath string, route *plugins.
|
|||||||
targetURL, _ := url.Parse(route.URL)
|
targetURL, _ := url.Parse(route.URL)
|
||||||
|
|
||||||
director := func(req *http.Request) {
|
director := func(req *http.Request) {
|
||||||
|
|
||||||
req.URL.Scheme = targetURL.Scheme
|
req.URL.Scheme = targetURL.Scheme
|
||||||
req.URL.Host = targetURL.Host
|
req.URL.Host = targetURL.Host
|
||||||
req.Host = targetURL.Host
|
req.Host = targetURL.Host
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPluginProxy(t *testing.T) {
|
func TestPluginProxy(t *testing.T) {
|
||||||
|
|
||||||
Convey("When getting proxy headers", t, func() {
|
Convey("When getting proxy headers", t, func() {
|
||||||
route := &plugins.AppPluginRoute{
|
route := &plugins.AppPluginRoute{
|
||||||
Headers: []plugins.AppPluginRouteHeader{
|
Headers: []plugins.AppPluginRouteHeader{
|
||||||
@ -129,7 +128,6 @@ func TestPluginProxy(t *testing.T) {
|
|||||||
So(route.URL, ShouldEqual, "{{.JsonData.dynamicUrl}}")
|
So(route.URL, ShouldEqual, "{{.JsonData.dynamicUrl}}")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPluginProxiedRequest is a helper for easier setup of tests based on global config and ReqContext.
|
// getPluginProxiedRequest is a helper for easier setup of tests based on global config and ReqContext.
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
// POST /api/preferences/set-home-dash
|
// POST /api/preferences/set-home-dash
|
||||||
func SetHomeDashboard(c *models.ReqContext, cmd models.SavePreferencesCommand) Response {
|
func SetHomeDashboard(c *models.ReqContext, cmd models.SavePreferencesCommand) Response {
|
||||||
|
|
||||||
cmd.UserId = c.UserId
|
cmd.UserId = c.UserId
|
||||||
cmd.OrgId = c.OrgId
|
cmd.OrgId = c.OrgId
|
||||||
|
|
||||||
|
@ -72,10 +72,8 @@ type routeRegister struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rr *routeRegister) Insert(pattern string, fn func(RouteRegister), handlers ...macaron.Handler) {
|
func (rr *routeRegister) Insert(pattern string, fn func(RouteRegister), handlers ...macaron.Handler) {
|
||||||
|
|
||||||
//loop over all groups at current level
|
//loop over all groups at current level
|
||||||
for _, g := range rr.groups {
|
for _, g := range rr.groups {
|
||||||
|
|
||||||
// apply routes if the prefix matches the pattern
|
// apply routes if the prefix matches the pattern
|
||||||
if g.prefix == pattern {
|
if g.prefix == pattern {
|
||||||
g.Group("", fn)
|
g.Group("", fn)
|
||||||
|
@ -108,7 +108,6 @@ func TestRouteGroupedRegister(t *testing.T) {
|
|||||||
user.Group("/admin", func(admin RouteRegister) {
|
user.Group("/admin", func(admin RouteRegister) {
|
||||||
admin.Delete("", emptyHandler("3"))
|
admin.Delete("", emptyHandler("3"))
|
||||||
admin.Get("/all", emptyHandler("3"), emptyHandler("4"), emptyHandler("5"))
|
admin.Get("/all", emptyHandler("3"), emptyHandler("4"), emptyHandler("5"))
|
||||||
|
|
||||||
}, emptyHandler("3"))
|
}, emptyHandler("3"))
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -235,7 +234,6 @@ func TestNamedMiddlewareRouteRegister(t *testing.T) {
|
|||||||
user.Group("/admin", func(admin RouteRegister) {
|
user.Group("/admin", func(admin RouteRegister) {
|
||||||
admin.Delete("", emptyHandler("3"))
|
admin.Delete("", emptyHandler("3"))
|
||||||
admin.Get("/all", emptyHandler("3"), emptyHandler("4"), emptyHandler("5"))
|
admin.Get("/all", emptyHandler("3"), emptyHandler("4"), emptyHandler("5"))
|
||||||
|
|
||||||
}, emptyHandler("3"))
|
}, emptyHandler("3"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ func StarDashboard(c *models.ReqContext) Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UnstarDashboard(c *models.ReqContext) Response {
|
func UnstarDashboard(c *models.ReqContext) Response {
|
||||||
|
|
||||||
cmd := models.UnstarDashboardCommand{UserId: c.UserId, DashboardId: c.ParamsInt64(":id")}
|
cmd := models.UnstarDashboardCommand{UserId: c.UserId, DashboardId: c.ParamsInt64(":id")}
|
||||||
|
|
||||||
if cmd.DashboardId <= 0 {
|
if cmd.DashboardId <= 0 {
|
||||||
|
@ -21,7 +21,6 @@ func (cmd Command) listRemoteCommand(c utils.CommandLine) error {
|
|||||||
logger.Infof("id: %v version: %s\n", plugin.Id, ver.Version)
|
logger.Infof("id: %v version: %s\n", plugin.Id, ver.Version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestApiKeyGen(t *testing.T) {
|
func TestApiKeyGen(t *testing.T) {
|
||||||
|
|
||||||
Convey("When generating new api key", t, func() {
|
Convey("When generating new api key", t, func() {
|
||||||
result, err := New(12, "Cool key")
|
result, err := New(12, "Cool key")
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
@ -162,7 +162,6 @@ func (b *BasicDiff) Basic(lines []*JSONLine) []*BasicBlock {
|
|||||||
// know there's a change somewhere in the JSON tree, but we
|
// know there's a change somewhere in the JSON tree, but we
|
||||||
// don't know exactly where, so we go deeper.
|
// don't know exactly where, so we go deeper.
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// if the change is anything but unchanged, continue processing
|
// if the change is anything but unchanged, continue processing
|
||||||
//
|
//
|
||||||
// we keep "narrowing" the key as we go deeper, in order to
|
// we keep "narrowing" the key as we go deeper, in order to
|
||||||
|
@ -240,7 +240,6 @@ func (f *JSONFormatter) processItem(value interface{}, deltas []diff.Delta, posi
|
|||||||
positionStr := position.String()
|
positionStr := position.String()
|
||||||
if len(matchedDeltas) > 0 {
|
if len(matchedDeltas) > 0 {
|
||||||
for _, matchedDelta := range matchedDeltas {
|
for _, matchedDelta := range matchedDeltas {
|
||||||
|
|
||||||
switch matchedDelta := matchedDelta.(type) {
|
switch matchedDelta := matchedDelta.(type) {
|
||||||
case *diff.Object:
|
case *diff.Object:
|
||||||
switch value.(type) {
|
switch value.(type) {
|
||||||
@ -314,7 +313,6 @@ func (f *JSONFormatter) processItem(value interface{}, deltas []diff.Delta, posi
|
|||||||
default:
|
default:
|
||||||
return errors.New("Unknown Delta type detected")
|
return errors.New("Unknown Delta type detected")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
f.printRecursive(positionStr, value, ChangeUnchanged)
|
f.printRecursive(positionStr, value, ChangeUnchanged)
|
||||||
|
@ -61,7 +61,6 @@ func TestDiff(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
Convey("Testing dashboard diffs", t, func() {
|
Convey("Testing dashboard diffs", t, func() {
|
||||||
|
|
||||||
// Compute the diff between the two JSON objects
|
// Compute the diff between the two JSON objects
|
||||||
baseData, err := simplejson.NewJson([]byte(leftJSON))
|
baseData, err := simplejson.NewJson([]byte(leftJSON))
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
@ -27,7 +27,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewImageUploader() (ImageUploader, error) {
|
func NewImageUploader() (ImageUploader, error) {
|
||||||
|
|
||||||
switch setting.ImageUploadProvider {
|
switch setting.ImageUploadProvider {
|
||||||
case "s3":
|
case "s3":
|
||||||
s3sec, err := setting.Raw.GetSection("external_image_storage.s3")
|
s3sec, err := setting.Raw.GetSection("external_image_storage.s3")
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestUploadToWebdav(t *testing.T) {
|
func TestUploadToWebdav(t *testing.T) {
|
||||||
|
|
||||||
// Can be tested with this docker container: https://hub.docker.com/r/morrisjobke/webdav/
|
// Can be tested with this docker container: https://hub.docker.com/r/morrisjobke/webdav/
|
||||||
SkipConvey("[Integration test] for external_image_store.webdav", t, func() {
|
SkipConvey("[Integration test] for external_image_store.webdav", t, func() {
|
||||||
webdavUploader, _ := NewWebdavImageUploader("http://localhost:8888/webdav/", "test", "test", "")
|
webdavUploader, _ := NewWebdavImageUploader("http://localhost:8888/webdav/", "test", "test", "")
|
||||||
|
@ -12,7 +12,6 @@ type TestEvent struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEventCreation(t *testing.T) {
|
func TestEventCreation(t *testing.T) {
|
||||||
|
|
||||||
Convey("Event to wire event", t, func() {
|
Convey("Event to wire event", t, func() {
|
||||||
e := TestEvent{
|
e := TestEvent{
|
||||||
Timestamp: time.Unix(1231421123, 223),
|
Timestamp: time.Unix(1231421123, 223),
|
||||||
@ -22,5 +21,4 @@ func TestEventCreation(t *testing.T) {
|
|||||||
So(e.Timestamp.Unix(), ShouldEqual, wire.Timestamp.Unix())
|
So(e.Timestamp.Unix(), ShouldEqual, wire.Timestamp.Unix())
|
||||||
So(wire.EventType, ShouldEqual, "TestEvent")
|
So(wire.EventType, ShouldEqual, "TestEvent")
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ func (w *FileLogWriter) WriteLine(line string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLogFile(t *testing.T) {
|
func TestLogFile(t *testing.T) {
|
||||||
|
|
||||||
Convey("When logging to file", t, func() {
|
Convey("When logging to file", t, func() {
|
||||||
fileLogWrite := NewFileWriter()
|
fileLogWrite := NewFileWriter()
|
||||||
So(fileLogWrite, ShouldNotBeNil)
|
So(fileLogWrite, ShouldNotBeNil)
|
||||||
|
@ -264,7 +264,6 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) error {
|
|||||||
|
|
||||||
func LogFilterHandler(maxLevel log15.Lvl, filters map[string]log15.Lvl, h log15.Handler) log15.Handler {
|
func LogFilterHandler(maxLevel log15.Lvl, filters map[string]log15.Lvl, h log15.Handler) log15.Handler {
|
||||||
return log15.FilterHandler(func(r *log15.Record) (pass bool) {
|
return log15.FilterHandler(func(r *log15.Record) (pass bool) {
|
||||||
|
|
||||||
if len(filters) > 0 {
|
if len(filters) > 0 {
|
||||||
for i := 0; i < len(r.Ctx); i += 2 {
|
for i := 0; i < len(r.Ctx); i += 2 {
|
||||||
key, ok := r.Ctx[i].(string)
|
key, ok := r.Ctx[i].(string)
|
||||||
|
@ -571,7 +571,6 @@ func initMetricVars() {
|
|||||||
StatsTotalDashboardVersions,
|
StatsTotalDashboardVersions,
|
||||||
StatsTotalAnnotations,
|
StatsTotalAnnotations,
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCounterVecStartingAtZero(opts prometheus.CounterOpts, labels []string, labelValues ...string) *prometheus.CounterVec {
|
func newCounterVecStartingAtZero(opts prometheus.CounterOpts, labels []string, labelValues ...string) *prometheus.CounterVec {
|
||||||
|
@ -130,7 +130,6 @@ func (dc *databaseCache) Delete(key string) error {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CacheData is the struct representing the table in the database
|
// CacheData is the struct representing the table in the database
|
||||||
|
@ -95,6 +95,5 @@ func Test_parseRedisConnStr(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assert.NoError(t, err, reason)
|
assert.NoError(t, err, reason)
|
||||||
assert.EqualValues(t, testCase.OutputOptions, options, reason)
|
assert.EqualValues(t, testCase.OutputOptions, options, reason)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ func TestMetrics(t *testing.T) {
|
|||||||
|
|
||||||
var getSystemStatsQuery *models.GetSystemStatsQuery
|
var getSystemStatsQuery *models.GetSystemStatsQuery
|
||||||
uss.Bus.AddHandler(func(query *models.GetSystemStatsQuery) error {
|
uss.Bus.AddHandler(func(query *models.GetSystemStatsQuery) error {
|
||||||
|
|
||||||
query.Result = &models.SystemStats{
|
query.Result = &models.SystemStats{
|
||||||
Dashboards: 1,
|
Dashboards: 1,
|
||||||
Datasources: 2,
|
Datasources: 2,
|
||||||
@ -273,7 +272,6 @@ func TestMetrics(t *testing.T) {
|
|||||||
So(metrics.Get("stats.auth_enabled.oauth_grafana_com.count").MustInt(), ShouldEqual, 1)
|
So(metrics.Get("stats.auth_enabled.oauth_grafana_com.count").MustInt(), ShouldEqual, 1)
|
||||||
|
|
||||||
So(metrics.Get("stats.packaging.deb.count").MustInt(), ShouldEqual, 1)
|
So(metrics.Get("stats.packaging.deb.count").MustInt(), ShouldEqual, 1)
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -77,7 +77,6 @@ func DisableExternalUser(username string) error {
|
|||||||
|
|
||||||
userInfo := userQuery.Result
|
userInfo := userQuery.Result
|
||||||
if !userInfo.IsDisabled {
|
if !userInfo.IsDisabled {
|
||||||
|
|
||||||
ldapLogger.Debug(
|
ldapLogger.Debug(
|
||||||
"Disabling external user",
|
"Disabling external user",
|
||||||
"user",
|
"user",
|
||||||
|
@ -251,7 +251,6 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
token := &oauth2.Token{}
|
token := &oauth2.Token{}
|
||||||
|
@ -114,7 +114,6 @@ func (s *SocialGithub) FetchTeamMemberships(client *http.Client) ([]GithubTeam,
|
|||||||
teams := make([]GithubTeam, 0)
|
teams := make([]GithubTeam, 0)
|
||||||
|
|
||||||
for hasMore {
|
for hasMore {
|
||||||
|
|
||||||
response, err := HttpGet(client, url)
|
response, err := HttpGet(client, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error getting team memberships: %s", err)
|
return nil, fmt.Errorf("Error getting team memberships: %s", err)
|
||||||
@ -136,7 +135,6 @@ func (s *SocialGithub) FetchTeamMemberships(client *http.Client) ([]GithubTeam,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SocialGithub) HasMoreRecords(headers http.Header) (string, bool) {
|
func (s *SocialGithub) HasMoreRecords(headers http.Header) (string, bool) {
|
||||||
|
|
||||||
value, exists := headers["Link"]
|
value, exists := headers["Link"]
|
||||||
if !exists {
|
if !exists {
|
||||||
return "", false
|
return "", false
|
||||||
@ -152,7 +150,6 @@ func (s *SocialGithub) HasMoreRecords(headers http.Header) (string, bool) {
|
|||||||
url := matches[1]
|
url := matches[1]
|
||||||
|
|
||||||
return url, true
|
return url, true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SocialGithub) FetchOrganizations(client *http.Client, organizationsUrl string) ([]string, error) {
|
func (s *SocialGithub) FetchOrganizations(client *http.Client, organizationsUrl string) ([]string, error) {
|
||||||
@ -181,7 +178,6 @@ func (s *SocialGithub) FetchOrganizations(client *http.Client, organizationsUrl
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SocialGithub) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) {
|
func (s *SocialGithub) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) {
|
||||||
|
|
||||||
var data struct {
|
var data struct {
|
||||||
Id int `json:"id"`
|
Id int `json:"id"`
|
||||||
Login string `json:"login"`
|
Login string `json:"login"`
|
||||||
|
@ -90,7 +90,6 @@ func (s *SocialGitlab) GetGroupsPage(client *http.Client, url string) ([]string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SocialGitlab) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) {
|
func (s *SocialGitlab) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) {
|
||||||
|
|
||||||
var data struct {
|
var data struct {
|
||||||
Id int
|
Id int
|
||||||
Username string
|
Username string
|
||||||
|
@ -102,7 +102,6 @@ func New(options *Options) *AuthProxy {
|
|||||||
|
|
||||||
// IsEnabled checks if the proxy auth is enabled
|
// IsEnabled checks if the proxy auth is enabled
|
||||||
func (auth *AuthProxy) IsEnabled() bool {
|
func (auth *AuthProxy) IsEnabled() bool {
|
||||||
|
|
||||||
// Bail if the setting is not enabled
|
// Bail if the setting is not enabled
|
||||||
return auth.enabled
|
return auth.enabled
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMiddlewareAuth(t *testing.T) {
|
func TestMiddlewareAuth(t *testing.T) {
|
||||||
|
|
||||||
Convey("Given the grafana middleware", t, func() {
|
Convey("Given the grafana middleware", t, func() {
|
||||||
reqSignIn := Auth(&AuthOptions{ReqSignedIn: true})
|
reqSignIn := Auth(&AuthOptions{ReqSignedIn: true})
|
||||||
|
|
||||||
|
@ -80,5 +80,4 @@ func TestMiddlewareDashboardRedirect(t *testing.T) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ func TestMiddleWareSecurityHeaders(t *testing.T) {
|
|||||||
setting.ERR_TEMPLATE_NAME = errorTemplate
|
setting.ERR_TEMPLATE_NAME = errorTemplate
|
||||||
|
|
||||||
Convey("Given the grafana middleware", t, func() {
|
Convey("Given the grafana middleware", t, func() {
|
||||||
|
|
||||||
middlewareScenario(t, "middleware should get correct x-xss-protection header", func(sc *scenarioContext) {
|
middlewareScenario(t, "middleware should get correct x-xss-protection header", func(sc *scenarioContext) {
|
||||||
setting.XSSProtectionHeader = true
|
setting.XSSProtectionHeader = true
|
||||||
sc.fakeReq("GET", "/api/").exec()
|
sc.fakeReq("GET", "/api/").exec()
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestOrgRedirectMiddleware(t *testing.T) {
|
func TestOrgRedirectMiddleware(t *testing.T) {
|
||||||
|
|
||||||
Convey("Can redirect to correct org", t, func() {
|
Convey("Can redirect to correct org", t, func() {
|
||||||
middlewareScenario(t, "when setting a correct org for the user", func(sc *scenarioContext) {
|
middlewareScenario(t, "when setting a correct org for the user", func(sc *scenarioContext) {
|
||||||
sc.withTokenSessionCookie("token")
|
sc.withTokenSessionCookie("token")
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMiddlewareQuota(t *testing.T) {
|
func TestMiddlewareQuota(t *testing.T) {
|
||||||
|
|
||||||
Convey("Given the grafana quota middleware", t, func() {
|
Convey("Given the grafana quota middleware", t, func() {
|
||||||
setting.AnonymousEnabled = false
|
setting.AnonymousEnabled = false
|
||||||
setting.Quota = setting.QuotaSettings{
|
setting.Quota = setting.QuotaSettings{
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestDashboardAclModel(t *testing.T) {
|
func TestDashboardAclModel(t *testing.T) {
|
||||||
|
|
||||||
Convey("When printing a PermissionType", t, func() {
|
Convey("When printing a PermissionType", t, func() {
|
||||||
view := PERMISSION_VIEW
|
view := PERMISSION_VIEW
|
||||||
printed := fmt.Sprint(view)
|
printed := fmt.Sprint(view)
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestDashboardModel(t *testing.T) {
|
func TestDashboardModel(t *testing.T) {
|
||||||
|
|
||||||
Convey("Generate full dashboard url", t, func() {
|
Convey("Generate full dashboard url", t, func() {
|
||||||
setting.AppUrl = "http://grafana.local/"
|
setting.AppUrl = "http://grafana.local/"
|
||||||
fullUrl := GetFullDashboardUrl("uid", "my-dashboard")
|
fullUrl := GetFullDashboardUrl("uid", "my-dashboard")
|
||||||
|
@ -113,7 +113,6 @@ type DashTemplateEvaluator struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *DashTemplateEvaluator) findInput(varName string, varType string) *ImportDashboardInput {
|
func (this *DashTemplateEvaluator) findInput(varName string, varType string) *ImportDashboardInput {
|
||||||
|
|
||||||
for _, input := range this.inputs {
|
for _, input := range this.inputs {
|
||||||
if varType == input.Type && (input.Name == varName || input.Name == "*") {
|
if varType == input.Type && (input.Name == varName || input.Name == "*") {
|
||||||
return &input
|
return &input
|
||||||
@ -146,7 +145,6 @@ func (this *DashTemplateEvaluator) Eval() (*simplejson.Json, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *DashTemplateEvaluator) evalValue(source *simplejson.Json) interface{} {
|
func (this *DashTemplateEvaluator) evalValue(source *simplejson.Json) interface{} {
|
||||||
|
|
||||||
sourceValue := source.Interface()
|
sourceValue := source.Interface()
|
||||||
|
|
||||||
switch v := sourceValue.(type) {
|
switch v := sourceValue.(type) {
|
||||||
|
@ -80,7 +80,6 @@ func TestDashboardImport(t *testing.T) {
|
|||||||
inputs := res.Get("__inputs")
|
inputs := res.Get("__inputs")
|
||||||
So(inputs.Interface(), ShouldBeNil)
|
So(inputs.Interface(), ShouldBeNil)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,5 +65,4 @@ func TestPluginDashboards(t *testing.T) {
|
|||||||
So(dashboards[1].ImportedRevision, ShouldEqual, 0)
|
So(dashboards[1].ImportedRevision, ShouldEqual, 0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fp *FrontendPluginBase) handleModuleDefaults() {
|
func (fp *FrontendPluginBase) handleModuleDefaults() {
|
||||||
|
|
||||||
if isExternalPlugin(fp.PluginDir) {
|
if isExternalPlugin(fp.PluginDir) {
|
||||||
fp.Module = path.Join("plugins", fp.Id, "module")
|
fp.Module = path.Join("plugins", fp.Id, "module")
|
||||||
fp.BaseUrl = path.Join("public/plugins", fp.Id)
|
fp.BaseUrl = path.Join("public/plugins", fp.Id)
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestFrontendPlugin(t *testing.T) {
|
func TestFrontendPlugin(t *testing.T) {
|
||||||
|
|
||||||
Convey("When setting paths based on App on Windows", t, func() {
|
Convey("When setting paths based on App on Windows", t, func() {
|
||||||
setting.StaticRootPath = "c:\\grafana\\public"
|
setting.StaticRootPath = "c:\\grafana\\public"
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ func TestEvaluators(t *testing.T) {
|
|||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
So(evaluator.Eval(null.FloatFromPtr(nil)), ShouldBeTrue)
|
So(evaluator.Eval(null.FloatFromPtr(nil)), ShouldBeTrue)
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestQueryCondition(t *testing.T) {
|
func TestQueryCondition(t *testing.T) {
|
||||||
|
|
||||||
Convey("when evaluating query condition", t, func() {
|
Convey("when evaluating query condition", t, func() {
|
||||||
|
|
||||||
queryConditionScenario("Given avg() and > 100", func(ctx *queryConditionTestContext) {
|
queryConditionScenario("Given avg() and > 100", func(ctx *queryConditionTestContext) {
|
||||||
|
|
||||||
ctx.reducer = `{"type": "avg"}`
|
ctx.reducer = `{"type": "avg"}`
|
||||||
ctx.evaluator = `{"type": "gt", "params": [100]}`
|
ctx.evaluator = `{"type": "gt", "params": [100]}`
|
||||||
|
|
||||||
@ -216,7 +213,6 @@ func (ctx *queryConditionTestContext) exec() (*alerting.ConditionResult, error)
|
|||||||
|
|
||||||
func queryConditionScenario(desc string, fn queryConditionScenarioFunc) {
|
func queryConditionScenario(desc string, fn queryConditionScenarioFunc) {
|
||||||
Convey(desc, func() {
|
Convey(desc, func() {
|
||||||
|
|
||||||
bus.AddHandler("test", func(query *models.GetDataSourceByIdQuery) error {
|
bus.AddHandler("test", func(query *models.GetDataSourceByIdQuery) error {
|
||||||
query.Result = &models.DataSource{Id: 1, Type: "graphite"}
|
query.Result = &models.DataSource{Id: 1, Type: "graphite"}
|
||||||
return nil
|
return nil
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
func TestSimpleReducer(t *testing.T) {
|
func TestSimpleReducer(t *testing.T) {
|
||||||
Convey("Test simple reducer by calculating", t, func() {
|
Convey("Test simple reducer by calculating", t, func() {
|
||||||
|
|
||||||
Convey("sum", func() {
|
Convey("sum", func() {
|
||||||
result := testReducer("sum", 1, 2, 3)
|
result := testReducer("sum", 1, 2, 3)
|
||||||
So(result, ShouldEqual, float64(6))
|
So(result, ShouldEqual, float64(6))
|
||||||
|
@ -49,7 +49,6 @@ func TestEngineProcessJob(t *testing.T) {
|
|||||||
job := &Job{running: true, Rule: &Rule{}}
|
job := &Job{running: true, Rule: &Rule{}}
|
||||||
|
|
||||||
Convey("Should trigger retry if needed", func() {
|
Convey("Should trigger retry if needed", func() {
|
||||||
|
|
||||||
Convey("error + not last attempt -> retry", func() {
|
Convey("error + not last attempt -> retry", func() {
|
||||||
engine.evalHandler = NewFakeEvalHandler(0)
|
engine.evalHandler = NewFakeEvalHandler(0)
|
||||||
|
|
||||||
@ -94,7 +93,6 @@ func TestEngineProcessJob(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("Should trigger as many retries as needed", func() {
|
Convey("Should trigger as many retries as needed", func() {
|
||||||
|
|
||||||
Convey("never success -> max retries number", func() {
|
Convey("never success -> max retries number", func() {
|
||||||
expectedAttempts := setting.AlertingMaxAttempts
|
expectedAttempts := setting.AlertingMaxAttempts
|
||||||
evalHandler := NewFakeEvalHandler(0)
|
evalHandler := NewFakeEvalHandler(0)
|
||||||
|
@ -82,7 +82,6 @@ func (e *DashAlertExtractor) getAlertFromPanels(jsonWithPanels *simplejson.Json,
|
|||||||
collapsedJSON, collapsed := panel.CheckGet("collapsed")
|
collapsedJSON, collapsed := panel.CheckGet("collapsed")
|
||||||
// check if the panel is collapsed
|
// check if the panel is collapsed
|
||||||
if collapsed && collapsedJSON.MustBool() {
|
if collapsed && collapsedJSON.MustBool() {
|
||||||
|
|
||||||
// extract alerts from sub panels for collapsed panels
|
// extract alerts from sub panels for collapsed panels
|
||||||
alertSlice, err := e.getAlertFromPanels(panel, validateAlertFunc)
|
alertSlice, err := e.getAlertFromPanels(panel, validateAlertFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -13,9 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestAlertRuleExtraction(t *testing.T) {
|
func TestAlertRuleExtraction(t *testing.T) {
|
||||||
|
|
||||||
Convey("Parsing alert rules from dashboard json", t, func() {
|
Convey("Parsing alert rules from dashboard json", t, func() {
|
||||||
|
|
||||||
RegisterCondition("query", func(model *simplejson.Json, index int) (Condition, error) {
|
RegisterCondition("query", func(model *simplejson.Json, index int) (Condition, error) {
|
||||||
return &FakeCondition{}, nil
|
return &FakeCondition{}, nil
|
||||||
})
|
})
|
||||||
@ -80,7 +78,6 @@ func TestAlertRuleExtraction(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("Parsing and validating dashboard containing graphite alerts", func() {
|
Convey("Parsing and validating dashboard containing graphite alerts", func() {
|
||||||
|
|
||||||
dashJSON, err := simplejson.NewJson(json)
|
dashJSON, err := simplejson.NewJson(json)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
|
@ -80,7 +80,6 @@ func TestWhenAlertManagerShouldNotify(t *testing.T) {
|
|||||||
//nolint:goconst
|
//nolint:goconst
|
||||||
func TestAlertmanagerNotifier(t *testing.T) {
|
func TestAlertmanagerNotifier(t *testing.T) {
|
||||||
Convey("Alertmanager notifier tests", t, func() {
|
Convey("Alertmanager notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -57,7 +57,6 @@ func init() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDingDingNotifier(model *models.AlertNotification) (alerting.Notifier, error) {
|
func newDingDingNotifier(model *models.AlertNotification) (alerting.Notifier, error) {
|
||||||
@ -113,7 +112,6 @@ func (dd *DingDingNotifier) Notify(evalContext *alerting.EvalContext) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dd *DingDingNotifier) genBody(evalContext *alerting.EvalContext, messageURL string) ([]byte, error) {
|
func (dd *DingDingNotifier) genBody(evalContext *alerting.EvalContext, messageURL string) ([]byte, error) {
|
||||||
|
|
||||||
q := url.Values{
|
q := url.Values{
|
||||||
"pc_slide": {"false"},
|
"pc_slide": {"false"},
|
||||||
"url": {messageURL},
|
"url": {messageURL},
|
||||||
|
@ -24,7 +24,6 @@ func TestDingDingNotifier(t *testing.T) {
|
|||||||
|
|
||||||
_, err := newDingDingNotifier(model)
|
_, err := newDingDingNotifier(model)
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
|
|
||||||
})
|
})
|
||||||
Convey("settings should trigger incident", func() {
|
Convey("settings should trigger incident", func() {
|
||||||
json := `{ "url": "https://www.google.com" }`
|
json := `{ "url": "https://www.google.com" }`
|
||||||
|
@ -105,7 +105,6 @@ func (dn *DiscordNotifier) Notify(evalContext *alerting.EvalContext) error {
|
|||||||
fields := make([]map[string]interface{}, 0)
|
fields := make([]map[string]interface{}, 0)
|
||||||
|
|
||||||
for _, evt := range evalContext.EvalMatches {
|
for _, evt := range evalContext.EvalMatches {
|
||||||
|
|
||||||
fields = append(fields, map[string]interface{}{
|
fields = append(fields, map[string]interface{}{
|
||||||
"name": evt.Metric,
|
"name": evt.Metric,
|
||||||
"value": evt.Value.FullString(),
|
"value": evt.Value.FullString(),
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestDiscordNotifier(t *testing.T) {
|
func TestDiscordNotifier(t *testing.T) {
|
||||||
Convey("Telegram notifier tests", t, func() {
|
Convey("Telegram notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestEmailNotifier(t *testing.T) {
|
func TestEmailNotifier(t *testing.T) {
|
||||||
Convey("Email notifier tests", t, func() {
|
Convey("Email notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestGoogleChatNotifier(t *testing.T) {
|
func TestGoogleChatNotifier(t *testing.T) {
|
||||||
Convey("Google Hangouts Chat notifier tests", t, func() {
|
Convey("Google Hangouts Chat notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -64,7 +64,6 @@ func init() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
//nolint:goconst
|
//nolint:goconst
|
||||||
func TestHipChatNotifier(t *testing.T) {
|
func TestHipChatNotifier(t *testing.T) {
|
||||||
Convey("HipChat notifier tests", t, func() {
|
Convey("HipChat notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestKafkaNotifier(t *testing.T) {
|
func TestKafkaNotifier(t *testing.T) {
|
||||||
Convey("Kafka notifier tests", t, func() {
|
Convey("Kafka notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -22,7 +22,6 @@ func TestLineNotifier(t *testing.T) {
|
|||||||
|
|
||||||
_, err := NewLINENotifier(model)
|
_, err := NewLINENotifier(model)
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
|
|
||||||
})
|
})
|
||||||
Convey("settings should trigger incident", func() {
|
Convey("settings should trigger incident", func() {
|
||||||
json := `
|
json := `
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
|
|
||||||
func TestOpsGenieNotifier(t *testing.T) {
|
func TestOpsGenieNotifier(t *testing.T) {
|
||||||
Convey("OpsGenie notifier tests", t, func() {
|
Convey("OpsGenie notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -134,7 +134,6 @@ type PagerdutyNotifier struct {
|
|||||||
|
|
||||||
// buildEventPayload is responsible for building the event payload body for sending to Pagerduty v2 API
|
// buildEventPayload is responsible for building the event payload body for sending to Pagerduty v2 API
|
||||||
func (pn *PagerdutyNotifier) buildEventPayload(evalContext *alerting.EvalContext) ([]byte, error) {
|
func (pn *PagerdutyNotifier) buildEventPayload(evalContext *alerting.EvalContext) ([]byte, error) {
|
||||||
|
|
||||||
eventType := "trigger"
|
eventType := "trigger"
|
||||||
if evalContext.Rule.State == models.AlertStateOK {
|
if evalContext.Rule.State == models.AlertStateOK {
|
||||||
eventType = "resolve"
|
eventType = "resolve"
|
||||||
@ -241,7 +240,6 @@ func (pn *PagerdutyNotifier) buildEventPayload(evalContext *alerting.EvalContext
|
|||||||
|
|
||||||
// Notify sends an alert notification to PagerDuty
|
// Notify sends an alert notification to PagerDuty
|
||||||
func (pn *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error {
|
func (pn *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||||
|
|
||||||
if evalContext.Rule.State == models.AlertStateOK && !pn.AutoResolve {
|
if evalContext.Rule.State == models.AlertStateOK && !pn.AutoResolve {
|
||||||
pn.log.Info("Not sending a trigger to Pagerduty", "state", evalContext.Rule.State, "auto resolve", pn.AutoResolve)
|
pn.log.Info("Not sending a trigger to Pagerduty", "state", evalContext.Rule.State, "auto resolve", pn.AutoResolve)
|
||||||
return nil
|
return nil
|
||||||
|
@ -14,7 +14,6 @@ import (
|
|||||||
|
|
||||||
func TestPushoverNotifier(t *testing.T) {
|
func TestPushoverNotifier(t *testing.T) {
|
||||||
Convey("Pushover notifier tests", t, func() {
|
Convey("Pushover notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
@ -65,7 +64,6 @@ func TestPushoverNotifier(t *testing.T) {
|
|||||||
|
|
||||||
func TestGenPushoverBody(t *testing.T) {
|
func TestGenPushoverBody(t *testing.T) {
|
||||||
Convey("Pushover body generation tests", t, func() {
|
Convey("Pushover body generation tests", t, func() {
|
||||||
|
|
||||||
Convey("Given common sounds", func() {
|
Convey("Given common sounds", func() {
|
||||||
sirenSound := "siren_sound_tst"
|
sirenSound := "siren_sound_tst"
|
||||||
successSound := "success_sound_tst"
|
successSound := "success_sound_tst"
|
||||||
@ -93,6 +91,5 @@ func TestGenPushoverBody(t *testing.T) {
|
|||||||
So(strings.Contains(pushoverBody.String(), successSound), ShouldBeTrue)
|
So(strings.Contains(pushoverBody.String(), successSound), ShouldBeTrue)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,6 @@ func init() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSensuNotifier is the constructor for the Sensu Notifier.
|
// NewSensuNotifier is the constructor for the Sensu Notifier.
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestSensuNotifier(t *testing.T) {
|
func TestSensuNotifier(t *testing.T) {
|
||||||
Convey("Sensu notifier tests", t, func() {
|
Convey("Sensu notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestSlackNotifier(t *testing.T) {
|
func TestSlackNotifier(t *testing.T) {
|
||||||
Convey("Slack notifier tests", t, func() {
|
Convey("Slack notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -33,7 +33,6 @@ func init() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTeamsNotifier is the constructor for Teams notifier.
|
// NewTeamsNotifier is the constructor for Teams notifier.
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestTeamsNotifier(t *testing.T) {
|
func TestTeamsNotifier(t *testing.T) {
|
||||||
Convey("Teams notifier tests", t, func() {
|
Convey("Teams notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -68,7 +68,6 @@ func init() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TelegramNotifier is responsible for sending
|
// TelegramNotifier is responsible for sending
|
||||||
@ -247,7 +246,6 @@ func generateImageCaption(evalContext *alerting.EvalContext, ruleURL string, met
|
|||||||
|
|
||||||
if len(message) > captionLengthLimit {
|
if len(message) > captionLengthLimit {
|
||||||
message = message[0:captionLengthLimit]
|
message = message[0:captionLengthLimit]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ruleURL) > 0 {
|
if len(ruleURL) > 0 {
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
func TestTelegramNotifier(t *testing.T) {
|
func TestTelegramNotifier(t *testing.T) {
|
||||||
Convey("Telegram notifier tests", t, func() {
|
Convey("Telegram notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
@ -68,7 +67,6 @@ func TestTelegramNotifier(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("When generating a message", func() {
|
Convey("When generating a message", func() {
|
||||||
|
|
||||||
Convey("URL should be skipped if it's too long", func() {
|
Convey("URL should be skipped if it's too long", func() {
|
||||||
evalContext := alerting.NewEvalContext(context.Background(),
|
evalContext := alerting.NewEvalContext(context.Background(),
|
||||||
&alerting.Rule{
|
&alerting.Rule{
|
||||||
|
@ -98,7 +98,6 @@ func init() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ThreemaNotifier is responsible for sending
|
// ThreemaNotifier is responsible for sending
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
func TestThreemaNotifier(t *testing.T) {
|
func TestThreemaNotifier(t *testing.T) {
|
||||||
Convey("Threema notifier tests", t, func() {
|
Convey("Threema notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestVictoropsNotifier(t *testing.T) {
|
func TestVictoropsNotifier(t *testing.T) {
|
||||||
Convey("Victorops notifier tests", t, func() {
|
Convey("Victorops notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -74,7 +74,6 @@ func init() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWebHookNotifier is the constructor for
|
// NewWebHookNotifier is the constructor for
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestWebhookNotifier(t *testing.T) {
|
func TestWebhookNotifier(t *testing.T) {
|
||||||
Convey("Webhook notifier tests", t, func() {
|
Convey("Webhook notifier tests", t, func() {
|
||||||
|
|
||||||
Convey("Parsing alert notification from settings", func() {
|
Convey("Parsing alert notification from settings", func() {
|
||||||
Convey("empty settings should return error", func() {
|
Convey("empty settings should return error", func() {
|
||||||
json := `{ }`
|
json := `{ }`
|
||||||
|
@ -71,7 +71,6 @@ func (handler *defaultResultHandler) handle(evalContext *EvalContext) error {
|
|||||||
|
|
||||||
handler.log.Error("Failed to save state", "error", err)
|
handler.log.Error("Failed to save state", "error", err)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// StateChanges is used for de duping alert notifications
|
// StateChanges is used for de duping alert notifications
|
||||||
// when two servers are raising. This makes sure that the server
|
// when two servers are raising. This makes sure that the server
|
||||||
// with the last state change always sends a notification.
|
// with the last state change always sends a notification.
|
||||||
|
@ -49,7 +49,6 @@ func TestAlertRuleFrequencyParsing(t *testing.T) {
|
|||||||
func TestAlertRuleModel(t *testing.T) {
|
func TestAlertRuleModel(t *testing.T) {
|
||||||
sqlstore.InitTestDB(t)
|
sqlstore.InitTestDB(t)
|
||||||
Convey("Testing alert rule", t, func() {
|
Convey("Testing alert rule", t, func() {
|
||||||
|
|
||||||
RegisterCondition("test", func(model *simplejson.Json, index int) (Condition, error) {
|
RegisterCondition("test", func(model *simplejson.Json, index int) (Condition, error) {
|
||||||
return &FakeCondition{}, nil
|
return &FakeCondition{}, nil
|
||||||
})
|
})
|
||||||
|
@ -25,7 +25,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleAlertTestCommand(cmd *AlertTestCommand) error {
|
func handleAlertTestCommand(cmd *AlertTestCommand) error {
|
||||||
|
|
||||||
dash := models.NewDashboardFromJson(cmd.Dashboard)
|
dash := models.NewDashboardFromJson(cmd.Dashboard)
|
||||||
|
|
||||||
extractor := NewDashAlertExtractor(dash, cmd.OrgID, cmd.User)
|
extractor := NewDashAlertExtractor(dash, cmd.OrgID, cmd.User)
|
||||||
|
@ -38,7 +38,6 @@ func (s *UserAuthTokenService) Init() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *UserAuthTokenService) ActiveTokenCount(ctx context.Context) (int64, error) {
|
func (s *UserAuthTokenService) ActiveTokenCount(ctx context.Context) (int64, error) {
|
||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
var err error
|
var err error
|
||||||
err = s.SQLStore.WithDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
|
err = s.SQLStore.WithDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
|
||||||
@ -119,9 +118,7 @@ func (s *UserAuthTokenService) LookupToken(ctx context.Context, unhashedToken st
|
|||||||
Get(&model)
|
Get(&model)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -373,7 +370,6 @@ func (s *UserAuthTokenService) GetUserToken(ctx context.Context, userId, userTok
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *UserAuthTokenService) GetUserTokens(ctx context.Context, userId int64) ([]*models.UserToken, error) {
|
func (s *UserAuthTokenService) GetUserTokens(ctx context.Context, userId int64) ([]*models.UserToken, error) {
|
||||||
|
|
||||||
result := []*models.UserToken{}
|
result := []*models.UserToken{}
|
||||||
err := s.SQLStore.WithDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
|
err := s.SQLStore.WithDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
|
||||||
var tokens []*userAuthToken
|
var tokens []*userAuthToken
|
||||||
@ -382,7 +378,6 @@ func (s *UserAuthTokenService) GetUserTokens(ctx context.Context, userId int64)
|
|||||||
s.createdAfterParam(),
|
s.createdAfterParam(),
|
||||||
s.rotatedAfterParam()).
|
s.rotatedAfterParam()).
|
||||||
Find(&tokens)
|
Find(&tokens)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestUserAuthTokenCleanup(t *testing.T) {
|
func TestUserAuthTokenCleanup(t *testing.T) {
|
||||||
|
|
||||||
Convey("Test user auth token cleanup", t, func() {
|
Convey("Test user auth token cleanup", t, func() {
|
||||||
ctx := createTestContext(t)
|
ctx := createTestContext(t)
|
||||||
ctx.tokenService.Cfg.LoginMaxInactiveLifetimeDays = 7
|
ctx.tokenService.Cfg.LoginMaxInactiveLifetimeDays = 7
|
||||||
|
@ -38,5 +38,4 @@ func TestCleanUpTmpFiles(t *testing.T) {
|
|||||||
So(service.shouldCleanupTempFile(weekAgo, now), ShouldBeFalse)
|
So(service.shouldCleanupTempFile(weekAgo, now), ShouldBeFalse)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,6 @@ func (dr *dashboardServiceImpl) SaveFolderForProvisionedDashboards(dto *SaveDash
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dr *dashboardServiceImpl) SaveDashboard(dto *SaveDashboardDTO, allowUiUpdate bool) (*models.Dashboard, error) {
|
func (dr *dashboardServiceImpl) SaveDashboard(dto *SaveDashboardDTO, allowUiUpdate bool) (*models.Dashboard, error) {
|
||||||
|
|
||||||
cmd, err := dr.buildSaveDashboardCommand(dto, true, !allowUiUpdate)
|
cmd, err := dr.buildSaveDashboardCommand(dto, true, !allowUiUpdate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -224,7 +224,6 @@ func TestDashboardService(t *testing.T) {
|
|||||||
_, err := service.SaveProvisionedDashboard(dto, nil)
|
_, err := service.SaveProvisionedDashboard(dto, nil)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(dto.Dashboard.Data.Get("refresh").MustString(), ShouldEqual, "5m")
|
So(dto.Dashboard.Data.Get("refresh").MustString(), ShouldEqual, "5m")
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -532,7 +532,6 @@ func (server *Server) requestMemberOf(entry *ldap.Entry) ([]string, error) {
|
|||||||
|
|
||||||
if len(groupSearchResult.Entries) > 0 {
|
if len(groupSearchResult.Entries) > 0 {
|
||||||
for _, group := range groupSearchResult.Entries {
|
for _, group := range groupSearchResult.Entries {
|
||||||
|
|
||||||
memberOf = append(
|
memberOf = append(
|
||||||
memberOf,
|
memberOf,
|
||||||
getAttribute(groupIDAttribute, group),
|
getAttribute(groupIDAttribute, group),
|
||||||
|
@ -241,5 +241,4 @@ func TestLDAPPrivateMethods(t *testing.T) {
|
|||||||
So(result, ShouldEqual, "cn=test,dc=grafana,dc=org")
|
So(result, ShouldEqual, "cn=test,dc=grafana,dc=org")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ func Test_syncOrgRoles_doesNotBreakWhenTryingToRemoveLastOrgAdmin(t *testing.T)
|
|||||||
bus.ClearBusHandlers()
|
bus.ClearBusHandlers()
|
||||||
defer bus.ClearBusHandlers()
|
defer bus.ClearBusHandlers()
|
||||||
bus.AddHandler("test", func(q *models.GetUserOrgListQuery) error {
|
bus.AddHandler("test", func(q *models.GetUserOrgListQuery) error {
|
||||||
|
|
||||||
q.Result = createUserOrgDTO()
|
q.Result = createUserOrgDTO()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -53,7 +52,6 @@ func Test_syncOrgRoles_whenTryingToRemoveLastOrgLogsError(t *testing.T) {
|
|||||||
bus.ClearBusHandlers()
|
bus.ClearBusHandlers()
|
||||||
defer bus.ClearBusHandlers()
|
defer bus.ClearBusHandlers()
|
||||||
bus.AddHandler("test", func(q *models.GetUserOrgListQuery) error {
|
bus.AddHandler("test", func(q *models.GetUserOrgListQuery) error {
|
||||||
|
|
||||||
q.Result = createUserOrgDTO()
|
q.Result = createUserOrgDTO()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -70,14 +70,12 @@ func New(configs []*ldap.ServerConfig) IMultiLDAP {
|
|||||||
|
|
||||||
// Ping dials each of the LDAP servers and returns their status. If the server is unavailable, it also returns the error.
|
// Ping dials each of the LDAP servers and returns their status. If the server is unavailable, it also returns the error.
|
||||||
func (multiples *MultiLDAP) Ping() ([]*ServerStatus, error) {
|
func (multiples *MultiLDAP) Ping() ([]*ServerStatus, error) {
|
||||||
|
|
||||||
if len(multiples.configs) == 0 {
|
if len(multiples.configs) == 0 {
|
||||||
return nil, ErrNoLDAPServers
|
return nil, ErrNoLDAPServers
|
||||||
}
|
}
|
||||||
|
|
||||||
serverStatuses := []*ServerStatus{}
|
serverStatuses := []*ServerStatus{}
|
||||||
for _, config := range multiples.configs {
|
for _, config := range multiples.configs {
|
||||||
|
|
||||||
status := &ServerStatus{}
|
status := &ServerStatus{}
|
||||||
|
|
||||||
status.Host = config.Host
|
status.Host = config.Host
|
||||||
@ -104,7 +102,6 @@ func (multiples *MultiLDAP) Ping() ([]*ServerStatus, error) {
|
|||||||
func (multiples *MultiLDAP) Login(query *models.LoginUserQuery) (
|
func (multiples *MultiLDAP) Login(query *models.LoginUserQuery) (
|
||||||
*models.ExternalUserInfo, error,
|
*models.ExternalUserInfo, error,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if len(multiples.configs) == 0 {
|
if len(multiples.configs) == 0 {
|
||||||
return nil, ErrNoLDAPServers
|
return nil, ErrNoLDAPServers
|
||||||
}
|
}
|
||||||
@ -125,12 +122,11 @@ func (multiples *MultiLDAP) Login(query *models.LoginUserQuery) (
|
|||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
user, err := server.Login(query)
|
user, err := server.Login(query)
|
||||||
|
// FIXME
|
||||||
if user != nil {
|
if user != nil {
|
||||||
return user, nil
|
return user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
if isSilentError(err) {
|
if isSilentError(err) {
|
||||||
logger.Debug(
|
logger.Debug(
|
||||||
"unable to login with LDAP - skipping server",
|
"unable to login with LDAP - skipping server",
|
||||||
@ -155,7 +151,6 @@ func (multiples *MultiLDAP) User(login string) (
|
|||||||
ldap.ServerConfig,
|
ldap.ServerConfig,
|
||||||
error,
|
error,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if len(multiples.configs) == 0 {
|
if len(multiples.configs) == 0 {
|
||||||
return nil, ldap.ServerConfig{}, ErrNoLDAPServers
|
return nil, ldap.ServerConfig{}, ErrNoLDAPServers
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,6 @@ type mockLDAP struct {
|
|||||||
|
|
||||||
// Login test fn
|
// Login test fn
|
||||||
func (mock *mockLDAP) Login(*models.LoginUserQuery) (*models.ExternalUserInfo, error) {
|
func (mock *mockLDAP) Login(*models.LoginUserQuery) (*models.ExternalUserInfo, error) {
|
||||||
|
|
||||||
mock.loginCalledTimes = mock.loginCalledTimes + 1
|
mock.loginCalledTimes = mock.loginCalledTimes + 1
|
||||||
return mock.loginReturn, mock.loginErrReturn
|
return mock.loginReturn, mock.loginErrReturn
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestEmailCodes(t *testing.T) {
|
func TestEmailCodes(t *testing.T) {
|
||||||
|
|
||||||
Convey("When generating code", t, func() {
|
Convey("When generating code", t, func() {
|
||||||
setting.EmailCodeValidMinutes = 120
|
setting.EmailCodeValidMinutes = 120
|
||||||
|
|
||||||
@ -34,7 +33,5 @@ func TestEmailCodes(t *testing.T) {
|
|||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(isValid, ShouldBeFalse)
|
So(isValid, ShouldBeFalse)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNotifications(t *testing.T) {
|
func TestNotifications(t *testing.T) {
|
||||||
|
|
||||||
Convey("Given the notifications service", t, func() {
|
Convey("Given the notifications service", t, func() {
|
||||||
setting.StaticRootPath = "../../../public/"
|
setting.StaticRootPath = "../../../public/"
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ var (
|
|||||||
|
|
||||||
func TestDashboardsAsConfig(t *testing.T) {
|
func TestDashboardsAsConfig(t *testing.T) {
|
||||||
t.Run("Dashboards as configuration", func(t *testing.T) {
|
t.Run("Dashboards as configuration", func(t *testing.T) {
|
||||||
|
|
||||||
logger := log.New("test-logger")
|
logger := log.New("test-logger")
|
||||||
|
|
||||||
t.Run("default values should be applied", func(t *testing.T) {
|
t.Run("default values should be applied", func(t *testing.T) {
|
||||||
|
@ -65,7 +65,6 @@ func NewDashboardFileReader(cfg *config, log log.Logger) (*FileReader, error) {
|
|||||||
|
|
||||||
// pollChanges periodically runs startWalkingDisk based on interval specified in the config.
|
// pollChanges periodically runs startWalkingDisk based on interval specified in the config.
|
||||||
func (fr *FileReader) pollChanges(ctx context.Context) {
|
func (fr *FileReader) pollChanges(ctx context.Context) {
|
||||||
|
|
||||||
ticker := time.NewTicker(time.Duration(int64(time.Second) * fr.Cfg.UpdateIntervalSeconds))
|
ticker := time.NewTicker(time.Duration(int64(time.Second) * fr.Cfg.UpdateIntervalSeconds))
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user