diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb0f858..7d28e48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: for k in totals: totals[k]+=int(r.get(k,'0')) except Exception: pass - exp_tests=465 + exp_tests=466 exp_skipped=0 if totals['tests']!=exp_tests or totals['skipped']!=exp_skipped: print(f"Unexpected test totals: {totals} != expected tests={exp_tests}, skipped={exp_skipped}") diff --git a/json-java21-jtd/src/test/java/json/java21/jtd/TestRfc8927.java b/json-java21-jtd/src/test/java/json/java21/jtd/TestRfc8927.java index 05dae59..9beacc5 100644 --- a/json-java21-jtd/src/test/java/json/java21/jtd/TestRfc8927.java +++ b/json-java21-jtd/src/test/java/json/java21/jtd/TestRfc8927.java @@ -595,4 +595,49 @@ public void testDiscriminatorInElementsSchema() throws Exception { .as("Discriminator in elements schema should validate the property test case") .isTrue(); } + + /// Test case from JtdExhaustiveTest property test failure + /// Nested elements containing properties schemas should reject additional properties + /// Schema: {"elements":{"elements":{"properties":{}}}} + /// Document: [[{},{},[{},{extraProperty":"extra-value"}]] + /// This should fail validation but currently passes incorrectly + @Test + public void testNestedElementsPropertiesRejectsAdditionalProperties() throws Exception { + JsonValue schema = Json.parse(""" + { + "elements": { + "elements": { + "properties": {} + } + } + } + """); + JsonValue document = Json.parse(""" + [ + [{}, {}], + [{}, {"extraProperty": "extra-value"}] + ] + """); + + LOG.info(() -> "Testing nested elements properties - property test failure case"); + LOG.fine(() -> "Schema: " + schema); + LOG.fine(() -> "Document: " + document); + + Jtd validator = new Jtd(); + Jtd.Result result = validator.validate(schema, document); + + LOG.fine(() -> "Validation result: " + (result.isValid() ? "VALID" : "INVALID")); + if (!result.isValid()) { + LOG.fine(() -> "Errors: " + result.errors()); + } + + // This should fail because the inner object has an extra property + // and the properties schema should reject additional properties by default + assertThat(result.isValid()) + .as("Nested elements properties should reject additional properties") + .isFalse(); + assertThat(result.errors()) + .as("Should have validation errors for additional property") + .isNotEmpty(); + } }