GSA / fedramp-automation

FedRAMP Automation
https://www.fedramp.gov/using-the-fedramp-oscal-resources-and-templates/
Other
276 stars 85 forks source link

Test Harness and Framework for OSCAL CLI testing #598

Closed Rene2mt closed 4 weeks ago

Rene2mt commented 3 months ago

This is a ...

research - something needs to be investigated

This relates to ...

User Story

As a developer, I need an automated testing approach to QA the OSCAL CLI whenever changes are made or new versions are released.

Goals

Problem Statement

The FedRAMP OSCAL automation team needs a good, light-weight, simple test harness and framework for automated unit testing. The solution will be used for QA of developed FedRAMP OSCAL validation rules integrated into the OSCAL CLI tool. The solution may also be used to integrate with testing of other FedRAMP OSCAL tools in the future.

Requirements

In order to identify a solution, the dev team will:

Dependencies

No response

Acceptance Criteria

Other information

No response

Rene2mt commented 3 months ago

Team did a preliminary review of various testing frameworks including:

After weighing the pros and cons of each, team decided to do a proof of concept with Jest.

Rene2mt commented 3 months ago

Need to:

tests: 
- test-content: oscal-ssp-file.json
  tag:
  - metadata
  - system-characteristics
  - system-implementation
  - control-implementation
  - back-matter
  expectation:
  - id: some-validation-id
    description: "some test description"
    command: "validate" # optional or not necessary at all if only testing oscal-cli validation
    level: ERROR
    location: /some/metapath/node
    result: pass
  - id: some-validation-id
    description: "some test description"
    command: "validate" # optional or not necessary at all if only testing oscal-cli validation
    level: ERROR
    location: /some/metapath/node2
    result: fail
  - id: some-other-validation-id
    description: "some test description"
    command: "validate" # optional or not necessary at all if only testing oscal-cli validation
    level: WARNING
    location: /some/metapath/node
    result: pass

Once a format is established, will need to update the test runner accordingly.

Rene2mt commented 3 months ago

OSCAL-CLI will be generating SARIF output - https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html

Rene2mt commented 2 months ago

YAML unit tests will follow this structure. Need naming convention and location for these declarative unit tests.

tests: 
- test-content: oscal-file.json
  tag:
  - metadata
  - system-implementation
  expectation:
  - id: some-validation-id
    level: ERROR
    location: /some/metapath/node
    result: pass
  - id: some-validation-id
    level: ERROR
    location: /some/metapath/node2
    result: fail
  - id: some-other-validation-id
    level: ERROR
    location: /some/metapath/node
    result: pass
Rene2mt commented 4 weeks ago

For full implementation details, see PR #622. In summary:

You can run make test at the root of your local fedramp-automation repository to setup the testing harness locally. More detailed instructions are forthcoming (see PR #638).