From 86620b3cd92bee3445c046f6035ebff8eb186b32 Mon Sep 17 00:00:00 2001 From: Matteo Bitussi Date: Thu, 19 Oct 2023 11:59:15 +0200 Subject: [PATCH] added mandatory keys in test --- tool/src/main/java/migt/Test.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tool/src/main/java/migt/Test.java b/tool/src/main/java/migt/Test.java index 66506a7..074ef13 100644 --- a/tool/src/main/java/migt/Test.java +++ b/tool/src/main/java/migt/Test.java @@ -38,6 +38,7 @@ public class Test { // Infos String name; String description; + List mandatory_keys = new ArrayList<>(); /** * Empty constructor for tests @@ -58,6 +59,13 @@ public Test(JSONObject test_json, setType(test_json.getString("type")); Iterator keys = test_json.keys(); + + for (String k : mandatory_keys) { + if (!test_json.keySet().contains(k)) { + throw new ParsingException("Test is missing required \"" + k + "\" key"); + } + } + while (keys.hasNext()) { String key = keys.next(); @@ -144,6 +152,11 @@ public void init() { references = ""; violated_properties = ""; mitigations = ""; + + mandatory_keys.add("result"); + mandatory_keys.add("name"); + mandatory_keys.add("type"); + mandatory_keys.add("sessions"); } public String getName() {