mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 18:00:31 -06:00
9eb2cd537d
* add new endpoint without auth+config * add cfg check * fit lint issue * Add basic auth support Co-authored-by: Will Browne <wbrowne@users.noreply.github.com> * WIP docs * Update docs/sources/administration/view-server/internal-metrics.md Co-authored-by: Dave Henderson <dhenderson@gmail.com> * update instructions Co-authored-by: Will Browne <will.browne@grafana.com> Co-authored-by: Will Browne <wbrowne@users.noreply.github.com> Co-authored-by: Dave Henderson <dhenderson@gmail.com>
29 lines
616 B
Go
29 lines
616 B
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestHTTPServer_MetricsBasicAuth(t *testing.T) {
|
|
ts := &HTTPServer{
|
|
Cfg: setting.NewCfg(),
|
|
}
|
|
|
|
t.Run("enabled", func(t *testing.T) {
|
|
ts.Cfg.MetricsEndpointBasicAuthUsername = "foo"
|
|
ts.Cfg.MetricsEndpointBasicAuthPassword = "bar"
|
|
|
|
assert.True(t, ts.metricsEndpointBasicAuthEnabled())
|
|
})
|
|
|
|
t.Run("disabled", func(t *testing.T) {
|
|
ts.Cfg.MetricsEndpointBasicAuthUsername = ""
|
|
ts.Cfg.MetricsEndpointBasicAuthPassword = ""
|
|
|
|
assert.False(t, ts.metricsEndpointBasicAuthEnabled())
|
|
})
|
|
}
|