Class: RSpec::RSpecOscalFormatter::CreateAssessmentResult
- Inherits:
-
Object
- Object
- RSpec::RSpecOscalFormatter::CreateAssessmentResult
- Defined in:
- lib/rspec_oscal_formatter/create_assessment_results.rb
Overview
Creates an Assessment Result from an RSpec Unit Test Run
Instance Method Summary collapse
- #build_metadata_block ⇒ Object
- #create_findings(metadata) ⇒ Object
- #create_observations(metadata) ⇒ Object
- #create_results_block(metadata) ⇒ Object
- #create_reviewed_controls(metadata) ⇒ Object
- #create_target(metadata) ⇒ Object
- #get ⇒ Object
-
#initialize(metadata) ⇒ CreateAssessmentResult
constructor
A new instance of CreateAssessmentResult.
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(metadata) ⇒ CreateAssessmentResult
Returns a new instance of CreateAssessmentResult.
12 13 14 15 16 17 18 19 |
# File 'lib/rspec_oscal_formatter/create_assessment_results.rb', line 12 def initialize() @assessment_result = Oscal::AssessmentResult::AssessmentResult.new( uuid: Random.uuid, metadata: , import_ap: { href: './exported_ap.json' }, # This is not correct. Should be dynamic. results: create_results_block(), ) end |
Instance Method Details
#build_metadata_block ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/rspec_oscal_formatter/create_assessment_results.rb', line 21 def { title: 'Test Result for login.gov.', last_modified: DateTime.now.iso8601, version: DateTime.now.iso8601, oscal_version: '1.1.2', } end |
#create_findings(metadata) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/rspec_oscal_formatter/create_assessment_results.rb', line 65 def create_findings() { uuid: Random.uuid, title: 'Automated Test Outcome', description: .description, target: create_target(), } end |
#create_observations(metadata) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/rspec_oscal_formatter/create_assessment_results.rb', line 55 def create_observations() { uuid: Random.uuid, title: .description, description: .description, methods: ['TEST'], collected: DateTime.now.iso8601, } end |
#create_results_block(metadata) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rspec_oscal_formatter/create_assessment_results.rb', line 30 def create_results_block() # TODO: - multiple results per test? [{ uuid: Random.uuid, title: .description, description: .description, start: DateTime.now.iso8601, reviewed_controls: create_reviewed_controls(), observations: [create_observations()], findings: [create_findings()], }] end |
#create_reviewed_controls(metadata) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rspec_oscal_formatter/create_assessment_results.rb', line 43 def create_reviewed_controls() { control_selections: [ { include_controls: [ { control_id: .control_id }, ], }, ], } end |
#create_target(metadata) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rspec_oscal_formatter/create_assessment_results.rb', line 74 def create_target() { type: 'statement-id', target_id: .statement_id, status: { state: .state, reason: .reason, }, } end |
#get ⇒ Object
85 86 87 |
# File 'lib/rspec_oscal_formatter/create_assessment_results.rb', line 85 def get @assessment_result end |
#to_json(*_args) ⇒ Object
89 90 91 |
# File 'lib/rspec_oscal_formatter/create_assessment_results.rb', line 89 def to_json(*_args) @assessment_result.to_json end |