Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion current_schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
- GF_SERVER_ROOT_URL=${GRAFANA_URL}
- GF_ENTERPRISE_LICENSE_TEXT=${GF_ENTERPRISE_LICENSE_TEXT:-}
- GF_SERVER_SERVE_FROM_SUB_PATH=${GF_SERVER_SERVE_FROM_SUB_PATH:-}
- GF_FEATURE_TOGGLES_ENABLE=nestedFolders,ssoSettingsApi,ssoSettingsSAML,ssoSettingsLDAP,grafanaManagedRecordingRulesDatasources
- GF_FEATURE_TOGGLES_ENABLE=nestedFolders,ssoSettingsApi,ssoSettingsSAML,ssoSettingsLDAP,grafanaManagedRecordingRulesDatasources,enableSCIM
healthcheck:
test: wget --no-verbose --tries=1 --spider http://0.0.0.0:3000/api/health || exit 1 # Use wget because older versions of Grafana don't have curl
interval: 10s
Expand Down
7 changes: 5 additions & 2 deletions internal/resources/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func TestAccExamples(t *testing.T) {
{
category: "Grafana Enterprise",
testCheck: func(t *testing.T, filename string) {
if strings.Contains(filename, "grafana_data_source_config_lbac_rules") {
switch {
case strings.Contains(filename, "grafana_data_source_config_lbac_rules"):
// TODO: Fix the example to work with import.
//
// It looks like the test setup fails because the resource is imported but the rules don't actually exist, so the following refresh-after-apply that calls the `.Read` method fails.
Expand All @@ -63,7 +64,9 @@ func TestAccExamples(t *testing.T) {
// getTeamLBACRulesApiInternalServerError {"message":"Validation error, invalid
// format of team LBAC rules"}
t.Skip()
} else {
case strings.Contains(filename, "grafana_scim_config"):
testutils.CheckEnterpriseTestsEnabled(t, ">=12.0.0")
default:
testutils.CheckEnterpriseTestsEnabled(t, ">=11.0.0") // Only run on latest version
}
},
Expand Down
25 changes: 22 additions & 3 deletions internal/resources/grafana/resource_scim_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ func CreateOrUpdateSCIMConfig(ctx context.Context, d *schema.ResourceData, meta
}

req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+transportConfig.APIKey)

if transportConfig.APIKey != "" {
req.Header.Set("Authorization", "Bearer "+transportConfig.APIKey)
} else if transportConfig.BasicAuth != nil {
username := transportConfig.BasicAuth.Username()
password, _ := transportConfig.BasicAuth.Password()
req.SetBasicAuth(username, password)
}

// Use the HTTP client from the transport configuration
httpClient := &http.Client{}
Expand Down Expand Up @@ -191,7 +198,13 @@ func ReadSCIMConfig(ctx context.Context, d *schema.ResourceData, meta interface{
return diag.FromErr(fmt.Errorf("failed to create request: %w", err))
}

req.Header.Set("Authorization", "Bearer "+transportConfig.APIKey)
if transportConfig.APIKey != "" {
req.Header.Set("Authorization", "Bearer "+transportConfig.APIKey)
} else if transportConfig.BasicAuth != nil {
username := transportConfig.BasicAuth.Username()
password, _ := transportConfig.BasicAuth.Password()
req.SetBasicAuth(username, password)
}

// Use the HTTP client from the transport configuration
httpClient := &http.Client{}
Expand Down Expand Up @@ -266,7 +279,13 @@ func DeleteSCIMConfig(ctx context.Context, d *schema.ResourceData, meta interfac
return diag.FromErr(fmt.Errorf("failed to create request: %w", err))
}

req.Header.Set("Authorization", "Bearer "+transportConfig.APIKey)
if transportConfig.APIKey != "" {
req.Header.Set("Authorization", "Bearer "+transportConfig.APIKey)
} else if transportConfig.BasicAuth != nil {
username := transportConfig.BasicAuth.Username()
password, _ := transportConfig.BasicAuth.Password()
req.SetBasicAuth(username, password)
}

// Use the HTTP client from the transport configuration
httpClient := &http.Client{}
Expand Down
4 changes: 2 additions & 2 deletions internal/resources/grafana/resource_scim_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAccResourceSCIMConfig_basic(t *testing.T) {
testutils.CheckEnterpriseTestsEnabled(t, ">=11.0.0")
testutils.CheckEnterpriseTestsEnabled(t, ">=12.0.0")

resourceName := "grafana_scim_config.test"

Expand Down Expand Up @@ -53,7 +53,7 @@ func TestAccResourceSCIMConfig_basic(t *testing.T) {
}

func TestAccResourceSCIMConfig_import(t *testing.T) {
testutils.CheckEnterpriseTestsEnabled(t, ">=11.0.0")
testutils.CheckEnterpriseTestsEnabled(t, ">=12.0.0")

resource.ParallelTest(t, resource.TestCase{
ProtoV5ProviderFactories: testutils.ProtoV5ProviderFactories,
Expand Down
Loading