Skip to content

Commit 1caffc5

Browse files
committed
Capture & Replay Integration Test for EngagementService
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent b9b45c2 commit 1caffc5

File tree

2 files changed

+204
-3
lines changed

2 files changed

+204
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,85 @@
11
package io.securecodebox.persistence.defectdojo.service;
22

3+
import io.securecodebox.persistence.defectdojo.model.Engagement;
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+
import java.util.Collections;
9+
10+
import static com.github.tomakehurst.wiremock.client.WireMock.*;
611
import static org.hamcrest.MatcherAssert.assertThat;
7-
import static org.hamcrest.Matchers.*;
12+
import static org.hamcrest.Matchers.containsInAnyOrder;
13+
import static org.hamcrest.Matchers.hasSize;
14+
import static org.junit.jupiter.api.Assertions.assertAll;
815

916
/**
1017
* Tests for {@link EngagementService}
1118
*/
1219
final class EngagementServiceTest extends WireMockBaseTestCase {
1320
private final EngagementService sut = new EngagementService(conf());
21+
22+
@Test
23+
void search() throws URISyntaxException, IOException {
24+
stubFor(
25+
get("/api/v2/engagements/?offset=0&limit=100")
26+
.willReturn(
27+
ok()
28+
.withBody(readResponseBodyFromFixture("EngagementService_response_fixture.json"))
29+
)
30+
);
31+
32+
final var result = sut.search();
33+
34+
assertAll(
35+
() -> assertThat(result, hasSize(3)),
36+
() -> assertThat(result, containsInAnyOrder(
37+
Engagement.builder()
38+
.id(806)
39+
.branch("")
40+
.name("nmap-vienna-client-1709886900")
41+
.description("")
42+
.version("")
43+
.targetStart("2024-03-08")
44+
.targetEnd("2024-03-08")
45+
.status(Engagement.Status.IN_PROGRESS)
46+
.engagementType("CI/CD")
47+
.lead(3)
48+
.product(162)
49+
.orchestrationEngine(1)
50+
.tags(Collections.emptyList())
51+
.build(),
52+
Engagement.builder()
53+
.id(807)
54+
.branch("")
55+
.name("nmap-stuttgart-client-1709886900")
56+
.description("")
57+
.version("")
58+
.targetStart("2024-03-08")
59+
.targetEnd("2024-03-08")
60+
.status(Engagement.Status.IN_PROGRESS)
61+
.engagementType("CI/CD")
62+
.lead(3)
63+
.product(139)
64+
.orchestrationEngine(1)
65+
.tags(Collections.emptyList())
66+
.build(),
67+
Engagement.builder()
68+
.id(808)
69+
.branch("")
70+
.name("nmap-frankfurt-client-1709886900")
71+
.description("")
72+
.version("")
73+
.targetStart("2024-03-08")
74+
.targetEnd("2024-03-08")
75+
.status(Engagement.Status.IN_PROGRESS)
76+
.engagementType("CI/CD")
77+
.lead(3)
78+
.product(140)
79+
.orchestrationEngine(1)
80+
.tags(Collections.emptyList())
81+
.build()
82+
))
83+
);
84+
}
1485
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,131 @@
1-
{}
1+
{
2+
"count": 3,
3+
"next": null,
4+
"previous": null,
5+
"results": [
6+
{
7+
"id": 806,
8+
"tags": [],
9+
"name": "nmap-vienna-client-1709886900",
10+
"description": "",
11+
"version": "",
12+
"first_contacted": null,
13+
"target_start": "2024-03-08",
14+
"target_end": "2024-03-08",
15+
"reason": null,
16+
"updated": "2024-03-08T08:35:45.813869Z",
17+
"created": "2024-03-08T08:35:45.345170Z",
18+
"active": true,
19+
"tracker": null,
20+
"test_strategy": null,
21+
"threat_model": false,
22+
"api_test": false,
23+
"pen_test": false,
24+
"check_list": false,
25+
"status": "In Progress",
26+
"progress": "threat_model",
27+
"tmodel_path": "none",
28+
"done_testing": false,
29+
"engagement_type": "CI/CD",
30+
"build_id": null,
31+
"commit_hash": null,
32+
"branch_tag": "",
33+
"source_code_management_uri": null,
34+
"deduplication_on_engagement": false,
35+
"lead": 3,
36+
"requester": null,
37+
"preset": null,
38+
"report_type": null,
39+
"product": 162,
40+
"build_server": null,
41+
"source_code_management_server": null,
42+
"orchestration_engine": 1,
43+
"notes": [],
44+
"files": [],
45+
"risk_acceptance": []
46+
},
47+
{
48+
"id": 807,
49+
"tags": [],
50+
"name": "nmap-stuttgart-client-1709886900",
51+
"description": "",
52+
"version": "",
53+
"first_contacted": null,
54+
"target_start": "2024-03-08",
55+
"target_end": "2024-03-08",
56+
"reason": null,
57+
"updated": "2024-03-08T08:36:12.942280Z",
58+
"created": "2024-03-08T08:36:12.467728Z",
59+
"active": true,
60+
"tracker": null,
61+
"test_strategy": null,
62+
"threat_model": false,
63+
"api_test": false,
64+
"pen_test": false,
65+
"check_list": false,
66+
"status": "In Progress",
67+
"progress": "threat_model",
68+
"tmodel_path": "none",
69+
"done_testing": false,
70+
"engagement_type": "CI/CD",
71+
"build_id": null,
72+
"commit_hash": null,
73+
"branch_tag": "",
74+
"source_code_management_uri": null,
75+
"deduplication_on_engagement": false,
76+
"lead": 3,
77+
"requester": null,
78+
"preset": null,
79+
"report_type": null,
80+
"product": 139,
81+
"build_server": null,
82+
"source_code_management_server": null,
83+
"orchestration_engine": 1,
84+
"notes": [],
85+
"files": [],
86+
"risk_acceptance": []
87+
},
88+
{
89+
"id": 808,
90+
"tags": [],
91+
"name": "nmap-frankfurt-client-1709886900",
92+
"description": "",
93+
"version": "",
94+
"first_contacted": null,
95+
"target_start": "2024-03-08",
96+
"target_end": "2024-03-08",
97+
"reason": null,
98+
"updated": "2024-03-08T08:36:23.745389Z",
99+
"created": "2024-03-08T08:36:23.172005Z",
100+
"active": true,
101+
"tracker": null,
102+
"test_strategy": null,
103+
"threat_model": false,
104+
"api_test": false,
105+
"pen_test": false,
106+
"check_list": false,
107+
"status": "In Progress",
108+
"progress": "threat_model",
109+
"tmodel_path": "none",
110+
"done_testing": false,
111+
"engagement_type": "CI/CD",
112+
"build_id": null,
113+
"commit_hash": null,
114+
"branch_tag": "",
115+
"source_code_management_uri": null,
116+
"deduplication_on_engagement": false,
117+
"lead": 3,
118+
"requester": null,
119+
"preset": null,
120+
"report_type": null,
121+
"product": 140,
122+
"build_server": null,
123+
"source_code_management_server": null,
124+
"orchestration_engine": 1,
125+
"notes": [],
126+
"files": [],
127+
"risk_acceptance": []
128+
}
129+
],
130+
"prefetch": {}
131+
}

0 commit comments

Comments
 (0)