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 } } 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: