Skip to content

Commit

Permalink
Feature migrate usage in system test to new open api module #3239 (#3366
Browse files Browse the repository at this point in the history
)

* move default sechub client to new open api module

* migrate systemtest to new open api module #3239

* merge develop branch #3239

* revert changes in AnonymousUserRequestNewApiTokenRestController #3239

* change from #!/usr/bin/bash to #!/bin/bash in shell files #3239

* change from #!/usr/bin/bash to #!/bin/bash in shell files #3239

* moved deletion of projects and profile from SystemTestRuntime into finally block

* moved deletion of projects and profile from SystemTestRuntime into finally block

* temp

* Refactored import path #3395

* temp

* Removed SystemSupport for ArchUnit #3395

* Removed predefined import options #3395

* temp

* add enabled field to ProductExecutionProfile

* temp

* temp

* store sechub result file in test folder

* Replaced package import through path import and ignore JAR import #3395

* Ignore generated API in coding rules #3395

* fix openapi.yaml

* reconfigure pr action events

* revert pr hooks in gh actions

* remove unnecessary runtime exception

* pr fixes

* pr fixes

* pr fixes

* pr fixes

* pr fixes

---------

Co-authored-by: Laura <[email protected]>
Co-authored-by: Jan Winz <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent e20de7f commit f50215d
Show file tree
Hide file tree
Showing 222 changed files with 2,298 additions and 701 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ plugins {
id 'org.asciidoctor.jvm.pdf' version '3.3.2'

// open api
id 'org.openapi.generator' version '7.7.0'
id 'org.openapi.generator' version '7.8.0'

// spring
id 'org.springframework.boot' version '3.2.2' apply false
Expand Down
2 changes: 1 addition & 1 deletion github-actions/scan/__test__/integrationtest/01-start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

set -e
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

set -e
Expand Down
2 changes: 1 addition & 1 deletion github-actions/scan/__test__/integrationtest/05-stop.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

set -e
Expand Down
2 changes: 1 addition & 1 deletion github-actions/scan/__test__/integrationtest/start_pds.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

SERVER_PORT=$1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

SERVER_PORT=$1
Expand Down
2 changes: 1 addition & 1 deletion github-actions/scan/__test__/integrationtest/stop_pds.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

# $1 = server port
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

# $1 = server port
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

echo "#PDS_INTTEST_PRODUCT_CODESCAN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

echo "#PDS_INTTEST_PRODUCT_CODESCAN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

echo "#PDS_INTTEST_PRODUCT_CODESCAN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

cat "__test__/integrationtest/test-product-output/example-scancode-spdx-output.json" > "${PDS_JOB_RESULT_FILE}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

cat "__test__/integrationtest/test-product-output/example-gitleaks-sarif-output-yellow.json" > "${PDS_JOB_RESULT_FILE}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

cat "__test__/integrationtest/test-product-output/example-owasp-zap-sarif-output-red.json" > "${PDS_JOB_RESULT_FILE}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash
# SPDX-License-Identifier: MIT

SERVER_TYPE=$1
Expand Down
19 changes: 17 additions & 2 deletions gradle/libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ ext {
// TODO de-jcup, 2024-04-18: Currently we cannot use versions > 0.17.1 because it introduces nullable and required in the spec file which causes issues
// There exists an issue for it at https://github.com/mercedes-benz/sechub/issues/3080
restDocsApiSpec: "0.17.1",

jacksonAnnotations: "2.17.2",
jacksonDatabind: "2.13.4.1",
jacksonDatatypeJsr310: "2.17.2",
jacksonDatabindNullable: "0.2.6",
javaxAnnotationApi: "1.3.2",
findbugs: "3.0.2",
httpmime: "4.3.1",

/* Owasp Zap wrapper */
owaspzap_client_api: "1.13.0",
jcommander: "1.82",
Expand Down Expand Up @@ -198,8 +205,16 @@ ext {

arch_unit: "com.tngtech.archunit:archunit-junit5:${libraryVersion.arch_unit}",

bouncy_castle_bcprov_jdk8: "org.bouncycastle:bcprov-jdk18on:${libraryVersion.bouncy_castle_bcprov_jdk8}"
bouncy_castle_bcprov_jdk8: "org.bouncycastle:bcprov-jdk18on:${libraryVersion.bouncy_castle_bcprov_jdk8}",

/* OpenAPI generator */
jacksonAnnotations: "com.fasterxml.jackson.core:jackson-annotations:${libraryVersion.jacksonAnnotations}",
jacksonDatabind: "com.fasterxml.jackson.core:jackson-databind:${libraryVersion.jacksonDatabind}",
jacksonDatatypeJsr310: "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${libraryVersion.jacksonDatatypeJsr310}",
jacksonDatabindNullable: "org.openapitools:jackson-databind-nullable:${libraryVersion.jacksonDatabindNullable}",
javaxAnnotationApi: "javax.annotation:javax.annotation-api:${libraryVersion.javaxAnnotationApi}",
findbugs: "com.google.code.findbugs:jsr305:${libraryVersion.findbugs}",
httpmime: "org.apache.httpcomponents:httpmime:${libraryVersion.httpmime}",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class AnonymousUserRequestNewApiTokenRestController {
private AnonymousUserRequestsNewApiTokenService newApiTokenService;

/* @formatter:off */
@CrossOrigin /* to allow call from getsechub.detss and maybe other sites using javascript */
@UseCaseUserRequestsNewApiToken(@Step(number=1, name="Rest API call",description="Rest api called to request new user api token. Normally done by user itself",needsRestDoc=true))
@RequestMapping(path = AdministrationAPIConstants.API_REQUEST_NEW_APITOKEN, method = RequestMethod.POST)
public void anonymousRequestToGetNewApiTokenForUserEmailAddress(@PathVariable(name="emailAddress") String emailAddress) {
/* @formatter:on */
@CrossOrigin /* to allow call from getsechub.detss and maybe other sites using javascript */
@UseCaseUserRequestsNewApiToken(@Step(number=1, name="Rest API call",description="Rest api called to request new user api token. Normally done by user itself",needsRestDoc=true))
@RequestMapping(path = AdministrationAPIConstants.API_REQUEST_NEW_APITOKEN, method = RequestMethod.POST)
public void anonymousRequestToGetNewApiTokenForUserEmailAddress(@PathVariable(name="emailAddress") String emailAddress) {
/* @formatter:on */
newApiTokenService.anonymousRequestToGetNewApiTokenForUserEmailAddress(emailAddress);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/bin/bash

# SPDX-License-Identifier: MIT

Expand Down
2 changes: 1 addition & 1 deletion sechub-api-java/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The goal of the API is to:

=== Usage

Create an instance of `com.mercedesbenz.sechub.api.DefaultSecHubClient` and use the client methods.
Create an instance of `com.mercedesbenz.sechub.api.OldDefaultSecHubClient` and use the client methods.

For a working example please look into `sechub-examples/example-sechub-api-java`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
import com.mercedesbenz.sechub.commons.model.JsonMapperFactory;
import com.mercedesbenz.sechub.commons.model.SecHubConfigurationModel;

public class DefaultSecHubClient extends AbstractSecHubClient {
public class OldDefaultSecHubClient extends AbstractSecHubClient {

private static final Logger LOG = LoggerFactory.getLogger(DefaultSecHubClient.class);
private static final Logger LOG = LoggerFactory.getLogger(OldDefaultSecHubClient.class);

private static JsonMapper mapper = JsonMapperFactory.createMapper();

Expand All @@ -76,7 +76,7 @@ public static DefaultSecHubClientBuilder builder() {
return new DefaultSecHubClientBuilder();
}

private DefaultSecHubClient(URI serverUri, String userId, String apiToken, boolean trustAll) {
private OldDefaultSecHubClient(URI serverUri, String userId, String apiToken, boolean trustAll) {
super(serverUri, userId, apiToken, trustAll);

apiClient = new ApiClientBuilder().createApiClient(this, mapper);
Expand Down Expand Up @@ -518,7 +518,7 @@ public SecHubClient build() {
if (sealedApiToken == null) {
throw new IllegalStateException("token is not defined!");
}
return new DefaultSecHubClient(serverUri, userName, apiTokenAccess.unseal(sealedApiToken), trustAll);
return new OldDefaultSecHubClient(serverUri, userName, apiTokenAccess.unseal(sealedApiToken), trustAll);
}
}

Expand Down
Loading

0 comments on commit f50215d

Please sign in to comment.