Skip to content

Commit

Permalink
Merge pull request #481 from psmf22/develop
Browse files Browse the repository at this point in the history
FoD test updates
  • Loading branch information
psmf22 authored Nov 29, 2023
2 parents fd1b63b + c8d678f commit 51861c8
Show file tree
Hide file tree
Showing 7 changed files with 390 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.fortify.cli.ftest.fod;

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

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.fod._common.FoDWebAppSupplier
import com.fortify.cli.ftest.fod._common.FoDUserSupplier
import com.fortify.cli.ftest.fod._common.FoDUserGroupSupplier

import spock.lang.AutoCleanup
import spock.lang.Shared
import spock.lang.Stepwise
import spock.lang.Unroll

@Prefix("fod.role") @FcliSession(FOD) @Stepwise
class FoDAccessControlRoleSpec extends FcliBaseSpec {
@Shared @AutoCleanup FoDUserSupplier user = new FoDUserSupplier()
@Shared @AutoCleanup FoDUserGroupSupplier group = new FoDUserGroupSupplier()
@Shared @AutoCleanup FoDWebAppSupplier app = new FoDWebAppSupplier()

def "list"() {
def args = "fod ac list-roles --store roles"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>=2
it[0].replace(' ', '').equals("IdName")
}
}

def "updateUserRole"() {
def args = "fod ac update-user ${user.get().userName} --lastname updatedLastname --firstname updatedFirstname --phone 5678 --role=Developer"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()==2
}
}

def "verifyUpdated"() {

def args = "fod ac get-user ${user.get().userName}"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>2
it[9].equals("roleName: \"Developer\"")
}
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import spock.lang.Stepwise

