Skip to content

Commit 7917f25

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

File tree

2 files changed

+152
-4
lines changed

2 files changed

+152
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,93 @@
11
package io.securecodebox.persistence.defectdojo.service;
22

3+
import io.securecodebox.persistence.defectdojo.model.TestType;
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 TestTypeService}
1117
*/
12-
final class TestTypeServiceTest extends WireMockBaseTestCase{
18+
final class TestTypeServiceTest extends WireMockBaseTestCase {
1319
private final TestTypeService sut = new TestTypeService(conf());
20+
21+
@Test
22+
void search() throws URISyntaxException, IOException {
23+
stubFor(
24+
get("/api/v2/test_types/?offset=0&limit=100")
25+
.willReturn(
26+
ok()
27+
.withBody(readResponseBodyFromFixture("TestTypeService_response_fixture.json"))
28+
)
29+
);
30+
31+
final var result = sut.search();
32+
33+
assertAll(
34+
() -> assertThat(result, hasSize(9)),
35+
() -> assertThat(result, containsInAnyOrder(
36+
TestType.builder()
37+
.id(99)
38+
.name("Acunetix360 Scan")
39+
.staticTool(false)
40+
.dynamicTool(false)
41+
.build(),
42+
TestType.builder()
43+
.id(19)
44+
.name("Acunetix Scan")
45+
.staticTool(false)
46+
.dynamicTool(false)
47+
.build(),
48+
TestType.builder()
49+
.id(125)
50+
.name("AnchoreCTL Policies Report")
51+
.staticTool(false)
52+
.dynamicTool(false)
53+
.build(),
54+
TestType.builder()
55+
.id(47)
56+
.name("AnchoreCTL Vuln Report")
57+
.staticTool(false)
58+
.dynamicTool(false)
59+
.build(),
60+
TestType.builder()
61+
.id(112)
62+
.name("Anchore Engine Scan")
63+
.staticTool(false)
64+
.dynamicTool(false)
65+
.build(),
66+
TestType.builder()
67+
.id(172)
68+
.name("Anchore Enterprise Policy Check")
69+
.staticTool(false)
70+
.dynamicTool(false)
71+
.build(),
72+
TestType.builder()
73+
.id(106)
74+
.name("Anchore Grype")
75+
.staticTool(true)
76+
.dynamicTool(false)
77+
.build(),
78+
TestType.builder()
79+
.id(1)
80+
.name("API Test")
81+
.staticTool(false)
82+
.dynamicTool(false)
83+
.build(),
84+
TestType.builder()
85+
.id(100)
86+
.name("AppSpider Scan")
87+
.staticTool(false)
88+
.dynamicTool(true)
89+
.build()
90+
))
91+
);
92+
}
1493
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,70 @@
1-
{}
1+
{
2+
"count": 9,
3+
"next": null,
4+
"previous": null,
5+
"results": [
6+
{
7+
"id": 99,
8+
"name": "Acunetix360 Scan",
9+
"static_tool": false,
10+
"dynamic_tool": false,
11+
"active": true
12+
},
13+
{
14+
"id": 19,
15+
"name": "Acunetix Scan",
16+
"static_tool": false,
17+
"dynamic_tool": false,
18+
"active": true
19+
},
20+
{
21+
"id": 125,
22+
"name": "AnchoreCTL Policies Report",
23+
"static_tool": false,
24+
"dynamic_tool": false,
25+
"active": true
26+
},
27+
{
28+
"id": 47,
29+
"name": "AnchoreCTL Vuln Report",
30+
"static_tool": false,
31+
"dynamic_tool": false,
32+
"active": true
33+
},
34+
{
35+
"id": 112,
36+
"name": "Anchore Engine Scan",
37+
"static_tool": false,
38+
"dynamic_tool": false,
39+
"active": true
40+
},
41+
{
42+
"id": 172,
43+
"name": "Anchore Enterprise Policy Check",
44+
"static_tool": false,
45+
"dynamic_tool": false,
46+
"active": true
47+
},
48+
{
49+
"id": 106,
50+
"name": "Anchore Grype",
51+
"static_tool": true,
52+
"dynamic_tool": false,
53+
"active": true
54+
},
55+
{
56+
"id": 1,
57+
"name": "API Test",
58+
"static_tool": false,
59+
"dynamic_tool": false,
60+
"active": true
61+
},
62+
{
63+
"id": 100,
64+
"name": "AppSpider Scan",
65+
"static_tool": false,
66+
"dynamic_tool": true,
67+
"active": true
68+
}
69+
]
70+
}

0 commit comments

Comments
 (0)