Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial setup for the system test api #2092
- introduce model - introduce first version of API - added some unit tests - added one integration test - implemented config features: - configrue url + credentials for sechub(remote) - configure start stop for sechub (local) - configure start stop for pds solutions (local) - configure executors for sechub - configure tests + asserts - automatically set calculated parts into configuration (altering configuration, but this is very useful for debugging) - automatically calculate pds server config file location - the wrong configuration exception does now always contain a stacktrace with the altered JSON - implemented runtime features - start /stop of sechub (local) - start /stop of pds-solutions (local) - environment variables on script launch (local) - fallback default-profile and default-project when missing in configuration + link to executors
- Loading branch information
Showing
59 changed files
with
2,031 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: MIT | ||
/*============================================================================ | ||
* Build file for subproject | ||
* | ||
* Root build file: "${rootProject.projectDir}/build.gradle" | ||
* ============================================================================ | ||
*/ | ||
plugins { | ||
id 'java-library' | ||
} | ||
|
||
version = VersionData.getServerVersion() | ||
|
||
dependencies { | ||
|
||
implementation project(':sechub-commons-model') | ||
|
||
testImplementation spring_boot_dependency.junit_jupiter | ||
testImplementation spring_boot_dependency.mockito_core | ||
|
||
implementation spring_boot_dependency.logback_classic | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
sechub-systemtest/src/main/java/com/mercedesbenz/sechub/systemtest/SystemTestAPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.mercedesbenz.sechub.systemtest; | ||
|
||
import com.mercedesbenz.sechub.systemtest.config.SystemTestConfiguration; | ||
import com.mercedesbenz.sechub.systemtest.config.SystemTestConfigurationBuilder; | ||
import com.mercedesbenz.sechub.systemtest.runtime.ExecutionSupport; | ||
import com.mercedesbenz.sechub.systemtest.runtime.LocationSupport; | ||
import com.mercedesbenz.sechub.systemtest.runtime.SystemTestResult; | ||
import com.mercedesbenz.sechub.systemtest.runtime.SystemTestRuntime; | ||
import com.mercedesbenz.sechub.systemtest.runtime.VariableSupport; | ||
|
||
/** | ||
* This is the central point for system tests | ||
* | ||
* @author Albert Tregnaghi | ||
* | ||
*/ | ||
public class SystemTestAPI { | ||
|
||
public static SystemTestConfigurationBuilder configure() { | ||
return SystemTestConfiguration.builder(); | ||
} | ||
|
||
public static SystemTestResult runSystemTests(SystemTestConfiguration configuration, String pathToPdsSolution) { | ||
LocationSupport locationSupport = new LocationSupport(pathToPdsSolution, null); | ||
|
||
VariableSupport variableSupport = new VariableSupport(); | ||
ExecutionSupport execSupport = new ExecutionSupport(variableSupport); | ||
|
||
SystemTestRuntime runtime = new SystemTestRuntime(locationSupport, execSupport); | ||
|
||
return runtime.run(configuration); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...ystemtest/src/main/java/com/mercedesbenz/sechub/systemtest/config/AbstractDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
public abstract class AbstractDefinition { | ||
private String comment; | ||
|
||
public String getComment() { | ||
return comment; | ||
} | ||
|
||
public void setComment(String comment) { | ||
this.comment = comment; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
.../main/java/com/mercedesbenz/sechub/systemtest/config/AssertContainsStringsDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class AssertContainsStringsDefinition extends AbstractDefinition { | ||
|
||
private List<String> values = new ArrayList<>(); | ||
|
||
public List<String> getValues() { | ||
return values; | ||
} | ||
|
||
public void setValues(List<String> strings) { | ||
this.values = strings; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...t/src/main/java/com/mercedesbenz/sechub/systemtest/config/AssertEqualsFileDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
public class AssertEqualsFileDefinition extends AbstractDefinition { | ||
|
||
private String path; | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
|
||
public void setPath(String path) { | ||
this.path = path; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...src/main/java/com/mercedesbenz/sechub/systemtest/config/AssertSechubResultDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
import java.util.Optional; | ||
|
||
import com.mercedesbenz.sechub.commons.model.TrafficLight; | ||
|
||
public class AssertSechubResultDefinition extends AbstractDefinition { | ||
|
||
private Optional<TrafficLight> hasTrafficLight = Optional.ofNullable(null); | ||
private Optional<AssertEqualsFileDefinition> equalsFile = Optional.ofNullable(null); | ||
private Optional<AssertContainsStringsDefinition> containsStrings = Optional.ofNullable(null); | ||
|
||
public Optional<TrafficLight> getHasTrafficLight() { | ||
return hasTrafficLight; | ||
} | ||
|
||
public void setHasTrafficLight(Optional<TrafficLight> hasTrafficLight) { | ||
this.hasTrafficLight = hasTrafficLight; | ||
} | ||
|
||
public void setEqualsFile(Optional<AssertEqualsFileDefinition> equalsFile) { | ||
this.equalsFile = equalsFile; | ||
} | ||
|
||
public Optional<AssertEqualsFileDefinition> getEqualsFile() { | ||
return equalsFile; | ||
} | ||
|
||
public Optional<AssertContainsStringsDefinition> getContainsStrings() { | ||
return containsStrings; | ||
} | ||
|
||
public void setContainsStrings(Optional<AssertContainsStringsDefinition> containsStrings) { | ||
this.containsStrings = containsStrings; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...b-systemtest/src/main/java/com/mercedesbenz/sechub/systemtest/config/ConfigConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
public class ConfigConstants { | ||
|
||
private static final String PREFIX_RUNTIME = "runtime."; | ||
|
||
public static final String RUNTIME_WORKSPACE_ROOT = PREFIX_RUNTIME + "workspaceRoot"; | ||
public static final String RUNTIME_PDS_SOLUTION_ROOT = PREFIX_RUNTIME + "pdsSolutionRoot"; | ||
public static final String RUNTIME_SECHUB_SOLUTION_ROOT = PREFIX_RUNTIME + "secHubSolutionRoot"; | ||
|
||
public static final String DEFAULT_PROJECT_NAME = "default-project"; | ||
public static final String DEFAULT_PROFILE_ID = "default-profile"; | ||
} |
24 changes: 24 additions & 0 deletions
24
...emtest/src/main/java/com/mercedesbenz/sechub/systemtest/config/CredentialsDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
public class CredentialsDefinition extends AbstractDefinition { | ||
|
||
private String userId; | ||
|
||
private String apiToken; | ||
|
||
public String getApiToken() { | ||
return apiToken; | ||
} | ||
|
||
public void setApiToken(String apiToken) { | ||
this.apiToken = apiToken; | ||
} | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(String userId) { | ||
this.userId = userId; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...test/src/main/java/com/mercedesbenz/sechub/systemtest/config/ExecutionStepDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Represents a step definition which really executes/does something at runtime. | ||
* For example: execute a script | ||
* | ||
* @author Albert Tregnaghi | ||
* | ||
*/ | ||
public class ExecutionStepDefinition extends AbstractDefinition { | ||
|
||
private Optional<ScriptDefinition> script = Optional.ofNullable(null); | ||
|
||
public Optional<ScriptDefinition> getScript() { | ||
return script; | ||
} | ||
|
||
public void setScript(Optional<ScriptDefinition> script) { | ||
this.script = script; | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...emtest/src/main/java/com/mercedesbenz/sechub/systemtest/config/LocalSecHubDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class LocalSecHubDefinition extends AbstractDefinition { | ||
|
||
private List<ExecutionStepDefinition> start = new ArrayList<>(); | ||
|
||
private SecHubConfigurationDefinition configure = new SecHubConfigurationDefinition(); | ||
|
||
private List<ExecutionStepDefinition> stop = new ArrayList<>(); | ||
|
||
private String baseDir; | ||
|
||
public SecHubConfigurationDefinition getConfigure() { | ||
return configure; | ||
} | ||
|
||
public List<ExecutionStepDefinition> getStart() { | ||
return start; | ||
} | ||
|
||
public List<ExecutionStepDefinition> getStop() { | ||
return stop; | ||
} | ||
|
||
public void setBaseDir(String baseDir) { | ||
this.baseDir = baseDir; | ||
} | ||
|
||
public String getBaseDir() { | ||
return baseDir; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...temtest/src/main/java/com/mercedesbenz/sechub/systemtest/config/LocalSetupDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class LocalSetupDefinition extends AbstractDefinition { | ||
|
||
private LocalSecHubDefinition secHub = new LocalSecHubDefinition(); | ||
|
||
private List<PDSSolutionDefinition> pdsSolutions = new ArrayList<>(); | ||
|
||
public List<PDSSolutionDefinition> getPdsSolutions() { | ||
return pdsSolutions; | ||
} | ||
|
||
public void setPdsSolutions(List<PDSSolutionDefinition> solutions) { | ||
this.pdsSolutions = solutions; | ||
} | ||
|
||
public LocalSecHubDefinition getSecHub() { | ||
return secHub; | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...emtest/src/main/java/com/mercedesbenz/sechub/systemtest/config/PDSSolutionDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class PDSSolutionDefinition extends AbstractDefinition { | ||
|
||
private String name; | ||
|
||
private String baseDir; | ||
|
||
private String pathToPdsServerConfigFile; | ||
|
||
private List<ExecutionStepDefinition> start = new ArrayList<>(); | ||
|
||
private boolean waitForPDSAvailable = true; | ||
|
||
private List<ExecutionStepDefinition> stop = new ArrayList<>(); | ||
|
||
public String getPathToPdsServerConfigFile() { | ||
return pathToPdsServerConfigFile; | ||
} | ||
|
||
public void setPathToPdsServerConfigFile(String pathToPdsServerConfigFile) { | ||
this.pathToPdsServerConfigFile = pathToPdsServerConfigFile; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public boolean isWaitForPDSAvailable() { | ||
return waitForPDSAvailable; | ||
} | ||
|
||
public void setWaitForPDSAvailable(boolean waitForAvailable) { | ||
this.waitForPDSAvailable = waitForAvailable; | ||
} | ||
|
||
public List<ExecutionStepDefinition> getStart() { | ||
return start; | ||
} | ||
|
||
public List<ExecutionStepDefinition> getStop() { | ||
return stop; | ||
} | ||
|
||
/** | ||
* Set the base directory for the solution. This is optional. If not defined, | ||
* the test runtime will try to resolve it automatically (by name and defined | ||
* folder location of "sechub-pds-solutions". The PDS base directory is | ||
* important, because the PDS configuration file must be loaded to determine the | ||
* provided products inside the PDS. | ||
* | ||
* @param baseDir | ||
*/ | ||
public void setBaseDirectory(String baseDir) { | ||
this.baseDir = baseDir; | ||
} | ||
|
||
public String getBaseDir() { | ||
return baseDir; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...systemtest/src/main/java/com/mercedesbenz/sechub/systemtest/config/ProjectDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.mercedesbenz.sechub.systemtest.config; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ProjectDefinition extends AbstractDefinition { | ||
|
||
private String name; | ||
private List<String> profiles = new ArrayList<>(); | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public List<String> getProfiles() { | ||
return profiles; | ||
} | ||
} |
Oops, something went wrong.