Skip to content

Commit

Permalink
fix audit tests for xray-url
Browse files Browse the repository at this point in the history
  • Loading branch information
hadarshjfrog committed Oct 15, 2024
1 parent 1dc43c1 commit ce26432
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,10 @@ func TestAuditOnEmptyProject(t *testing.T) {
securityTestUtils.VerifySimpleJsonJasResults(t, output, 0, 0, 0, 0, 0, 0, 0, 0, 0)
}

// xray-url only
// xray-url only - the following tests check the case of adding "xray-url", instead of "url", which is the more common one

func TestXrayAuditNotEntitledForJasWithXrayUrl(t *testing.T) {
cliToRun, cleanUp := securityTestUtils.InitTestWithMockCommandOrParams(t, true, getNoJasAuditMockCommandWithXrayUrl)
cliToRun, cleanUp := securityTestUtils.InitTestWithMockCommandOrParams(t, true, getNoJasAuditMockCommand)
defer cleanUp()
output := testXrayAuditJas(t, cliToRun, filepath.Join("jas", "jas"), "3", false)
// Verify that scan results are printed
Expand All @@ -682,24 +682,10 @@ func TestXrayAuditNotEntitledForJasWithXrayUrl(t *testing.T) {
securityTestUtils.VerifySimpleJsonJasResults(t, output, 0, 0, 0, 0, 0, 0, 0, 0, 0)
}

func getNoJasAuditMockCommandWithXrayUrl() components.Command {
return components.Command{
Name: docs.Audit,
Flags: docs.GetCommandFlags(docs.Audit),
Action: func(c *components.Context) error {
auditCmd, err := cli.CreateAuditCmd(c)
if err != nil {
return err
}
// Disable Jas for this test
auditCmd.SetUseJas(false)
return progressbar.ExecWithProgress(auditCmd)
},
}
}

func TestXrayAuditJasSimpleJsonWithXrayUrl(t *testing.T) {
output := testXrayAuditJas(t, securityTests.PlatformCli, filepath.Join("jas", "jas"), "3", false)
cliToRun, cleanUp := securityTestUtils.InitTestWithMockCommandOrParams(t, true, getNoJasAuditMockCommand)
defer cleanUp()
output := testXrayAuditJas(t, cliToRun, filepath.Join("jas", "jas"), "3", false)
securityTestUtils.VerifySimpleJsonScanResults(t, output, 0, 8, 0)
securityTestUtils.VerifySimpleJsonJasResults(t, output, 1, 9, 6, 3, 1, 1, 2, 0, 0)
}

0 comments on commit ce26432

Please sign in to comment.