Revision 4cfaf31e18e9cc7724d788b263bdd3b0f8183fd8 authored by Giordano Ricci on 12 January 2022, 09:19:10 UTC, committed by grafanabot on 14 January 2022, 12:39:54 UTC
(cherry picked from commit afd110309c3ca7776c8e95c4aa64fec1061657e3)
1 parent e801e20
Raw File
http_server_test.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())
	})
}
back to top