Ejemplo n.º 1
0
    def mock_class(name, perms, com_perms=[]):
        policy = Mock(qpol.qpol_policy_t)

        cls = Mock(qpol.qpol_class_t)
        cls.name.return_value = name
        cls.perm_iter = lambda x: iter(perms)

        if com_perms:
            com = Mock(qpol.qpol_common_t)
            com.name.return_value = name+"_common"
            com.perm_iter = lambda x: iter(com_perms)
            cls.common.return_value = com
        else:
            cls.common.side_effect = ValueError

        return class_factory(policy, cls)
Ejemplo n.º 2
0
    def mock_class(name, perms, com_perms=[]):
        policy = Mock(qpol.qpol_policy_t)

        cls = Mock(qpol.qpol_class_t)
        cls.name.return_value = name
        cls.perm_iter = lambda x: iter(perms)

        if com_perms:
            com = Mock(qpol.qpol_common_t)
            com.name.return_value = name + "_common"
            com.perm_iter = lambda x: iter(com_perms)
            cls.common.return_value = com
        else:
            cls.common.side_effect = ValueError

        return class_factory(policy, cls)
Ejemplo n.º 3
0
 def test_003_lookup_object(self):
     """ObjClass: factory policy lookup of ObjClass object."""
     cls1 = class_factory(self.p.policy, "infoflow4")
     cls2 = class_factory(self.p.policy, cls1)
     self.assertIs(cls2, cls1)
Ejemplo n.º 4
0
 def test_002_lookup_invalid(self):
     """ObjClass: factory policy invalid lookup."""
     with self.assertRaises(InvalidClass):
         class_factory(self.p.policy, "INVALID")
Ejemplo n.º 5
0
 def test_001_lookup(self):
     """ObjClass: factory policy lookup."""
     cls = class_factory(self.p.policy, "infoflow")
     self.assertEqual("infoflow", cls.qpol_symbol.name(self.p.policy))
Ejemplo n.º 6
0
 def test_003_lookup_object(self):
     """ObjClass: factory policy lookup of ObjClass object."""
     cls1 = class_factory(self.p.policy, "infoflow4")
     cls2 = class_factory(self.p.policy, cls1)
     self.assertIs(cls2, cls1)
Ejemplo n.º 7
0
 def test_002_lookup_invalid(self):
     """ObjClass: factory policy invalid lookup."""
     with self.assertRaises(InvalidClass):
         class_factory(self.p.policy, "INVALID")
Ejemplo n.º 8
0
 def test_001_lookup(self):
     """ObjClass: factory policy lookup."""
     cls = class_factory(self.p.policy, "infoflow")
     self.assertEqual("infoflow", cls.qpol_symbol.name(self.p.policy))