Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix e2e tests for branch protection #1837

Merged
merged 1 commit into from
Apr 13, 2022
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
6 changes: 4 additions & 2 deletions clients/githubrepo/branches_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {
})

Context("E2E TEST: Validate query cost", func() {
skipIfTokenIsNot(githubWorkflowDefaultTokenType, "GITHUB_TOKEN only")

It("Should not have increased for HEAD query", func() {
skipIfTokenIsNot(githubWorkflowDefaultTokenType, "GITHUB_TOKEN only")

repourl := &repoURL{
owner: "ossf",
repo: "scorecard",
Expand All @@ -48,6 +48,8 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {
Expect(*brancheshandler.data.RateLimit.Cost).Should(BeNumerically("<=", 1))
})
It("Should fail for non-HEAD query", func() {
skipIfTokenIsNot(githubWorkflowDefaultTokenType, "GITHUB_TOKEN only")

repourl := &repoURL{
owner: "ossf",
repo: "scorecard",
Expand Down
11 changes: 7 additions & 4 deletions e2e/branch_protection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (

var _ = Describe("E2E TEST PAT:"+checks.CheckBranchProtection, func() {
Context("E2E TEST:Validating branch protection", func() {
skipIfTokenIsNot(patTokenType, "PAT only")

It("Should get non-admin branch protection on other repositories", func() {
skipIfTokenIsNot(patTokenType, "PAT only")

dl := scut.TestDetailLogger{}
repo, err := githubrepo.MakeGithubRepo("ossf-tests/scorecard-check-branch-protection-e2e")
Expect(err).Should(BeNil())
Expand Down Expand Up @@ -62,6 +62,8 @@ var _ = Describe("E2E TEST PAT:"+checks.CheckBranchProtection, func() {
Expect(repoClient.Close()).Should(BeNil())
})
It("Should fail to return branch protection on other repositories", func() {
skipIfTokenIsNot(patTokenType, "PAT only")

dl := scut.TestDetailLogger{}
repo, err := githubrepo.MakeGithubRepo("ossf-tests/scorecard-check-branch-protection-e2e-none")
Expect(err).Should(BeNil())
Expand Down Expand Up @@ -92,6 +94,8 @@ var _ = Describe("E2E TEST PAT:"+checks.CheckBranchProtection, func() {
Expect(repoClient.Close()).Should(BeNil())
})
It("Should fail to return branch protection on other repositories", func() {
skipIfTokenIsNot(patTokenType, "PAT only")

dl := scut.TestDetailLogger{}
repo, err := githubrepo.MakeGithubRepo("ossf-tests/scorecard-check-branch-protection-e2e-patch-1")
Expect(err).Should(BeNil())
Expand Down Expand Up @@ -126,9 +130,8 @@ 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() {
skipIfTokenIsNot(githubWorkflowDefaultTokenType, "GITHUB_TOKEN only")
dl := scut.TestDetailLogger{}
repo, err := githubrepo.MakeGithubRepo("ossf-tests/scorecard-check-branch-protection-e2e")
Expect(err).Should(BeNil())
Expand Down