Unit tests with filesystem-related mocks fail in SeLinuxGuard when run on RHEL or CentOS

Bug #1825253 reported by Jason Zions
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Undecided
Jason Zions

Bug Description

When the unit tests are run on RHEL or CentOS, some tests which mock filesystem directories so as to "lie" about things can cause util.SeLinuxGuard to fail. The SeLinuxGuard does nothing in environments which lack the selinux python module or when that module reports that selinux is not enabled. When the guard is functional, though, it can be confused by some mocks used in various tests.

tests.unittests.test_datasource.test_azure.TestCanDevBeReformatted.test_one_partition_ntfs_empty_with_dataloss_file_is_true

tests.unittests.test_datasource.test_azure.TestCanDevBeReformatted.test_one_partition_ntfs_populated_false

tests.unittests.test_datasource.test_azure.TestCanDevBeReformatted.test_one_partition_through_realpath_is_true

tests.unittests.test_datasource.test_azure.TestCanDevBeReformatted.test_two_partitions_ntfs_populated_false

tests.unittests.test_net.TestNetplanPostcommands.test_netplan_postcmds

In the first four cases, the tests mock os.path.realpath by remapping path prefixes to point to a temporary directory, but SeLinuxGuard doesn't see the mapping. In the last case, the test case mocks os.path.islink to lie and claim a directory is actually a symlink, but code invoked by SeLinuxGuard gets very confused when it tries to treat the (quite real) directory as if it were a symlink.

Related branches

Dan Watkins (oddbloke)
Changed in cloud-init:
status: New → In Progress
assignee: nobody → Jason Zions (jasonzio)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

This bug is fixed with commit c8c32515 to cloud-init on branch master.
To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=c8c32515

Changed in cloud-init:
status: In Progress → Fix Committed
Revision history for this message
Chad Smith (chad.smith) wrote : Fixed in cloud-init version 19.1.

This bug is believed to be fixed in cloud-init in version 19.1. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.