def test_report_fail_to_generate(self, evidence_path_mock, get_cfg_mock, gen_chk_mock, gen_toc_mock): """Test report generation failure affects on general execution.""" config_mock = create_autospec(ComplianceConfig) config_mock.get_template_dir.return_value = '/tmp/templates' get_cfg_mock.return_value = config_mock report = ReportEvidence('test', 'test', 12345) report.set_content(None) evidence_path_mock.return_value = report locker = create_autospec(Locker()) locker.local_path = '/tmp/fake_locker' locker.get_reports_metadata = MagicMock(return_value={'foo': 'bar'}) test_obj = build_test_mock() test_obj.test.get_reports.return_value = ['test/example.md'] results = {'mock.test.test_one': {'status': 'pass', 'test': test_obj}} controls = create_autospec(ControlDescriptor) builder = ReportBuilder(locker, results, controls) builder.build() self.assertEqual(results['mock.test.test_one']['status'], 'error') gen_chk_mock.assert_called_once_with({'foo': 'bar'}) gen_toc_mock.assert_called_once_with({'foo': 'bar'})
def setUpClass(cls): """Initialize the check object with configuration settings.""" cls.config.add_evidences([ ReportEvidence('repo_branch_new_commits.md', 'auditree', DAY, 'Repository/branch new commits report.') ]) return cls
def setUpClass(cls): """Initialize the check object with configuration settings.""" cls.config.add_evidences([ ReportEvidence('locker_repo_integrity.md', 'auditree', DAY, 'Evidence locker repository integrity report.') ]) return cls
def test_report_evidence(self): """Test putting ReportEvidence into the locker.""" locker = Locker(name=REPO_DIR) with locker: f = tempfile.mkstemp(prefix='testfile', suffix='.json', dir=FILES_DIR) evidence_name = os.path.split(f[1])[1] evidence = ReportEvidence(evidence_name, 'test_category', DAY, 'This tests evidence.py') test_content = '{"BLAH": "Test"}' evidence.set_content(test_content) locker.add_evidence(evidence) self.assertEqual(len(locker.touched_files), 1)
def setUpClass(cls): """Initialize the check object with configuration settings.""" cls.config.add_evidences([ ReportEvidence('abandoned_evidence.md', 'auditree', DAY, 'Evidence locker abandoned evidence report.') ]) return cls
def setUpClass(cls): """Initialize the check object with configuration settings.""" cls.config.add_evidences([ ReportEvidence('org_collaborators.md', 'permissions', DAY, 'Repository organization collaborators report.') ]) return cls
def setUpClass(cls): """Initialize the check object with configuration settings.""" cls.config.add_evidences([ ReportEvidence('python_packages.md', 'auditree', DAY, 'Execution environment Python packages report.') ]) return cls
def setUpClass(cls): """Initialize the check object with configuration settings.""" cls.config.add_evidences([ ReportEvidence( 'compliance_config.md', 'auditree', DAY, 'Compliance repository configuration settings report.') ]) return cls
# -*- mode:python; coding:utf-8 -*- # Copyright (c) 2020 IBM Corp. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from compliance.config import get_config from compliance.evidence import DAY, ReportEvidence, RawEvidence get_config().add_evidences([ RawEvidence('world_clock_utc.json', 'time', DAY, 'Coordinated Universal Time'), ReportEvidence('world_clock.md', 'time', DAY, 'World Clock Analysis report.') ])