[v10.3.x] Auth: Use cfg.Raw in OAuthStrategy for loading settings (#80441)

Auth: Use cfg.Raw in OAuthStrategy for loading settings (#80136)

Use cfg.Raw in OAuthStrategy, remove unnecessary tests

(cherry picked from commit eae6adf002)

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-01-12 14:35:02 +01:00
committed by GitHub
co-authored by Misi
parent be211fbccb
commit 4ba9afa45f
3 changed files with 15 additions and 76 deletions
+13
View File
@@ -75,6 +75,19 @@ func TestLoadingSettings(t *testing.T) {
require.Equal(t, filepath.Join(cfg.DataPath, "log"), cfg.LogsPath)
})
t.Run("Should be able to expand parameter from environment variables", func(t *testing.T) {
t.Setenv("DEFAULT_IDP_URL", "grafana.com")
t.Setenv("GF_AUTH_GENERIC_OAUTH_AUTH_URL", "${DEFAULT_IDP_URL}/auth")
cfg := NewCfg()
err := cfg.Load(CommandLineArgs{HomePath: "../../"})
require.Nil(t, err)
genericOAuthSection, err := cfg.Raw.GetSection("auth.generic_oauth")
require.NoError(t, err)
require.Equal(t, "grafana.com/auth", genericOAuthSection.Key("auth_url").Value())
})
t.Run("Should replace password when defined in environment", func(t *testing.T) {
t.Setenv("GF_SECURITY_ADMIN_PASSWORD", "supersecret")