Skip to content

Commit

Permalink
Update tests to support corrected JSON Schema Generation PR (#380)
Browse files Browse the repository at this point in the history
* Correct field and flag enumerations in JSON schemas.

Previously in #360, @kylelaker reported a needed
improvement to fix a regression for usnistgov/OSCAL#1773. While I had
been completing testing in #360 and properly expanding test coverage to
address how we handle enumerations based on allow-other and target
attributes for field and flag elements in Metaschema (both act similarly
but subtly different with more scenarios for field), I observed my test data
instances needed further correction in a way that cannot be address in the
PR by Kyle. This merges the changes from the commit reffed by the URL
below, adds my enhancement, tests, and all examples that helped me
uncover missing code.

6fb8a74

* Surpress bottlecaps.de link fail

More info below:
https://github.com/usnistgov/metaschema/actions/runs/5228171226/jobs/9440341454


Co-authored-by: Kyle Laker <kyle@laker.email>
  • Loading branch information
aj-stein-nist and laurelmay authored Jun 26, 2023
1 parent d3c1d1f commit 13cde79
Show file tree
Hide file tree
Showing 43 changed files with 720 additions and 368 deletions.
3 changes: 3 additions & 0 deletions build/config/.markdown-link-check/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
},
{
"pattern": "https://help.github.com"
},
{
"pattern": "https://www.bottlecaps.de/rex/"
}
],
"replacementPatterns": [
Expand Down
70 changes: 42 additions & 28 deletions test-suite/metaschema-xspec/json-schema-gen/json-schema-gen.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,50 @@
xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
xmlns:j="http://www.w3.org/2005/xpath-functions"
stylesheet="../../../toolchains/xslt-M4/nist-metaschema-MAKE-JSON-SCHEMA.xsl" run-as="external">

<x:scenario label="When generating a JSON schema from composed Metaschema definitions">
<x:scenario label="if it has a defined field with no constraint and no allowed-values">
<x:context href="json-value_unconstrained_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_unconstrained.json' => j:unparsed-text() => j:json-to-xml()"/>
<x:scenario label="if it has a defined flag">
<x:scenario label="with no constraint and no allowed-values">
<x:context href="json-value_flag_unconstrained_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_flag_unconstrained.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
<x:scenario label="with a constraint, allowed-values, strict enforcement of allow-other='no' and explicit target of '.'">
<x:context href="json-value_flag_constrained-closed_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_flag_constrained-closed.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
<x:scenario label="with a constraint, allowed-values, no explicit target, and permissive enforcement of allow-other='yes'">
<x:context href="json-value_flag_constrained-open_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_flag_constrained-open.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
</x:scenario>

<x:scenario label="if it has a defined field with a constraint, allowed-values, strict enforcement of allow-other='no' and explicit target of '.'">
<x:context href="json-value_constrained-closed_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_constrained-closed.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>

<x:scenario label="if it has a defined field with a constraint, allowed-values, no explicit target, and permissive enforcement of allow-other='yes'">
<x:context href="json-value_constrained-open_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_constrained-open.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>

<x:scenario label="if it has a defined field with a constraint, allowed-values, strict enforcement of allow-other='no' and explicit target other than '.'">
<x:context href="json-value_constrained-narrow_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_constrained-narrow.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>

<x:scenario label="if it has a defined field with a constraint, allowed-values, permissive enforcement of allow-other='yes' and explicit target other than '.'">
<x:context href="json-value_constrained-sortof_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_constrained-sortof.json' => j:unparsed-text() => j:json-to-xml()"/>
<x:scenario label="if it has a defined field">
<x:scenario label="with no constraint and no allowed-values">
<x:context href="json-value_field_unconstrained_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_field_unconstrained.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
<x:scenario label="with a constraint, allowed-values, strict enforcement of allow-other='no' and explicit target of '.'">
<x:context href="json-value_field_constrained-closed_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_field_constrained-closed.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
<x:scenario label="with a constraint, allowed-values, no explicit target, and permissive enforcement of allow-other='yes'">
<x:context href="json-value_field_constrained-open_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_field_constrained-open.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
<x:scenario label="with a constraint, allowed-values, strict enforcement of allow-other='no' and explicit target other than '.'">
<x:context href="json-value_field_constrained-narrow_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_field_constrained-narrow.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
<x:scenario label="with a constraint, allowed-values, permissive enforcement of allow-other='yes' and explicit target other than '.'">
<x:context href="json-value_field_constrained-sortof_metaschema.xml"/>
<x:expect label="the resulting JSON Schema should not have an enum to enforce it."
test="$x:result => j:json-to-xml()" select="'../json-value_field_constrained-sortof.json' => j:unparsed-text() => j:json-to-xml()"/>
</x:scenario>
</x:scenario>
</x:scenario>
</x:description>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 13cde79

Please sign in to comment.