Commit graph

85 commits

Author SHA1 Message Date
Milos Malik
3e4943c596 add missing metadata to the tests
Some tests were missing important TCMS metadata. Now, the problem
should be fixed.
2024-07-10 17:18:28 +00:00
Milos Malik
ab5c434f53 improve the failing tests
The /policycoreutils/setfiles_binary test: the --downloaddir option
is not recognized by the latest version of DNF. The option is removed
now.

The /other/update-packages test: the --skip-broken option is not
recognized by the latest version of DNF. The option is removed now.

The /selinux-policy/install-uninstall-dsp-packages test: let's not
run this test together with other tests, because it often finds
a problem that brakes the environment for the following tests.
2024-05-18 11:21:13 +02:00
Milos Malik
cc86664885 improve other tests which fail on CentOS-stream-10
Some components/packages are not available on CentOS-stream-10,
which leads to conclusion not to run the affected tests/phases there.

The /var and /run directories very often contain mislabeled files
and directories. In order to find discrepancies between file context
patterns and type_transition rules defined in the SELinux policy,
the restorecon command is needed.
2024-04-15 16:09:41 +02:00
Milos Malik
85a3f368bd adapt to semanage port dealing with duplicated local customization
The semanage command from older policycoreutils versions (<= 3.6-1.el9)
behaves in a certain way when a duplicated port context pattern is added.
It does not add the pattern but produces the following message:

  ValueError: Port <protocol>/<number> already defined

The semanage command from new policycoreutils versions (>= 3.6-2.el9)
behaves differently when a duplicated port context pattern is added.
It adds the pattern and produces the following message:

  Port <protocol>/<number> already defined, modifying instead

Above-mentioned differences in behavior have some consequences for the
automated test when removing a duplicated port context pattern. If the
automated test should pass, it needs to anticipate both possibilities.
2024-02-15 08:09:55 +01:00
Milos Malik
7582d85628 fix the relevancy of tests failing on centos stream
Apparently, the first attempt to adjust the relevancy was not
complete. So here is another one.
Certain tests should not be executed on centos-stream 8 or 9 at all,
because packages required by those tests are not available there.
Certain tests need to reflect the fact that SELinux policies which
confine the tested programs are not present on all versions of RHEL,
CentOS or Fedora.
2023-11-03 20:45:01 +01:00
Milos Malik
fc767823c1 do not require abrt, use recommend instead
The abrt* packages are not available on RHEL-9, which means that
one of the test phases would fail if this change was not done.
The test phase dedicated to /usr/sbin/abrtd will be executed only
if the file is present.
2023-08-23 12:49:30 +02:00
Petr Lautrbach
91109dac9f Does sepolicy generate --application detect writeable locations?
Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
2023-08-09 10:57:04 +00:00
Ondrej Mosnacek
733f960966
Narrow down relevancy in some tests
Make it reflect the current status in RHEL to avoid running the test
where it doesn't make sense.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-06-12 14:28:57 +02:00
Milos Malik
f5c43be61e improve the test to clean-up after itself
Restore the restorecond service to its original state.
The restorecond service should not stay running if it was not
running before execution of the test.
2023-06-05 15:36:19 +02:00
Ondrej Mosnacek
2c82db3d51
semodule-rebuild-if-modules-changed: fix RHEL version check (take 2)
Rework the conditional so that the new part of the test runs everywhere
except specified old version cases. Before this it wouldn't be run on
Fedora, CentOS, or RHEL>=10.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-03-24 10:15:21 +01:00
Ondrej Mosnacek
85268e7d6a
semodule-rebuild-if-modules-changed: add libsemanage as component in metatada
The bulk of the logic is implemented inside libsemanage, so add to the
component list, so that the test is run also on changes in libsemanage.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-03-23 16:23:59 +01:00
Ondrej Mosnacek
cdc801666e
semodule-rebuild-if-modules-changed: fix RHEL version check
The comparisons were inverted by accident - fix them.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-03-23 16:23:22 +01:00
Ondrej Mosnacek
93eca7b0a9 policycoreutils/semodule-rebuild-...: add coverage for dontaudit
Test that semodule --refresh works correctly with the disable_dontaudit
flag.

This currently requires the following patch to pass:
https://lore.kernel.org/selinux/20230309143741.346749-1-omosnace@redhat.com/

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-03-21 15:15:30 +00:00
Milos Malik
e0866a22fe fix the failing tests
Not all packages required by the tests were installed. The issue
should be fixed now.

Relevancy of certain tests was set incorrectly. The issue should
be fixed now.

At least 1 test runs longer than its specified duration. The issue
should be fixed now.
2023-01-23 12:47:27 +00:00
Milos Malik
afff1ecfd4 test if sepolicy manpage can generate all man pages
A new test phase was added. Purpose of the test phase is to find
out whether the `sepolicy manpage` command can generate man pages
for all SELinux domains without triggering an error or traceback.

