From cb205cc5e4c890df5d0344682e6c958ecb087c68 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Thu, 21 May 2020 13:00:39 -0400 Subject: [PATCH] IPA-EPN: add test to validate smtp_delay value Configuration test to ensure that smtp_delay validation is properly enforced. Also reset the epn configuration when the tests are run. https://pagure.io/freeipa/issue/3687 Signed-off-by: Rob Crittenden Reviewed-By: Francois Cami --- ipatests/test_integration/test_epn.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ipatests/test_integration/test_epn.py b/ipatests/test_integration/test_epn.py index 3186a1a70..2e335adc7 100644 --- a/ipatests/test_integration/test_epn.py +++ b/ipatests/test_integration/test_epn.py @@ -214,6 +214,10 @@ class TestEPN(IntegrationTest): With the default configuration, the result should be an empty list. Also check behavior on master and client alike. """ + epn_conf = textwrap.dedent(''' + [global] + ''') + self.master.put_file_contents('/etc/ipa/epn.conf', epn_conf) # check EPN on client (LDAP+GSSAPI) (stdout_text, unused) = self._check_epn_output( self.clients[0], dry_run=True @@ -438,3 +442,23 @@ class TestEPN(IntegrationTest): for i in self.notify_ttls: validate_mail(self.master, i, "Hi user,\nYour login entry user%d is going" % i) + + def test_EPN_delay_config(self, cleanupmail): + """Test the smtp_delay configuration option + """ + epn_conf = textwrap.dedent(''' + [global] + smtp_delay=A + ''') + self.master.put_file_contents('/etc/ipa/epn.conf', epn_conf) + + result = tasks.ipa_epn(self.master, raiseonerr=False) + assert "could not convert string to float: 'A'" in result.stderr_text + + epn_conf = textwrap.dedent(''' + [global] + smtp_delay=-1 + ''') + self.master.put_file_contents('/etc/ipa/epn.conf', epn_conf) + result = tasks.ipa_epn(self.master, raiseonerr=False) + assert "smtp_delay cannot be less than zero" in result.stderr_text