From 7e592b6eb8a151f49bca1df1bc113edc023de42a Mon Sep 17 00:00:00 2001 From: "A.J. Stein" Date: Tue, 29 Oct 2024 12:45:17 -0400 Subject: [PATCH] Add unit test metaschema conformant with ADR#6 (#826) * [skip ci] Metaschema module for unit test struct We are proposing changes to the structure of the JSON/YAML unit test file used for all constraints test suite management. This version documents the model of that YAML file before the proposed change in the comments of the #817 PR, linked below. https://github.com/GSA/fedramp-automation/pull/817#issuecomment-2441621714 * [skip ci] Document unit test metaschema elements * [skip ci] Do not explicitly use default types * [skip ci] Add missing `@id` and `@level` to model * [skip ci] Add pipeline to pipeline, thx @wandmagic * [skip ci] Backport #219 docs into model remarks * [skip ci] Fix max-occurs re bad model cardinality This addresses changes that should be handled as determined by upstream guidance from metaschema-framework maintainers. metaschema-framework/metaschema-java#221 metaschema-framework/metaschema#44 * [skip ci] Is a pipeline with a ref even a pipeline at all? Thanks to @Rene2mt for PR feedback about the missing ref to the assembly definition of pipeline in the model. Co-authored-by: Rene Tshiteya --------- Co-authored-by: Rene Tshiteya --- .../unit-tests/unit_test_metaschema.xml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/validations/constraints/unit-tests/unit_test_metaschema.xml diff --git a/src/validations/constraints/unit-tests/unit_test_metaschema.xml b/src/validations/constraints/unit-tests/unit_test_metaschema.xml new file mode 100644 index 000000000..8317bdc65 --- /dev/null +++ b/src/validations/constraints/unit-tests/unit_test_metaschema.xml @@ -0,0 +1,93 @@ + + + OSCAL Unit Test Module + 1.0.0 + oscal-unit-tests + http://github.com/gsa/fedramp-automation/constraint/test + http://github.com/gsa/fedramp-automation/constraint/test + + Test Case Document + This is the root element of the FedRAMP Automation Test Suite format for collections of unit tests. + test-case + + + + + + + + + + + + + + Test Case Name + The name of the test case collection within a test cases file. + + + Test Case Description + The description of the test case collection within a test case file. + + + Test Case Content Path + A relative or absolute file path or HTTP URL to the OSCAL document instance for which the test runs. + + + Test content URL does not point to a valid file or HTTP resource. If the path is invalid, tests are not operable. Are you sure it's correct? + + + +

In this format, we often use relative paths that are not strictly conformant to the URI datatype in Metaschema.

+

There, we use the default implied as-type="string" and not as-type="uri".

+

However, this approach does work and the constraint passes successfully.

+

At this time, a violation where the test evaluates to `false()` throws a lower-level exception.

+

See metaschema-framework/metaschema-java#219 for details.

+
+
+ + Test Case Pipeline Action + The test case pipeline is a sequence of one or more actions to execute before the test runner executes the test suite. + + + + + + + + Test Case Expectation + This assembly defines the relevant constraint ID and the desired result when executing tests over the content. There MAY be one or more expectations. + + + + + + + Constraint ID for the Expectation + The @id attribute for a given constraint for which the test serves to match the expectation. + + + Expectation Result + The expected result type in SARIF format for the expectation. The expectation only supports specific values, defined in a constraint. + + + Use when the desired result of test execution without a constraint passing + Use when the desired result of test execution with a constraint violation + + + + + Pipeline Action + An action for a pipeline to perform before the test runner executes the test suite. This field only supports allowed values explicitly defined in the constraint. + + + An action declaration to perform profile resolution for a profile associated with expectation test case. + +

See the official FedRAMP's documentation on profile resolution for detailed information.

+
+
+
+
+