The TC covers BZ#1416372.
2023-01-17 15:27:53 +01:00
Milos Malik
b6ec2fee8d test if sepolicy manpage can generate manpage in HTML form
The sepolicy tool can generate man pages for specific SELinux domains.
When the sepolicy tool was instructed to generate man pages in HTML
form (--web), the generated HTML files were very incomplete. The TC
reproduces the situation.

The newly added TC checks if the sepolicy manpage command works
correctly. The checks related to the sepolicy manpage command
were removed from the sepolicy-generate TC.

The TC covers BZ#1989840.
2023-01-17 11:43:37 +01:00
Petr Lautrbach
8effe6fd87 Use ausearch --input-logs
CI systems don't necessary attach stdin to terminal and this option make
`ausearch` to use audit logs as input for searching.
2022-11-24 11:30:48 +01:00
Petr Lautrbach
3727a6ade6 Adjust duration to 20m in linux-system-roles.selinux-tests
Fixes:
    Maximum test time '10m' exceeded.
    Adjust the test 'duration' attribute if necessary.
    https://tmt.readthedocs.io/en/stable/spec/tests.html#duration
2022-11-10 15:38:16 +01:00
Amith Kumar
8f54ba515e harden tools to block rogue python modules
Add test to policycoreutils/Regression suite which verifies bug 2128976
and ensures that irrelevant python scripts are not given precedence over
tools like semanage.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2022-11-01 18:39:40 +00:00
Ondrej Mosnacek
c3dd00f4bc
semodule-rebuild-if-modules-changed: test changing booleans
Extend the test to verify correct behavior when a boolean setting
override is injected. Also add auto-detection of the --refresh /
--rebuild-if-modules-changed command-line option support, which
indicates the expected level of functionality. (And we also need to
ensure that --refresh is used when supported because the other option
may be removed in the future.)

Additionally, we need to work around the fact that the exact binary
policy content can now be different depending on if the optimized code
path has been taken. Do this by toggling a boolean before introducing
injected customizations, thus obtaining the expected policy content for
the case after `semodule --refresh`.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-08-02 15:03:48 +02:00
Ondrej Mosnacek
a77df42754
semodule-rebuild-if-modules-changed: expand vars early
This will make the test output more explicit.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-08-02 15:03:48 +02:00
Milos Malik
98145eff71 add Makefile to enable runs via STI
Some CI frameworks still use STI which depends on existence of the
Makefile. In order to run this TC successfully in such frameworks,
the Makefile was added. Test description was also improved.
2022-08-02 10:00:37 +02:00
Milos Malik
09061d2739 test if semanage can import port definitions correctly
Recent testing revealed that `semanage import` cannot import
SELinux port definitions correctly if `port -D` is present
among them. The TC reproduces the situation.

The TC covers BZ#2063353 and BZ#2108174.
2022-07-27 10:12:11 +02:00
Milos Malik
01e114b092 test how semanage handles spaces in fcontext patterns
The semanage tool refuses (for some time already) fcontext patterns
which contain spaces. The TC checks if other whitespace characters
are treated the same way.

The TC covers BZ#1893545.
2022-07-15 13:27:05 +00:00
Zdenek Pytela
12dd91c7d4 avoid testing empty CIL modules
SELinux user-space version 3.3 and higher does not support loading
of empty CIL modules. If such version is installed, one of the test
phases will be skipped. This commit changes existing code to using
rlTestVersion.
2022-06-07 15:43:51 +00:00
Amith Kumar
81bb79481d policycoreutils: fix main.fmf file
Automated tests executed via TMT/FMF are failing due to absence of relevant packages.
Fix the main.fmf file to match the list of required packages/programs in `Makefile`.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2022-05-11 04:56:25 +05:30
Milos Malik
f1ffb0bbe5 remove all rhts-environment.sh includes
The rhts-environment.sh files are not needed anymore.
The include of beakerlib.sh is sufficient.
2022-04-26 13:18:49 +00:00
Milos Malik
1bf11b6606 convert metadata of all policycoreutils tests to TMT/FMF 2022-04-26 13:18:49 +00:00
Ondrej Mosnacek
8b7e684a0d Add a test for semodule --rebuild-if-modules-changed
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-03-01 12:58:06 +01:00
Petr Lautrbach
c6c5a1fbe6 semodule-l-checksum: checksum format changed
In the latest update, the checksum format in `semodule -l --checksum`
changed from "$SHA256" to "sha256:$SHA256"
2022-02-19 11:26:57 +01:00
Milos Malik
edffc3122c test if the checksum option is mentioned in help/manpages
The test phase checks if the newly added checksum option is listed
in the help message and in the semodule man page.
2022-01-12 12:01:43 +00:00
Petr Lautrbach
4e4c91dbc4 Test semodule -l --checksum 2021-12-02 14:54:52 +01:00
Milos Malik
37adc8484f avoid testing empty CIL modules
SELinux user-space of version 3.3 and higher does not support loading
of empty CIL modules. If such version is installed, one of the test
phases will be skipped.
2021-10-07 14:24:29 +02:00
Petr Lautrbach
a335bae5ea Install ansible-playbook using pip3
Sometimes ansible is not available as rpm in repositories, but it should
be possible to install ansible using pip3

