File: test_initsid.py

package info (click to toggle)
setools 4.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,600 kB
  • sloc: python: 24,485; makefile: 14
file content (28 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright 2015, Tresys Technology, LLC
#
# SPDX-License-Identifier: GPL-2.0-only
#
import pytest
import setools


@pytest.mark.obj_args("tests/library/policyrep/initsid.conf")
class TestInitialSID:

    def test_string(self, compiled_policy: setools.SELinuxPolicy) -> None:
        """InitialSID: basic string rendering."""
        sids = list(compiled_policy.initialsids())
        assert len(sids) == 1
        assert "kernel" == str(sids[0])

    def test_context(self, compiled_policy: setools.SELinuxPolicy) -> None:
        """InitialSID: context."""
        sids = list(compiled_policy.initialsids())
        assert len(sids) == 1
        assert "system:system:system:s0" == sids[0].context, sids[0].context

    def test_statement(self, compiled_policy: setools.SELinuxPolicy) -> None:
        """InitialSID: statement."""
        sids = list(compiled_policy.initialsids())
        assert len(sids) == 1
        assert "sid kernel system:system:system:s0" == sids[0].statement(), sids[0].statement()