Imported Debian patch 4.0.5-6~numeezy
This commit is contained in:
committed by
Mario Fetka
parent
c44de33144
commit
10dfc9587b
@@ -17,11 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
|
||||
from ipatests.test_integration.base import IntegrationTest
|
||||
from ipatests.test_integration.tasks import clear_sssd_cache, modify_sssd_conf
|
||||
from ipatests.test_integration import util
|
||||
from ipatests.test_integration.tasks import clear_sssd_cache
|
||||
|
||||
|
||||
class TestSudo(IntegrationTest):
|
||||
@@ -33,8 +30,8 @@ class TestSudo(IntegrationTest):
|
||||
topology = 'line'
|
||||
|
||||
@classmethod
|
||||
def install(cls, mh):
|
||||
super(TestSudo, cls).install(mh)
|
||||
def setup_class(cls):
|
||||
super(TestSudo, cls).setup_class()
|
||||
|
||||
cls.client = cls.clients[0]
|
||||
|
||||
@@ -73,10 +70,10 @@ class TestSudo(IntegrationTest):
|
||||
'localuser'])
|
||||
|
||||
@classmethod
|
||||
def uninstall(cls, mh):
|
||||
def teardown_class(cls):
|
||||
cls.client.run_command(['groupdel', 'localgroup'], raiseonerr=False)
|
||||
cls.client.run_command(['userdel', 'localuser'], raiseonerr=False)
|
||||
super(TestSudo, cls).uninstall(mh)
|
||||
super(TestSudo, cls).teardown_class()
|
||||
|
||||
def list_sudo_commands(self, user, raiseonerr=False, verbose=False):
|
||||
clear_sssd_cache(self.client)
|
||||
@@ -272,38 +269,13 @@ class TestSudo(IntegrationTest):
|
||||
'--hostgroups', 'testhostgroup'])
|
||||
|
||||
def test_sudo_rule_restricted_to_one_hostmask_setup(self):
|
||||
# We need to detect the hostmask first
|
||||
full_ip = util.get_host_ip_with_hostmask(self.client)
|
||||
|
||||
# Make a note for the next test, which needs to be skipped
|
||||
# if hostmask detection failed
|
||||
self.__class__.skip_hostmask_based = False
|
||||
|
||||
if not full_ip:
|
||||
self.__class__.skip_hostmask_based = True
|
||||
raise pytest.skip("Hostmask could not be detected")
|
||||
|
||||
# Add the client's /24 hostmask to the rule
|
||||
ip = self.client.ip
|
||||
self.master.run_command(['ipa', '-n', 'sudorule-add-host',
|
||||
'testrule',
|
||||
'--hostmask', full_ip])
|
||||
|
||||
# SSSD >= 1.13.3-3 uses native IPA schema instead of compat entries to
|
||||
# pull in sudoers. Since native schema does not (yet) support
|
||||
# hostmasks, we need to point ldap_sudo_search_base to the old schema
|
||||
domain = self.client.domain
|
||||
modify_sssd_conf(
|
||||
self.client,
|
||||
domain.name,
|
||||
{
|
||||
'ldap_sudo_search_base': 'ou=sudoers,{}'.format(domain.basedn)
|
||||
},
|
||||
provider_subtype='sudo'
|
||||
)
|
||||
'--hostmask', '%s/24' % ip])
|
||||
|
||||
def test_sudo_rule_restricted_to_one_hostmask(self):
|
||||
if self.__class__.skip_hostmask_based:
|
||||
raise pytest.skip("Hostmask could not be detected")
|
||||
|
||||
result1 = self.list_sudo_commands("testuser1")
|
||||
assert "(ALL : ALL) NOPASSWD: ALL" in result1.stdout_text
|
||||
|
||||
@@ -312,16 +284,11 @@ class TestSudo(IntegrationTest):
|
||||
assert result.returncode != 0
|
||||
|
||||
def test_sudo_rule_restricted_to_one_hostmask_teardown(self):
|
||||
if self.__class__.skip_hostmask_based:
|
||||
raise pytest.skip("Hostmask could not be detected")
|
||||
|
||||
# Detect the hostmask first to delete the hostmask based rule
|
||||
full_ip = util.get_host_ip_with_hostmask(self.client)
|
||||
|
||||
# Remove the client's hostmask from the rule
|
||||
# Remove the client's /24 hostmask from the rule
|
||||
ip = self.client.ip
|
||||
self.master.run_command(['ipa', '-n', 'sudorule-remove-host',
|
||||
'testrule',
|
||||
'--hostmask', full_ip])
|
||||
'--hostmask', '%s/24' % ip])
|
||||
|
||||
def test_sudo_rule_restricted_to_one_hostmask_negative_setup(self):
|
||||
# Add the master's hostmask to the rule
|
||||
@@ -341,18 +308,6 @@ class TestSudo(IntegrationTest):
|
||||
'testrule',
|
||||
'--hostmask', '%s/32' % ip])
|
||||
|
||||
# reset ldap_sudo_search_base back to the default value, the old
|
||||
# schema is not needed for the upcoming tests
|
||||
domain = self.client.domain
|
||||
modify_sssd_conf(
|
||||
self.client,
|
||||
domain.name,
|
||||
{
|
||||
'ldap_sudo_search_base': None
|
||||
},
|
||||
provider_subtype='sudo'
|
||||
)
|
||||
|
||||
def test_sudo_rule_restricted_to_one_command_setup(self):
|
||||
# Reset testrule configuration
|
||||
self.reset_rule_categories()
|
||||
|
||||
Reference in New Issue
Block a user