Skip to content

Commit

Permalink
fix audit tests for xray-url - with jas - test
Browse files Browse the repository at this point in the history
  • Loading branch information
hadarshjfrog committed Oct 28, 2024
1 parent 6ea39e4 commit 3e17308
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
22 changes: 20 additions & 2 deletions audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,9 @@ func TestXrayAuditNotEntitledForJasWithXrayUrl(t *testing.T) {
}

func TestXrayAuditJasSimpleJsonWithXrayUrl(t *testing.T) {
output := testXrayAuditJas(t, securityTests.PlatformCli, filepath.Join("jas", "jas"), "3", false, false)
validations.VerifySimpleJsonResults(t, output, validations.ValidationParams{Vulnerabilities: 8})
cliToRun, cleanUp := securityTestUtils.InitTestWithMockCommandOrParams(t, true, getRealAuditCommand)
defer cleanUp()
output := testXrayAuditJas(t, cliToRun, filepath.Join("jas", "jas"), "3", false, false)
validations.VerifySimpleJsonResults(t, output, validations.ValidationParams{
Sast: 1,
Iac: 9,
Expand All @@ -767,3 +768,20 @@ func TestXrayAuditJasSimpleJsonWithXrayUrl(t *testing.T) {
NotApplicable: 2,
})
}

func getRealAuditCommand() components.Command {
return components.Command{
Name: docs.Audit,
Flags: docs.GetCommandFlags(docs.Audit),
Category: "Security",
Action: cli.AuditCmd,
}
}

//func getRealAuditCommand() []components.Command {
// var cmds []components.Command
// for i := range cli.GetJfrogCliSecurityApp().Subcommands {
// cmds = append(cmds, cli.GetJfrogCliSecurityApp().Subcommands[i].Commands...)
// }
// return cmds
//}
3 changes: 2 additions & 1 deletion jas/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ func CreateJasScanner(serverDetails *config.ServerDetails, validateSecrets bool,
if len(serverDetails.Url) == 0 {
if len(serverDetails.XrayUrl) != 0 {
log.Debug("Xray URL provided without platform URL")
} else {
log.Warn(NoServerUrlWarn)
}
if len(serverDetails.ArtifactoryUrl) != 0 {
log.Debug("Artifactory URL provided without platform URL")
}
log.Warn(NoServerUrlWarn)
return
}
scanner = &JasScanner{}
Expand Down

0 comments on commit 3e17308

Please sign in to comment.