-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat-e2e tests for signed tags and signed releases (#115)
Implemented e2e tests using ginkgo for validating signed tags and signed releases. ginkgo is utilized as a standard BDD testing framework in other projects like kubebuilder.
- Loading branch information
1 parent
3df1191
commit f77da77
Showing
6 changed files
with
156 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/google/go-github/v32/github" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/ossf/scorecard/roundtripper" | ||
"github.com/shurcooL/githubv4" | ||
"go.uber.org/zap" | ||
) | ||
|
||
var ghClient *github.Client | ||
var graphClient *githubv4.Client | ||
var client *http.Client | ||
|
||
type log struct { | ||
messages []string | ||
} | ||
|
||
func (l *log) Logf(s string, f ...interface{}) { | ||
l.messages = append(l.messages, fmt.Sprintf(s, f...)) | ||
} | ||
|
||
func TestE2e(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "E2e Suite") | ||
} | ||
|
||
var _ = BeforeSuite(func() { | ||
ctx := context.TODO() | ||
|
||
logLevel := zap.LevelFlag("verbosity", zap.InfoLevel, "override the default log level") | ||
cfg := zap.NewProductionConfig() | ||
cfg.Level.SetLevel(*logLevel) | ||
logger, err := cfg.Build() | ||
Expect(err).Should(BeNil()) | ||
|
||
sugar := logger.Sugar() | ||
// nolint | ||
defer logger.Sync() // flushes buffer, if any | ||
Expect(sugar).ShouldNot(BeNil()) | ||
|
||
rt := roundtripper.NewTransport(ctx, sugar) | ||
|
||
client = &http.Client{ | ||
Transport: rt, | ||
} | ||
|
||
ghClient = github.NewClient(client) | ||
graphClient = githubv4.NewClient(client) | ||
|
||
}) | ||
|
||
var _ = AfterSuite(func() { | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/ossf/scorecard/checker" | ||
"github.com/ossf/scorecard/checks" | ||
) | ||
|
||
var _ = Describe("E2E TEST:Signedreleases", func() { | ||
Context("E2E TEST:Validating signed releases", func() { | ||
It("Should return valid signed releases", func() { | ||
l := log{} | ||
checker := checker.Checker{ | ||
Ctx: context.Background(), | ||
Client: ghClient, | ||
HttpClient: client, | ||
Owner: "apache", | ||
Repo: "airflow", | ||
GraphClient: graphClient, | ||
Logf: l.Logf, | ||
} | ||
result := checks.SignedReleases(checker) | ||
Expect(result.Error).Should(BeNil()) | ||
Expect(result.Pass).Should(BeTrue()) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/ossf/scorecard/checker" | ||
"github.com/ossf/scorecard/checks" | ||
) | ||
|
||
var _ = Describe("E2E TEST:Signedtags", func() { | ||
Context("E2E TEST:Validating signed tags", func() { | ||
It("Should return valid signed tags", func() { | ||
l := log{} | ||
checker := checker.Checker{ | ||
Ctx: context.Background(), | ||
Client: ghClient, | ||
HttpClient: client, | ||
Owner: "apache", | ||
Repo: "airflow", | ||
GraphClient: graphClient, | ||
Logf: l.Logf, | ||
} | ||
result := checks.SignedTags(checker) | ||
Expect(result.Error).Should(BeNil()) | ||
Expect(result.Pass).Should(BeTrue()) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters