Skip to content

Commit 2a921ab

Browse files
committed
Capture & Replay Integration Test for ToolConfigService
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent 7917f25 commit 2a921ab

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

src/main/java/io/securecodebox/persistence/defectdojo/model/ToolConfig.java

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public final class ToolConfig implements Model, HasId, HasName {
3030
@JsonProperty("tool_type")
3131
private long toolType;
3232

33+
// FIXME: This is not present in my actual JSON response. Should remove?
3334
@JsonProperty("configuration_url")
3435
String configUrl;
3536

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
11
package io.securecodebox.persistence.defectdojo.service;
22

3+
import io.securecodebox.persistence.defectdojo.model.ToolConfig;
34
import org.junit.jupiter.api.Test;
45

5-
import static org.junit.jupiter.api.Assertions.*;
6+
import java.io.IOException;
7+
import java.net.URISyntaxException;
8+
9+
import static com.github.tomakehurst.wiremock.client.WireMock.*;
610
import static org.hamcrest.MatcherAssert.assertThat;
7-
import static org.hamcrest.Matchers.*;
11+
import static org.hamcrest.Matchers.containsInAnyOrder;
12+
import static org.hamcrest.Matchers.hasSize;
13+
import static org.junit.jupiter.api.Assertions.assertAll;
814

915
/**
1016
* Tests for {@link ToolConfigService}
1117
*/
1218
final class ToolConfigServiceTest extends WireMockBaseTestCase {
1319
private final ToolConfigService sut = new ToolConfigService(conf());
20+
21+
@Test
22+
void search() throws URISyntaxException, IOException {
23+
stubFor(
24+
get("/api/v2/tool_configurations/?offset=0&limit=100")
25+
.willReturn(
26+
ok()
27+
.withBody(readResponseBodyFromFixture("ToolConfigService_response_fixture.json"))
28+
)
29+
);
30+
31+
final var result = sut.search();
32+
33+
assertAll(
34+
() -> assertThat(result, hasSize(1)),
35+
() -> assertThat(result, containsInAnyOrder(
36+
ToolConfig.builder()
37+
.id(1)
38+
.name("secureCodeBox")
39+
.description("secureCodeBox is a kubernetes based, modularized toolchain for continuous security scans of your software project.")
40+
.url("https://github.com/secureCodeBox")
41+
.toolType(7)
42+
.build()
43+
))
44+
);
45+
}
1446
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
{}
1+
{
2+
"count": 1,
3+
"next": null,
4+
"previous": null,
5+
"results": [
6+
{
7+
"id": 1,
8+
"name": "secureCodeBox",
9+
"description": "secureCodeBox is a kubernetes based, modularized toolchain for continuous security scans of your software project.",
10+
"url": "https://github.com/secureCodeBox",
11+
"authentication_type": null,
12+
"extras": null,
13+
"username": null,
14+
"auth_title": null,
15+
"tool_type": 7
16+
}
17+
],
18+
"prefetch": {}
19+
}

0 commit comments

Comments
 (0)