-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation Agnostic Testing #1946
Merged
nikitawootten-nist
merged 18 commits into
usnistgov:develop
from
nikitawootten-nist:nikitawootten-nist/issue1771
Oct 25, 2023
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6c9395e
Deleted duplicate `metaschema_datatypes` file
nikitawootten-nist aaec9f9
Added spec test adr and prototype spec test file
nikitawootten-nist 6ea93d5
[WIP] Prototype spec application progress
nikitawootten-nist 0eeb820
Add missing `req/@level`s, fix `@id` typo
nikitawootten-nist c69f77d
Spec testing coverage subcommand
nikitawootten-nist 0790257
Spec test pass logic
nikitawootten-nist 69cd332
Ported the first xspec unit test
nikitawootten-nist ddbfbed
Spec tester respects tests file working directory
nikitawootten-nist 4a60f48
Misc fixes, test scenario now runs!
nikitawootten-nist d1e2559
[WIP] Added canned namespaces, queries now work
nikitawootten-nist 5769c5a
[WIP] overhaul comparison + results printing
nikitawootten-nist 58ea683
[WIP] Added more XPath selection comments
nikitawootten-nist 2c3c1f4
[WIP] Aligned XPath selection comments
nikitawootten-nist c5c8e45
[WIP] Spec tester verbosity is configurable
nikitawootten-nist 2bdecaa
[WIP] Spec tester argument to keep outputs
nikitawootten-nist 5f654b7
[WIP] Spec tester print scenario description
nikitawootten-nist 8626b98
[WIP] Fill out ADR details
nikitawootten-nist dfc0209
[WIP] Prevent output collisions, add usage example
nikitawootten-nist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Implementation-agnostic Testing and Test Harness | ||
|
||
Date: 10/06/2023 | ||
|
||
## Status | ||
|
||
Proposed | ||
|
||
## Context | ||
|
||
In order to support the development of OSCAL tooling, it was decided prototype a unified tool responsible for validating OSCAL implementations against specification requirements. | ||
|
||
Currently, only profile resolution has been [formalized into a draft specification](../src/specifications/profile-resolution/profile-resolution-specml.xml). | ||
|
||
### Existing Infrastructure | ||
|
||
The profile resolver specification currently leverages an in-house XML format known as SpecML, which breaks down a specification into a collection of **sections**, which contain in turn a collection of **requirements**. | ||
Each `<section/>` and `<requirement/>` has a unique `@id` attribute. | ||
|
||
The sections and requirements are mirrored in the XSLT implementation's profile resolution unit tests. | ||
Although crucial to the XSLT implementation, these tests are not portable and it would not be simple to use the tests in their current state to validate other implementations. | ||
|
||
### Specification Tests | ||
|
||
Some specifications such as [CommonMark](https://commonmark.org/) include a [test suite and testing harness](https://github.com/commonmark/commonmark-spec/tree/master/test) to make it possible for implementors to "score" their implementation's conformance to the specification. | ||
|
||
## Decision | ||
|
||
### SpecML | ||
|
||
The specification format will remain unchanged for now. | ||
There is an argument for the format to be replaced or simplified in the future, but the use of `@id` attributes for sections and requirements make linking a test to a example simple. | ||
|
||
### Test Suite Data Format | ||
|
||
The test suite will be described using a JSON file with a simple data format. | ||
|
||
This file will contain a collection of objects that map to a given spec requirement via `section_id` and `requirement_id` fields. | ||
These objects will further contain a collection of "scenario" objects, each of which containing a `description`, `source_profile_path`, `expected_catalog_path`, and a collection of `selection_expressions`. | ||
|
||
For a given scenario, a test runner would be expected to perform profile resolution with the `source_profile_path` and compare selections of the resulting document with the `expected_catalog_path`. | ||
The `selection_expressions` are XPath expressions, though the [test harness](#test-harness) may further constrain the XPath expression's capabilities. | ||
|
||
Here is an example test suite made up of one requirement: | ||
|
||
```json | ||
[ | ||
{ | ||
"section_id": "import", | ||
"requirement_id": "req-uri-resolve", | ||
"scenarios": [ | ||
{ | ||
"description": "Check that group and control titles match, signalling that URIs have been resolved", | ||
"source_profile_path": "requirement-tests/req-include-all-asis.xml", | ||
"expected_catalog_path": "requirement-tests/output-expected/req-include-all-asis_RESOLVED.xml", | ||
"selection_expressions": [ | ||
"./oscal:group/oscal:title", | ||
"./oscal:group/oscal:control/oscal:title" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
The development of a JSON schema for this format is left as future work. | ||
|
||
### Test Harness | ||
|
||
A prototype testing harness has been developed, with the capability to report a given profile resolver's compliance to a specification given a [test suite JSON file](#test-suite-data-format). | ||
|
||
The prototype harness is built to be as simple as possible, avoiding external libraries. | ||
Python's native XPath capabilities are limited, further constraining the capabilities of the test suite. | ||
|
||
## Consequences | ||
|
||
Writing specification tests for profile resolution will require significant resources, but will make profile resolution more approachable for implementors and will make changes to the specification more maintainable. | ||
|
||
Due to the "requirement based" approach of the specification test suite, new tests can be added gradually. | ||
Test coverage can be determined by determining which requirements do not have tests. |
241 changes: 0 additions & 241 deletions
241
src/specifications/profile-resolution/metaschema-datatypes.xsd
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: as an aside, did you consider/review the Test Anything Protocol (TAP) or any similar efforts while designing the MVP JSON test data format you are proposing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not heard of this protocol, though it looks like compelling follow-up work. The format seems simple enough to adapt the current output to (perhaps behind a CLI flag). The current output format is arbitrarily chosen as it's "easy enough" to read both as a human and to grep for basic automation.