File: test-profiles.py

package info (click to toggle)
apparmor 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,096 kB
  • sloc: ansic: 24,943; python: 24,914; cpp: 9,074; sh: 8,166; yacc: 2,061; makefile: 1,923; lex: 1,215; pascal: 1,147; perl: 1,033; ruby: 365; lisp: 282; exp: 250; java: 212; xml: 159
file content (39 lines) | stat: -rw-r--r-- 1,392 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/python3
# ------------------------------------------------------------------
#
#    Copyright (C) 2020 Christian Boltz <apparmor@cboltz.de>
#
#    This program is free software; you can redistribute it and/or
#    modify it under the terms of version 2 of the GNU General Public
#    License published by the Free Software Foundation.
#
# ------------------------------------------------------------------

import unittest

import apparmor.aa as aa
from common_test import AATest, setup_aa, setup_all_loops, skip_active_profiles, skip_extra_profiles


class TestFoo(AATest):
    # Make sure the python code can parse all profiles shipped with AppArmor.
    # If this fails, read_profiles() / read_inactive_profiles() will raise an exception.
    #
    # Checking for the number of read profiles is mostly done to ensure *something* is read
    # (to make sure an empty or non-existing directory won't make this test useless).

    def test_active_profiles(self):
        aa.read_profiles(skip_profiles=skip_active_profiles)

        self.assertGreaterEqual(len(aa.active_profiles.profile_names), 42)

    def test_extra_profiles(self):
        aa.read_inactive_profiles(skip_profiles=skip_extra_profiles)

        self.assertGreaterEqual(len(aa.extra_profiles.profile_names), 100)


setup_aa(aa)
setup_all_loops(__name__)
if __name__ == '__main__':
    unittest.main(verbosity=1)