Skip to content

Commit 95afb10

Browse files
committedMar 15, 2024
Capture & Replay Integration Test for EndpointService
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent 4c9d441 commit 95afb10

File tree

2 files changed

+243
-1
lines changed

2 files changed

+243
-1
lines changed
 

‎src/test/java/io/securecodebox/persistence/defectdojo/service/EndpointServiceTest.java

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

3+
import io.securecodebox.persistence.defectdojo.model.Endpoint;
4+
import io.securecodebox.persistence.defectdojo.model.User;
35
import org.junit.jupiter.api.Test;
46

7+
import java.io.IOException;
8+
import java.net.URISyntaxException;
9+
10+
import static com.github.tomakehurst.wiremock.client.WireMock.*;
511
import static org.junit.jupiter.api.Assertions.*;
612
import static org.hamcrest.MatcherAssert.assertThat;
713
import static org.hamcrest.Matchers.*;
@@ -11,4 +17,58 @@
1117
*/
1218
final class EndpointServiceTest extends WireMockBaseTestCase {
1319
private final EndpointService sut = new EndpointService(conf());
20+
21+
@Test
22+
void search() throws URISyntaxException, IOException {
23+
stubFor(
24+
get("/api/v2/endpoints/?offset=0&limit=100")
25+
.willReturn(
26+
ok()
27+
.withBody(readResponseBodyFromFixture("io/securecodebox/persistence/defectdojo/service/fixture_EndpointService.json"))
28+
)
29+
);
30+
31+
final var result = sut.search();
32+
33+
assertAll(
34+
() -> assertThat(result, hasSize(5)),
35+
() -> assertThat(result, containsInAnyOrder(
36+
Endpoint.builder()
37+
.id(956)
38+
.protocol("tcp")
39+
.host("10.0.0.1")
40+
.port(80)
41+
.product(320)
42+
.build(),
43+
Endpoint.builder()
44+
.id(957)
45+
.protocol("tcp")
46+
.host("10.0.0.1")
47+
.port(443)
48+
.product(320)
49+
.build(),
50+
Endpoint.builder()
51+
.id(961)
52+
.protocol("tcp")
53+
.host("10.0.0.2")
54+
.port(80)
55+
.product(323)
56+
.build(),
57+
Endpoint.builder()
58+
.id(962)
59+
.protocol("tcp")
60+
.host("10.0.0.2")
61+
.port(443)
62+
.product(323)
63+
.build(),
64+
Endpoint.builder()
65+
.id(893)
66+
.protocol("tcp")
67+
.host("10.0.0.3")
68+
.port(443)
69+
.product(296)
70+
.build()
71+
))
72+
);
73+
}
1474
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,183 @@
1-
{}
1+
{
2+
"count": 5,
3+
"next": null,
4+
"previous": null,
5+
"results": [
6+
{
7+
"id": 956,
8+
"tags": [],
9+
"protocol": "tcp",
10+
"userinfo": null,
11+
"host": "10.0.0.1",
12+
"port": 80,
13+
"path": null,
14+
"query": null,
15+
"fragment": null,
16+
"product": 320,
17+
"endpoint_params": [],
18+
"findings": [
19+
31763,
20+
31742,
21+
31737,
22+
31735,
23+
28079,
24+
28063,
25+
28052,
26+
28042,
27+
24615,
28+
24554,
29+
24516,
30+
24507,
31+
20736,
32+
20670,
33+
20653,
34+
20634,
35+
18800,
36+
18622,
37+
18447,
38+
18426
39+
]
40+
},
41+
{
42+
"id": 957,
43+
"tags": [],
44+
"protocol": "tcp",
45+
"userinfo": null,
46+
"host": "10.0.0.1",
47+
"port": 443,
48+
"path": null,
49+
"query": null,
50+
"fragment": null,
51+
"product": 320,
52+
"endpoint_params": [],
53+
"findings": [
54+
31764,
55+
31743,
56+
31738,
57+
31736,
58+
28080,
59+
28064,
60+
28053,
61+
28043,
62+
24616,
63+
24555,
64+
24517,
65+
24508,
66+
20737,
67+
20671,
68+
20654,
69+
20635,
70+
18802,
71+
18623,
72+
18448,
73+
18427
74+
]
75+
},
76+
{
77+
"id": 961,
78+
"tags": [],
79+
"protocol": "tcp",
80+
"userinfo": null,
81+
"host": "10.0.0.2",
82+
"port": 80,
83+
"path": null,
84+
"query": null,
85+
"fragment": null,
86+
"product": 323,
87+
"endpoint_params": [],
88+
"findings": [
89+
31733,
90+
31731,
91+
31729,
92+
31726,
93+
28113,
94+
28081,
95+
28069,
96+
28065,
97+
24626,
98+
24558,
99+
24521,
100+
24505,
101+
20746,
102+
20681,
103+
20655,
104+
20636,
105+
18630,
106+
18530,
107+
18482,
108+
18445
109+
]
110+
},
111+
{
112+
"id": 962,
113+
"tags": [],
114+
"protocol": "tcp",
115+
"userinfo": null,
116+
"host": "10.0.0.2",
117+
"port": 443,
118+
"path": null,
119+
"query": null,
120+
"fragment": null,
121+
"product": 323,
122+
"endpoint_params": [],
123+
"findings": [
124+
31734,
125+
31732,
126+
31730,
127+
31727,
128+
28114,
129+
28082,
130+
28070,
131+
28066,
132+
24627,
133+
24559,
134+
24522,
135+
24506,
136+
20747,
137+
20682,
138+
20656,
139+
20637,
140+
18631,
141+
18531,
142+
18483,
143+
18446
144+
]
145+
},
146+
{
147+
"id": 893,
148+
"tags": [],
149+
"protocol": "tcp",
150+
"userinfo": null,
151+
"host": "10.0.0.3",
152+
"port": 443,
153+
"path": null,
154+
"query": null,
155+
"fragment": null,
156+
"product": 296,
157+
"endpoint_params": [],
158+
"findings": [
159+
31728,
160+
31725,
161+
31724,
162+
31723,
163+
28141,
164+
28088,
165+
28078,
166+
28071,
167+
24612,
168+
24551,
169+
24515,
170+
24504,
171+
20732,
172+
20669,
173+
20639,
174+
20633,
175+
19585,
176+
18914,
177+
18054,
178+
18018
179+
]
180+
}
181+
],
182+
"prefetch": {}
183+
}

0 commit comments

Comments
 (0)
Please sign in to comment.