示例#1
0
    def mock_sens_factory(self, sens, aliases=[]):
        """Factory function for Sensitivity objects, using a mock qpol object."""
        mock_sens = Mock(qpol.qpol_level_t)
        mock_sens.name.return_value = sens
        mock_sens.isalias.return_value = False
        mock_sens.value.return_value = int(sens[1:])
        mock_sens.alias_iter = lambda x: iter(aliases)

        return sensitivity_factory(self.p.policy, mock_sens)
示例#2
0
文件: mls.py 项目: GitForNeo/setools
    def mock_sens_factory(self, sens, aliases=[]):
        """Factory function for Sensitivity objects, using a mock qpol object."""
        mock_sens = Mock(qpol.qpol_level_t)
        mock_sens.name.return_value = sens
        mock_sens.isalias.return_value = False
        mock_sens.value.return_value = int(sens[1:])
        mock_sens.alias_iter = lambda x: iter(aliases)

        return sensitivity_factory(self.p.policy, mock_sens)
示例#3
0
 def test_003_lookup_object(self):
     """Sensitivity factory policy lookup of Sensitivity object."""
     sens1 = sensitivity_factory(self.p.policy, "s1")
     sens2 = sensitivity_factory(self.p.policy, sens1)
     self.assertIs(sens2, sens1)
示例#4
0
 def test_002_lookup_invalid(self):
     """Sensitivity factory policy invalid lookup."""
     with self.assertRaises(InvalidSensitivity):
         sensitivity_factory(self.p.policy, "INVALID")
示例#5
0
 def test_001_lookup(self):
     """Sensitivity factory policy lookup."""
     sens = sensitivity_factory(self.p.policy, "s1")
     self.assertEqual("s1", sens.qpol_symbol.name(self.p.policy))
示例#6
0
文件: mls.py 项目: GitForNeo/setools
 def test_003_lookup_object(self):
     """Sensitivity factory policy lookup of Sensitivity object."""
     sens1 = sensitivity_factory(self.p.policy, "s1")
     sens2 = sensitivity_factory(self.p.policy, sens1)
     self.assertIs(sens2, sens1)
示例#7
0
文件: mls.py 项目: GitForNeo/setools
 def test_002_lookup_invalid(self):
     """Sensitivity factory policy invalid lookup."""
     with self.assertRaises(InvalidSensitivity):
         sensitivity_factory(self.p.policy, "INVALID")
示例#8
0
文件: mls.py 项目: GitForNeo/setools
 def test_001_lookup(self):
     """Sensitivity factory policy lookup."""
     sens = sensitivity_factory(self.p.policy, "s1")
     self.assertEqual("s1", sens.qpol_symbol.name(self.p.policy))