From 47df36b3d5777d90cffc00bdb250464753755ad0 Mon Sep 17 00:00:00 2001 From: rilical <109667925+rilical@users.noreply.github.com> Date: Wed, 12 Aug 2026 12:35:36 -0400 Subject: [PATCH 1/2] test: allow anonymous test metadata without credentials Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- github/acc_test.go | 20 +++++++++++--------- github/provider_test.go | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/github/acc_test.go b/github/acc_test.go index d623abeec1..f984be6c76 100644 --- a/github/acc_test.go +++ b/github/acc_test.go @@ -245,16 +245,18 @@ func getTestMeta(conf *testAccConfig) (*Owner, error) { Owner: conf.owner, } - if config.LegacyClient || conf.appID == "" { - token, err := getTestToken(conf) - if err != nil { - return nil, fmt.Errorf("error getting test token: %w", err) + if conf.authMode != anonymous { + if config.LegacyClient || conf.appID == "" { + token, err := getTestToken(conf) + if err != nil { + return nil, fmt.Errorf("error getting test token: %w", err) + } + config.Token = token + } else { + config.AppID = &conf.appID + config.AppInstallationID = &conf.appInstallationID + config.AppPEM = []byte(conf.appPEM) } - config.Token = token - } else { - config.AppID = &conf.appID - config.AppInstallationID = &conf.appInstallationID - config.AppPEM = []byte(conf.appPEM) } return configureProviderMeta(context.Background(), "test", config) diff --git a/github/provider_test.go b/github/provider_test.go index 158e5872e3..7a6975299d 100644 --- a/github/provider_test.go +++ b/github/provider_test.go @@ -19,6 +19,24 @@ func TestProvider(t *testing.T) { }) } +func Test_getTestMeta_anonymousDoesNotRequireCredentials(t *testing.T) { + baseURL, _, err := getBaseURL(DotComAPIURL) + if err != nil { + t.Fatalf("parsing base URL: %v", err) + } + + meta, err := getTestMeta(&testAccConfig{ + authMode: anonymous, + baseURL: baseURL, + }) + if err != nil { + t.Fatalf("configuring anonymous provider meta: %v", err) + } + if meta == nil { + t.Fatal("anonymous provider meta is nil") + } +} + func Test_configureProviderMeta(t *testing.T) { t.Parallel() From 7043077a1536a368adae08f9f49c9ae54c3fd308 Mon Sep 17 00:00:00 2001 From: Omar Ghabayen Date: Fri, 14 Aug 2026 11:09:45 -0400 Subject: [PATCH 2/2] Update github/provider_test.go Co-authored-by: Steve Hipwell --- github/provider_test.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/github/provider_test.go b/github/provider_test.go index 7a6975299d..158e5872e3 100644 --- a/github/provider_test.go +++ b/github/provider_test.go @@ -19,24 +19,6 @@ func TestProvider(t *testing.T) { }) } -func Test_getTestMeta_anonymousDoesNotRequireCredentials(t *testing.T) { - baseURL, _, err := getBaseURL(DotComAPIURL) - if err != nil { - t.Fatalf("parsing base URL: %v", err) - } - - meta, err := getTestMeta(&testAccConfig{ - authMode: anonymous, - baseURL: baseURL, - }) - if err != nil { - t.Fatalf("configuring anonymous provider meta: %v", err) - } - if meta == nil { - t.Fatal("anonymous provider meta is nil") - } -} - func Test_configureProviderMeta(t *testing.T) { t.Parallel()