예제 #1
0
    def test_000_unset(self):
        """Default query: no criteria."""
        # query with no parameters gets all defaults
        alldefaults = sorted(self.p.defaults())

        q = DefaultQuery(self.p)
        qdefaults = sorted(q.results())

        self.assertListEqual(alldefaults, qdefaults)
예제 #2
0
    def test_000_unset(self):
        """Default query: no criteria."""
        # query with no parameters gets all defaults
        alldefaults = sorted(self.p.defaults())

        q = DefaultQuery(self.p)
        qdefaults = sorted(q.results())

        self.assertListEqual(alldefaults, qdefaults)
예제 #3
0
    def test_001_ruletype(self):
        """Default query: ruletype criterion."""
        q = DefaultQuery(self.p, ruletype=["default_user"])
        defaults = list(q.results())
        self.assertEqual(1, len(defaults))

        d = defaults[0]
        self.assertEqual(DefaultRuletype.default_user, d.ruletype)
        self.assertEqual("infoflow", d.tclass)
        self.assertEqual(DefaultValue.target, d.default)
예제 #4
0
    def test_001_ruletype(self):
        """Default query: ruletype criterion."""
        q = DefaultQuery(self.p, ruletype=["default_user"])
        defaults = list(q.results())
        self.assertEqual(1, len(defaults))

        d = defaults[0]
        self.assertEqual(DefaultRuletype.default_user, d.ruletype)
        self.assertEqual("infoflow", d.tclass)
        self.assertEqual(DefaultValue.target, d.default)
예제 #5
0
 def test_903_invalid_default_range(self):
     """Default query: invalid default range"""
     with self.assertRaises(KeyError):
         q = DefaultQuery(self.p, default_range="INVALID")
예제 #6
0
 def test_902_invalid_default_value(self):
     """Default query: invalid default value"""
     with self.assertRaises(KeyError):
         q = DefaultQuery(self.p, default="INVALID")
예제 #7
0
 def test_901_invalid_class(self):
     """Default query: invalid object class"""
     with self.assertRaises(InvalidClass):
         q = DefaultQuery(self.p, tclass=["INVALID"])
예제 #8
0
 def test_900_invalid_ruletype(self):
     """Default query: invalid ruletype"""
     with self.assertRaises(KeyError):
         q = DefaultQuery(self.p, ruletype=["INVALID"])
예제 #9
0
    def test_030_default_range(self):
        """Default query: default_range setting."""
        q = DefaultQuery(self.p, default_range="high")

        defaults = sorted(c.tclass for c in q.results())
        self.assertListEqual(["infoflow7"], defaults)
예제 #10
0
    def test_020_default(self):
        """Default query: default setting."""
        q = DefaultQuery(self.p, default="source")

        defaults = sorted(c.tclass for c in q.results())
        self.assertListEqual(["infoflow", "infoflow3"], defaults)
예제 #11
0
    def test_011_class_regex(self):
        """Default query: object class regex match."""
        q = DefaultQuery(self.p, tclass="infoflow(3|5)", tclass_regex=True)

        defaults = sorted(c.tclass for c in q.results())
        self.assertListEqual(["infoflow3", "infoflow5"], defaults)
예제 #12
0
    def test_010_class_list(self):
        """Default query: object class list match."""
        q = DefaultQuery(self.p, tclass=["infoflow3", "infoflow4"])

        defaults = sorted(d.tclass for d in q.results())
        self.assertListEqual(["infoflow3", "infoflow4"], defaults)
예제 #13
0
    def test_010_class_list(self):
        """Default query: object class list match."""
        q = DefaultQuery(self.p, tclass=["infoflow3", "infoflow4"])

        defaults = sorted(d.tclass for d in q.results())
        self.assertListEqual(["infoflow3", "infoflow4"], defaults)
예제 #14
0
 def __init__(self, parent, policy, perm_map):
     super(DefaultQueryTab, self).__init__(parent)
     self.log = logging.getLogger(__name__)
     self.policy = policy
     self.query = DefaultQuery(policy)
     self.setupUi()
예제 #15
0
    def test_030_default_range(self):
        """Default query: default_range setting."""
        q = DefaultQuery(self.p, default_range="high")

        defaults = sorted(c.tclass for c in q.results())
        self.assertListEqual(["infoflow7"], defaults)
예제 #16
0
    def test_020_default(self):
        """Default query: default setting."""
        q = DefaultQuery(self.p, default="source")

        defaults = sorted(c.tclass for c in q.results())
        self.assertListEqual(["infoflow", "infoflow3"], defaults)
예제 #17
0
    def test_011_class_regex(self):
        """Default query: object class regex match."""
        q = DefaultQuery(self.p, tclass="infoflow(3|5)", tclass_regex=True)

        defaults = sorted(c.tclass for c in q.results())
        self.assertListEqual(["infoflow3", "infoflow5"], defaults)