Skip to content

Commit

Permalink
Merge pull request #437 from psmf22/develop
Browse files Browse the repository at this point in the history
chore: fixed tests
  • Loading branch information
rsenden authored Sep 19, 2023
2 parents 76f0652 + e6ab344 commit dec7037
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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:
Expand Down Expand Up @@ -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
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dec7037

Please sign in to comment.