コード例 #1
0
 def test_filtered_output_for_single_key(self):
     f = AttributeFilter()
     summary = ViolationsSummary(f)
     summary.set(data.violations(), data.metadata_with_filtered_data(), data.key())
     f.exclude_attributes = "key1"
     assert summary.get() == {'Kind:Name:Namespace': {'key': 'value', 'key1': 'value1', 'key2': 'value2', 'Violations': 3}}
     expected = "\n".join(['| key   | key2   |   Violations |', '|-------+--------+--------------|', '| value | value2 |            3 |', ])
     assert summary.pritify() == expected
コード例 #2
0
 def test_filtered_output_for_single_key(self):
     f = AttributeFilter()
     lst = ViolationsList(f)
     violations = ViolationsList(f)
     violations.set(data.violations(), data.metadata_with_filtered_data(), data.key())
     f.exclude_attributes = "key1"
     assert violations.get() == {'Kind:Name:Namespace': {'key': 'value', 'key1': 'value1', 'key2': 'value2', 'violations': [{'Violation Name': 'privileged-container', 'Violation Category': 'SecurityContext'}, {
         'Violation Name': 'share-host-network-container', 'Violation Category': 'SecurityContext'}, {'Violation Name': 'container-sys-admin-cap-added', 'Violation Category': 'SecurityContext'}]}}
     expected = "\n".join(['| key   | key2   | Violation Name                | Violation Category   |',
                           '|-------+--------+-------------------------------+----------------------|',
                           '| value | value2 | privileged-container          | SecurityContext      |',
                           '| value | value2 | share-host-network-container  | SecurityContext      |',
                           '| value | value2 | container-sys-admin-cap-added | SecurityContext      |'])
     assert violations.pritify() == expected
コード例 #3
0
def new_summary_instance():
    f = AttributeFilter()
    summary = ViolationsSummary(f)
    summary.set(data.violations(), data.metadata(), data.key())
    return summary
コード例 #4
0
 def test_set_for_many_keys(self, new_violations_instance):
     for key in data.keys():
         new_violations_instance.set(data.violations(), data.metadata(), key)
     assert len(new_violations_instance.violations.keys()) == len(data.keys())+1
コード例 #5
0
def new_violations_instance():
    f = AttributeFilter()
    violations = ViolationsList(f)
    violations.set(data.violations(), data.metadata(), data.key())
    return violations