Skip to content

Commit 5bc0772

Browse files
committed
test: stub TC /recommend endpoint for tests
Signed-off-by: Zvi Grinberg <[email protected]>
1 parent a8f47dc commit 5bc0772

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/main/resources/application.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ project.build=${timestamp}
77

88
api.snyk.token=placeholder
99
api.snyk.host=https://app.snyk.io/api/v1
10-
api.trustedcontent.host=https://exhort.trust.rhcloud.com/api/v1
10+
api.trustedcontent.host=https://exhort.staging.trustification.dev/api/v1
1111
# api.snyk.timeout=10s
1212
# api.snyk.disabled=true
1313
api.ossindex.host=https://ossindex.sonatype.org/api/v3
@@ -39,4 +39,4 @@ quarkus.index-dependency.spdx-java.artifact-id=java-spdx-library
3939
quarkus.index-dependency.exhort-api.group-id=com.redhat.ecosystemappeng
4040
quarkus.index-dependency.exhort-api.artifact-id=exhort-api-spec
4141
quarkus.camel.native.reflection.include-patterns=org.cyclonedx.model.*,com.redhat.exhort.api.*,com.redhat.exhort.api.v3.*,com.redhat.exhort.api.v4.*,org.spdx.jacksonstore.*,org.spdx.storage.listedlicense.*
42-
# quarkus.jackson.serialization-inclusion=non-empty
42+
# quarkus.jackson.serialization-inclusion=non-empty

src/test/java/com/redhat/exhort/extensions/WiremockV3Extension.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public Map<String, String> start() {
3939
return Map.of(
4040
"api.snyk.host", server.baseUrl(),
4141
"api.snyk.token", SNYK_TOKEN,
42+
"api.trustedcontent.host", server.baseUrl(),
4243
"api.ossindex.host", server.baseUrl());
4344
}
4445

src/test/java/com/redhat/exhort/integration/AbstractAnalysisTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ protected void verifySnykTokenRequest(String token) {
195195
protected void stubAllProviders() {
196196
stubSnykRequests();
197197
stubOssToken();
198+
stubTrustedContentRequests();
198199
}
199200

200201
protected void verifyProviders(
@@ -260,6 +261,17 @@ protected void stubSnykTokenRequests() {
260261
+ " has exceeded the rate limit.\""
261262
+ ", \"error\": \"true\"}")));
262263
}
264+
protected void stubTrustedContentRequests() {
265+
server.stubFor(
266+
get(Constants.TRUSTED_CONTENT_PATH)
267+
.willReturn(
268+
aResponse()
269+
.withStatus(200)
270+
.withBody(
271+
"{ \"recommendations\": {}\n" +
272+
"}")));
273+
274+
}
263275

264276
protected void stubSnykRequests() {
265277
// Missing token

src/test/java/com/redhat/exhort/integration/AnalysisTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@
5959
@QuarkusTest
6060
public class AnalysisTest extends AbstractAnalysisTest {
6161

62+
6263
private static final String CYCLONEDX = "cyclonedx";
6364
private static final String SPDX = "spdx";
6465
private static final String DEFAULT_RHDA_TOKEN = "example-rhda-token";
6566

67+
6668
@ParameterizedTest
6769
@ValueSource(strings = {CYCLONEDX, SPDX})
6870
public void testWithWrongProvider(String sbom) {

0 commit comments

Comments
 (0)