This commit is contained in:
laurentsimon 2022-04-12 00:39:32 +00:00 committed by Naveen
parent 2873c0d58d
commit 4b2c677185

View File

@ -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())
})
})
})