Ejemplo n.º 1
0
    def test_011_type_set_equality(self):
        """Type attribute query with type set equality."""
        q = TypeAttributeQuery(self.p, types=["test11t1", "test11t2",
                                              "test11t3", "test11t5"], types_equal=True)

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test11a"], attrs)
Ejemplo n.º 2
0
    def test_000_unset(self):
        """Type attribute query with no criteria."""
        # query with no parameters gets all attrs.
        allattrs = sorted(self.p.typeattributes())

        q = TypeAttributeQuery(self.p)
        qattrs = sorted(q.results())

        self.assertListEqual(allattrs, qattrs)
Ejemplo n.º 3
0
    def test_000_unset(self):
        """Type attribute query with no criteria."""
        # query with no parameters gets all attrs.
        allattrs = sorted(self.p.typeattributes())

        q = TypeAttributeQuery(self.p)
        qattrs = sorted(q.results())

        self.assertListEqual(allattrs, qattrs)
Ejemplo n.º 4
0
def get_type_names(policy, tname, is_regex, indirect):
    # Looks like we have to match types and attributes separately
    types = set()
    attributes = set()
    if isinstance(tname, str) or isinstance(tname, BaseType) or is_regex:
        tname = [tname]
    for name in tname:
        types.update(
            TypeQuery(policy, name=name, name_regex=is_regex).results())
        attributes.update(
            TypeAttributeQuery(policy, name=name,
                               name_regex=is_regex).results())

    out = set()
    start = types | attributes
    for x in start:
        out.add(str(x))
        if indirect:
            if isinstance(x, Type):
                [out.add(str(y)) for y in x.attributes()]
            else:
                [out.add(str(y)) for y in x.expand()]

    return out
Ejemplo n.º 5
0
 def __init__(self, parent, policy, perm_map):
     super(TypeAttributeQueryTab, self).__init__(parent)
     self.log = logging.getLogger(__name__)
     self.policy = policy
     self.query = TypeAttributeQuery(policy)
     self.setupUi()
Ejemplo n.º 6
0
    def test_012_type_set_regex(self):
        """Type attribute query with type set regex match."""
        q = TypeAttributeQuery(self.p, types="test12t(1|2)", types_regex=True)

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test12a", "test12b"], attrs)
Ejemplo n.º 7
0
    def test_010_type_set_intersect(self):
        """Type attribute query with type set intersection."""
        q = TypeAttributeQuery(self.p, types=["test10t1", "test10t7"])

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test10a", "test10c"], attrs)
Ejemplo n.º 8
0
    def test_002_name_regex(self):
        """Type attribute query with regex name match."""
        q = TypeAttributeQuery(self.p, name="test2(a|b)", name_regex=True)

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test2a", "test2b"], attrs)
Ejemplo n.º 9
0
    def test_001_name_exact(self):
        """Type attribute query with exact name match."""
        q = TypeAttributeQuery(self.p, name="test1")

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test1"], attrs)
Ejemplo n.º 10
0
    def test_012_type_set_regex(self):
        """Type attribute query with type set regex match."""
        q = TypeAttributeQuery(self.p, types="test12t(1|2)", types_regex=True)

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test12a", "test12b"], attrs)
Ejemplo n.º 11
0
    def test_011_type_set_equality(self):
        """Type attribute query with type set equality."""
        q = TypeAttributeQuery(self.p, types=["test11t1", "test11t2", "test11t3", "test11t5"], types_equal=True)

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test11a"], attrs)
Ejemplo n.º 12
0
    def test_010_type_set_intersect(self):
        """Type attribute query with type set intersection."""
        q = TypeAttributeQuery(self.p, types=["test10t1", "test10t7"])

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test10a", "test10c"], attrs)
Ejemplo n.º 13
0
    def test_002_name_regex(self):
        """Type attribute query with regex name match."""
        q = TypeAttributeQuery(self.p, name="test2(a|b)", name_regex=True)

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test2a", "test2b"], attrs)
Ejemplo n.º 14
0
    def test_001_name_exact(self):
        """Type attribute query with exact name match."""
        q = TypeAttributeQuery(self.p, name="test1")

        attrs = sorted(str(t) for t in q.results())
        self.assertListEqual(["test1"], attrs)