-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature-2562-fix-buildDoc-script
- Loading branch information
Showing
75 changed files
with
4,630 additions
and
795 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
1 change: 1 addition & 0 deletions
1
sechub-api-java/src/main/java/com/mercedesbenz/sechub/api/ExecutionProfile.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.api; | ||
|
||
import java.util.HashSet; | ||
|
1 change: 1 addition & 0 deletions
1
sechub-api-java/src/main/java/com/mercedesbenz/sechub/api/Job.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.api; | ||
|
||
import java.util.UUID; | ||
|
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
1 change: 1 addition & 0 deletions
1
sechub-api-java/src/main/java/com/mercedesbenz/sechub/api/SecHubClient.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.api; | ||
|
||
import java.net.URI; | ||
|
1 change: 1 addition & 0 deletions
1
sechub-api-java/src/main/java/com/mercedesbenz/sechub/api/User.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.api; | ||
|
||
public class User { | ||
|
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
20 changes: 0 additions & 20 deletions
20
...pi-java/src/main/java/com/mercedesbenz/sechub/api/internal/SecHubClientAuthenticator.java
This file was deleted.
Oops, something went wrong.
102 changes: 102 additions & 0 deletions
102
...b-api-java/src/test/java/com/mercedesbenz/sechub/api/DefaultSechubClientWireMockTest.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,102 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.api; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.*; | ||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.*; | ||
import static org.junit.Assert.*; | ||
|
||
import java.net.URI; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import com.github.tomakehurst.wiremock.junit.WireMockRule; | ||
import com.mercedesbenz.sechub.test.TestPortProvider; | ||
|
||
import wiremock.org.apache.http.HttpStatus; | ||
|
||
/** | ||
* Junit 4 test because of missing official WireMock Junit5 extension - so we | ||
* use WireMock Rule and Junit4. | ||
* | ||
* @author Albert Tregnaghi | ||
* | ||
*/ | ||
public class DefaultSechubClientWireMockTest { | ||
|
||
private static final String EXAMPLE_TOKEN = "example-token"; | ||
|
||
private static final String EXAMPLE_USER = "example-user"; | ||
private static final String APPLICATION_JSON = "application/json"; | ||
|
||
private static final int HTTPS_PORT = TestPortProvider.DEFAULT_INSTANCE.getWireMockTestHTTPSPort(); | ||
|
||
private static final int HTTP_PORT = TestPortProvider.DEFAULT_INSTANCE.getWireMockTestHTTPPort(); | ||
|
||
@Rule | ||
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(HTTP_PORT).httpsPort(HTTPS_PORT)); | ||
|
||
@Test | ||
public void fetch_sechub_status_with_basic_auth() throws Exception { | ||
|
||
/* prepare */ | ||
String statusBody = """ | ||
[ { | ||
"key" : "status.scheduler.enabled", | ||
"value" : "true" | ||
}, { | ||
"key" : "status.scheduler.jobs.all", | ||
"value" : "2" | ||
} ] | ||
"""; | ||
stubFor(get(urlEqualTo("/api/admin/status")).withBasicAuth(EXAMPLE_USER, EXAMPLE_TOKEN) | ||
.willReturn(aResponse().withStatus(HttpStatus.SC_OK).withHeader("Content-Type", APPLICATION_JSON).withBody(statusBody))); | ||
|
||
DefaultSecHubClient client = createTestClientWithExampleCredentials(); | ||
|
||
/* execute */ | ||
SecHubStatus status = client.fetchSecHubStatus(); | ||
|
||
/* test */ | ||
verify(getRequestedFor(urlEqualTo("/api/admin/status"))); | ||
assertNotNull(status); | ||
assertEquals("true", status.getStatusInformationMap().get("status.scheduler.enabled")); | ||
assertEquals("2", status.getStatusInformationMap().get("status.scheduler.jobs.all")); | ||
|
||
} | ||
|
||
@Test | ||
public void credential_changes_on_client_after_creation_are_possible() throws Exception { | ||
|
||
/* prepare */ | ||
String statusBody = """ | ||
[ { | ||
"key" : "status.scheduler.enabled", | ||
"value" : "false" | ||
}, { | ||
"key" : "status.scheduler.jobs.all", | ||
"value" : "0" | ||
} ] | ||
"""; | ||
stubFor(get(urlEqualTo("/api/admin/status")).withBasicAuth("other-user", "other-token") | ||
.willReturn(aResponse().withStatus(HttpStatus.SC_OK).withHeader("Content-Type", APPLICATION_JSON).withBody(statusBody))); | ||
|
||
DefaultSecHubClient client = createTestClientWithExampleCredentials(); | ||
|
||
/* execute */ | ||
client.setApiToken("other-token"); | ||
client.setUsername("other-user"); | ||
|
||
/* test */ | ||
SecHubStatus status = client.fetchSecHubStatus(); | ||
verify(getRequestedFor(urlEqualTo("/api/admin/status"))); | ||
|
||
assertEquals("false", status.getStatusInformationMap().get("status.scheduler.enabled")); | ||
assertEquals("0", status.getStatusInformationMap().get("status.scheduler.jobs.all")); | ||
} | ||
|
||
private DefaultSecHubClient createTestClientWithExampleCredentials() { | ||
DefaultSecHubClient client = new DefaultSecHubClient(URI.create(wireMockRule.baseUrl()), EXAMPLE_USER, EXAMPLE_TOKEN, true); | ||
return client; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
sechub-api-java/src/test/java/com/mercedesbenz/sechub/api/MockedSecHubClientTest.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
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
Oops, something went wrong.