From 4b2c67718554c53a0ef46590b625c347e561bb03 Mon Sep 17 00:00:00 2001 From: laurentsimon Date: Tue, 12 Apr 2022 00:39:32 +0000 Subject: [PATCH] fix --- e2e/branch_protection_test.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/e2e/branch_protection_test.go b/e2e/branch_protection_test.go index fb56d749e6e..3c1465fd808 100644 --- a/e2e/branch_protection_test.go +++ b/e2e/branch_protection_test.go @@ -29,7 +29,7 @@ import ( var _ = Describe("E2E TEST PAT:"+checks.CheckBranchProtection, func() { Context("E2E TEST:Validating branch protection", func() { - skipIfTokenIs(githubWorkflowDefaultTokenType, checks.CheckBranchProtection+" does not support GITHUB_TOKEN") + skipIfTokenIsNot(patTokenType, "PAT only") It("Should get non-admin branch protection on other repositories", func() { dl := scut.TestDetailLogger{} @@ -123,3 +123,28 @@ var _ = Describe("E2E TEST PAT:"+checks.CheckBranchProtection, func() { }) }) }) + +var _ = Describe("E2E TEST GITHUB_TOKEN:"+checks.CheckBranchProtection, func() { + Context("E2E TEST:Validating branch protection", func() { + skipIfTokenIsNot(githubWorkflowDefaultTokenType, "GITHUB_TOKEN only") + + It("Should get errors with GITHUB_TOKEN", func() { + dl := scut.TestDetailLogger{} + repo, err := githubrepo.MakeGithubRepo("ossf-tests/scorecard-check-branch-protection-e2e") + Expect(err).Should(BeNil()) + repoClient := githubrepo.CreateGithubRepoClient(context.Background(), logger) + err = repoClient.InitRepo(repo, clients.HeadSHA) + Expect(err).Should(BeNil()) + req := checker.CheckRequest{ + Ctx: context.Background(), + RepoClient: repoClient, + Repo: repo, + Dlogger: &dl, + } + + result := checks.BranchProtection(&req) + Expect(result.Error).ShouldNot(BeNil()) + Expect(repoClient.Close()).Should(BeNil()) + }) + }) +})