Skip to content

Commit c8ff8c2

Browse files
authored
feat: restrict the logical constraints domain (#134)
1 parent 9bac6a0 commit c8ff8c2

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

artifacts/src/main/resources/negotiation/contract-schema.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,28 +213,27 @@
213213
"properties": {
214214
"and": {
215215
"type": "array",
216-
"items": "object"
216+
"items": {
217+
"$ref": "#/definitions/Constraint"
218+
}
217219
},
218220
"andSequence": {
219221
"type": "array",
220-
"items": "object"
222+
"items": {
223+
"$ref": "#/definitions/Constraint"
224+
}
221225
},
222226
"or": {
223227
"type": "array",
224228
"items": {
225-
"oneOf": [
226-
{
227-
"$ref": "#/definitions/LogicalConstraint"
228-
},
229-
{
230-
"$ref": "#/definitions/AtomicConstraint"
231-
}
232-
]
229+
"$ref": "#/definitions/Constraint"
233230
}
234231
},
235232
"xone": {
236233
"type": "array",
237-
"items": "object"
234+
"items": {
235+
"$ref": "#/definitions/Constraint"
236+
}
238237
}
239238
},
240239
"oneOf": [

artifacts/src/test/java/org/eclipse/dsp/schema/negotiation/InvalidPolicySchemaTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void verifyInvalidCases() {
3232
assertThat(schema.validate(INVALID_NO_OPERATOR, JSON).iterator().next().getType()).isEqualTo(ONE_OF);
3333
assertThat(schema.validate(INVALID_NO_RIGHT_OPERAND, JSON).iterator().next().getType()).isEqualTo(ONE_OF);
3434
assertThat(schema.validate(INVALID_MULTIPLICITY_CONSTRAINT, JSON).iterator().next().getType()).isEqualTo(ONE_OF);
35+
assertThat(schema.validate(INVALID_LOGICAL_CONTENT_NESTING, JSON).iterator().next().getType()).isEqualTo(ONE_OF);
3536
}
3637

3738
@BeforeEach
@@ -161,4 +162,32 @@ void setUp() {
161162
]
162163
}
163164
""";
165+
166+
private static final String INVALID_LOGICAL_CONTENT_NESTING = """
167+
{
168+
"@id": "urn:uuid:3dd1add8-4d2d-569e-d634-8394a8836a88",
169+
"@type": "Offer",
170+
"target": "asset:1",
171+
"permission": [
172+
{
173+
"action": "use",
174+
"constraint": {
175+
"and": [
176+
{
177+
"leftOperand": "partner",
178+
"operator": "eq",
179+
"rightOperand": "gold"
180+
},
181+
{
182+
"something": "that",
183+
"is": "definitely",
184+
"not": "a",
185+
"valid": "constraint"
186+
}
187+
]
188+
}
189+
}
190+
]
191+
}
192+
""";
164193
}

0 commit comments

Comments
 (0)