Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ArchUnit tests #3778

Merged
merged 27 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b1f2640
Modified gradle.build of arch unit test #3713
lorriborri Jan 8, 2025
94f2977
Fixing test name convention #3713
lorriborri Jan 8, 2025
3196a56
Renamed faile test classes #3713
lorriborri Jan 8, 2025
f6e5e4d
Added info message to failed tests #3713
lorriborri Jan 8, 2025
5968934
Renamed test classes, must start or end with Test #3713
lorriborri Jan 13, 2025
ac2554f
Added custom extension for AchUnit Message #3713
lorriborri Jan 13, 2025
b78a880
Added assertJ dependency
lorriborri Jan 13, 2025
2a0d198
Refactored dependency and new naming convention rule #3713
lorriborri Jan 14, 2025
dade353
applied spotless #3713
lorriborri Jan 14, 2025
160ce13
Refactored import and message on fail #3713
lorriborri Jan 15, 2025
8613b4c
Native IDE builds and gradle builds do now work together #3713
de-jcup Jan 16, 2025
e17ac34
Update spring boot version to 3.3.5 #3544 (#3615)
hamidonos Jan 8, 2025
7a77257
Start a scan via web UI (#3767)
lorriborri Jan 8, 2025
e7d41df
Bump peter-evans/create-pull-request from 7.0.5 to 7.0.6
dependabot[bot] Dec 30, 2024
6eb94e9
added security section to Helm chart #3779
sven-dmlr Jan 8, 2025
a983856
adapted variable names in Helm chart #3779
sven-dmlr Jan 9, 2025
17eefdc
PR suggestion added #3779
sven-dmlr Jan 10, 2025
5eb5d0a
Changed ordering of cancel and ok button #3781
de-jcup Jan 13, 2025
23c119f
server access from web-ui enabled #3786
sven-dmlr Jan 13, 2025
425823c
SPDX headers added by SecHub release job @github-actions
sven-dmlr Jan 13, 2025
39c3a60
release wf fixed #3793
sven-dmlr Jan 13, 2025
b925b56
SPDX headers added by SecHub release job @github-actions
sven-dmlr Jan 13, 2025
a174cd2
implement job report download in web ui #3557 (#3806)
hamidonos Jan 15, 2025
a70efe5
Explicitly set geckodriver system property #3800
winzj Jan 15, 2025
6b8f419
Feature 3789 user can cancel job (#3799)
lorriborri Jan 16, 2025
8d869bf
fixed imports #3713
lorriborri Jan 17, 2025
94648fe
Merge branch 'develop' into feature-3713-fix-arch-unit-tests
lorriborri Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class NessusAdapterV1Test {

@BeforeClass
public static void beforeClass() {
NESSUS_7_0_2_GET_POLICIES_RESULT_JSON = NessusAdapterTestFileSupport.getTestfileSupport().loadTestFile("nessus_7.0.2.get_policies_result.json");
NESSUS_7_0_2_GET_POLICIES_RESULT_JSON = TestNessusAdapterFileSupport.getTestfileSupport().loadTestFile("nessus_7.0.2.get_policies_result.json");
}

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import com.mercedesbenz.sechub.test.TestFileSupport;

@SechubTestComponent
public class NessusAdapterTestFileSupport extends TestFileSupport {
private static final NessusAdapterTestFileSupport TESTFILE_SUPPORT = new NessusAdapterTestFileSupport();
public class TestNessusAdapterFileSupport extends TestFileSupport {
private static final TestNessusAdapterFileSupport TESTFILE_SUPPORT = new TestNessusAdapterFileSupport();

public static NessusAdapterTestFileSupport getTestfileSupport() {
public static TestNessusAdapterFileSupport getTestfileSupport() {
return TESTFILE_SUPPORT;
}

NessusAdapterTestFileSupport() {
TestNessusAdapterFileSupport() {
super("deprecated-sechub-adapter-nessus/src/test/resources");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void build_json_for_new_scan_with_basic_auth_contains_basic_login_parts()
String json = adapterToTest.buildJsonForCreateNewScan(jsonAdapterSupport, config);

/* test */
String expected = NetsparkerAdapterTestFileSupport.getTestfileSupport().loadTestFile("json/basic_weblogin_expected1.json");
String expected = TestNetsparkerAdapterFileSupport.getTestfileSupport().loadTestFile("json/basic_weblogin_expected1.json");
assertEquals(expected, json);
}

Expand All @@ -83,7 +83,7 @@ public void build_json_for_new_scan_with_max_scan_duration_one_hour() throws Exc
String json = adapterToTest.buildJsonForCreateNewScan(jsonAdapterSupport, config);

/* test */
String expected = NetsparkerAdapterTestFileSupport.getTestfileSupport().loadTestFile("json/max_duration_one_hour_expected.json");
String expected = TestNetsparkerAdapterFileSupport.getTestfileSupport().loadTestFile("json/max_duration_one_hour_expected.json");
assertEquals(expected, json);
}

Expand All @@ -106,7 +106,7 @@ public void build_json_for_new_scan_with_max_scan_duration_5_minutes() throws Ex
/* test */

// the minimum scan duration for Netsparker is 1 hour
String expected = NetsparkerAdapterTestFileSupport.getTestfileSupport().loadTestFile("json/max_duration_one_hour_expected.json");
String expected = TestNetsparkerAdapterFileSupport.getTestfileSupport().loadTestFile("json/max_duration_one_hour_expected.json");
assertEquals(expected, json);
}

Expand All @@ -126,7 +126,7 @@ public void build_json_for_new_scan_with_max_scan_duration_129_minutes() throws
String json = adapterToTest.buildJsonForCreateNewScan(jsonAdapterSupport, config);

/* test */
String expected = NetsparkerAdapterTestFileSupport.getTestfileSupport().loadTestFile("json/max_duration_three_hours_expected.json");
String expected = TestNetsparkerAdapterFileSupport.getTestfileSupport().loadTestFile("json/max_duration_three_hours_expected.json");
assertEquals(expected, json);
}

Expand All @@ -146,7 +146,7 @@ public void build_json_for_new_scan_with_max_scan_duration_180_minutes() throws
String json = adapterToTest.buildJsonForCreateNewScan(jsonAdapterSupport, config);

/* test */
String expected = NetsparkerAdapterTestFileSupport.getTestfileSupport().loadTestFile("json/max_duration_three_hours_expected.json");
String expected = TestNetsparkerAdapterFileSupport.getTestfileSupport().loadTestFile("json/max_duration_three_hours_expected.json");
assertEquals(expected, json);
}

Expand Down Expand Up @@ -253,7 +253,7 @@ public void build_json_for_new_scan_with_form_auth_scripts() throws Exception {
String json = adapterToTest.buildJsonForCreateNewScan(jsonAdapterSupport, config);

/* test */
String expected = NetsparkerAdapterTestFileSupport.getTestfileSupport().loadTestFile("json/form_scripts_weblogin.json");
String expected = TestNetsparkerAdapterFileSupport.getTestfileSupport().loadTestFile("json/form_scripts_weblogin.json");
assertEquals(expected, json);
}

Expand All @@ -276,7 +276,7 @@ public void a_fetch_report__triggers_rest_tempate_with_correct_params() {
@Test
public void isAbleTo_extract_id_from_netsparker_v1_0_40_109_result_when_create_new_scan_triggered() throws AdapterException {
/* prepare */
String body = NetsparkerAdapterTestFileSupport.getTestfileSupport().loadTestFile("netsparker_v1.0.40.109_new_scan_output.json");
String body = TestNetsparkerAdapterFileSupport.getTestfileSupport().loadTestFile("netsparker_v1.0.40.109_new_scan_output.json");

/* execute */
String id = adapterToTest.extractIDFromScanResult(body, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @author Albert Tregnaghi
*
*/
public class NetsparkerAdapterTestApplication {
public class TestNetsparkerAdapterApplication {

public static void main(String[] args) throws Exception {
SecHubTimeUnitData maxScanDuration = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import com.mercedesbenz.sechub.test.TestFileSupport;

@SechubTestComponent
public class NetsparkerAdapterTestFileSupport extends TestFileSupport {
private static final NetsparkerAdapterTestFileSupport TESTFILE_SUPPORT = new NetsparkerAdapterTestFileSupport();
public class TestNetsparkerAdapterFileSupport extends TestFileSupport {
private static final TestNetsparkerAdapterFileSupport TESTFILE_SUPPORT = new TestNetsparkerAdapterFileSupport();

public static NetsparkerAdapterTestFileSupport getTestfileSupport() {
public static TestNetsparkerAdapterFileSupport getTestfileSupport() {
return TESTFILE_SUPPORT;
}

NetsparkerAdapterTestFileSupport() {
TestNetsparkerAdapterFileSupport() {
super("deprecated-sechub-adapter-netsparker/src/test/resources");
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ext {
wiremock: "com.github.tomakehurst:wiremock-standalone:${libraryVersion.wiremock}",
s3mock: "com.adobe.testing:s3mock:${libraryVersion.s3mock}",
s3mock_junit5: "com.adobe.testing:s3mock-junit5:${libraryVersion.s3mock}",

/*
* RE2 is a regular expression engine that runs in time linear in the size of the input.
* It's the default RegularExpression engine of Go
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @author Albert Tregnaghi, Jeremias Eppler
*
*/
public class CheckmarxAdapterTestApplication {
public class TestCheckmarxAdapterApplication {

public static void main(String[] args) throws Exception {
System.setProperty("log4j.logger.org.apache.http", "ERROR");
Expand All @@ -46,7 +46,7 @@ public static void main(String[] args) throws Exception {
// "zipfile_contains_only_test1.txt.zip"; // leads to FAILED in queue
// "zipfile_contains_sechub_doc_java.zip"; // should work

File zipFile = CheckmarxTestFileSupport.getTestfileSupport().createFileFromRoot("sechub-other/testsourcecode/" + pathInOtherProject);
File zipFile = TestCheckmarxFileSupport.getTestfileSupport().createFileFromRoot("sechub-other/testsourcecode/" + pathInOtherProject);
/* @formatter:off */
CheckmarxAdapterConfig config =
CheckmarxConfig.builder().
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.adapter.checkmarx;

import com.mercedesbenz.sechub.test.TestFileSupport;

public class TestCheckmarxFileSupport extends TestFileSupport {

private static final TestCheckmarxFileSupport TESTFILE_SUPPORT = new TestCheckmarxFileSupport();

public static TestCheckmarxFileSupport getTestfileSupport() {
return TESTFILE_SUPPORT;
}

TestCheckmarxFileSupport() {
super("sechub-adapter-checkmarx/src/test/resources");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void when_pds_config_use_sechub_store_not_set__upload_is_called() throws
expectedJobParameters.put(PDSDefaultParameterKeyConstants.PARAM_KEY_PDS_SCAN_TARGET_TYPE,"");

/* prepare */
PDSWiremockTestSupport testSupport = PDSWiremockTestSupport.builder(wireMockRule).
TestPDSWiremockSupport testSupport = TestPDSWiremockSupport.builder(wireMockRule).
simulateJobCanBeCreated(sechubJobUUID,productIdentifier,expectedJobParameters).
simulateUploadData(SOURCECODE_ZIP, SIM_SOURCE_ZIP_SIZE).
simulateMarkReadyToStart().
Expand Down Expand Up @@ -102,7 +102,7 @@ public void when_pds_config_use_sechub_store_set_to_false__upload_is_called() th
expectedJobParameters.put(PDSDefaultParameterKeyConstants.PARAM_KEY_PDS_SCAN_TARGET_TYPE,"");
expectedJobParameters.put(PDSDefaultParameterKeyConstants.PARAM_KEY_PDS_CONFIG_USE_SECHUB_STORAGE,"false");

PDSWiremockTestSupport testSupport = PDSWiremockTestSupport.builder(wireMockRule).
TestPDSWiremockSupport testSupport = TestPDSWiremockSupport.builder(wireMockRule).
simulateJobCanBeCreated(sechubJobUUID,productIdentifier,expectedJobParameters).
simulateUploadData(SOURCECODE_ZIP,SIM_SOURCE_ZIP_SIZE).
simulateMarkReadyToStart().
Expand Down Expand Up @@ -131,7 +131,7 @@ public void when_pds_config_use_sechub_store_set_to_false__upload_is_called__bin
expectedJobParameters.put(PDSDefaultParameterKeyConstants.PARAM_KEY_PDS_SCAN_TARGET_TYPE,"");
expectedJobParameters.put(PDSDefaultParameterKeyConstants.PARAM_KEY_PDS_CONFIG_USE_SECHUB_STORAGE,"false");

PDSWiremockTestSupport testSupport = PDSWiremockTestSupport.builder(wireMockRule).
TestPDSWiremockSupport testSupport = TestPDSWiremockSupport.builder(wireMockRule).
simulateJobCanBeCreated(sechubJobUUID,productIdentifier,expectedJobParameters).
simulateUploadData(BINARIES_TAR,SIM_BINARIES_TAR_SIZE).
simulateMarkReadyToStart().
Expand Down Expand Up @@ -161,7 +161,7 @@ public void when_pds_config_use_sechub_store_set_to_true__upload_is_NOT_called()
expectedJobParameters.put(PDSDefaultParameterKeyConstants.PARAM_KEY_PDS_CONFIG_USE_SECHUB_STORAGE,"true");


PDSWiremockTestSupport testSupport = PDSWiremockTestSupport.builder(wireMockRule).
TestPDSWiremockSupport testSupport = TestPDSWiremockSupport.builder(wireMockRule).
simulateJobCanBeCreated(sechubJobUUID,productIdentifier,expectedJobParameters).
//no simulate upload here! --> if an upload would be called, wiremock would fail, because no stubbing available
simulateMarkReadyToStart().
Expand Down Expand Up @@ -195,7 +195,7 @@ public void messages_are_returned_to_adapter_result() throws Exception {
messagesFromPDS.getSecHubMessages().add(new SecHubMessage(SecHubMessageType.INFO,"i am the info sent back by wiremock"));


PDSWiremockTestSupport testSupport = PDSWiremockTestSupport.builder(wireMockRule).
TestPDSWiremockSupport testSupport = TestPDSWiremockSupport.builder(wireMockRule).
simulateJobCanBeCreated(sechubJobUUID,productIdentifier,expectedJobParameters).
//no simulate upload here!
simulateMarkReadyToStart().
Expand All @@ -218,7 +218,7 @@ public void messages_are_returned_to_adapter_result() throws Exception {
}

/* @formatter:off */
private PDSAdapterConfig createCodeScanConfiguration(PDSWiremockTestSupport testSupport) {
private PDSAdapterConfig createCodeScanConfiguration(TestPDSWiremockSupport testSupport) {
String baseURL = testSupport.getTestBaseUrl();
PDSCodeScanConfigBuilder builder = PDSCodeScanConfigImpl.builder().
setUser("testuser").
Expand Down Expand Up @@ -248,7 +248,7 @@ private PDSAdapterConfig createCodeScanConfiguration(PDSWiremockTestSupport test
/* @formatter:on */

/* @formatter:off */
private PDSAdapterConfig createCodeScanConfigurationWithBinary(PDSWiremockTestSupport testSupport) {
private PDSAdapterConfig createCodeScanConfigurationWithBinary(TestPDSWiremockSupport testSupport) {
String baseURL = testSupport.getTestBaseUrl();
PDSCodeScanConfigBuilder builder = PDSCodeScanConfigImpl.builder().
setUser("testuser").
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.mercedesbenz.sechub.test.JSONTestUtil.DirectJSonable;

public class PDSTestSupport {
public class TestPDSSupport {

public List<JSONKeyValue> toKeyValue(Map<String, String> map) {
List<JSONKeyValue> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.mercedesbenz.sechub.test.TestVerifier;
import com.mercedesbenz.sechub.test.WiremockUrlHistory;

public class PDSWiremockTestSupport {
public class TestPDSWiremockSupport {

private boolean pdsJobCanBeCreated;
private boolean pdsMarkReadyToStart;
Expand All @@ -33,19 +33,19 @@ public class PDSWiremockTestSupport {
public String pdsProductIdentifier;
public Map<String, String> pdsJobParameters;
public SecHubMessagesList sechubMessageList;
private PDSTestSupport pdsTestSupport;
private TestPDSSupport testPDSSupport;
private UUID pdsJobUUID;
private List<UploadInfo> uploads = new ArrayList<>();
private List<StateQueueInfo> stateRequestsResults = new ArrayList<>();

private TestVerifier testVerifier = new TestVerifier();
public boolean useSecHubStorage;

public PDSWiremockTestSupport(WireMockServer server) {
public TestPDSWiremockSupport(WireMockServer server) {
this.server = server;
this.history = new WiremockUrlHistory();
this.pdsURLBuilder = new PDSUrlBuilder("");
this.pdsTestSupport = new PDSTestSupport();
this.testPDSSupport = new TestPDSSupport();
}

private static class UploadInfo {
Expand Down Expand Up @@ -207,7 +207,7 @@ private void simulationJobCreation() throws Exception {
map.put("sechubJobUUID", sechubJobUUID.toString());
map.put("productId", pdsProductIdentifier);

map.put("parameters", pdsTestSupport.toKeyValue(pdsJobParameters));
map.put("parameters", testPDSSupport.toKeyValue(pdsJobParameters));

/* @formatter:off */
String requestBody = JSONTestUtil.toJSONContainingNullValues(map);
Expand All @@ -226,10 +226,10 @@ private void simulationJobCreation() throws Exception {

public static class PDSWiremockTestSupportBuilder {

private PDSWiremockTestSupport current;
private TestPDSWiremockSupport current;

public PDSWiremockTestSupportBuilder(WireMockServer server) {
current = new PDSWiremockTestSupport(server);
current = new TestPDSWiremockSupport(server);
}

public PDSWiremockTestSupportBuilder simulateJobCanBeCreated(UUID sechubJobUUID, String pdsProductIdentifier, Map<String, String> parameters) {
Expand Down Expand Up @@ -287,10 +287,10 @@ public PDSWiremockTestSupportBuilder simulateFetchJobMessages(SecHubMessagesList
return this;
}

PDSWiremockTestSupport build() {
TestPDSWiremockSupport build() {

PDSWiremockTestSupport buildResult = current;
current = new PDSWiremockTestSupport(buildResult.server);
TestPDSWiremockSupport buildResult = current;
current = new TestPDSWiremockSupport(buildResult.server);
return buildResult;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.adapter;

import com.mercedesbenz.sechub.test.TestFileSupport;

public class TestSecHubAdapterFileSupport extends TestFileSupport {

public static final TestSecHubAdapterFileSupport INSTANCE = new TestSecHubAdapterFileSupport();

protected TestSecHubAdapterFileSupport() {
super("sechub-adapter");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import com.mercedesbenz.sechub.adapter.AbstractAdapterConfig;
import com.mercedesbenz.sechub.adapter.AdapterOptionKey;
import com.mercedesbenz.sechub.adapter.SecHubAdapterTestFileSupport;
import com.mercedesbenz.sechub.adapter.TestSecHubAdapterFileSupport;

public class MockedAdapterSetupServiceTest {

Expand All @@ -29,7 +29,7 @@ public void before() {
@Test
public void static_read_default_setup_possible_and_has_at_least_checkmarx_and_netsparker_data_for_ANY_OTHER_TARGET_inside() {
/* prepare */
File gradleSafeTestFile = SecHubAdapterTestFileSupport.INSTANCE.createFileFromResourcePath(MockedAdapterSetupService.DEFAULT_FILE_PATH);
File gradleSafeTestFile = TestSecHubAdapterFileSupport.INSTANCE.createFileFromResourcePath(MockedAdapterSetupService.DEFAULT_FILE_PATH);

serviceToTest.filePath = gradleSafeTestFile.getAbsolutePath();

Expand Down
19 changes: 14 additions & 5 deletions sechub-archunit-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@
* ============================================================================
*/

dependencies {
testImplementation library.springframework_web
// Ensure the ArchUnit module depends on all other modules
projectType.archUnitProjects.each { Project project ->
evaluationDependsOn(project.path)
}

for (project in projectType.archUnitProjects) {
testImplementation project
// Define a task dependency to ensure all tests are run before ArchUnit tests
tasks.named('test') {
projectType.archUnitProjects.each { Project project ->
dependsOn "${project.path}:test"
}
}

dependencies {
testImplementation library.springframework_web
testImplementation spring_boot_dependency.junit_jupiter
testImplementation library.arch_unit
}

// executing archunit tests: ./gradlew sechub-archunit-test:test


// executing archunit tests: ./gradlew sechub-archunit-test:test
Loading
Loading