Fixes:
    [   FAIL   ] :: Checking for the presence of ansible rpm
    [   FAIL   ] :: Command 'ansible-playbook -i localhost, -c local -v tests_all_purge.yml' (Expected 0, got 127)
2021-08-04 08:24:58 +02:00
Vit Mojzis
d686d5b10c policycoreutils/setfiles_binary: fix yaml formatting
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2021-07-16 14:42:09 +02:00
Vit Mojzis
99db07804e policycoretuils: add new test for setfiles with binary policy
setfiles didn't allow using "-c" parameter (binary policy) when path was
specified. Verify that setfiles now gives the same results regardless of
weather binary policy was provided.

The TC covers BZ#1973754

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2021-07-09 17:17:41 +02:00
Milos Malik
28aaa75dde skip the policy which is not installed
The TC expected that all SELinux policies are installed before the
TC is executed. If some of them is not installed, one of the test
phases failed.
Now, the test phase checks if particular policy is installed before
calling the D-bus interface on it.
2021-05-14 10:00:47 +02:00
Amith Kumar
9e8c0e2107 file-contexts: Add test for bug1822100
Add an semanage case to file-contexts test suite which verifies bug
1822100. The fix checks for the broken pipe error generated by the
'semanage fcontext -l | egrep ..' command.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2021-04-07 14:46:07 +00:00
Petr Lautrbach
f1d94dfd61 policycoreutils/setfiles: Add path to main.fmf 2021-02-05 15:43:57 +01:00
Petr Lautrbach
e48b62767b policycoreutils/setfiles: Make the relabel test robust
- use directory which is not usually mounted as tmpfs
- use own spec_file
- use -F option
- check context of all directories and files inside chroot
2021-02-05 15:28:21 +01:00
Petr Lautrbach
33abfe035c policycoreutils/setfiles: Basic sanity test for setfiles 2021-02-04 18:18:44 +01:00
Ondrej Mosnacek
596ec7fafe Make all relevancy expressions use comparison operators
Rather than enumerating RHEL versions, use comparison against
"known-good" version to make the expressions easier to read and
understand.

Also convert users of '~<' to '<', as '~<' compares only minor versions
within the same major.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2020-12-15 12:38:32 +01:00
Milos Malik
15f6d6c612 update test relevancy based on packages availability
Relevancy changes are made based on recommendations from:
  tmt test lint --fix

Some packages are available for Fedoras only and are not available
for RHELs at all.
Some packages are available for latest RHEL major versions only.
2020-12-15 11:53:28 +01:00
Milos Malik
1572bc3434 skip some checks if /sys/fs/selinux cannot be unmounted
Some checks in the automated tests require an unmounted SELinux
file-system. This way is used to pretend that SELinux is disabled.
Sometimes the file-system cannot be unmounted because of

  umount: /sys/fs/selinux: target is busy.

To work around this issue, umount with --lazy option will be used.
If umount --lazy still complains, the problematic checks will be
skipped, because it still make sense to run the other parts of the
automated tests.
2020-12-08 08:18:30 +00:00
Milos Malik
6b50be9a83 add the selinux-autorelabel service test to upstream
The selinux-autorelabel service is available in various Fedoras
and RHELs, so it makes sense to run the TC in upstream testing.

There are no changes in the TC functionality, only moving the
downstream TC to the upstream repo.
2020-09-11 13:56:37 +00:00
Amith Kumar
56a35b10fd sepolicy : Add fix for bug 1854639
The testcase verifies HTML page generated by "sepolicy manpage"
and ensures links to generated man page exists.
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1854639

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2020-08-12 15:12:35 +00:00
Richard Filo
cba138dc22 policycoreutils/org-selinux-dbus-interfaces: Add missing requirements
Fedora CI fails because dbus-tools package is required.

fixes: https://src.fedoraproject.org/tests/selinux/issue/66
2020-05-19 11:03:45 +02:00
Petr Lautrbach
fff775a47b sctp_test: sctp module is in kernel-modules in Fedora 2020-05-13 11:06:00 +00:00
Petr Lautrbach
2489409dc5 sctp_test: Add Makefile to automatically resolve dependencies
FMF is not able to resolve test dependencies yet so we need to ship Makefile
with Requires metadata. STR uses this to satisfy test dependencies.
2020-05-13 11:06:00 +00:00
Petr Lautrbach
933ad30a55 org.selinux dbus interface is shipped by policycoreutils-dbus
In past it was policycoreutils-gui so check whether at least one of them is
installed.

Resolves: https://src.fedoraproject.org/tests/selinux/issue/39
2020-01-24 11:11:20 +01:00