Пример #1
0
 def test_check_passes_expect_target(self):
     """Test the check passes, expect_target"""
     config = {"tclass": "infoflow6",
               "perms": "hi_r",
               "expect_target": "target1 target2"}
     check = AssertTE(self.p, "test_check_passes_expect_target", config)
     self.assertFalse(check.run())
Пример #2
0
 def test_check_passes_expect_target_attr(self):
     """Test the check passes, expect_target with attribute"""
     config = {"tclass": "infoflow4",
               "perms": "med_w",
               "expect_target": "all_targets"}
     check = AssertTE(self.p, "test_check_passes_expect_target_attr", config)
     self.assertFalse(check.run())
Пример #3
0
 def test_check_passes_exempt_target_attr(self):
     """Test the check passes, exempt_target_attr"""
     config = {"tclass": "infoflow5",
               "perms": "low_r",
               "exempt_target": "all_targets"}
     check = AssertTE(self.p, "test_check_passes_exempt_target_attr", config)
     self.assertFalse(check.run())
Пример #4
0
 def test_check_passes_expect_source(self):
     """Test the check passes, expect_source"""
     config = {"tclass": "infoflow6",
               "perms": "hi_r",
               "expect_source": "source1 source2"}
     check = AssertTE(self.p, "test_check_passes_expect_source", config)
     self.assertFalse(check.run())
Пример #5
0
 def test_check_passes_exempt_target_type(self):
     """Test the check passes, exempt_target_type"""
     config = {"tclass": "infoflow5",
               "perms": "low_w",
               "exempt_source": "source1"}
     check = AssertTE(self.p, "test_check_passes_exempt_target_type", config)
     self.assertFalse(check.run())
Пример #6
0
 def test_check_passes_exempt_source_attr(self):
     """Test the check passes, exempt_source_attr"""
     config = {"tclass": "infoflow6",
               "perms": "hi_r",
               "exempt_source": "all_sources"}
     check = AssertTE(self.p, "test_check_passes_exempt_source_attr", config)
     self.assertFalse(check.run())
Пример #7
0
 def test_check_passes_expect_exempt_target(self):
     """"Test the check passes with both expected and exempted targets."""
     config = {"tclass": "infoflow5",
               "perms": "low_r",
               "expect_source": "source1",
               "exempt_source": "source2"}
     check = AssertTE(self.p, "test_check_passes_expect_exempt_target", config)
     self.assertFalse(check.run())
Пример #8
0
 def test_check_fails_expect_target(self):
     """Test the check fails, expect_target"""
     config = {"tclass": "infoflow7",
               "perms": "super_r",
               "expect_target": "target2"}
     check = AssertTE(self.p, "test_check_fails_expect_target", config)
     result = check.run()
     self.assertEqual(1, len(result), msg=result)
     self.assertIn("target2", result[0])
Пример #9
0
 def test_check_fails_expect_source(self):
     """Test the check fails, expect_source"""
     config = {"tclass": "infoflow7",
               "perms": "super_w",
               "expect_source": "source1"}
     check = AssertTE(self.p, "test_check_fails_expect_source", config)
     result = check.run()
     self.assertEqual(1, len(result), msg=result)
     self.assertIn("source1", result[0])
Пример #10
0
 def test_check_fails(self):
     """Test the check fails"""
     with open("/dev/null", "w") as fd:
         config = {"tclass": "infoflow4",
                   "perms": "med_w",
                   "exempt_source": "source1",
                   "exempt_target": "target2"}
         check = AssertTE(self.p, "test_check_passes_exempt_target_attr", config)
         check.output = fd
         result = check.run()
         self.assertEqual(1, len(result), msg=result)
         self.validate_rule(result[0], TERuletype.allow, "source3", "target3", "infoflow4",
                            set(["med_w"]))
Пример #11
0
 def test_check_passes_empty_target(self):
     """Test the check passes, empty target attribute"""
     config = {"tclass": "infoflow7",
               "perms": "super_r"}
     check = AssertTE(self.p, "test_check_passes_empty_target", config)
     self.assertFalse(check.run())
Пример #12
0
 def test_check_passes_empty_source(self):
     """Test the check passes, empty source attribute"""
     config = {"tclass": "infoflow7",
               "perms": "super_w"}
     check = AssertTE(self.p, "test_check_passes_empty_source", config)
     self.assertFalse(check.run())
Пример #13
0
 def test_check_passes(self):
     """Test the check passes, no matches"""
     config = {"perms": "null"}
     check = AssertTE(self.p, "test_check_passes", config)
     self.assertFalse(check.run())