Skip to content

Commit

Permalink
ftest: Add test for sc-sast scan --sargs arguments (#646)
Browse files Browse the repository at this point in the history
Co-authored-by: Shajaan Shahul <[email protected]>
  • Loading branch information
shajaan and Shajaan Shahul authored Nov 19, 2024
1 parent 5fd18f0 commit 1f7c9b6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import spock.lang.Stepwise
class SCSastScanSpec extends FcliBaseSpec {
@Shared @TestResource("runtime/shared/EightBall-package.zip") String packageZip
@Shared @TestResource("runtime/shared/EightBall-22.1.0.mbs") String packageMbs
@Shared @TestResource("runtime/shared/Filter.txt") String fileFilter
String user = System.getProperty('ft.ssc.user');
String pass = System.getProperty('ft.ssc.password');

Expand All @@ -46,44 +47,51 @@ class SCSastScanSpec extends FcliBaseSpec {
verifyAll(result.stdout) {
size()>1
it[0].replace(' ', '').equals("HostnameStatePoolnameIpaddressScaversionLastseenSensorstarttime")

}
}


def "extractHighestVersionSensor"() {
def args = "util variable contents sensors -q uuid==#var('sensors').get(#var('sensors').size()-1).uuid --store highestSensor"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>=2
it[0].replace(' ', '').equals("UuidProcessuuidStateWorkerstarttimeWorkerexpirytimeLastseenLastactivityIpaddressHostnameScaversionVmnameAvailableprocessorsTotalphysicalmemoryOsnameOsversionOsarchitectureCloudpooluuidCloudpoolpathCloudpoolnameCloudpooldescriptionCloudpoolchildofglobalpoolCloudpoolisdeletableCloudpoolstatsHref")

}
}


def "startScan"() {
def args = "sc-sast scan start -v ::highestSensor::get(0).scaVersion -p=$packageZip --store upload"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()==2
it[0].replace(' ', '').equals("JobtokenHasfilesScanstatePublishstateSscprocessingstateEndpointversionAction")
}
}

def "wait-for"() {
// Depending on externalmetadata versions in FPR and on SSC, approval
// may be required
def args = "sc-sast scan wait-for ::upload:: -i 2s --until=all-match --any-scan-state=COMPLETED,CANCELLED,FAILED,RUNNING"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
//
it[0].replace(' ', '').equals("UuidProcessuuidStateWorkerstarttimeWorkerexpirytimeLastseenLastactivityIpaddressHostnameScaversionVmnameAvailableprocessorsTotalphysicalmemoryOsnameOsversionOsarchitectureCloudpooluuidCloudpoolpathCloudpoolnameCloudpooldescriptionCloudpoolchildofglobalpoolCloudpoolisdeletableCloudpoolstatsSensorversionHref")
}
}

def "startScanFilter"() {
def args = "sc-sast scan start -v ::highestSensor::get(0).scaVersion -p=$packageZip --sargs -quick\\ -filter\\ file:$fileFilter --store scanfilter"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()==2
it[0].replace(' ', '').equals("JobtokenHasfilesScanstatePublishstateSscprocessingstateEndpointversionAction")
}
}

def "wait-for"() {
// Depending on externalmetadata versions in FPR and on SSC, approval
// may be required
def args = "sc-sast scan wait-for ::scanfilter:: -i 2s --until=all-match --any-scan-state=COMPLETED,CANCELLED,FAILED"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
//
}
}

def "verifyScanRule"() {
def args = "ssc rest call ::scanfilter::'/api/v1/cloudjobs/'+jobToken -o expr={scaArgs}"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
it[0].contains("-quick")
it[0].contains("-filter")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#This is a category to filter from scan output
Unchecked Return Value
9C5BD1B5-C296-48d4-B5F5-5D2958661BC4

0 comments on commit 1f7c9b6

Please sign in to comment.