From 15fd36612ea451cec2e1302a462fa440663fcc74 Mon Sep 17 00:00:00 2001 From: Sergey Orlov Date: Tue, 28 Jan 2020 16:52:49 +0100 Subject: [PATCH] ipatests: add check for output contents of ipa-client-samba Check that ipa-client-samba tool reports specific properties of domains: name, netbios name, sid and id range Related to https://pagure.io/freeipa/issue/8149 Reviewed-By: Alexander Bokovoy --- ipatests/test_integration/test_smb.py | 32 ++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/ipatests/test_integration/test_smb.py b/ipatests/test_integration/test_smb.py index 5068a0ea0..d857ad4de 100644 --- a/ipatests/test_integration/test_smb.py +++ b/ipatests/test_integration/test_smb.py @@ -10,6 +10,7 @@ from __future__ import absolute_import from functools import partial import textwrap +import re import pytest @@ -194,6 +195,31 @@ class TestSMB(IntegrationTest): finally: run_smb_server(['rm', '-rf', test_dir], raiseonerr=False) + def smb_installation_check(self, result): + domain_regexp_tpl = r''' + Domain\ name:\s*{domain}\n + \s*NetBIOS\ name:\s*{netbios}\n + \s*SID:\s*S-1-5-21-\d+-\d+-\d+\n + \s+ID\ range:\s*\d+\s*-\s*\d+ + ''' + # pylint: disable=no-member + ipa_regexp = domain_regexp_tpl.format( + domain=re.escape(self.master.domain.name), + netbios=self.master.netbios) + ad_regexp = domain_regexp_tpl.format( + domain=re.escape(self.ad.domain.name), netbios=self.ad.netbios) + # pylint: enable=no-member + output_regexp = r''' + Discovered\ domains.* + {} + .* + {} + .* + Samba.+configured.+check.+/etc/samba/smb\.conf + '''.format(ipa_regexp, ad_regexp) + assert re.search(output_regexp, result.stdout_text, + re.VERBOSE | re.DOTALL) + def cleanup_mount(self, mountpoint): self.smbclient.run_command(['umount', mountpoint], raiseonerr=False) self.smbclient.run_command(['rmdir', mountpoint], raiseonerr=False) @@ -204,7 +230,8 @@ class TestSMB(IntegrationTest): assert res.stdout_text == 'Samba domain member is not configured yet\n' def test_install_samba(self): - self.smbserver.run_command(['ipa-client-samba', '-U']) + samba_install_result = self.smbserver.run_command( + ['ipa-client-samba', '-U']) # smb and winbind are expected to be not running for service in ['smb', 'winbind']: result = self.smbserver.run_command( @@ -219,6 +246,9 @@ class TestSMB(IntegrationTest): self.smbserver.run_command(['systemctl', 'status', service]) # print status for debugging purposes self.smbserver.run_command(['smbstatus']) + # checks postponed till the end of method to be sure services are + # started - this way we prevent other tests from failing + self.smb_installation_check(samba_install_result) def test_samba_service_listed(self): """Check samba service is listed.