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

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

Use cfg.Raw in OAuthStrategy, remove unnecessary tests

(cherry picked from commit eae6adf002)
This commit is contained in:
Misi
2024-01-08 16:40:39 +01:00
committed by GitHub
parent 74c0546233
commit 1b3d09fdda
3 changed files with 15 additions and 82 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")