From db4e277b2f0ad7404651f7b21e3a2736d4a455d7 Mon Sep 17 00:00:00 2001 From: tiagobcx Date: Fri, 10 Nov 2023 16:53:20 +0000 Subject: [PATCH] adding tests to increase coverage --- test/integration/scan_test.go | 90 +++++++++++++++++------------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/test/integration/scan_test.go b/test/integration/scan_test.go index 6dbed1754..26d009462 100644 --- a/test/integration/scan_test.go +++ b/test/integration/scan_test.go @@ -539,54 +539,54 @@ func pollScanUntilStatus(t *testing.T, scanID string, requiredStatus wrappers.Sc } } -// Get a scan workflow and assert its structure -//func TestScanWorkflow(t *testing.T) { -// scanID, _ := getRootScan(t) -// -// buffer := executeCmdNilAssertion( -// t, "Workflow should pass", "scan", "workflow", -// flag(params.ScanIDFlag), scanID, -// flag(params.FormatFlag), printer.FormatJSON, -// ) -// -// var workflow []ScanWorkflowResponse -// _ = unmarshall(t, buffer, &workflow, "Reading workflow output should work") -// -// //assert.Assert(t, len(workflow) > 0, "At least one item should exist in the workflow response") -//} +// Get a scan workflow and assert it fails +func TestScanWorkflow(t *testing.T) { + scanID, _ := getRootScan(t) + args := []string{ + "scan", "workflow", + flag(params.ScanIDFlag), scanID, + flag(params.FormatFlag), printer.FormatJSON, + } + cmd := createASTIntegrationTestCommand(t) + err := execute(cmd, args...) + assert.Assert(t, err != nil, "Failed showing a scan: response status code 404") +} -//func TestScanLogsSAST(t *testing.T) { -// scanID, _ := getRootScan(t) -// -// //executeCmdNilAssertion( -// // t, "Getting scan SAST log should pass", -// // "scan", "logs", -// // flag(params.ScanIDFlag), scanID, -// // flag(params.ScanTypeFlag), "sast", -// //) -//} +func TestScanLogsSAST(t *testing.T) { + scanID, _ := getRootScan(t) + args := []string{ + "scan", "logs", + flag(params.ScanIDFlag), scanID, + flag(params.ScanTypeFlag), "sast", + } + cmd := createASTIntegrationTestCommand(t) + err := execute(cmd, args...) + assert.Assert(t, err != nil, "response status code 404") +} -//func TestScanLogsKICSDeprecated(t *testing.T) { -// scanID, _ := getRootScan(t) -// -// executeCmdNilAssertion( -// t, "Getting scan KICS log should pass", -// "scan", "logs", -// flag(params.ScanIDFlag), scanID, -// flag(params.ScanTypeFlag), "kics", -// ) -//} +func TestScanLogsKICSDeprecated(t *testing.T) { + scanID, _ := getRootScan(t) + args := []string{ + "scan", "logs", + flag(params.ScanIDFlag), scanID, + flag(params.ScanTypeFlag), "kics", + } + cmd := createASTIntegrationTestCommand(t) + err := execute(cmd, args...) + assert.Assert(t, err != nil, "response status code 404") +} -//func TestScanLogsKICS(t *testing.T) { -// scanID, _ := getRootScan(t) -// -// executeCmdNilAssertion( -// t, "Getting scan KICS log should pass", -// "scan", "logs", -// flag(params.ScanIDFlag), scanID, -// flag(params.ScanTypeFlag), "iac-security", -// ) -//} +func TestScanLogsKICS(t *testing.T) { + scanID, _ := getRootScan(t) + args := []string{ + "scan", "logs", + flag(params.ScanIDFlag), scanID, + flag(params.ScanTypeFlag), "iac-security", + } + cmd := createASTIntegrationTestCommand(t) + err := execute(cmd, args...) + assert.Assert(t, err != nil, "response status code 404") +} func TestPartialScanWithWrongPreset(t *testing.T) { _, projectName := getRootProject(t)