Skip to content

Commit 4129ad5

Browse files
committed
[backend] Fix PR issues
1 parent 408da22 commit 4129ad5

File tree

4 files changed

+89
-163
lines changed

4 files changed

+89
-163
lines changed

openaev-api/src/main/java/io/openaev/rest/inject/InjectApi.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import io.openaev.rest.exercise.exports.ExportOptions;
2323
import io.openaev.rest.helper.RestBehavior;
2424
import io.openaev.rest.inject.form.*;
25-
import io.openaev.rest.inject.output.InjectOutput;
2625
import io.openaev.rest.inject.service.ExecutableInjectService;
2726
import io.openaev.rest.inject.service.InjectExecutionService;
2827
import io.openaev.rest.inject.service.InjectExportService;
@@ -413,8 +412,7 @@ public List<Inject> nextInjectsToExecute(@RequestParam Optional<Integer> size) {
413412
@PutMapping(INJECT_URI)
414413
@RBAC(actionPerformed = Action.WRITE, resourceType = ResourceType.INJECT)
415414
@LogExecutionTime
416-
public List<Inject> bulkUpdateInject(
417-
@RequestBody @Valid final InjectBulkUpdateInputs input) {
415+
public List<Inject> bulkUpdateInject(@RequestBody @Valid final InjectBulkUpdateInputs input) {
418416

419417
// Control and format inputs
420418
List<Inject> injectsToUpdate =

openaev-api/src/main/java/io/openaev/rest/inject/output/InjectOutput.java

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -25,90 +25,90 @@
2525
@NoArgsConstructor
2626
public class InjectOutput {
2727

28-
@JsonProperty("inject_id")
29-
@NotBlank
30-
@Schema(description = "ID of the inject")
31-
private String id;
32-
33-
@JsonProperty("inject_title")
34-
@NotBlank
35-
@Schema(description = "Title of the inject")
36-
private String title;
37-
38-
@JsonProperty("inject_enabled")
39-
@Schema(description = "Enabled state of the inject")
40-
private boolean enabled;
41-
42-
@JsonProperty("inject_exercise")
43-
@JsonSerialize(using = MonoIdDeserializer.class)
44-
@Schema(description = "Simulation ID of the inject")
45-
private Exercise exercise;
46-
47-
@JsonProperty("inject_scenario")
48-
@JsonSerialize(using = MonoIdDeserializer.class)
49-
@Schema(description = "Scenario ID of the inject")
50-
private Scenario scenario;
51-
52-
@JsonProperty("inject_depends_duration")
53-
@NotNull
54-
@Min(value = 0L, message = "The value must be positive")
55-
@Schema(description = "Depend duration of the inject")
56-
private Long dependsDuration;
57-
58-
@JsonProperty("inject_depends_on")
59-
@ArraySchema(schema = @Schema(description = "Inject dependencies of the inject"))
60-
private List<InjectDependency> dependsOn;
61-
62-
@JsonProperty("inject_injector_contract")
63-
@Schema(description = "Injector contract of the inject")
64-
private InjectorContract injectorContract;
65-
66-
@JsonProperty("inject_tags")
67-
@JsonSerialize(using = MultiIdSetDeserializer.class)
68-
@ArraySchema(schema = @Schema(description = "Tags of the inject"))
69-
private Set<Tag> tags;
70-
71-
@JsonProperty("inject_type")
72-
@Schema(description = "Type of the inject")
73-
public String injectType;
74-
75-
@JsonProperty("inject_teams")
76-
@JsonSerialize(using = MultiIdListDeserializer.class)
77-
@ArraySchema(schema = @Schema(description = "Teams of the inject"))
78-
private List<Team> teams;
79-
80-
@JsonProperty("inject_assets")
81-
@JsonSerialize(using = MultiIdListDeserializer.class)
82-
@ArraySchema(schema = @Schema(description = "Assets of the inject"))
83-
private List<Asset> assets;
84-
85-
@JsonProperty("inject_asset_groups")
86-
@JsonSerialize(using = MultiIdListDeserializer.class)
87-
@ArraySchema(schema = @Schema(description = "Asset groups of the inject"))
88-
private List<AssetGroup> assetGroups;
89-
90-
@JsonProperty("inject_content")
91-
@Schema(description = "Content of the inject")
92-
private ObjectNode content;
93-
94-
@JsonProperty("inject_ready")
95-
@Schema(description = "Ready state of the inject")
96-
public boolean isReady() {
97-
return healthchecks.isEmpty()
98-
|| healthchecks.stream()
99-
.noneMatch(
100-
healthcheck ->
101-
HealthCheck.Detail.MANDATORY_CONTENT.equals(healthcheck.getDetail()));
102-
}
103-
104-
@JsonProperty("inject_healthchecks")
105-
@ArraySchema(schema = @Schema(description = "Healthchecks of the inject"))
106-
private List<HealthCheck> healthchecks = new ArrayList<>();
107-
108-
@JsonProperty("inject_testable")
109-
@Schema(description = "Testable state of the inject")
110-
public boolean canBeTested() {
111-
return EmailContract.TYPE.equals(this.getInjectType())
112-
|| OvhSmsContract.TYPE.equals(this.getInjectType());
113-
}
28+
@JsonProperty("inject_id")
29+
@NotBlank
30+
@Schema(description = "ID of the inject")
31+
private String id;
32+
33+
@JsonProperty("inject_title")
34+
@NotBlank
35+
@Schema(description = "Title of the inject")
36+
private String title;
37+
38+
@JsonProperty("inject_enabled")
39+
@Schema(description = "Enabled state of the inject")
40+
private boolean enabled;
41+
42+
@JsonProperty("inject_exercise")
43+
@JsonSerialize(using = MonoIdDeserializer.class)
44+
@Schema(description = "Simulation ID of the inject")
45+
private Exercise exercise;
46+
47+
@JsonProperty("inject_scenario")
48+
@JsonSerialize(using = MonoIdDeserializer.class)
49+
@Schema(description = "Scenario ID of the inject")
50+
private Scenario scenario;
51+
52+
@JsonProperty("inject_depends_duration")
53+
@NotNull
54+
@Min(value = 0L, message = "The value must be positive")
55+
@Schema(description = "Depend duration of the inject")
56+
private Long dependsDuration;
57+
58+
@JsonProperty("inject_depends_on")
59+
@ArraySchema(schema = @Schema(description = "Inject dependencies of the inject"))
60+
private List<InjectDependency> dependsOn;
61+
62+
@JsonProperty("inject_injector_contract")
63+
@Schema(description = "Injector contract of the inject")
64+
private InjectorContract injectorContract;
65+
66+
@JsonProperty("inject_tags")
67+
@JsonSerialize(using = MultiIdSetDeserializer.class)
68+
@ArraySchema(schema = @Schema(description = "Tags of the inject"))
69+
private Set<Tag> tags;
70+
71+
@JsonProperty("inject_type")
72+
@Schema(description = "Type of the inject")
73+
public String injectType;
74+
75+
@JsonProperty("inject_teams")
76+
@JsonSerialize(using = MultiIdListDeserializer.class)
77+
@ArraySchema(schema = @Schema(description = "Teams of the inject"))
78+
private List<Team> teams;
79+
80+
@JsonProperty("inject_assets")
81+
@JsonSerialize(using = MultiIdListDeserializer.class)
82+
@ArraySchema(schema = @Schema(description = "Assets of the inject"))
83+
private List<Asset> assets;
84+
85+
@JsonProperty("inject_asset_groups")
86+
@JsonSerialize(using = MultiIdListDeserializer.class)
87+
@ArraySchema(schema = @Schema(description = "Asset groups of the inject"))
88+
private List<AssetGroup> assetGroups;
89+
90+
@JsonProperty("inject_content")
91+
@Schema(description = "Content of the inject")
92+
private ObjectNode content;
93+
94+
@JsonProperty("inject_ready")
95+
@Schema(description = "Ready state of the inject")
96+
public boolean isReady() {
97+
return healthchecks.isEmpty()
98+
|| healthchecks.stream()
99+
.noneMatch(
100+
healthcheck ->
101+
HealthCheck.Detail.MANDATORY_CONTENT.equals(healthcheck.getDetail()));
102+
}
103+
104+
@JsonProperty("inject_healthchecks")
105+
@ArraySchema(schema = @Schema(description = "Healthchecks of the inject"))
106+
private List<HealthCheck> healthchecks = new ArrayList<>();
107+
108+
@JsonProperty("inject_testable")
109+
@Schema(description = "Testable state of the inject")
110+
public boolean canBeTested() {
111+
return EmailContract.TYPE.equals(this.getInjectType())
112+
|| OvhSmsContract.TYPE.equals(this.getInjectType());
113+
}
114114
}

openaev-api/src/main/java/io/openaev/service/ScenarioService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,8 @@ public List<HealthCheck> runChecks(String scenarioId) {
944944

945945
// Since Injects healthchecks now have the "Missing Content" (and maybe others) checks details,
946946
// we dont want them into the Scenario checks.
947-
// That's why we have to verify if there is existing checks necessary to the scenario onto the injects checks.
947+
// That's why we have to verify if there is existing checks necessary to the scenario into the
948+
// injects checks.
948949
healthChecks.addAll(
949950
healthCheckUtils.runInjectsChecksFor(
950951
HealthCheck.Type.SMTP,

openaev-api/src/main/java/io/openaev/utils/mapper/InjectMapper.java

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import io.openaev.utils.InjectExpectationResultUtils;
1313
import io.openaev.utils.InjectUtils;
1414
import io.openaev.utils.TargetType;
15-
import java.time.Instant;
1615
import java.util.*;
1716
import java.util.stream.Collectors;
1817
import lombok.RequiredArgsConstructor;
@@ -150,80 +149,32 @@ private static RelatedEntityOutput toRelatedEntityOutput(Inject inject) {
150149
public InjectOutput toInjectOutput(
151150
String id,
152151
String title,
153-
// String description,
154-
// String country,
155-
// String city,
156152
boolean enabled,
157-
// Instant triggerNowDate,
158153
ObjectNode content,
159-
// Instant createdAt,
160-
// Instant updatedAt,
161-
// boolean allTeams,
162154
Exercise exercise,
163155
Scenario scenario,
164156
List<InjectDependency> dependsOn,
165157
Long dependsDuration,
166158
InjectorContract injectorContract,
167-
// User user,
168-
// InjectStatus status,
169-
// CollectExecutionStatus collectExecutionStatus,
170159
Set<Tag> tags,
171160
List<Team> teams,
172161
List<Asset> assets,
173162
List<AssetGroup> assetGroups,
174-
// List<InjectDocument> documents,
175-
// List<Communication> communications,
176-
// List<InjectExpectation> expectations,
177-
// boolean isListened,
178-
// String header,
179-
// String footer,
180-
// Long numberOfTargetUsers,
181-
// Instant date,
182-
// Long communicationsNumber,
183-
// Long communicationsNotAckNumber,
184-
// Instant sentAt,
185-
// List<KillChainPhase> killChainPhases,
186-
// List<AttackPattern> attackPatterns,
187-
// String type,
188163
List<HealthCheck> healthchecks) {
189164
InjectOutput injectOutput = new InjectOutput();
190165
injectOutput.setId(id);
191166
injectOutput.setTitle(title);
192-
// injectOutput.setDescription(description);
193-
// injectOutput.setCountry(country);
194-
// injectOutput.setCity(city);
195167
injectOutput.setEnabled(enabled);
196-
// injectOutput.setTriggerNowDate(triggerNowDate);
197168
injectOutput.setContent(content);
198-
// injectOutput.setCreatedAt(createdAt);
199-
// injectOutput.setUpdatedAt(updatedAt);
200-
// injectOutput.setAllTeams(allTeams);
201169
injectOutput.setExercise(exercise);
202170
injectOutput.setScenario(scenario);
203171
injectOutput.setDependsOn(dependsOn);
204172
injectOutput.setDependsDuration(dependsDuration);
205173
injectOutput.setInjectorContract(injectorContract);
206-
// injectOutput.setUser(user);
207-
// injectOutput.setStatus(status);
208-
// injectOutput.setCollectExecutionStatus(collectExecutionStatus);
209174
injectOutput.setTags(tags);
210175
injectOutput.setTeams(teams);
211176
injectOutput.setAssets(assets);
212177
injectOutput.setAssetGroups(assetGroups);
213-
// injectOutput.setDocuments(documents);
214-
// injectOutput.setCommunications(communications);
215-
// injectOutput.setExpectations(expectations);
216-
// injectOutput.setListened(isListened);
217-
// injectOutput.setHeader(header);
218-
// injectOutput.setFooter(footer);
219-
// injectOutput.setNumberOfTargetUsers(numberOfTargetUsers);
220-
// injectOutput.setDate(date);
221-
// injectOutput.setCommunicationsNumber(communicationsNumber);
222-
// injectOutput.setCommunicationsNotAckNumber(communicationsNotAckNumber);
223-
// injectOutput.setSentAt(sentAt);
224-
// injectOutput.setKillChainPhases(killChainPhases);
225-
// injectOutput.setAttackPatterns(attackPatterns);
226-
// injectOutput.setType(type);
227178
injectOutput.setHealthchecks(healthchecks);
228179
return injectOutput;
229180
}
@@ -232,41 +183,17 @@ public InjectOutput toInjectOutput(Inject inject, List<HealthCheck> healthchecks
232183
return toInjectOutput(
233184
inject.getId(),
234185
inject.getTitle(),
235-
// inject.getDescription(),
236-
// inject.getCountry(),
237-
// inject.getCity(),
238186
inject.isEnabled(),
239-
// inject.getTriggerNowDate(),
240187
inject.getContent(),
241-
// inject.getCreatedAt(),
242-
// inject.getUpdatedAt(),
243-
// inject.isAllTeams(),
244188
inject.getExercise(),
245189
inject.getScenario(),
246190
inject.getDependsOn(),
247191
inject.getDependsDuration(),
248192
inject.getInjectorContract().orElse(null),
249-
// inject.getUser(),
250-
// inject.getStatus().orElse(null),
251-
// inject.getCollectExecutionStatus(),
252193
inject.getTags(),
253194
inject.getTeams(),
254195
inject.getAssets(),
255196
inject.getAssetGroups(),
256-
// inject.getDocuments(),
257-
// inject.getCommunications(),
258-
// inject.getExpectations(),
259-
// inject.isListened(),
260-
// inject.getHeader(),
261-
// inject.getFooter(),
262-
// inject.getNumberOfTargetUsers(),
263-
// inject.getDate().orElse(null),
264-
// inject.getCommunicationsNumber(),
265-
// inject.getCommunicationsNotAckNumber(),
266-
// inject.getSentAt(),
267-
// inject.getKillChainPhases(),
268-
// inject.getAttackPatterns(),
269-
// inject.getType(),
270197
healthchecks);
271198
}
272199
}

0 commit comments

Comments
 (0)