From 8b19f5874c83ca2fe8bc4c39da5458d109a73844 Mon Sep 17 00:00:00 2001 From: Steve Hipwell Date: Tue, 20 Jan 2026 15:02:42 +0000 Subject: [PATCH] fix: Revert provider input constraints Signed-off-by: Steve Hipwell --- github/provider.go | 20 +++++++-------- github/provider_test.go | 56 +++++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/github/provider.go b/github/provider.go index 480bcba3fb..4f857d27c0 100644 --- a/github/provider.go +++ b/github/provider.go @@ -18,11 +18,11 @@ func Provider() *schema.Provider { p := &schema.Provider{ Schema: map[string]*schema.Schema{ "token": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("GITHUB_TOKEN", nil), - Description: descriptions["token"], - ConflictsWith: []string{"app_auth"}, + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("GITHUB_TOKEN", nil), + Description: descriptions["token"], + // ConflictsWith: []string{"app_auth"}, // TODO: Enable as part of v7. }, "owner": { Type: schema.TypeString, @@ -94,11 +94,11 @@ func Provider() *schema.Provider { Description: descriptions["parallel_requests"], }, "app_auth": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Description: descriptions["app_auth"], - ConflictsWith: []string{"token"}, + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: descriptions["app_auth"], + // ConflictsWith: []string{"token"}, // TODO: Enable as part of v7. Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { diff --git a/github/provider_test.go b/github/provider_test.go index 037c91cbf4..a30c91f8bb 100644 --- a/github/provider_test.go +++ b/github/provider_test.go @@ -51,7 +51,7 @@ func TestProvider(t *testing.T) { } func TestAccProviderConfigure(t *testing.T) { - t.Run("can be configured to run anonymously", func(t *testing.T) { + t.Run("can_be_configured_to_run_anonymously", func(t *testing.T) { config := ` provider "github" { } @@ -71,10 +71,36 @@ func TestAccProviderConfigure(t *testing.T) { }) }) + t.Run("can_be_configured_with_app_auth_and_ignore_github_token", func(t *testing.T) { + t.Skip("This test requires a valid app auth setup to run.") + config := fmt.Sprintf(` +provider "github" { + owner = "%s" + app_auth { + id = "1234567890" + installation_id = "1234567890" + pem_file = "1234567890" + } +} + +data "github_ip_ranges" "test" {} +`, testAccConf.owner) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { t.Setenv("GITHUB_TOKEN", "1234567890") }, + ProviderFactories: providerFactories, + Steps: []resource.TestStep{ + { + Config: config, + ExpectNonEmptyPlan: false, + }, + }, + }) + }) + t.Run("can be configured to run insecurely", func(t *testing.T) { config := ` provider "github" { - token = "" insecure = true } data "github_ip_ranges" "test" {} @@ -231,6 +257,7 @@ func TestAccProviderConfigure(t *testing.T) { }) }) t.Run("should not allow both token and app_auth to be configured", func(t *testing.T) { + t.Skip("This would be a semver breaking change, this will be reinstated for v7.") config := fmt.Sprintf(` provider "github" { owner = "%s" @@ -255,29 +282,4 @@ func TestAccProviderConfigure(t *testing.T) { }, }) }) - t.Run("should not allow app_auth and GITHUB_TOKEN to be configured", func(t *testing.T) { - config := fmt.Sprintf(` - provider "github" { - owner = "%s" - app_auth { - id = "1234567890" - installation_id = "1234567890" - pem_file = "1234567890" - } - } - - data "github_ip_ranges" "test" {} - `, testAccConf.owner) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { t.Setenv("GITHUB_TOKEN", "1234567890") }, - ProviderFactories: providerFactories, - Steps: []resource.TestStep{ - { - Config: config, - ExpectError: regexp.MustCompile(`"token": conflicts with app_auth`), - }, - }, - }) - }) }