From 9749c7fb489be5af1215335e5e1e1428697335bb Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:12:43 +0100 Subject: [PATCH] ftest: Refactoring --- .../com/fortify/cli/ftest/_common/Fcli.groovy | 11 +- .../extension/AbstractTempDirExtension.groovy | 70 ------ .../extension/DisplayNameExtension.groovy | 22 -- .../extension/FcliGlobalExtension.groovy | 179 ++++++++++++++ .../extension/FcliInitializerExtension.groovy | 22 -- .../extension/FcliSessionExtension.groovy | 35 --- .../extension/SkipFeaturesExtension.groovy | 30 --- .../extension/TempPathExtension.groovy | 35 --- .../extension/TestResourceExtension.groovy | 32 --- .../cli/ftest/_common/spec/FcliSession.groovy | 229 +++++++++++++++++- .../ftest/_common/spec/FcliSessionType.groovy | 229 ------------------ .../cli/ftest/_common/spec/Global.groovy | 19 ++ .../util/RuntimeResourcesHelper.groovy | 48 ---- .../ftest/_common/util/TempDirHelper.groovy | 37 --- .../ftest/_common/util/WorkDirHelper.groovy | 117 +++++++++ .../cli/ftest/config/ConfigProxySpec.groovy | 6 +- .../ftest/config/ConfigTrustStoreSpec.groovy | 6 +- .../fod/FoDAccessControlGroupSpec.groovy | 2 +- .../ftest/fod/FoDAccessControlRoleSpec.groovy | 2 +- .../ftest/fod/FoDAccessControlUserSpec.groovy | 2 +- .../fortify/cli/ftest/fod/FoDAppSpec.groovy | 2 +- .../cli/ftest/fod/FoDMicroserviceSpec.groovy | 2 +- .../cli/ftest/fod/FoDReleaseSpec.groovy | 2 +- .../fortify/cli/ftest/fod/FoDRestSpec.groovy | 2 +- .../cli/ftest/fod/FoDScanImportSpec.groovy | 2 +- .../fortify/cli/ftest/fod/FoDScanSpec.groovy | 2 +- .../ftest/sc_dast/SCDastRestCallSpec.groovy | 4 +- .../cli/ftest/sc_dast/SCDastSensorSpec.groovy | 2 +- .../ftest/sc_sast/SCSastRestCallSpec.groovy | 2 +- .../cli/ftest/sc_sast/SCSastScanSpec.groovy | 4 +- .../SSCAccessControlAppVersionUserSpec.groovy | 7 +- .../ssc/SSCAccessControlPermissionSpec.groovy | 2 +- .../ftest/ssc/SSCAccessControlRoleSpec.groovy | 2 +- ...SSCAccessControlTokenDefinitionSpec.groovy | 2 +- .../ssc/SSCAccessControlTokenSpec.groovy | 2 +- .../ftest/ssc/SSCAccessControlUserSpec.groovy | 2 +- .../ftest/ssc/SSCAlertDefinitionSpec.groovy | 2 +- .../fortify/cli/ftest/ssc/SSCAlertSpec.groovy | 2 +- .../fortify/cli/ftest/ssc/SSCAppSpec.groovy | 2 +- .../cli/ftest/ssc/SSCAppVersionSpec.groovy | 2 +- .../ftest/ssc/SSCArtifactUploadSpec.groovy | 7 +- .../ssc/SSCAttributeDefinitionSpec.groovy | 2 +- .../cli/ftest/ssc/SSCAttributeSpec.groovy | 5 +- .../ftest/ssc/SSCIssueFilterSetSpec.groovy | 5 +- .../cli/ftest/ssc/SSCIssueTemplateSpec.groovy | 9 +- .../cli/ftest/ssc/SSCPluginSpec.groovy | 2 +- .../cli/ftest/ssc/SSCReportSpec.groovy | 21 +- .../ftest/ssc/SSCReportTemplateSpec.groovy | 2 +- .../cli/ftest/ssc/SSCRestCallSpec.groovy | 2 +- .../ssc/SSCSystemStateActivitySpec.groovy | 5 +- .../ftest/ssc/SSCSystemStateEventSpec.groovy | 5 +- .../ftest/ssc/SSCSystemStateJobSpec.groovy | 2 +- .../fortify/cli/ftest/ssc/SSCTestSpec.groovy | 35 --- .../ssc/_common/SSCAppVersionSupplier.groovy | 59 ++++- .../cli/ftest/ssc/_common/SSCGlobal.groovy | 60 ----- .../cli/ftest/tool/ToolDefinitionsSpec.groovy | 2 +- ...amework.runtime.extension.IGlobalExtension | 7 +- 57 files changed, 670 insertions(+), 742 deletions(-) delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/AbstractTempDirExtension.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/DisplayNameExtension.groovy create mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliGlobalExtension.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliInitializerExtension.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliSessionExtension.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/SkipFeaturesExtension.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/TempPathExtension.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/TestResourceExtension.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/FcliSessionType.groovy create mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/Global.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/RuntimeResourcesHelper.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/TempDirHelper.groovy create mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/WorkDirHelper.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCTestSpec.groovy delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/_common/SSCGlobal.groovy diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/Fcli.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/Fcli.groovy index 0d4db840fe..3d198a68be 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/Fcli.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/Fcli.groovy @@ -1,12 +1,11 @@ package com.fortify.cli.ftest._common; -import java.nio.file.Files import java.nio.file.Path import org.spockframework.runtime.IStandardStreamsListener import org.spockframework.runtime.StandardStreamsCapturer -import com.fortify.cli.ftest._common.util.TempDirHelper +import com.fortify.cli.ftest._common.util.WorkDirHelper import groovy.transform.CompileStatic import groovy.transform.Immutable @@ -17,11 +16,10 @@ public class Fcli { private static IRunner runner private static Set stringsToMask = [] - static void initialize() { + static void initialize(Path fortifyDataDir) { System.setProperty("picocli.ansi", "false") - fcliDataDir = TempDirHelper.create() - System.setProperty("fcli.env.FORTIFY_DATA_DIR", fcliDataDir.toString()) - println("Using fcli data directory "+fcliDataDir) + System.setProperty("fcli.env.FORTIFY_DATA_DIR", fortifyDataDir.toString()) + println("Using fcli data directory "+fortifyDataDir) runner = createRunner() } @@ -105,7 +103,6 @@ public class Fcli { if ( runner ) { runner.close() } - TempDirHelper.rm(fcliDataDir) } private static IRunner createRunner() { diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/AbstractTempDirExtension.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/AbstractTempDirExtension.groovy deleted file mode 100644 index 196b102510..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/AbstractTempDirExtension.groovy +++ /dev/null @@ -1,70 +0,0 @@ -package com.fortify.cli.ftest._common.extension; - -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.StandardCopyOption - -import org.spockframework.runtime.extension.IGlobalExtension -import org.spockframework.runtime.model.FieldInfo -import org.spockframework.runtime.model.SpecInfo - -import com.fortify.cli.ftest._common.spec.TestResource -import com.fortify.cli.ftest._common.util.TempDirHelper - -import groovy.transform.CompileStatic - -@CompileStatic -abstract class AbstractTempDirExtension implements IGlobalExtension { - private Path tempDir - - public final Path getTempDir() { return tempDir } - - @Override - public final void start() { - tempDir = TempDirHelper.create() - afterCreate() - } - - @Override - public final void stop() { - if ( !System.getProperty("ft.keep-temp-dirs") ) { - TempDirHelper.rm(tempDir) - } - } - - public void visitSpec(SpecInfo spec) { - // Register an interceptor for setting up any fields for which we can determine a path - spec.allFields.each { FieldInfo field -> - def path = getPathForField(field) - if ( path ) { - if ( field.shared ) { - spec.addSharedInitializerInterceptor { - setPathOnField(field, it.instance, path) - it.proceed() - } - } else { - spec.addSetupInterceptor { - setPathOnField(field, it.instance, path) - it.proceed() - } - } - } - } - } - - protected void afterCreate() {} - protected abstract Path getPathForField(FieldInfo field); - - private final void setPathOnField(FieldInfo field, Object instance, Path path) { - def type = field.reflection.type - if ( type.isAssignableFrom(Path) ) { - instance.metaClass.setProperty(instance, field.reflection.name, path) - } else if ( type.isAssignableFrom(File) ) { - instance.metaClass.setProperty(instance, field.reflection.name, path.toFile()) - } else if ( type.isAssignableFrom(String) ) { - instance.metaClass.setProperty(instance, field.reflection.name, path.toFile().absolutePath) - } else { - throw new RuntimeException("Only Path, File or String fields are supported, not "+type) - } - } -} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/DisplayNameExtension.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/DisplayNameExtension.groovy deleted file mode 100644 index 0f07b9bdd7..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/DisplayNameExtension.groovy +++ /dev/null @@ -1,22 +0,0 @@ -package com.fortify.cli.ftest._common.extension; - -import org.spockframework.runtime.extension.IGlobalExtension -import org.spockframework.runtime.model.SpecInfo - -import com.fortify.cli.ftest._common.spec.Prefix - -import groovy.transform.CompileStatic - -@CompileStatic -class DisplayNameExtension implements IGlobalExtension { - @Override - void visitSpec(SpecInfo spec) { - def prefixAnnotation = spec.getAnnotation(Prefix.class) - if ( prefixAnnotation ) { - spec.allFeatures.each { - it.name = prefixAnnotation.value()+"."+it.name - } - spec.name = prefixAnnotation.value()+" ("+spec.name+")" - } - } -} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliGlobalExtension.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliGlobalExtension.groovy new file mode 100644 index 0000000000..7686e3c7f9 --- /dev/null +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliGlobalExtension.groovy @@ -0,0 +1,179 @@ +package com.fortify.cli.ftest._common.extension; + +import java.nio.file.Path + +import org.spockframework.runtime.extension.IGlobalExtension +import org.spockframework.runtime.model.FieldInfo +import org.spockframework.runtime.model.SpecElementInfo +import org.spockframework.runtime.model.SpecInfo + +import com.fortify.cli.ftest._common.Fcli +import com.fortify.cli.ftest._common.Input +import com.fortify.cli.ftest._common.spec.FcliSession +import com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType +import com.fortify.cli.ftest._common.spec.Global +import com.fortify.cli.ftest._common.spec.Global.IGlobalValueSupplier +import com.fortify.cli.ftest._common.spec.Prefix +import com.fortify.cli.ftest._common.spec.TempDir +import com.fortify.cli.ftest._common.spec.TempFile +import com.fortify.cli.ftest._common.spec.TestResource +import com.fortify.cli.ftest._common.util.WorkDirHelper + +import groovy.transform.CompileStatic + +@CompileStatic +public class FcliGlobalExtension implements IGlobalExtension { + private WorkDirHelper workDirHelper; + private Map, IGlobalValueSupplier> globalValueSuppliers = new HashMap<>(); + + @Override + public void start() { + workDirHelper = new WorkDirHelper(); + Fcli.initialize(workDirHelper.getFortifyDataDir()); + } + + @Override + public void visitSpec(SpecInfo spec) { + updateSpecName(spec); + skipFeatures(spec); + initFcliSessions(spec); + if ( !spec.skipped ) { + spec.allFields.each { FieldInfo field -> initializeField(spec, field) } + } + } + + @Override + public void stop() { + globalValueSuppliers.values().each { s -> s.close() } + FcliSessionType.logoutAll() + Fcli.close() + workDirHelper.close(); + } + + private void updateSpecName(SpecInfo spec) { + def prefixAnnotation = spec.getAnnotation(Prefix.class) + if ( prefixAnnotation ) { + spec.allFeatures.each { + it.name = prefixAnnotation.value()+"."+it.name + } + spec.name = prefixAnnotation.value()+" ("+spec.name+")" + } + } + + private void skipFeatures(SpecInfo spec) { + // Exclude any features not matching any of the feature names listed in + // the fcli.run property + // TODO Add support for skipping features based on tag include/exclude + // expressions + def run = Input.TestsToRun.get()?.split(",") + if (run) { + spec.allFeatures.each({ feature -> + if ( !run.any {feature.name.startsWith(it) && !feature.skipped } ) { + feature.skip "Not included in "+Input.TestsToRun.propertyName()+" property" + } + }) + skipSpec(spec); // Skip spec if all features skipped + } + } + + private void skipSpec(SpecInfo spec) { + if ( !spec.allFeatures.findAll({ f->!f.skipped }) ) { + spec.skip "All features skipped" + } + } + + private void initFcliSessions(SpecInfo spec) { + if ( !spec.skipped ) { + initFcliSession(spec, spec.getAnnotation(FcliSession.class)); + spec.allFeatures.each({ feature -> + if ( !feature.skipped ) { + initFcliSession(feature, feature.featureMethod.getAnnotation(FcliSession.class)); + } + }) + skipSpec(spec) + } + } + + private void initFcliSession(SpecElementInfo elt, FcliSession annotation) { + if ( annotation ) { + 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"; + } + } + } + } + } + + private void initializeField(SpecInfo spec, FieldInfo field) { + addFieldTempDirInterceptor(spec, field); + addFieldTempFileInterceptor(spec, field); + addFieldResourceFileInterceptor(spec, field); + addFieldGlobalInterceptor(spec, field); + } + + private final void addFieldTempDirInterceptor(SpecInfo spec, FieldInfo field) { + def tempDirAnnotation = field.getAnnotation(TempDir.class) + if ( tempDirAnnotation!=null ) { + addFieldInterceptor(spec, field, convertPath(field, workDirHelper.getTempDir(tempDirAnnotation.value()))) + } + } + + private final void addFieldTempFileInterceptor(SpecInfo spec, FieldInfo field) { + def tempFileAnnotation = field.getAnnotation(TempFile.class) + if ( tempFileAnnotation!=null ) { + addFieldInterceptor(spec, field, convertPath(field, workDirHelper.getTempFile(tempFileAnnotation.value()))) + } + } + + private final void addFieldResourceFileInterceptor(SpecInfo spec, FieldInfo field) { + def resourceFileAnnotation = field.getAnnotation(TestResource.class) + if ( resourceFileAnnotation!=null ) { + addFieldInterceptor(spec, field, convertPath(field, workDirHelper.getResource(resourceFileAnnotation.value()))) + } + } + + private final void addFieldGlobalInterceptor(SpecInfo spec, FieldInfo field) { + def globalAnnotation = field.getAnnotation(Global.class) + if ( globalAnnotation!=null ) { + def clazz = globalAnnotation.value(); + def valueSupplier = globalValueSuppliers.computeIfAbsent(clazz, {c->c.newInstance()}); + addFieldInterceptor(spec, field, valueSupplier.getValue(workDirHelper)); + } + } + + private final void addFieldInterceptor(SpecInfo spec, FieldInfo field, Object value) { + if ( value ) { + if ( field.shared ) { + spec.addSharedInitializerInterceptor { + it.instance.metaClass.setProperty(it.instance, field.reflection.name, value) + it.proceed() + } + } else { + spec.addSetupInterceptor { + it.instance.metaClass.setProperty(it.instance, field.reflection.name, value) + it.proceed() + } + } + } + } + + private final Object convertPath(FieldInfo field, Path path) { + def type = field.reflection.type + if ( type.isAssignableFrom(Path) ) { + return path; + } else if ( type.isAssignableFrom(File) ) { + return path.toFile(); + } else if ( type.isAssignableFrom(String) ) { + return path.toFile().absolutePath; + } else { + throw new RuntimeException("Only Path, File or String fields are supported, not "+type) + } + } +} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliInitializerExtension.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliInitializerExtension.groovy deleted file mode 100644 index c30c0d0156..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliInitializerExtension.groovy +++ /dev/null @@ -1,22 +0,0 @@ -package com.fortify.cli.ftest._common.extension; - -import org.spockframework.runtime.extension.IGlobalExtension - -import com.fortify.cli.ftest._common.Fcli -import com.fortify.cli.ftest._common.spec.FcliSessionType - -import groovy.transform.CompileStatic - -@CompileStatic -class FcliInitializerExtension implements IGlobalExtension { - @Override - public void start() { - Fcli.initialize(); - } - - @Override - public void stop() { - FcliSessionType.logoutAll() - Fcli.close() - } -} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliSessionExtension.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliSessionExtension.groovy deleted file mode 100644 index 2c566462c7..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/FcliSessionExtension.groovy +++ /dev/null @@ -1,35 +0,0 @@ -package com.fortify.cli.ftest._common.extension; - -import org.spockframework.runtime.extension.IAnnotationDrivenExtension -import org.spockframework.runtime.model.FeatureInfo -import org.spockframework.runtime.model.SpecElementInfo -import org.spockframework.runtime.model.SpecInfo - -import com.fortify.cli.ftest._common.spec.FcliSession - -public class FcliSessionExtension implements IAnnotationDrivenExtension { - @Override - public void visitSpecAnnotation(FcliSession annotation, SpecInfo spec) { - visit(annotation, spec) - } - - @Override - public void visitFeatureAnnotation(FcliSession annotation, FeatureInfo feature) { - visit(annotation, feature) - } - - private void visit(FcliSession annotation, SpecElementInfo elt) { - 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"; - } - } - } - } -} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/SkipFeaturesExtension.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/SkipFeaturesExtension.groovy deleted file mode 100644 index a92719db58..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/SkipFeaturesExtension.groovy +++ /dev/null @@ -1,30 +0,0 @@ -package com.fortify.cli.ftest._common.extension; - -import org.spockframework.runtime.extension.IGlobalExtension -import org.spockframework.runtime.model.SpecInfo - -import com.fortify.cli.ftest._common.Input - -import groovy.transform.CompileStatic - -@CompileStatic -class SkipFeaturesExtension implements IGlobalExtension { - @Override - void visitSpec(SpecInfo spec) { - // Exclude any features not matching any of the feature names listed in - // the fcli.run property - // TODO Add support for skipping features based on tag include/exclude - // expressions - def run = Input.TestsToRun.get()?.split(",") - if (run) { - spec.allFeatures.each({ feature -> - if ( !run.any {feature.name.startsWith(it) && !feature.skipped } ) { - feature.skip "Not included in "+Input.TestsToRun.propertyName()+" property" - } - }) - if ( !spec.allFeatures.findAll({ f->!f.skipped }) ) { - spec.skip "All features skipped" - } - } - } -} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/TempPathExtension.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/TempPathExtension.groovy deleted file mode 100644 index 731f81ed88..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/TempPathExtension.groovy +++ /dev/null @@ -1,35 +0,0 @@ -package com.fortify.cli.ftest._common.extension; - -import java.nio.file.Path - -import org.spockframework.runtime.model.FieldInfo - -import com.fortify.cli.ftest._common.spec.TempDir -import com.fortify.cli.ftest._common.spec.TempFile - -import groovy.transform.CompileStatic - -@CompileStatic -class TempPathExtension extends AbstractTempDirExtension { - @Override - protected void afterCreate() { - println "Using temporary working directory $tempDir" - } - - @Override - protected Path getPathForField(FieldInfo field) { - Path result = null - def dirAnnotation = field.getAnnotation(TempDir.class) - if ( dirAnnotation!=null ) { - result = tempDir.resolve(dirAnnotation.value()) - result.toFile().mkdirs() // Make sure directory exists - } else { - def fileAnnotation = field.getAnnotation(TempFile.class) - if ( fileAnnotation!=null ) { - result = tempDir.resolve(fileAnnotation.value()) - result.parent.toFile().mkdirs() // Make sure parent directory exists - } - } - return result - } -} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/TestResourceExtension.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/TestResourceExtension.groovy deleted file mode 100644 index bfa6fb9c7c..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/extension/TestResourceExtension.groovy +++ /dev/null @@ -1,32 +0,0 @@ -package com.fortify.cli.ftest._common.extension; - -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.StandardCopyOption - -import org.spockframework.runtime.extension.IGlobalExtension -import org.spockframework.runtime.model.FieldInfo -import org.spockframework.runtime.model.SpecInfo - -import com.fortify.cli.ftest._common.spec.TestResource -import com.fortify.cli.ftest._common.util.RuntimeResourcesHelper -import com.fortify.cli.ftest._common.util.TempDirHelper - -import groovy.transform.CompileStatic - -@CompileStatic -class TestResourceExtension extends AbstractTempDirExtension { - @Override - protected void afterCreate() { - println "Using test resources directory $tempDir" - } - - @Override - protected Path getPathForField(FieldInfo field) { - def annotation = field.getAnnotation(TestResource.class) - return annotation==null ? null : RuntimeResourcesHelper.extractResource(annotation.value()) - } - - - -} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/FcliSession.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/FcliSession.groovy index e86556d53f..92dcba8006 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/FcliSession.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/FcliSession.groovy @@ -7,13 +7,234 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME import java.lang.annotation.Retention import java.lang.annotation.Target -import org.spockframework.runtime.extension.ExtensionAnnotation - -import com.fortify.cli.ftest._common.extension.FcliSessionExtension +import com.fortify.cli.ftest._common.Fcli +import com.fortify.cli.ftest._common.Input @Target([METHOD, TYPE]) @Retention(RUNTIME) -@ExtensionAnnotation(FcliSessionExtension.class) @interface FcliSession { FcliSessionType[] value() + + public static enum FcliSessionType { + SSC(new SSCSessionHandler()), + FOD(new FoDSessionHandler()), + SCSAST(new SCSastSessionHandler()), + SCDAST(new SCDastSessionHandler()) + + final ISessionHandler handler + + private FcliSessionType(ISessionHandler handler) { + this.handler = handler + } + + static void logoutAll() { + FcliSessionType.values().each { it.handler.logout() } + } + + public interface ISessionHandler { + String friendlyName(); + boolean isEnabled(); + boolean login(); + void logout(); + List getMaskedProperties(); + } + + private static abstract class AbstractSessionHandler implements ISessionHandler { + def STD_LOGIN_ARGS = [module(), "session","login"] + def STD_LOGOUT_ARGS = [module(), "session","logout"] + private boolean loggedIn = false; + private boolean failed = false; + + @Override + public final boolean login() { + if ( !loggedIn && !failed ) { + println("Logging in to "+friendlyName()) + try { + def loginCredentialOptions = loginCredentialOptions() + if ( loginCredentialOptions==null || loginCredentialOptions.size()==0 ) { + throw new IllegalArgumentException("No or incomplete "+friendlyName()+" credentials provided, tests will be skipped") + } + def valuesToMask = values(maskedProperties) + Fcli.stringsToMask += valuesToMask + Fcli.run( + STD_LOGIN_ARGS+loginOptions()+loginCredentialOptions, + {it.expectSuccess(true, "Error logging in to "+friendlyName()+", tests will be skipped")} + ) + + loggedIn = true + } catch ( Exception e ) { + e.printStackTrace() + failed = true + } + } + return !failed; + } + + @Override + public synchronized final void logout() { + if ( loggedIn ) { + Fcli.stringsToMask += values(maskedProperties) + def result = Fcli.run( + STD_LOGOUT_ARGS+logoutOptions(), + { + if ( !it.success ) { + err.println("Error logging out from "+friendlyName()+"\n"+it.stderr.join("\n ")) + } + }) + loggedIn = false + } + } + + abstract String module() + abstract List loginOptions() + abstract List loginCredentialOptions() + abstract List logoutOptions() + + String basePropertyName() { + Input.addPropertyPrefix(module()) + } + String get(String subPropertyName) { + System.properties[basePropertyName()+"."+subPropertyName] + } + boolean has(String subPropertyName) { + get(subPropertyName) + } + List option(String optName) { + has(optName) ? ["--"+optName, get(optName)] : [] + } + List options(String ... optNames) { + return optNames.every { has(it) } + ? optNames.stream().map(this.&option).collect().flatten() + : [] + } + List values(List optNames) { + return optNames.stream().map(this.&get).filter({it!=null}).collect().flatten(); + } + } + + private static class SSCSessionHandler extends AbstractSessionHandler { + @Override public String friendlyName() { "SSC" } + @Override public String module() { "ssc" } + + @Override + public boolean isEnabled() { + has("url") + } + + @Override + public List loginOptions() { + option("url") + } + + @Override + public List loginCredentialOptions() { + options("user", "password")+options("token")+options("ci-token") + } + + @Override + public List logoutOptions() { + def result = options("user", "password") + return result.size()==0 ? ["--no-revoke-token"] : result + } + + @Override + public List getMaskedProperties() { + ["url", "user", "password", "token", "ci-token"] + } + + } + + private static class FoDSessionHandler extends AbstractSessionHandler { + @Override public String friendlyName() { "FoD" } + @Override public String module() { "fod" } + + @Override + public boolean isEnabled() { + has("url") + } + + @Override + public List loginOptions() { + option("url") + } + + @Override + public List loginCredentialOptions() { + options("tenant", "user", "password")+options("client-id", "client-secret") + } + + @Override + public List logoutOptions() { + return [] + } + + @Override + public List getMaskedProperties() { + ["url", "tenant", "user", "password", "client-id", "client-secret"] + } + } + + private static class SCSastSessionHandler extends AbstractSessionHandler { + @Override public String friendlyName() { "ScanCentral SAST" } + @Override public String module() { "sc-sast" } + + @Override + public boolean isEnabled() { + has("ssc-url") + } + + @Override + public List loginOptions() { + option("ssc-url") + } + + @Override + public List loginCredentialOptions() { + options("ssc-user", "ssc-password", "client-auth-token")+options("ssc-ci-token", "client-auth-token") + } + + @Override + public List logoutOptions() { + def result = options("ssc-user", "ssc-password") + return result.size()==0 ? "--no-revoke-token" : result + } + + @Override + public List getMaskedProperties() { + ["ssc-url", "ssc-user", "ssc-password", "ssc-ci-token", "client-auth-token"] + } + } + + private static class SCDastSessionHandler extends AbstractSessionHandler { + @Override public String friendlyName() { "ScanCentral DAST" } + @Override public String module() { "sc-dast" } + + @Override + public boolean isEnabled() { + has("ssc-url") + } + + @Override + public List loginOptions() { + options("ssc-url") + } + + @Override + public List loginCredentialOptions() { + options("ssc-user", "ssc-password")+options("ssc-ci-token") + } + + @Override + public List logoutOptions() { + def result = options("ssc-user", "ssc-password") + return result.size()==0 ? "--no-revoke-token" : result + } + + @Override + public List getMaskedProperties() { + ["ssc-url", "ssc-user", "ssc-password", "ssc-ci-token"] + } + } + + } } \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/FcliSessionType.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/FcliSessionType.groovy deleted file mode 100644 index f7d253e9b4..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/FcliSessionType.groovy +++ /dev/null @@ -1,229 +0,0 @@ -package com.fortify.cli.ftest._common.spec; - -import org.spockframework.runtime.extension.IMethodInterceptor - -import com.fortify.cli.ftest._common.Fcli -import com.fortify.cli.ftest._common.Input - -public enum FcliSessionType { - SSC(new SSCSessionHandler()), - FOD(new FoDSessionHandler()), - SCSAST(new SCSastSessionHandler()), - SCDAST(new SCDastSessionHandler()) - - final ISessionHandler handler - - private FcliSessionType(ISessionHandler handler) { - this.handler = handler - } - - static void logoutAll() { - FcliSessionType.values().each { it.handler.logout() } - } - - private interface ISessionHandler { - String friendlyName(); - boolean isEnabled(); - boolean login(); - void logout(); - List getMaskedProperties(); - } - - private static abstract class AbstractSessionHandler implements ISessionHandler { - def STD_LOGIN_ARGS = [module(), "session","login"] - def STD_LOGOUT_ARGS = [module(), "session","logout"] - private boolean loggedIn = false; - private boolean failed = false; - - @Override - public final boolean login() { - if ( !loggedIn && !failed ) { - println("Logging in to "+friendlyName()) - try { - def loginCredentialOptions = loginCredentialOptions() - if ( loginCredentialOptions==null || loginCredentialOptions.size()==0 ) { - throw new IllegalArgumentException("No or incomplete "+friendlyName()+" credentials provided, tests will be skipped") - } - def valuesToMask = values(maskedProperties) - Fcli.stringsToMask += valuesToMask - Fcli.run( - STD_LOGIN_ARGS+loginOptions()+loginCredentialOptions, - {it.expectSuccess(true, "Error logging in to "+friendlyName()+", tests will be skipped")} - ) - - loggedIn = true - } catch ( Exception e ) { - e.printStackTrace() - failed = true - } - } - return !failed; - } - - @Override - public synchronized final void logout() { - if ( loggedIn ) { - Fcli.stringsToMask += values(maskedProperties) - def result = Fcli.run( - STD_LOGOUT_ARGS+logoutOptions(), - { - if ( !it.success ) { - err.println("Error logging out from "+friendlyName()+"\n"+it.stderr.join("\n ")) - } - }) - loggedIn = false - } - } - - abstract String module() - abstract List loginOptions() - abstract List loginCredentialOptions() - abstract List logoutOptions() - - String basePropertyName() { - Input.addPropertyPrefix(module()) - } - String get(String subPropertyName) { - System.properties[basePropertyName()+"."+subPropertyName] - } - boolean has(String subPropertyName) { - get(subPropertyName) - } - List option(String optName) { - has(optName) ? ["--"+optName, get(optName)] : [] - } - List options(String ... optNames) { - return optNames.every { has(it) } - ? optNames.stream().map(this.&option).collect().flatten() - : [] - } - List values(List optNames) { - return optNames.stream().map(this.&get).filter({it!=null}).collect().flatten(); - } - } - - private static class SSCSessionHandler extends AbstractSessionHandler { - @Override public String friendlyName() { "SSC" } - @Override public String module() { "ssc" } - - @Override - public boolean isEnabled() { - has("url") - } - - @Override - public List loginOptions() { - option("url") - } - - @Override - public List loginCredentialOptions() { - options("user", "password")+options("token")+options("ci-token") - } - - @Override - public List logoutOptions() { - def result = options("user", "password") - return result.size()==0 ? ["--no-revoke-token"] : result - } - - @Override - public List getMaskedProperties() { - ["url", "user", "password", "token", "ci-token"] - } - - } - - private static class FoDSessionHandler extends AbstractSessionHandler { - @Override public String friendlyName() { "FoD" } - @Override public String module() { "fod" } - - @Override - public boolean isEnabled() { - has("url") - } - - @Override - public List loginOptions() { - option("url") - } - - @Override - public List loginCredentialOptions() { - options("tenant", "user", "password")+options("client-id", "client-secret") - } - - @Override - public List logoutOptions() { - return [] - } - - @Override - public List getMaskedProperties() { - ["url", "tenant", "user", "password", "client-id", "client-secret"] - } - } - - private static class SCSastSessionHandler extends AbstractSessionHandler { - @Override public String friendlyName() { "ScanCentral SAST" } - @Override public String module() { "sc-sast" } - - @Override - public boolean isEnabled() { - has("ssc-url") - } - - @Override - public List loginOptions() { - option("ssc-url") - } - - @Override - public List loginCredentialOptions() { - options("ssc-user", "ssc-password", "client-auth-token")+options("ssc-ci-token", "client-auth-token") - } - - @Override - public List logoutOptions() { - def result = options("ssc-user", "ssc-password") - return result.size()==0 ? "--no-revoke-token" : result - } - - @Override - public List getMaskedProperties() { - ["ssc-url", "ssc-user", "ssc-password", "ssc-ci-token", "client-auth-token"] - } - } - - private static class SCDastSessionHandler extends AbstractSessionHandler { - @Override public String friendlyName() { "ScanCentral DAST" } - @Override public String module() { "sc-dast" } - - @Override - public boolean isEnabled() { - has("ssc-url") - } - - @Override - public List loginOptions() { - options("ssc-url") - } - - @Override - public List loginCredentialOptions() { - options("ssc-user", "ssc-password")+options("ssc-ci-token") - } - - @Override - public List logoutOptions() { - def result = options("ssc-user", "ssc-password") - return result.size()==0 ? "--no-revoke-token" : result - } - - @Override - public List getMaskedProperties() { - ["ssc-url", "ssc-user", "ssc-password", "ssc-ci-token"] - } - } - -} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/Global.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/Global.groovy new file mode 100644 index 0000000000..8e7f140676 --- /dev/null +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/spec/Global.groovy @@ -0,0 +1,19 @@ +package com.fortify.cli.ftest._common.spec; + +import static java.lang.annotation.ElementType.FIELD +import static java.lang.annotation.RetentionPolicy.RUNTIME + +import java.lang.annotation.Retention +import java.lang.annotation.Target + +import com.fortify.cli.ftest._common.util.WorkDirHelper + +@Target([FIELD]) +@Retention(RUNTIME) +@interface Global { + Class value() + + public static interface IGlobalValueSupplier extends Closeable, AutoCloseable { + public Object getValue(WorkDirHelper workDirHelper); + } +} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/RuntimeResourcesHelper.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/RuntimeResourcesHelper.groovy deleted file mode 100644 index efd0a87428..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/RuntimeResourcesHelper.groovy +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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._common.util - -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.StandardCopyOption - -class RuntimeResourcesHelper { - private static tempDir = TempDirHelper.create(); - - static void close() { - TempDirHelper.rm(tempDir); - } - - static Path extractResource(String resourceFile) { - Path outputFilePath = tempDir.resolve(resourceFile); - if ( !Files.exists(outputFilePath) ) { - getResource(resourceFile).withCloseable { - outputFilePath.parent.toFile().mkdirs() - Files.copy(it, outputFilePath, StandardCopyOption.REPLACE_EXISTING) - } - } - return outputFilePath - } - - private static InputStream getResource(String resourceFile) { - def cl = RuntimeResourcesHelper.class.classLoader - def stream = cl.getResourceAsStream(resourceFile) - if ( stream==null ) { - stream = cl.getResourceAsStream(resourceFile+"-no-shadow") - } - if ( stream==null ) { - throw new IllegalStateException("${resourceFile} (or ${resourceFile}-no-shadow) referenced in @TestResource not found") - } - return stream - } -} diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/TempDirHelper.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/TempDirHelper.groovy deleted file mode 100644 index 9284081c2d..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/TempDirHelper.groovy +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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._common.util - -import java.nio.file.Files -import java.nio.file.Path - -class TempDirHelper { - static Path create() { - Files.createTempDirectory("fcli").toAbsolutePath() - } - static void rm(Path tempDir) { - try { - Files.walk(tempDir) - .sorted(Comparator.reverseOrder()) - .map(Path.&toFile) - .forEach(File.&delete); // For some reason this throws an exception on the - // top-level directory, but the full directory tree - // is being deleted anyway. As such, we just swallow - // any exceptions, and print an error if the directory - // still exists afterwards. - } catch ( IOException e ) {} - if ( tempDir.toFile().exists() ) { - println "Error deleting directory "+tempDir+", please clean up manually"; - } - } -} diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/WorkDirHelper.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/WorkDirHelper.groovy new file mode 100644 index 0000000000..b89913bd81 --- /dev/null +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/_common/util/WorkDirHelper.groovy @@ -0,0 +1,117 @@ +/** + * 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._common.util + +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.StandardCopyOption + +import groovy.transform.CompileStatic + +@CompileStatic +class WorkDirHelper implements Closeable, AutoCloseable { + private Path workDir; + + @Override + public void close() { + removeWorkDir(); + } + + public final Path getFortifyDataDir() { + return resolve(".fortify", PathType.DIR); + } + + public final Path getResource(String name) { + return extractResource(name); + } + + public final Path getTempDir(String name) { + return getTempPath(name, PathType.DIR); + } + + public final Path getTempFile(String name) { + return getTempPath(name, PathType.FILE); + } + + private final Path getTempPath(String name, PathType type) { + return resolve(Path.of("temp", name), type); + } + + private final enum PathType { + DIR, FILE + } + + private final Path resolve(String relativePath, PathType type) { + return resolve(Path.of(relativePath), type); + } + + private final Path resolve(Path relativePath, PathType type) { + def path = getWorkDir().resolve(relativePath); + ensureDir(type==PathType.DIR ? path : path.getParent()); + return path; + } + + private final void ensureDir(Path path) { + if ( !Files.exists(path) ) { + Files.createDirectories(path); + } + } + + private final Path getWorkDir() { + if ( workDir==null ) { + workDir = Files.createTempDirectory("fcli").toAbsolutePath() + } + return workDir; + } + + private Path extractResource(String resourceFile) { + Path outputFilePath = resolve(resourceFile, PathType.FILE); + if ( !Files.exists(outputFilePath) ) { + getResourceInputStream(resourceFile).withCloseable { + outputFilePath.parent.toFile().mkdirs() + Files.copy(it, outputFilePath, StandardCopyOption.REPLACE_EXISTING) + } + } + return outputFilePath + } + + private InputStream getResourceInputStream(String resourceFile) { + def cl = this.class.classLoader + def stream = cl.getResourceAsStream(resourceFile) + if ( stream==null ) { + stream = cl.getResourceAsStream(resourceFile+"-no-shadow") + } + if ( stream==null ) { + throw new IllegalStateException("${resourceFile} (or ${resourceFile}-no-shadow) referenced in @TestResource not found") + } + return stream + } + + private void removeWorkDir() { + if ( workDir && !System.getProperty("ft.keep-temp-dirs") ) { + try { + Files.walk(workDir) + .sorted(Comparator.reverseOrder()) + .map(Path.&toFile) + .forEach(File.&delete); // For some reason this throws an exception on the + // top-level directory, but the full directory tree + // is being deleted anyway. As such, we just swallow + // any exceptions, and print an error if the directory + // still exists afterwards. + } catch ( IOException e ) {} + if ( workDir.toFile().exists() ) { + println "Error deleting directory "+workDir+", please clean up manually"; + } + } + } +} diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/config/ConfigProxySpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/config/ConfigProxySpec.groovy index ac5c711453..3fe6006aea 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/config/ConfigProxySpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/config/ConfigProxySpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.config; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec @@ -15,7 +15,7 @@ import spock.lang.Stepwise @Prefix("config.proxy") @Stepwise class ConfigProxySpec extends FcliBaseSpec { - @Shared @TempDir("sc-client") String scClientInstallDir; + @Shared @TempDir("fortify/tools") String baseDir; def setupSpec() { Fcli.run("config proxy clear") @@ -57,7 +57,7 @@ class ConfigProxySpec extends FcliBaseSpec { } def "install.failure"() { - def args = "tool sc-client install -y -d ${scClientInstallDir}" + def args = "tool sc-client install -y -b ${baseDir}" when: def result = Fcli.run(args, {it.expectSuccess(false)}) then: diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/config/ConfigTrustStoreSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/config/ConfigTrustStoreSpec.groovy index 8c0567391e..d1ff88d559 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/config/ConfigTrustStoreSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/config/ConfigTrustStoreSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.config; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec @@ -15,7 +15,7 @@ import spock.lang.Stepwise @Prefix("config.truststore") @Stepwise class ConfigTrustStoreSpec extends FcliBaseSpec { - @Shared @TempDir("sc-client") String scClientInstallDir; + @Shared @TempDir("fortify/tools") String baseDir; @Shared @TestResource("runtime/config/dummyStore.jks") String dummyStore; def setupSpec() { @@ -57,7 +57,7 @@ class ConfigTrustStoreSpec extends FcliBaseSpec { } def "install.failure"() { - def args = "tool sc-client install -y -d ${scClientInstallDir}" + def args = "tool sc-client install -y -b ${baseDir}" when: def result = Fcli.run(args, {it.expectSuccess(false)}) then: diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlGroupSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlGroupSpec.groovy index dbe7a02f97..d3370176fd 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlGroupSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlGroupSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.fod; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.FOD +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.FOD import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlRoleSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlRoleSpec.groovy index b42755578e..b4ce15d9a6 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlRoleSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlRoleSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.fod; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.FOD +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.FOD import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlUserSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlUserSpec.groovy index 72f3e4d5a7..7e121740d1 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlUserSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAccessControlUserSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.fod; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.FOD +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.FOD import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAppSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAppSpec.groovy index 38b679c663..b68cd70e87 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAppSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDAppSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.fod; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.FOD +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.FOD import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDMicroserviceSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDMicroserviceSpec.groovy index ae1d7e4e7b..9e0bd441e4 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDMicroserviceSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDMicroserviceSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.fod; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.FOD +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.FOD import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDReleaseSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDReleaseSpec.groovy index 9c826d8708..b95efc3b10 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDReleaseSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDReleaseSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.fod; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.FOD +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.FOD import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDRestSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDRestSpec.groovy index 36c8d57544..e044726df3 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDRestSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDRestSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.fod; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.FOD +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.FOD import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanImportSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanImportSpec.groovy index ec65277da0..93fe63c867 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanImportSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanImportSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.fod; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.FOD +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.FOD import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanSpec.groovy index 9081726115..96be061bad 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.fod; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.FOD +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.FOD import com.fortify.cli.ftest._common.spec.FcliBaseSpec import com.fortify.cli.ftest._common.spec.FcliSession diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_dast/SCDastRestCallSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_dast/SCDastRestCallSpec.groovy index 21835aa76f..21c29d9d67 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_dast/SCDastRestCallSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_dast/SCDastRestCallSpec.groovy @@ -12,8 +12,8 @@ */ 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 static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SCDAST +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SCSAST import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_dast/SCDastSensorSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_dast/SCDastSensorSpec.groovy index 3e6f40c223..382d33f924 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_dast/SCDastSensorSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_dast/SCDastSensorSpec.groovy @@ -1,6 +1,6 @@ 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.FcliSession.FcliSessionType.SCDAST import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_sast/SCSastRestCallSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_sast/SCSastRestCallSpec.groovy index 86733ae36f..74eb5a235f 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_sast/SCSastRestCallSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/sc_sast/SCSastRestCallSpec.groovy @@ -12,7 +12,7 @@ */ 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.FcliSession.FcliSessionType.SCSAST import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec 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 845af96791..fc0533f50b 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 @@ -1,7 +1,7 @@ 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 static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SCSAST +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlAppVersionUserSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlAppVersionUserSpec.groovy index fecd2ed1ee..2e14f830e3 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlAppVersionUserSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlAppVersionUserSpec.groovy @@ -1,21 +1,22 @@ package com.fortify.cli.ftest.ssc; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli -import com.fortify.cli.ftest._common.Fcli.UnexpectedFcliResultException import com.fortify.cli.ftest._common.spec.FcliBaseSpec import com.fortify.cli.ftest._common.spec.FcliSession +import com.fortify.cli.ftest._common.spec.Global import com.fortify.cli.ftest._common.spec.Prefix import com.fortify.cli.ftest.ssc._common.SSCAppVersionSupplier import com.fortify.cli.ftest.ssc._common.SSCLocalUserSupplier + import spock.lang.AutoCleanup import spock.lang.Shared import spock.lang.Stepwise @Prefix("ssc.appversion-user") @FcliSession(SSC) @Stepwise class SSCAccessControlAppVersionUserSpec extends FcliBaseSpec { - @Shared @AutoCleanup SSCAppVersionSupplier versionSupplier = new SSCAppVersionSupplier() + @Global(SSCAppVersionSupplier.Empty.class) SSCAppVersionSupplier versionSupplier; @Shared @AutoCleanup SSCLocalUserSupplier userSupplier = new SSCLocalUserSupplier() def "list"() { diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlPermissionSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlPermissionSpec.groovy index 98c75f248a..ce8289a295 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlPermissionSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlPermissionSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlRoleSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlRoleSpec.groovy index 72e617966c..72fe8146f8 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlRoleSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlRoleSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlTokenDefinitionSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlTokenDefinitionSpec.groovy index bf36ac749a..ef1c930b91 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlTokenDefinitionSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlTokenDefinitionSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlTokenSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlTokenSpec.groovy index 7f57f6f086..ab2650e0f8 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlTokenSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlTokenSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlUserSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlUserSpec.groovy index 6601b06b11..e5c149f2fc 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlUserSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAccessControlUserSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAlertDefinitionSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAlertDefinitionSpec.groovy index 407b4eba24..956b51168a 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAlertDefinitionSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAlertDefinitionSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAlertSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAlertSpec.groovy index c95f7f6d3b..21c2df2047 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAlertSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAlertSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAppSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAppSpec.groovy index e211aa4fbf..cdc2aa1e7d 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAppSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAppSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.ssc; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAppVersionSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAppVersionSpec.groovy index 3ef9960859..9e7fc6c230 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAppVersionSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAppVersionSpec.groovy @@ -1,6 +1,6 @@ package com.fortify.cli.ftest.ssc; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.Fcli.UnexpectedFcliResultException diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCArtifactUploadSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCArtifactUploadSpec.groovy index 4d68b93e71..3227c62b38 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCArtifactUploadSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCArtifactUploadSpec.groovy @@ -1,11 +1,12 @@ package com.fortify.cli.ftest.ssc; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.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._common.spec.TempFile import com.fortify.cli.ftest._common.spec.TestResource import com.fortify.cli.ftest.ssc._common.SSCAppVersionSupplier @@ -21,6 +22,7 @@ class SSCArtifactUploadSpec extends FcliBaseSpec { @Shared @TestResource("runtime/shared/LoginProject.fpr") String diffpr @Shared String uploadVariableName = versionSupplier.version.fcliVariableName+"_artifact" @Shared String uploadVariableRef = "::$uploadVariableName::" + @Shared @TempFile("artifactUploadSpec/download.fpr") String downloadedFpr; def "upload"() { def args = "ssc artifact upload -f $fpr --appversion "+ @@ -125,11 +127,12 @@ class SSCArtifactUploadSpec extends FcliBaseSpec { } def "download"() { - def args = "ssc artifact download ::upload::id -f download.fpr --no-include-sources" + def args = "ssc artifact download ::upload::id -f ${downloadedFpr} --no-include-sources" when: def result = Fcli.run(args) then: noExceptionThrown() + new File(downloadedFpr).exists() verifyAll(result.stdout) { it.last().contains("ARTIFACT_DOWNLOADED"); } diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAttributeDefinitionSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAttributeDefinitionSpec.groovy index 96cdaaaa61..5d5d6c7324 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAttributeDefinitionSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAttributeDefinitionSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAttributeSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAttributeSpec.groovy index 3d5a3583bb..9d73b44856 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAttributeSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCAttributeSpec.groovy @@ -1,11 +1,12 @@ package com.fortify.cli.ftest.ssc; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.Fcli.UnexpectedFcliResultException import com.fortify.cli.ftest._common.spec.FcliBaseSpec import com.fortify.cli.ftest._common.spec.FcliSession +import com.fortify.cli.ftest._common.spec.Global import com.fortify.cli.ftest._common.spec.Prefix import com.fortify.cli.ftest.ssc._common.SSCAppVersionSupplier @@ -15,7 +16,7 @@ import spock.lang.Stepwise @Prefix("ssc.appversion-attribute") @FcliSession(SSC) @Stepwise class SSCAttributeSpec extends FcliBaseSpec { - @Shared @AutoCleanup SSCAppVersionSupplier versionSupplier = new SSCAppVersionSupplier() + @Global(SSCAppVersionSupplier.Empty.class) SSCAppVersionSupplier versionSupplier; def "list"() { def args = "ssc attribute list --appversion " + versionSupplier.version.appName + ":" + versionSupplier.version.versionName diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCIssueFilterSetSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCIssueFilterSetSpec.groovy index 85692fbe5c..1d2a13849a 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCIssueFilterSetSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCIssueFilterSetSpec.groovy @@ -1,11 +1,12 @@ package com.fortify.cli.ftest.ssc; -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.Fcli.UnexpectedFcliResultException import com.fortify.cli.ftest._common.spec.FcliBaseSpec import com.fortify.cli.ftest._common.spec.FcliSession +import com.fortify.cli.ftest._common.spec.Global import com.fortify.cli.ftest._common.spec.Prefix import com.fortify.cli.ftest.ssc._common.SSCAppVersionSupplier @@ -15,7 +16,7 @@ import spock.lang.Stepwise @Prefix("ssc.appversion-filterset") @FcliSession(SSC) @Stepwise class SSCIssueFilterSetSpec extends FcliBaseSpec { - @Shared @AutoCleanup SSCAppVersionSupplier versionSupplier = new SSCAppVersionSupplier() + @Global(SSCAppVersionSupplier.Empty.class) SSCAppVersionSupplier versionSupplier; def "list"() { def args = "ssc issue list-filtersets --appversion " + versionSupplier.version.appName + ":" + versionSupplier.version.versionName + " --store filtersets" diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCIssueTemplateSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCIssueTemplateSpec.groovy index e92c87d690..f5c610b09b 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCIssueTemplateSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCIssueTemplateSpec.groovy @@ -12,22 +12,22 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.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._common.spec.TempFile import com.fortify.cli.ftest._common.spec.TestResource -import spock.lang.AutoCleanup -import spock.lang.Requires import spock.lang.Shared import spock.lang.Stepwise @Prefix("ssc.issue-template") @FcliSession(SSC) @Stepwise class SSCIssueTemplateSpec extends FcliBaseSpec { @Shared @TestResource("runtime/ssc/issueTemplate.xml") String templateFile + @Shared @TempFile("issueTemplateSpec/download.xml") String downloadedTemplateFile private static final String random = System.currentTimeMillis() private static final String templateName = "fcli-test-Template"+random @@ -102,10 +102,11 @@ class SSCIssueTemplateSpec extends FcliBaseSpec { } def "download"() { - def args = "ssc issue download-template ::template::id" + def args = "ssc issue download-template ::template::id -f ${downloadedTemplateFile}" when: def result = Fcli.run(args) then: + new File(downloadedTemplateFile).exists() verifyAll(result.stdout) { size()>0 it.last().contains("DOWNLOADED") diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCPluginSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCPluginSpec.groovy index e726bb517f..e04a7f7306 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCPluginSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCPluginSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCReportSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCReportSpec.groovy index 43b772614a..cace3777a7 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCReportSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCReportSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import java.nio.file.Files import java.nio.file.Path @@ -21,6 +21,7 @@ import java.text.SimpleDateFormat 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.Global import com.fortify.cli.ftest._common.spec.Prefix import com.fortify.cli.ftest._common.spec.TempDir import com.fortify.cli.ftest._common.spec.TempFile @@ -34,23 +35,15 @@ import spock.lang.Stepwise @Prefix("ssc.report") @FcliSession(SSC) @Stepwise class SSCReportSpec extends FcliBaseSpec { @Shared @TempFile("report.pdf") String reportFile; - @Shared @AutoCleanup SSCAppVersionSupplier version1Supplier = new SSCAppVersionSupplier() - @Shared @AutoCleanup SSCAppVersionSupplier version2Supplier = new SSCAppVersionSupplier() - @Shared @TestResource("runtime/shared/EightBall-22.1.0.fpr") String fpr1 - @Shared @TestResource("runtime/shared/LoginProject.fpr") String fpr2 + @Global(SSCAppVersionSupplier.EightBall.class) SSCAppVersionSupplier eightBallVersionSupplier; + @Global(SSCAppVersionSupplier.LoginProject.class) SSCAppVersionSupplier loginProjectVersionSupplier; @Shared String random = System.currentTimeMillis() @Shared String owaspReportName = "fcli-OWASP-${random}" @Shared String trendingReportName = "fcli-Trending-${random}" @Shared String kpiReportName = "fcli-KPI-${random}" - def setupSpec() { - Fcli.run("ssc artifact upload -f $fpr1 --appversion ${version1Supplier.version.variableRef} --store fpr1") - Fcli.run("ssc artifact upload -f $fpr2 --appversion ${version2Supplier.version.variableRef} --store fpr2") - Fcli.run("ssc artifact wait-for ::fpr1:: ::fpr2:: -i 2s") - } - def "createOWASP"() { - def args = "ssc report create --template OWASP\\ Top\\ 10 --name ${owaspReportName} -p Application\\ Version=${version1Supplier.version.get("id")} --store owasp" + def args = "ssc report create --template OWASP\\ Top\\ 10 --name ${owaspReportName} -p Application\\ Version=${eightBallVersionSupplier.version.get("id")} --store owasp" when: def result = Fcli.run(args) then: @@ -62,7 +55,7 @@ class SSCReportSpec extends FcliBaseSpec { def "createTrending"() { def today = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); - def args = "ssc report create --template Issue\\ Trending --name ${trendingReportName} -p startDate=2010-01-01,endDate=${today},projectversionids=[${version1Supplier.version.get("id")};${version2Supplier.version.get("id")}] --store trending" + def args = "ssc report create --template Issue\\ Trending --name ${trendingReportName} -p startDate=2010-01-01,endDate=${today},projectversionids=[${eightBallVersionSupplier.version.get("id")};${loginProjectVersionSupplier.version.get("id")}] --store trending" when: def result = Fcli.run(args) then: @@ -73,7 +66,7 @@ class SSCReportSpec extends FcliBaseSpec { } def "createKPI"() { - def args = "ssc report create --template Key\\ Performance\\ Indicators --name ${kpiReportName} -p Application\\ Attribute=Accessibility,projectversionids=[${version1Supplier.version.get("id")};${version2Supplier.version.get("id")}] --store kpi" + def args = "ssc report create --template Key\\ Performance\\ Indicators --name ${kpiReportName} -p Application\\ Attribute=Accessibility,projectversionids=[${eightBallVersionSupplier.version.get("id")};${loginProjectVersionSupplier.version.get("id")}] --store kpi" when: def result = Fcli.run(args) then: diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCReportTemplateSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCReportTemplateSpec.groovy index bfb238cfb1..ad0e650fbc 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCReportTemplateSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCReportTemplateSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCRestCallSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCRestCallSpec.groovy index 17205209ee..88212fe943 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCRestCallSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCRestCallSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateActivitySpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateActivitySpec.groovy index 17edbfc8b4..7a7693e9dc 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateActivitySpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateActivitySpec.groovy @@ -12,11 +12,12 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.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.Global import com.fortify.cli.ftest._common.spec.Prefix import com.fortify.cli.ftest.ssc._common.SSCAppVersionSupplier @@ -27,7 +28,7 @@ import spock.lang.Shared @Prefix("ssc.activity-feed") @FcliSession(SSC) @Requires({System.getProperty('ft.include.long-running')}) class SSCSystemStateActivitySpec extends FcliBaseSpec { - @Shared @AutoCleanup SSCAppVersionSupplier versionSupplier = new SSCAppVersionSupplier() + @Global(SSCAppVersionSupplier.Empty.class) SSCAppVersionSupplier versionSupplier; def "list"() { def args = "ssc state list-activities" diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateEventSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateEventSpec.groovy index a1e8fd3be9..5cd1512e2b 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateEventSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateEventSpec.groovy @@ -12,11 +12,12 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.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.Global import com.fortify.cli.ftest._common.spec.Prefix import com.fortify.cli.ftest.ssc._common.SSCAppVersionSupplier @@ -27,7 +28,7 @@ import spock.lang.Shared @Prefix("ssc.event") @FcliSession(SSC) @Requires({System.getProperty('ft.include.long-running')}) class SSCSystemStateEventSpec extends FcliBaseSpec { - @Shared @AutoCleanup SSCAppVersionSupplier versionSupplier = new SSCAppVersionSupplier() + @Global(SSCAppVersionSupplier.Empty.class) SSCAppVersionSupplier versionSupplier; def "list"() { def args = "ssc state list-events" diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateJobSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateJobSpec.groovy index 4a2310e0c8..c706fa32eb 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateJobSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCSystemStateJobSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.ssc -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCTestSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCTestSpec.groovy deleted file mode 100644 index a20ddb1f49..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/SSCTestSpec.groovy +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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.ssc - -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC - -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.SSCGlobal - -@Prefix("test") @FcliSession(SSC) -class SSCTestSpec extends FcliBaseSpec { - def setupSpec() { - println "setup" - } - - def "t"() { - println SSCGlobal.AppVersion.eightball.version - when: - def a = "b" - then: - a=="b" - } -} diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/_common/SSCAppVersionSupplier.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/_common/SSCAppVersionSupplier.groovy index 8a78d27599..d72d0ca088 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/_common/SSCAppVersionSupplier.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/_common/SSCAppVersionSupplier.groovy @@ -12,15 +12,28 @@ */ package com.fortify.cli.ftest.ssc._common +import java.nio.file.Path + import com.fortify.cli.ftest._common.Fcli -import com.fortify.cli.ftest.ssc._common.SSCLocalUserSupplier.SSCUser +import com.fortify.cli.ftest._common.spec.Global.IGlobalValueSupplier +import com.fortify.cli.ftest._common.util.WorkDirHelper public class SSCAppVersionSupplier implements Closeable, AutoCloseable { + private final Closure init; private SSCAppVersion version; + public SSCAppVersionSupplier() { + this({}); + } + + public SSCAppVersionSupplier(Closure init) { + this.init = init; + } + public SSCAppVersion getVersion() { if ( !version ) { version = new SSCAppVersion().create() + init(version); } return version } @@ -33,8 +46,6 @@ public class SSCAppVersionSupplier implements Closeable, AutoCloseable { } } - - public static class SSCAppVersion { private final String random = System.currentTimeMillis() private final String fcliVariableName = "ssc_appversion_"+random @@ -69,6 +80,48 @@ public class SSCAppVersionSupplier implements Closeable, AutoCloseable { } } + private static abstract class AppVersionGlobalValueSupplier implements IGlobalValueSupplier { + private SSCAppVersionSupplier versionSupplier; + public final SSCAppVersionSupplier getValue(WorkDirHelper workDirHelper) { + if ( !versionSupplier ) { + versionSupplier = new SSCAppVersionSupplier({ SSCAppVersion v -> initVersion(workDirHelper, v) }); + } + return versionSupplier + } + @Override + public final void close() { + if ( versionSupplier ) { + versionSupplier.close(); + versionSupplier = null; + } + } + protected String upload(SSCAppVersion version, Path fprPath) { + def varName = "global${this.class.simpleName}Fpr" + Fcli.run("ssc artifact upload -f $fprPath --appversion ${version.variableRef} --store ${varName}") + Fcli.run("ssc artifact wait-for ::${varName}:: -i 2s") + return varName; + } + protected abstract void initVersion(WorkDirHelper workDirHelper, SSCAppVersion version); + } + + public static class Empty extends AppVersionGlobalValueSupplier { + @Override + protected void initVersion(WorkDirHelper workDirHelper, SSCAppVersion version) {} + } + + public static class EightBall extends AppVersionGlobalValueSupplier { + @Override + protected void initVersion(WorkDirHelper workDirHelper, SSCAppVersion version) { + upload(version, workDirHelper.getResource("runtime/shared/EightBall-22.1.0.fpr")); + } + } + + public static class LoginProject extends AppVersionGlobalValueSupplier { + @Override + protected void initVersion(WorkDirHelper workDirHelper, SSCAppVersion version) { + upload(version, workDirHelper.getResource("runtime/shared/LoginProject.fpr")); + } + } } diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/_common/SSCGlobal.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/_common/SSCGlobal.groovy deleted file mode 100644 index 41bf2b87ee..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/ssc/_common/SSCGlobal.groovy +++ /dev/null @@ -1,60 +0,0 @@ -package com.fortify.cli.ftest.ssc._common; - -import java.nio.file.Path - -import org.spockframework.runtime.extension.IGlobalExtension - -import com.fortify.cli.ftest._common.Fcli -import com.fortify.cli.ftest._common.spec.TestResource -import com.fortify.cli.ftest._common.util.RuntimeResourcesHelper -import com.fortify.cli.ftest.ssc._common.SSCAppVersionSupplier.SSCAppVersion - -import groovy.transform.CompileStatic - -@CompileStatic -class SSCGlobal implements IGlobalExtension { - @Override - public void start() {} - - @Override - public void stop() { - AppVersion.values().each { v->v.close() } - } - - public static enum AppVersion implements Closeable, AutoCloseable { - empty(AppVersion.&initEmpty), - eightball(AppVersion.&initEightball), - - private SSCAppVersion version; - private Closure initVersion; - private AppVersion(Closure initVersion) { - this.initVersion = initVersion; - } - - private static void initEmpty(SSCAppVersion version) { - - } - - private static void initEightball(SSCAppVersion version) { - Path fprPath = RuntimeResourcesHelper.extractResource("runtime/shared/EightBall-22.1.0.fpr"); - Fcli.run("ssc artifact upload -f $fprPath --appversion ${version.variableRef} --store globalEightBallFpr") - Fcli.run("ssc artifact wait-for ::globalEightBallFpr:: -i 2s") - } - - public SSCAppVersion getVersion() { - if ( !version ) { - version = new SSCAppVersion().create() - initVersion(version) - } - return version - } - - @Override - public void close() { - if ( version ) { - version.close(); - version = null; - } - } - } -} \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolDefinitionsSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolDefinitionsSpec.groovy index 232dc4e273..7644e0426c 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolDefinitionsSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolDefinitionsSpec.groovy @@ -12,7 +12,7 @@ */ package com.fortify.cli.ftest.tool -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC +import static com.fortify.cli.ftest._common.spec.FcliSession.FcliSessionType.SSC import com.fortify.cli.ftest._common.Fcli import com.fortify.cli.ftest._common.spec.FcliBaseSpec diff --git a/fcli-other/fcli-functional-test/src/ftest/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension b/fcli-other/fcli-functional-test/src/ftest/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension index e0b3452b41..2cde83f43f 100644 --- a/fcli-other/fcli-functional-test/src/ftest/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension +++ b/fcli-other/fcli-functional-test/src/ftest/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension @@ -1,6 +1 @@ -com.fortify.cli.ftest.ssc._common.SSCGlobal -com.fortify.cli.ftest._common.extension.FcliInitializerExtension -com.fortify.cli.ftest._common.extension.TestResourceExtension -com.fortify.cli.ftest._common.extension.TempPathExtension -com.fortify.cli.ftest._common.extension.DisplayNameExtension -com.fortify.cli.ftest._common.extension.SkipFeaturesExtension \ No newline at end of file +com.fortify.cli.ftest._common.extension.FcliGlobalExtension \ No newline at end of file