Skip to content

Commit

Permalink
Fix the remaining spec tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Pop <apop@chef.io>
  • Loading branch information
alexpop committed Apr 16, 2020
1 parent 8e87240 commit 660f48f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 54 deletions.
88 changes: 49 additions & 39 deletions spec/unit/libraries/automate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,55 @@
run_id = '3f0536f7-3361-4bca-ae53-b45118dceb5d'
insecure = false
@enriched_report_expected = {
"version": '1.2.1',
"profiles": [
{
"name": 'tmp_compliance_profile',
"title": '/tmp Compliance Profile',
"summary": 'An Example Compliance Profile',
"sha256": "7bd598e369970002fc6f2d16d5b988027d58b044ac3fa30ae5fc1b8492e215cd",
"version": '0.1.1',
"maintainer": 'Nathen Harvey <nharvey@chef.io>',
"license": 'Apache 2.0 License',
"copyright": 'Nathen Harvey <nharvey@chef.io>',
"supports": [],
"controls":[
{
"title": 'A /tmp directory must exist',
"desc": 'A /tmp directory must exist',
"impact": 0.3,
"refs": [],
"tags": {},
"code":
"control 'tmp-1.0' do\n impact 0.3\n title 'A /tmp directory must exist'\n desc 'A /tmp directory must exist'\n describe file '/tmp' do\n it { should be_directory }\n end\nend\n",
"source_location": { "ref": '/Users/vjeffrey/code/delivery/insights/data_generator/chef-client/cache/cookbooks/test-cookbook/recipes/../files/default/compliance_profiles/tmp_compliance_profile/controls/tmp.rb', "line": 3 },
"id": 'tmp-1.0',
"results": [{ "status": 'passed', "code_desc": 'File /tmp should be directory', "run_time": 0.002312, "start_time": '2016-10-19 11:09:43 -0400' }]
},
{
"title": '/tmp directory is owned by the root user',
"desc": 'The /tmp directory must be owned by the root user',
"impact": 0.3,
"refs": [{ "url": 'https://pages.chef.io/rs/255-VFB-268/images/compliance-at-velocity2015.pdf', "ref": 'Compliance Whitepaper' }],
"tags": { "production": nil, "development": nil, "identifier": 'value', "remediation": 'https://github.com/chef-cookbooks/audit' },
"code":
"control 'tmp-1.1' do\n impact 0.3\n title '/tmp directory is owned by the root user'\n desc 'The /tmp directory must be owned by the root user'\n tag 'production','development'\n tag identifier: 'value'\n tag remediation: 'https://github.com/chef-cookbooks/audit'\n ref 'Compliance Whitepaper', url: 'https://pages.chef.io/rs/255-VFB-268/images/compliance-at-velocity2015.pdf'\n describe file '/tmp' do\n it { should be_owned_by 'root' }\n end\nend\n",
"source_location": { "ref": '/Users/vjeffrey/code/delivery/insights/data_generator/chef-client/cache/cookbooks/test-cookbook/recipes/../files/default/compliance_profiles/tmp_compliance_profile/controls/tmp.rb', "line": 12 },
"id": 'tmp-1.1',
"results": [{ "status": 'passed', "code_desc": 'File /tmp should be owned by "root"', "run_time": 1.228845, "start_time": '2016-10-19 11:09:43 -0400' }] }],
"groups": [{ "title": '/tmp Compliance Profile', "controls": ['tmp-1.0', 'tmp-1.1'], "id": 'controls/tmp.rb' }],
"attributes": [{ "name": 'syslog_pkg', "options": { "default": 'rsyslog', "description": 'syslog package...' } }]
}
"version": '1.2.1',
"profiles": [
{
"name": 'tmp_compliance_profile',
"title": '/tmp Compliance Profile',
"summary": 'An Example Compliance Profile',
"sha256": '7bd598e369970002fc6f2d16d5b988027d58b044ac3fa30ae5fc1b8492e215cd',
"version": '0.1.1',
"maintainer": 'Nathen Harvey <nharvey@chef.io>',
"license": 'Apache 2.0 License',
"copyright": 'Nathen Harvey <nharvey@chef.io>',
"supports": [],
"controls": [
{
"title": 'A /tmp directory must exist',
"desc": 'A /tmp directory must exist',
"impact": 0.3,
"refs": [],
"tags": {},
"code": "control 'tmp-1.0' do\n impact 0.3\n title 'A /tmp directory must exist'\n desc 'A /tmp directory must exist'\n describe file '/tmp' do\n it { should be_directory }\n end\nend\n",
"source_location": { "ref": '/Users/vjeffrey/code/delivery/insights/data_generator/chef-client/cache/cookbooks/test-cookbook/recipes/../files/default/compliance_profiles/tmp_compliance_profile/controls/tmp.rb', "line": 3 },
"id": 'tmp-1.0',
"results": [
{ "status": 'passed', "code_desc": 'File /tmp should be directory', "run_time": 0.002312, "start_time": '2016-10-19 11:09:43 -0400' },
],
},
{
"title": '/tmp directory is owned by the root user',
"desc": 'The /tmp directory must be owned by the root user',
"impact": 0.3,
"refs": [
{ "url": 'https://pages.chef.io/rs/255-VFB-268/images/compliance-at-velocity2015.pdf', "ref": 'Compliance Whitepaper' },
],
"tags": { "production": nil, "development": nil, "identifier": 'value', "remediation": 'https://github.com/chef-cookbooks/audit' },
"code": "control 'tmp-1.1' do\n impact 0.3\n title '/tmp directory is owned by the root user'\n desc 'The /tmp directory must be owned by the root user'\n tag 'production','development'\n tag identifier: 'value'\n tag remediation: 'https://github.com/chef-cookbooks/audit'\n ref 'Compliance Whitepaper', url: 'https://pages.chef.io/rs/255-VFB-268/images/compliance-at-velocity2015.pdf'\n describe file '/tmp' do\n it { should be_owned_by 'root' }\n end\nend\n",
"source_location": { "ref": '/Users/vjeffrey/code/delivery/insights/data_generator/chef-client/cache/cookbooks/test-cookbook/recipes/../files/default/compliance_profiles/tmp_compliance_profile/controls/tmp.rb', "line": 12 },
"id": 'tmp-1.1',
"results": [
{ "status": 'passed', "code_desc": 'File /tmp should be owned by "root"', "run_time": 1.228845, "start_time": '2016-10-19 11:09:43 -0400' },
],
},
],
"groups": [
{ "title": '/tmp Compliance Profile', "controls": ['tmp-1.0', 'tmp-1.1'], "id": 'controls/tmp.rb' },
],
"attributes": [
{ "name": 'syslog_pkg', "options": { "default": 'rsyslog', "description": 'syslog package...' } },
],
},
],
"other_checks": [],
"statistics": { "duration": 0.032332 },
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/libraries/cs_automate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[{ "name": 'tmp_compliance_profile',
"title": '/tmp Compliance Profile',
"summary": 'An Example Compliance Profile',
"sha256": "7bd598e369970002fc6f2d16d5b988027d58b044ac3fa30ae5fc1b8492e215cd",
"sha256": '7bd598e369970002fc6f2d16d5b988027d58b044ac3fa30ae5fc1b8492e215cd',
"version": '0.1.1',
"maintainer": 'Nathen Harvey <nharvey@chef.io>',
"license": 'Apache 2.0 License',
Expand Down
28 changes: 14 additions & 14 deletions spec/unit/libraries/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
name: 'syslog_pkg',
options: {
default: 'rsyslog',
description: 'syslog package...'
}
}
description: 'syslog package...',
},
},
],
controls: [
{
id: 'tmp-1.0',
results: [
{
code_desc: 'File /tmp should be directory',
status: 'passed'
}
]
status: 'passed',
},
],
},
{
id: 'tmp-1.1',
Expand All @@ -73,21 +73,21 @@
code_desc: 'File /tmp should be owned by "root"',
run_time: 1.228845,
start_time: '2016-10-19 110943 -0400',
status: 'passed'
}
]
}
status: 'passed',
},
],
},
],
sha256: '7bd598e369970002fc6f2d16d5b988027d58b044ac3fa30ae5fc1b8492e215cd',
title: '/tmp Compliance Profile',
version: '0.1.1'
}
version: '0.1.1',
},
],
run_time_limit: 1.1,
statistics: {
duration: 0.032332
duration: 0.032332,
},
version: '1.2.1'
version: '1.2.1',
}
expect(@helpers.strip_profiles_meta(MockData.inspec_results, [], 1.1)).to eq(expected_stripped_report)
end
Expand Down

0 comments on commit 660f48f

Please sign in to comment.