@Prefix("fod.app") @FcliSession(FOD) @Stepwise
class FoDAppSpec extends FcliBaseSpec {
/*
@Shared FoDWebAppSupplier webAppSupplier = null;
@Shared FoDMobileAppSupplier mobileAppSupplier = null;
@Shared FoDMicroservicesAppSupplier microservicesAppSupplier = null;

@Shared FoDWebAppSupplier webApp = new FoDWebAppSupplier();
@Shared FoDMobileAppSupplier mobileApp = new FoDMobileAppSupplier();
@Shared FoDMicroservicesAppSupplier microservicesApp = new FoDMicroservicesAppSupplier();
@Shared FoDWebApp

def "list"() {
def args = "fod app list"
def args = "fod app list --store=apps"
when:
def result = Fcli.run(args)
then:
Expand All @@ -35,96 +36,111 @@ class FoDAppSpec extends FcliBaseSpec {
}
}

def "list-scans"() {
def args = "fod app list-scans --app=::apps::get(0).applicationId"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>=0
if(size()>1) {
it[0].replace(' ', '').equals("IdTypeAnalysisStatusNameMicroserviceReleaseStartedCompletedScanMethod")
} else {
it[0].equals("No data")
}
}
}

def "createWebApp"() {
when:
webApp = new FoDWebAppSupplier().createWebApp();
webApp.get();
then:
noExceptionThrown()
}

def "createMicroserviceApp"() {
when:
microservicesApp = new FoDWebAppSupplier().createMicroservicesApp();
microservicesApp.get();
then:
noExceptionThrown()
}

def "createMobileApp"() {
when:
mobileApp = new FoDWebAppSupplier().createMobileApp();
mobileApp.get();
then:
noExceptionThrown()
}

def "get.byIdWebApp"() {
def args = "fod app get " + webApp.get("applicationId")
def args = "fod app get " + webApp.get().get("applicationId")
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>2
it[2].equals("applicationName: \"" + webApp.appName + ":" + webApp.versionName +"\"")
it[2].equals("applicationName: \"" + webApp.get().appName + "\"")
}
}

def "get.byIdMobileApp"() {
def args = "fod app get " + mobileApp.get("applicationId")
def args = "fod app get " + mobileApp.get().get("applicationId")
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>2
it[2].equals("applicationName: \"" + mobileApp.appName + ":" + mobileApp.versionName +"\"")
it[2].equals("applicationName: \"" + mobileApp.get().appName + "\"")
}
}

def "get.byIdMicroservicesApp"() {
def args = "fod app get " + microservicesApp.get("applicationId")
def args = "fod app get " + microservicesApp.get().get("applicationId")
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>2
it[2].equals("applicationName: \"" + microservicesApp.appName + ":" + microservicesApp.versionName +"\"")
it[2].equals("applicationName: \"" + microservicesApp.get().appName + "\"")
}
}

def "get.byNameWebApp"() {
def args = "fod app get " + webApp.appName
def args = "fod app get " + webApp.get().appName
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>2
it[1].startsWith("applicationId: " + webApp.get("applicationId"))
it[1].startsWith("applicationId: " + webApp.get().get("applicationId"))
}
}

def "get.byNameMobileApp"() {
def args = "fod app get " + mobileApp.appName
def args = "fod app get " + mobileApp.get().appName
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>2
it[1].startsWith("applicationId: " + mobileApp.get("applicationId"))
it[1].startsWith("applicationId: " + mobileApp.get().get("applicationId"))
}
}

def "get.byNameMicroservicesApp"() {
def args = "fod app get " + microservicesApp.appName
def args = "fod app get " + microservicesApp.get().appName
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>2
it[1].startsWith("applicationId: " + microservicesApp.get("applicationId"))
it[1].startsWith("applicationId: " + microservicesApp.get().get("applicationId"))
}
}


def "update"() {
def args = "fod app update " + webApp.appName + " --business-criticality High"
def args = "fod app update " + webApp.get().appName + " --business-criticality High"
when:
def result = Fcli.run(args)
then:
Expand All @@ -134,7 +150,7 @@ class FoDAppSpec extends FcliBaseSpec {
}

def "verifyUpdated"() {
def args = "fod app get " + webApp.get("applicationId")
def args = "fod app get " + webApp.get().get("applicationId")
when:
def result = Fcli.run(args)
then:
Expand Down Expand Up @@ -170,12 +186,12 @@ class FoDAppSpec extends FcliBaseSpec {
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
!it.any { it.contains(webApp.appName) }
!it.any { it.contains(microservicesApp.appName) }
!it.any { it.contains(mobileApp.appName) }
!it.any { it.contains(webApp.get().appName) }
!it.any { it.contains(microservicesApp.get().appName) }
!it.any { it.contains(mobileApp.get().appName) }
}
}
*/


}

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FoDReleaseSpec extends FcliBaseSpec {
@Shared @AutoCleanup FoDMicroservicesAppSupplier app = new FoDMicroservicesAppSupplier()

def "list"() {
def args = "fod release list"
def args = "fod release list --store=releases"
when:
def result = Fcli.run(args)
then:
Expand All @@ -26,6 +26,36 @@ class FoDReleaseSpec extends FcliBaseSpec {
it[0].replace(' ', '').equals("IdNameMicroserviceApplicationSDLCStatus")
}
}

def "list-scans"() {
def args = "fod release list-scans --rel=::releases::get(0).releaseId"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>=0
if(size()>1) {
it[0].replace(' ', '').equals("IdTypeAnalysisStatusApplicationMicroserviceNameStartedCompletedScanMethod")
} else {
it[0].equals("No data")
}
}
}

def "list-assessment-types"() {
def args = "fod release lsat --rel=::releases::get(0).releaseId"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>=0
if(size()>1) {
it[0].replace(' ', '').equals("IdNameScantypeFrequencytypeUnitsEntitlementidEntitlementdescription")
} else {
it[0].equals("No data")
}
}
}

def "create"() {
def args = "fod release create ${app.get().qualifiedMicroserviceName}:testrel --sdlc-status=Development --store testrel"
Expand Down
Loading

0 comments on commit 51861c8

Please sign in to comment.