Skip to content

Commit

Permalink
Add/update functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rsenden committed Jul 20, 2023
1 parent 6e3ccf4 commit 4aeb324
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ public class FcliSessionExtension implements IAnnotationDrivenExtension<FcliSess
}

private void visit(FcliSession annotation, SpecElementInfo elt) {
def handler = annotation.value().handler
if ( !elt.excluded && !elt.skipped ) {
if (handler.isEnabled() ) {
if ( !handler.login() ) {
elt.skip "Skipped due to "+handler.friendlyName()+" login failure"
annotation.value().each {
def handler = it.handler
if ( !elt.excluded && !elt.skipped ) {
if (handler.isEnabled() ) {
if ( !handler.login() ) {
elt.skip "Skipped due to "+handler.friendlyName()+" login failure"
}
} else {
elt.skip "No "+handler.friendlyName()+ " session available";
}
} else {
elt.skip "No "+handler.friendlyName()+ " session available";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ import com.fortify.cli.ftest._common.extension.FcliSessionExtension
@Retention(RUNTIME)
@ExtensionAnnotation(FcliSessionExtension.class)
@interface FcliSession {
FcliSessionType value()
FcliSessionType[] value()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright 2023 Open Text.
*
* The only warranties for products and services of Open Text
* and its affiliates and licensors ("Open Text") are as may
* be set forth in the express warranty statements accompanying
* such products and services. Nothing herein should be construed
* as constituting an additional warranty. Open Text shall not be
* liable for technical or editorial errors or omissions contained
* herein. The information contained herein is subject to change
* without notice.
*/
package com.fortify.cli.ftest.sc_dast

import static com.fortify.cli.ftest._common.spec.FcliSessionType.SCDAST
import static com.fortify.cli.ftest._common.spec.FcliSessionType.SCSAST

import com.fortify.cli.ftest._common.Fcli
import com.fortify.cli.ftest._common.spec.FcliBaseSpec
import com.fortify.cli.ftest._common.spec.FcliSession
import com.fortify.cli.ftest._common.spec.Prefix
import com.fortify.cli.ftest.ssc._common.SSCAppVersion

import spock.lang.AutoCleanup
import spock.lang.Shared

@Prefix("sc-sast.rest.call") @FcliSession(SCDAST)
class SCDastRestCallSpec extends FcliBaseSpec {
def "user-permissions"() {
def args = ["sc-dast", "rest", "call", "/api/v2/auth/user-permissions"]
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>0
it[0] == '---'
it[1].startsWith '-'
it.any { it =~ 'username' }
it.any { it =~ 'permissions' }
}
}

def "transform-no-paging"() {
def args = ["sc-dast", "rest", "call", "-X", "GET", "/api/v2/applications?limit=1", "--no-paging", '-t', 'items.![{x: id}]']
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()==2
it[0] == '---'
it[1].startsWith '- x:'
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2023 Open Text.
*
* The only warranties for products and services of Open Text
* and its affiliates and licensors ("Open Text") are as may
* be set forth in the express warranty statements accompanying
* such products and services. Nothing herein should be construed
* as constituting an additional warranty. Open Text shall not be
* liable for technical or editorial errors or omissions contained
* herein. The information contained herein is subject to change
* without notice.
*/
package com.fortify.cli.ftest.sc_sast

import static com.fortify.cli.ftest._common.spec.FcliSessionType.SCSAST

import com.fortify.cli.ftest._common.Fcli
import com.fortify.cli.ftest._common.spec.FcliBaseSpec
import com.fortify.cli.ftest._common.spec.FcliSession
import com.fortify.cli.ftest._common.spec.Prefix
import com.fortify.cli.ftest.ssc._common.SSCAppVersion

import spock.lang.AutoCleanup
import spock.lang.Shared

@Prefix("sc-sast.rest.call") @FcliSession(SCSAST)
class SCSastRestCallSpec extends FcliBaseSpec {
def "ping"() {
def args = ["sc-sast", "rest", "call", "/rest/v2/ping"]
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()==2
it[0] == '---'
it[1] =~ '- message: ".* I am still alive."'
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package com.fortify.cli.ftest.sc_sast;

import static com.fortify.cli.ftest._common.spec.FcliSessionType.SCSAST
import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC

import com.fortify.cli.ftest._common.Fcli
import com.fortify.cli.ftest._common.spec.FcliBaseSpec
import com.fortify.cli.ftest._common.spec.FcliSession
import com.fortify.cli.ftest._common.spec.Prefix
import com.fortify.cli.ftest.ssc._common.SSCAppVersion

@Prefix("sc-sast.scan") @FcliSession(SCSAST)
import spock.lang.AutoCleanup
import spock.lang.Shared

@Prefix("sc-sast.scan") @FcliSession([SCSAST, SSC])
class SCSastSensorSpec extends FcliBaseSpec {
@Shared @AutoCleanup SSCAppVersion version = new SSCAppVersion().create()

def "help"() {
def args = ["sc-sast", "scan", "-h"]
when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@ class SSCRestCallSpec extends FcliBaseSpec {
it.any { it =~ 'permissions' }
}
}

def "transform-no-paging"() {
def args = ["ssc", "rest", "call", "-X", "GET", "/api/v1/events?limit=1", "--no-paging", '-t', 'data.![{x: id}]']
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()==2
it[0] == '---'
it[1].startsWith '- x:'
}
}
}

0 comments on commit 4aeb324

Please sign in to comment.