From ae94e057dd8fdbe369c8eac4c6dc21b87fea3fad Mon Sep 17 00:00:00 2001 From: psmf22 <117990501+psmf22@users.noreply.github.com> Date: Tue, 19 Sep 2023 17:58:54 +0200 Subject: [PATCH 1/2] chore: update FoDReleaseImportSpec add wait function to avoid errors on autoCleanup --- .../cli/ftest/fod/FoDReleaseImportSpec.groovy | 56 ++++++++++++++++--- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDReleaseImportSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDReleaseImportSpec.groovy index 683b4bb8f0..4526a38ca9 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDReleaseImportSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDReleaseImportSpec.groovy @@ -9,9 +9,11 @@ import com.fortify.cli.ftest._common.spec.Prefix import com.fortify.cli.ftest._common.spec.TestResource import com.fortify.cli.ftest.fod._common.FoDMobileAppSupplier import com.fortify.cli.ftest.fod._common.FoDWebAppSupplier - +import groovy.time.TimeDuration import spock.lang.AutoCleanup import spock.lang.Shared +import org.hamcrest.Matchers +import org.hamcrest.collection.ArrayMatching @Prefix("fod.import-scan") @FcliSession(FOD) class FoDReleaseImportSpec extends FcliBaseSpec { @@ -23,6 +25,17 @@ class FoDReleaseImportSpec extends FcliBaseSpec { @Shared @AutoCleanup FoDMobileAppSupplier mobileApp = new FoDMobileAppSupplier() + def "import-mobile"() { + def args = "fod release import-mobile --release ${mobileApp.get().qualifiedRelease} $mobileResults --store upload" + when: + def result = Fcli.run(args) + then: + verifyAll(result.stdout) { + size()>2 + it.last().contains("IMPORT_REQUESTED") + } + } + def "import-sast"() { def args = "fod release import-sast --release ${webApp.get().qualifiedRelease} $sastResults --store upload" when: @@ -56,15 +69,44 @@ class FoDReleaseImportSpec extends FcliBaseSpec { } } - def "import-mobile"() { - def args = "fod release import-mobile --release ${mobileApp.get().qualifiedRelease} $mobileResults --store upload" + def "waitForScans"() { when: - def result = Fcli.run(args) + def relScanurl = Fcli.run("fod release get ${webApp.get().qualifiedRelease} -o expr=/api/v3/releases/{releaseId}/scans --store relId").stdout[0] + def timeoutMs = 60000 + def start = System.currentTimeMillis() + def success = false; + while(true){ + def result = Fcli.run("fod rest call ${relScanurl}") + if(result.stdout.findAll{element -> element.contains("analysisStatusType: \"Completed\"")}.size()==3) { + success=true; + break; + } else if(System.currentTimeMillis()-start > timeoutMs) { + break; + } + sleep(3000) + } then: - verifyAll(result.stdout) { - size()>2 - it.last().contains("IMPORT_REQUESTED") + success + } + + def "waitForScans2"() { + when: + def relScanurl = Fcli.run("fod release get ${mobileApp.get().qualifiedRelease} -o expr=/api/v3/releases/{releaseId}/scans --store relId").stdout[0] + def timeoutMs = 60000 + def start = System.currentTimeMillis() + def success = false; + while(true){ + def result = Fcli.run("fod rest call ${relScanurl}") + if(result.stdout.findAll{element -> element.contains("analysisStatusType: \"Completed\"")}.size()==1) { + success=true; + break; + } else if(System.currentTimeMillis()-start > timeoutMs) { + break; + } + sleep(3000) } + then: + success } } From e6ab344d71dd32de746a8e0ff97239c4f2709802 Mon Sep 17 00:00:00 2001 From: psmf22 <117990501+psmf22@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:25:24 +0200 Subject: [PATCH 2/2] chore: update SCSastScanSpec added filter condition to exclude sensors not assigned to a cloudpool --- .../groovy/com/fortify/cli/ftest/sc_sast/SCSastScanSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_sast/SCSastScanSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_sast/SCSastScanSpec.groovy index 15ee2a7720..845af96791 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_sast/SCSastScanSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_sast/SCSastScanSpec.groovy @@ -39,7 +39,7 @@ class SCSastScanSpec extends FcliBaseSpec { } def "listSensors"() { - def args = "sc-sast sensor list -q state=='ACTIVE' --store sensors" + def args = "sc-sast sensor list -q state=='ACTIVE'&&cloudPool!=null --store sensors" when: def result = Fcli.run(args) then: