Prometheus: Add missing Azure setting (#84094)

This commit is contained in:
Andreas Christou
2024-03-11 08:57:42 +00:00
committed by GitHub
parent ea84a66ff4
commit 07676ab8a0
2 changed files with 25 additions and 0 deletions

View File

@@ -9,6 +9,10 @@ func (cfg *Cfg) readAzureSettings() {
azureSettings := &azsettings.AzureSettings{}
azureSection := cfg.Raw.Section("azure")
authSection := cfg.Raw.Section("auth")
// This setting is specific to Prometheus
azureSettings.AzureAuthEnabled = authSection.Key("azure_auth_enabled").MustBool(false)
// Cloud
cloudName := azureSection.Key("cloud").MustString(azsettings.AzurePublic)

View File

@@ -64,6 +64,27 @@ func TestAzureSettings(t *testing.T) {
}
})
t.Run("prometheus", func(t *testing.T) {
t.Run("should enable azure auth", func(t *testing.T) {
cfg := NewCfg()
authSection, err := cfg.Raw.NewSection("auth")
require.NoError(t, err)
_, err = authSection.NewKey("azure_auth_enabled", "true")
require.NoError(t, err)
cfg.readAzureSettings()
require.NotNil(t, cfg.Azure.AzureAuthEnabled)
assert.True(t, cfg.Azure.AzureAuthEnabled)
})
t.Run("should default to disabled", func(t *testing.T) {
cfg := NewCfg()
cfg.readAzureSettings()
require.NotNil(t, cfg.Azure.AzureAuthEnabled)
assert.False(t, cfg.Azure.AzureAuthEnabled)
})
})
t.Run("User Identity", func(t *testing.T) {
t.Run("should be disabled by default", func(t *testing.T) {
cfg := NewCfg()