Skip to content

Commit

Permalink
Improve Audit result table views
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Sverdlov <[email protected]>
  • Loading branch information
sverdlov93 committed Aug 30, 2023
1 parent 01d650c commit 294eda0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion xray/audit/go/gloang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestBuildGoDependencyList(t *testing.T) {
}
rootNode, uniqueDeps, err := BuildDependencyTree(server, "test-remote")
assert.NoError(t, err)
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps)
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps, "First is actual, Second is Expected")

assert.Equal(t, "https://user:[email protected]/artifactoryapi/go/test-remote|direct", os.Getenv("GOPROXY"))
assert.NotEmpty(t, rootNode)
Expand Down
14 changes: 7 additions & 7 deletions xray/audit/java/gradle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ func TestGradleTreesExcludeTestDeps(t *testing.T) {
// Run getModulesDependencyTrees
modulesDependencyTrees, uniqueDeps, err := buildGradleDependencyTree(&DependencyTreeParams{UseWrapper: true})
if assert.NoError(t, err) && assert.NotNil(t, modulesDependencyTrees) {
assert.Len(t, modulesDependencyTrees, 3)
assert.Len(t, modulesDependencyTrees, 2)
assert.Len(t, uniqueDeps, 11)
// Check direct dependency
directDependency := audit.GetAndAssertNode(t, modulesDependencyTrees, "services")
directDependency := audit.GetAndAssertNode(t, modulesDependencyTrees, "api")
assert.Empty(t, directDependency.Nodes)
}
}
Expand Down Expand Up @@ -178,9 +178,9 @@ func TestGetGraphFromDepTree(t *testing.T) {
}()
assert.NoError(t, os.Chmod(filepath.Join(tempDirPath, "gradlew"), 0700))
testCase := struct {
name string
expectedTree map[string]map[string]string
expectedUnique []string
name string
expectedTree map[string]map[string]string
expectedUniqueDeps []string
}{
name: "ValidOutputFileContent",
expectedTree: map[string]map[string]string{
Expand All @@ -202,7 +202,7 @@ func TestGetGraphFromDepTree(t *testing.T) {
GavPackageTypeIdentifier + "commons-lang:commons-lang:2.4": "",
},
},
expectedUnique: []string{
expectedUniqueDeps: []string{
GavPackageTypeIdentifier + "webservice",
GavPackageTypeIdentifier + "junit:junit:4.11",
GavPackageTypeIdentifier + "commons-io:commons-io:1.2",
Expand All @@ -222,7 +222,7 @@ func TestGetGraphFromDepTree(t *testing.T) {
assert.NoError(t, err)
depTree, uniqueDeps, err := (&depTreeManager{}).getGraphFromDepTree(outputFileContent)
assert.NoError(t, err)
assert.ElementsMatch(t, uniqueDeps, testCase.expectedUnique)
assert.ElementsMatch(t, uniqueDeps, testCase.expectedUniqueDeps, "First is actual, Second is Expected")

for _, dependency := range depTree {
depChild, exists := testCase.expectedTree[dependency.Id]
Expand Down
4 changes: 2 additions & 2 deletions xray/audit/java/mvn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestMavenTreesMultiModule(t *testing.T) {
// Run getModulesDependencyTrees
modulesDependencyTrees, uniqueDeps, err := buildMvnDependencyTree(&DependencyTreeParams{IgnoreConfigFile: true})
if assert.NoError(t, err) && assert.NotEmpty(t, modulesDependencyTrees) {
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps)
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps, "First is actual, Second is Expected")
// Check root module
multi := audit.GetAndAssertNode(t, modulesDependencyTrees, "org.jfrog.test:multi:3.7-SNAPSHOT")
if assert.NotNil(t, multi) {
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestMavenWrapperTrees(t *testing.T) {

modulesDependencyTrees, uniqueDeps, err := buildMvnDependencyTree(&DependencyTreeParams{IgnoreConfigFile: true, UseWrapper: true})
if assert.NoError(t, err) && assert.NotEmpty(t, modulesDependencyTrees) {
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps)
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps, "First is actual, Second is Expected")
// Check root module
multi := audit.GetAndAssertNode(t, modulesDependencyTrees, "org.jfrog.test:multi:3.7-SNAPSHOT")
if assert.NotNil(t, multi) {
Expand Down
2 changes: 1 addition & 1 deletion xray/audit/npm/npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestParseNpmDependenciesList(t *testing.T) {
for _, dep := range dependencies {
expectedUniqueDeps = append(expectedUniqueDeps, npmPackageTypeIdentifier+dep.Id)
}
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps)
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps, "First is actual, Second is Expected")

}

Expand Down
2 changes: 1 addition & 1 deletion xray/audit/nuget/nuget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestBuildNugetDependencyTree(t *testing.T) {
nugetPackageTypeIdentifier + "MsbuildLibrary",
}
xrayDependenciesTree, uniqueDeps := parseNugetDependencyTree(dependencies)
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps)
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps, "First is actual, Second is Expected")
expectedTreeJson, err := os.ReadFile("expectedTree.json")
assert.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions xray/audit/python/python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestBuildPipenvDependencyList(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.ElementsMatch(t, uniqueDeps, expectedPipenvUniqueDeps)
assert.ElementsMatch(t, uniqueDeps, expectedPipenvUniqueDeps, "First is actual, Second is Expected")
assert.Len(t, rootNode, 1)
if len(rootNode) > 0 {
assert.NotEmpty(t, rootNode[0].Nodes)
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestBuildPoetryDependencyList(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.ElementsMatch(t, uniqueDeps, expectedPoetryUniqueDeps)
assert.ElementsMatch(t, uniqueDeps, expectedPoetryUniqueDeps, "First is actual, Second is Expected")
assert.Len(t, rootNode, 1)
if len(rootNode) > 0 {
assert.NotEmpty(t, rootNode[0].Nodes)
Expand Down
2 changes: 1 addition & 1 deletion xray/audit/yarn/yarn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ func TestParseYarnDependenciesList(t *testing.T) {
}

xrayDependenciesTree, uniqueDeps := parseYarnDependenciesMap(yarnDependencies, rootXrayId)
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps)
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps, "First is actual, Second is Expected")
assert.True(t, tests.CompareTree(expectedTree, xrayDependenciesTree), "expected:", expectedTree.Nodes, "got:", xrayDependenciesTree.Nodes)
}

0 comments on commit 294eda0

Please sign in to comment.