This is an automated email from the ASF dual-hosted git repository.
jsinovassinnaik pushed a commit to branch UNOMI-598-validate-events-with-scope
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to
refs/heads/UNOMI-598-validate-events-with-scope by this push:
new 3ff605734 feedbacks
3ff605734 is described below
commit 3ff60573496f671e139d7f0343bd41e0b6be875b
Author: jsinovassin <[email protected]>
AuthorDate: Tue Jun 28 17:39:39 2022 +0200
feedbacks
---
.../apache/unomi/schema/keyword/ScopeKeyword.java | 2 +-
.../unomi/schema/keyword/ScopeValidator.java | 2 +-
.../META-INF/cxs/schemas/events/event.json | 2 +-
.../cxs/schemas/items/consent/consent.json | 2 +-
.../resources/META-INF/cxs/schemas/items/item.json | 2 +-
.../org/apache/unomi/itests/InputValidationIT.java | 25 ++++++++++++++++++++++
.../resources/schemas/event-flattened-valid.json | 20 ++++++++---------
.../resources/schemas/schema-dummy-properties.json | 2 +-
8 files changed, 41 insertions(+), 16 deletions(-)
diff --git
a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/keyword/ScopeKeyword.java
b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/keyword/ScopeKeyword.java
index ebe15ce30..471a475ab 100644
---
a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/keyword/ScopeKeyword.java
+++
b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/keyword/ScopeKeyword.java
@@ -28,7 +28,7 @@ public class ScopeKeyword extends AbstractKeyword {
private ScopeService scopeService;
public ScopeKeyword(ScopeService scopeService) {
- super("scope");
+ super("validateScope");
this.scopeService = scopeService;
}
diff --git
a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/keyword/ScopeValidator.java
b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/keyword/ScopeValidator.java
index 2f41d9b28..63bc65b29 100644
---
a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/keyword/ScopeValidator.java
+++
b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/keyword/ScopeValidator.java
@@ -34,7 +34,7 @@ public class ScopeValidator extends AbstractJsonValidator {
private ScopeService scopeService;
public ScopeValidator(ScopeService scopeService) {
- super("scope");
+ super("validateScope");
this.scopeService = scopeService;
}
diff --git
a/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/events/event.json
b/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/events/event.json
index 3e0dcf346..b4673a760 100644
---
a/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/events/event.json
+++
b/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/events/event.json
@@ -25,7 +25,7 @@
},
"scope" : {
"type" : [ "string"],
- "scope": true,
+ "validateScope": true,
"pattern" : "^(\\w|[-_@\\.]){0,60}$"
},
"sourceId" : {
diff --git
a/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/items/consent/consent.json
b/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/items/consent/consent.json
index 5e35b89a0..40b09d64d 100644
---
a/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/items/consent/consent.json
+++
b/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/items/consent/consent.json
@@ -12,7 +12,7 @@
"properties" : {
"scope" : {
"type" : "string",
- "scope": true
+ "validateScope" : true
},
"typeIdentifier" : {
"type" : "string"
diff --git
a/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/items/item.json
b/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/items/item.json
index 0c6e3d91e..d4a9f7772 100644
---
a/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/items/item.json
+++
b/extensions/json-schema/services/src/main/resources/META-INF/cxs/schemas/items/item.json
@@ -21,7 +21,7 @@
},
"scope" : {
"type" : ["null","string"],
- "scope": true,
+ "validateScope": true,
"description" : "The item's scope"
},
"version" : {
diff --git
a/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
b/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
index 0723d58c2..5bda5bc09 100644
--- a/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
@@ -24,6 +24,9 @@ import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.apache.unomi.api.Event;
+import org.apache.unomi.api.Metadata;
+import org.apache.unomi.api.Scope;
+import org.apache.unomi.api.services.ScopeService;
import org.apache.unomi.itests.tools.httpclient.HttpClientThatWaitsForUnomi;
import org.apache.unomi.schema.api.JsonSchemaWrapper;
import org.apache.unomi.schema.api.SchemaService;
@@ -39,7 +42,9 @@ import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Objects;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -59,6 +64,26 @@ public class InputValidationIT extends BaseIT {
@Filter(timeout = 600000)
protected SchemaService schemaService;
+ @Inject
+ @Filter(timeout = 600000)
+ protected ScopeService scopeService;
+
+ @Before
+ public void setUp() {
+ Scope scope = new Scope();
+ scope.setItemId("dummy_scope");
+ Metadata metadata = new Metadata();
+ metadata.setName("Dummy scope");
+ metadata.setId("dummy_scope");
+ scope.setMetadata(metadata);
+ scopeService.save(scope);
+ }
+
+ @After
+ public void tearDown() throws InterruptedException {
+ removeItems(Scope.class);
+ }
+
@Test
public void test_param_EventsCollectorRequestNotNull() throws IOException {
doPOSTRequestTest(EVENT_COLLECTOR_URL, null, null, 400,
ERROR_MESSAGE_INVALID_DATA_RECEIVED);
diff --git a/itests/src/test/resources/schemas/event-flattened-valid.json
b/itests/src/test/resources/schemas/event-flattened-valid.json
index e83d0101f..7c8e380b6 100644
--- a/itests/src/test/resources/schemas/event-flattened-valid.json
+++ b/itests/src/test/resources/schemas/event-flattened-valid.json
@@ -1,13 +1,13 @@
{
- "eventType":"flattened",
- "scope":"dummy_scope",
- "flattenedProperties": {
- "interests": {
- "cars": 15,
- "football": 59
+ "eventType": "flattened",
+ "scope": "dummy_scope",
+ "flattenedProperties": {
+ "interests": {
+ "cars": 15,
+ "football": 59
+ }
+ },
+ "properties": {
+ "marker": "###EVENT_MARKER###"
}
- },
- "properties": {
- "marker": "###EVENT_MARKER###"
- }
}
diff --git a/itests/src/test/resources/schemas/schema-dummy-properties.json
b/itests/src/test/resources/schemas/schema-dummy-properties.json
index 194bf8d00..e497791ee 100644
--- a/itests/src/test/resources/schemas/schema-dummy-properties.json
+++ b/itests/src/test/resources/schemas/schema-dummy-properties.json
@@ -15,7 +15,7 @@
},
"scope": {
"type": "string",
- "scope": true
+ "validateScope": true
},
"path": {
"type": "string",