2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00
Christian Boltz 564e5748bc ProfileStorage: store correct name
Instead of always storing the name of the main profile, store the child
profile/hat name if we are in a child profile or hat.

As a result, we always get the correct "profile xy" header even for
child profiles when dumping the ProfileStorage object.

Also extend the tests to check that the name gets stored correctly.

(cherry picked from commit cb943e4efcff851e4114248effd30b5934798124)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-12-20 15:46:20 -08:00
..
2023-08-13 21:02:50 +02:00
2024-07-05 13:14:10 +02:00
2024-05-20 20:42:50 +02:00

Test data generated elsewhere

The tests in parser generate additional test profiles in parser/tst/simple_tests/: see gen-dbus.py and gen-xtrans.py.

utils/test/test-parser-simple-tests.py uses this test data when it is available. If this test data has not been generated, this test will not complain: it will simply exercise fewer test profiles.

Running individual tests

Python's unittest allows individual tests to be executed by specifying the class name and the test on the command line. When running tests individually, the unittest framework executes the "setUp" and "tearDown" methods automatically. For more information, refer to the unittest documentation.

Make sure to set the environment variables pointing to the in-tree apparmor modules, and the in-tree libapparmor and its python wrapper:

$ export PYTHONPATH=..:../../libraries/libapparmor/swig/python/build/$(/usr/bin/python3 ../../libraries/libapparmor/swig/python/test/buildpath.py)
$ export __AA_CONFDIR=.

To execute the test individually, run:

$ python3 ./test-tile.py ClassFoo.test_bar