grafana/pkg/api/http_server_test.go
chalapat 65c0669f01
Server: Reload TLS certs without a server restart (#83589)
* server: reload of grafana server certs when renewed without restart.

Signed-off-by: Rao, B V Chalapathi <b_v_chalapathi.rao@nokia.com>

* server: reload of grafana server certs when renewed without restart.

Signed-off-by: Rao, B V Chalapathi <b_v_chalapathi.rao@nokia.com>

* Update http_server.go

* Update docs/sources/setup-grafana/configure-grafana/_index.md

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>

* Update http_server.go

Address the comments

* Update docs/sources/setup-grafana/configure-grafana/_index.md

Co-authored-by: Dan Cech <dan@aussiedan.com>

* Update http_server.go

Align the spaces

* Update http_server.go

* Update http_server.go

* Update pkg/api/http_server.go

Co-authored-by: Dan Cech <dan@aussiedan.com>

---------

Signed-off-by: Rao, B V Chalapathi <b_v_chalapathi.rao@nokia.com>
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
Co-authored-by: Dan Cech <dan@aussiedan.com>
2024-03-22 17:13:22 +02:00

40 lines
886 B
Go

package api
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/grafana/grafana/pkg/setting"
)
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())
})
}
func TestHTTPServer_readCertificates(t *testing.T) {
ts := &HTTPServer{
Cfg: setting.NewCfg(),
}
t.Run("ReadCertificates should return error when cert files are not configured", func(t *testing.T) {
_, err := ts.readCertificates()
assert.NotNil(t, err)
})
}