Skip to content
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
21 changes: 0 additions & 21 deletions packagehandlers/packagehandlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,27 +596,6 @@ func TestGetProjectPoms(t *testing.T) {
assert.Len(t, mvnHandler.pomPaths, 2)
}

// General Utils functions
func TestFixVersionInfo_UpdateFixVersionIfMax(t *testing.T) {
type testCase struct {
fixVersionInfo utils.VulnerabilityDetails
newFixVersion string
expectedOutput string
}

testCases := []testCase{
{fixVersionInfo: utils.VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.2.4", expectedOutput: "1.2.4"},
{fixVersionInfo: utils.VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.0.4", expectedOutput: "1.2.3"},
}

for _, tc := range testCases {
t.Run(tc.expectedOutput, func(t *testing.T) {
tc.fixVersionInfo.UpdateFixVersionIfMax(tc.newFixVersion)
assert.Equal(t, tc.expectedOutput, tc.fixVersionInfo.SuggestedFixedVersion)
})
}
}

func TestUpdatePackageVersion(t *testing.T) {
testProjectPath := filepath.Join("..", "testdata", "packagehandlers")
currDir, err := os.Getwd()
Expand Down
4 changes: 2 additions & 2 deletions scanpullrequest/scanpullrequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func prepareConfigAndClient(t *testing.T, xrayVersion, xscVersion string, server
return repository, client
}

func TestDeletePreviousPullRequestMessages(t *testing.T) {
func TestDeleteExistingPullRequestComments(t *testing.T) {
repository := &utils.Repository{
Params: utils.Params{
Git: utils.Git{
Expand Down Expand Up @@ -345,7 +345,7 @@ func TestDeletePreviousPullRequestMessages(t *testing.T) {
}
}

func TestDeletePreviousPullRequestReviewMessages(t *testing.T) {
func TestDeleteExistingPullRequestReviewComments(t *testing.T) {
repository := &utils.Repository{
Params: utils.Params{
Git: utils.Git{
Expand Down
2 changes: 1 addition & 1 deletion utils/analytics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestCreateAnalyticsGeneralEvent(t *testing.T) {
func TestCreateScanEvent(t *testing.T) {
gitInfoContext := &xscservices.XscGitInfoContext{
Source: xscservices.CommitContext{
GitRepoHttpsCloneUrl: "http://localhost:8080/my-user/my-project.git",
Expand Down
4 changes: 2 additions & 2 deletions utils/getconfiguration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
configProfileFile = filepath.Join("..", "testdata", "configprofile", "configProfileExample.json")
)

func TestExtractParamsFromEnvError(t *testing.T) {
func TestExtractJFrogCredentialsFromEnvs(t *testing.T) {
SetEnvAndAssert(t, map[string]string{
JFrogUrlEnv: "",
JFrogTokenEnv: "",
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestExtractVcsProviderFromEnv(t *testing.T) {
assert.Equal(t, vcsutils.AzureRepos, vcsProvider)
}

func TestExtractClientInfo(t *testing.T) {
func TestExtractGitParamsFromEnvs(t *testing.T) {
defer func() {
assert.NoError(t, SanitizeEnv())
}()
Expand Down
2 changes: 1 addition & 1 deletion utils/issues/issuescollection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func getTestData() ScansIssuesCollection {
return issuesCollection
}

func TestCountIssuesCollectionFindings(t *testing.T) {
func TestGetAllIssuesCount(t *testing.T) {
testCases := []struct {
name string
includeSecrets bool
Expand Down
20 changes: 20 additions & 0 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,26 @@ func TestUploadSbomSnapshotToGithubDependencyGraph(t *testing.T) {
}
}

func TestUpdateFixVersionIfMax(t *testing.T) {
type testCase struct {
fixVersionInfo VulnerabilityDetails
newFixVersion string
expectedOutput string
}

testCases := []testCase{
{fixVersionInfo: VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.2.4", expectedOutput: "1.2.4"},
{fixVersionInfo: VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.0.4", expectedOutput: "1.2.3"},
}

for _, tc := range testCases {
t.Run(tc.expectedOutput, func(t *testing.T) {
tc.fixVersionInfo.UpdateFixVersionIfMax(tc.newFixVersion)
assert.Equal(t, tc.expectedOutput, tc.fixVersionInfo.SuggestedFixedVersion)
})
}
}

func createTestSecurityCommandResults() *results.SecurityCommandResults {
// Create a simple BOM with components
components := []cyclonedx.Component{
Expand Down
Loading