ipatests: add too-restritive mask tests

If the mask used during the installation is "too restrictive", ie.0027,
installing FreeIPA results in a broken server or replica.
Add two tests that expect an error message at install time to catch
too restrictive masks.

Related to: https://pagure.io/freeipa/issue/7193
Signed-off-by: François Cami <fcami@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
François Cami 2019-03-01 11:56:50 +01:00
parent 8327e11b6b
commit f2e7c3f68b
4 changed files with 82 additions and 0 deletions

View File

@ -1180,3 +1180,15 @@ jobs:
template: *ci-master-f28
timeout: 3600
topology: *master_1repl
fedora-28/mask:
requires: [fedora-28/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{fedora-28/build_url}'
test_suite: test_integration/test_installation.py::TestMaskInstall
template: *ci-master-f28
timeout: 3600
topology: *ipaserver

View File

@ -1192,3 +1192,15 @@ jobs:
template: *ci-master-f29
timeout: 6300
topology: *master_1repl
fedora-29/mask:
requires: [fedora-29/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{fedora-29/build_url}'
test_suite: test_integration/test_installation.py::TestMaskInstall
template: *ci-master-f29
timeout: 3600
topology: *ipaserver

View File

@ -1180,3 +1180,15 @@ jobs:
template: *ci-master-frawhide
timeout: 3600
topology: *master_1repl
fedora-rawhide/mask:
requires: [fedora-rawhide/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{fedora-rawhide/build_url}'
test_suite: test_integration/test_installation.py::TestMaskInstall
template: *ci-master-frawhide
timeout: 3600
topology: *ipaserver

View File

@ -567,3 +567,49 @@ class TestKRAinstallAfterCertRenew(IntegrationTest):
self.master.run_command(['kinit', 'admin'], stdin_text=passwd)
cmd = self.master.run_command(['ipa-kra-install', '-p', dm_pass, '-U'])
self.master.run_command(['systemctl', 'start', 'chronyd'])
class TestMaskInstall(IntegrationTest):
""" Test master and replica installation with wrong mask
This test checks that master/replica installation fails (expectedly) if
mask > 022.
related ticket: https://pagure.io/freeipa/issue/7193
"""
num_replicas = 0
@classmethod
def install(cls, mh):
super(TestMaskInstall, cls).install(mh)
cls.bashrc_file = cls.master.get_file_contents('/root/.bashrc')
def test_install_master(self):
self.master.run_command('echo "umask 0027" >> /root/.bashrc')
result = self.master.run_command(['umask'])
assert '0027' in result.stdout_text
cmd = tasks.install_master(
self.master, setup_dns=False, raiseonerr=False
)
exp_str = ("Unexpected system mask")
assert (exp_str in cmd.stderr_text and cmd.returncode != 0)
def test_install_replica(self):
result = self.master.run_command(['umask'])
assert '0027' in result.stdout_text
cmd = self.master.run_command([
'ipa-replica-install', '-w', self.master.config.admin_password,
'-n', self.master.domain.name, '-r', self.master.domain.realm,
'--server', 'dummy_master.%s' % self.master.domain.name,
'-U'], raiseonerr=False
)
exp_str = ("Unexpected system mask")
assert (exp_str in cmd.stderr_text and cmd.returncode != 0)
def test_files_ownership_and_permission_teardown(self):
""" Method to restore the default bashrc contents"""
if self.bashrc_file is not None:
self.master.put_file_contents('/root/.bashrc', self.bashrc_file)