7e1b55
From 86869364a30f071ee79974b301ff68e80c0950ba Mon Sep 17 00:00:00 2001
7e1b55
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
7e1b55
Date: Tue, 20 Jul 2021 20:19:16 +0200
7e1b55
Subject: [PATCH] test_acme: refactor with tasks
7e1b55
MIME-Version: 1.0
7e1b55
Content-Type: text/plain; charset=UTF-8
7e1b55
Content-Transfer-Encoding: 8bit
7e1b55
7e1b55
Signed-off-by: François Cami <fcami@redhat.com>
7e1b55
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
7e1b55
---
7e1b55
 ipatests/pytest_ipa/integration/tasks.py | 11 +++++++++++
7e1b55
 ipatests/test_integration/test_acme.py   | 19 ++++---------------
7e1b55
 2 files changed, 15 insertions(+), 15 deletions(-)
7e1b55
7e1b55
diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py
7e1b55
index 22c7ba782..c2e548617 100755
7e1b55
--- a/ipatests/pytest_ipa/integration/tasks.py
7e1b55
+++ b/ipatests/pytest_ipa/integration/tasks.py
7e1b55
@@ -2800,3 +2800,14 @@ def is_package_installed(host, pkg):
7e1b55
             'is_package_installed: unknown platform %s' % platform
7e1b55
         )
7e1b55
     return result.returncode == 0
7e1b55
+
7e1b55
+
7e1b55
+def move_date(host, chrony_cmd, date_str):
7e1b55
+    """Helper method to move system date
7e1b55
+    :param host: host on which date is to be manipulated
7e1b55
+    :param chrony_cmd: systemctl command to apply to
7e1b55
+                       chrony service, for instance 'start', 'stop'
7e1b55
+    :param date_str: date string to change the date i.e '3years2months1day1'
7e1b55
+    """
7e1b55
+    host.run_command(['systemctl', chrony_cmd, 'chronyd'])
7e1b55
+    host.run_command(['date', '-s', date_str])
7e1b55
diff --git a/ipatests/test_integration/test_acme.py b/ipatests/test_integration/test_acme.py
7e1b55
index d90f1ff7d..b4aa1b351 100644
7e1b55
--- a/ipatests/test_integration/test_acme.py
7e1b55
+++ b/ipatests/test_integration/test_acme.py
7e1b55
@@ -35,17 +35,6 @@ skip_mod_md_tests = osinfo.id not in ['rhel', 'fedora', ]
7e1b55
 CERTBOT_DNS_IPA_SCRIPT = '/usr/libexec/ipa/acme/certbot-dns-ipa'
7e1b55
 
7e1b55
 
7e1b55
-def move_date(host, chrony_cmd, date_str):
7e1b55
-    """Helper method to move system date
7e1b55
-    :param host: host on which date is to be manipulated
7e1b55
-    :param chrony_cmd: systemctl command to apply to
7e1b55
-                       chrony service, for instance 'start', 'stop'
7e1b55
-    :param date_str: date string to change the date i.e '3years2months1day1'
7e1b55
-    """
7e1b55
-    host.run_command(['systemctl', chrony_cmd, 'chronyd'])
7e1b55
-    host.run_command(['date', '-s', date_str])
7e1b55
-
7e1b55
-
7e1b55
 def check_acme_status(host, exp_status, timeout=60):
7e1b55
     """Helper method to check the status of acme server"""
7e1b55
     for _i in range(0, timeout, 5):
7e1b55
@@ -598,8 +587,8 @@ class TestACMERenew(IntegrationTest):
7e1b55
         )
7e1b55
         # move system date to expire acme cert
7e1b55
         for host in self.clients[0], self.master:
7e1b55
-            host.run_command(['kdestroy', '-A'])
7e1b55
-            move_date(host, 'stop', '+90days')
7e1b55
+            tasks.kdestroy_all(host)
7e1b55
+            tasks.move_date(host, 'stop', '+90days')
7e1b55
         self.clients[0].run_command(
7e1b55
             ['kinit', 'admin'],
7e1b55
             stdin_text=cmd_input.format(
7e1b55
@@ -611,8 +600,8 @@ class TestACMERenew(IntegrationTest):
7e1b55
 
7e1b55
         # move back date
7e1b55
         for host in self.clients[0], self.master:
7e1b55
-            host.run_command(['kdestroy', '-A'])
7e1b55
-            move_date(host, 'start', '-90days')
7e1b55
+            tasks.kdestroy_all(host)
7e1b55
+            tasks.move_date(host, 'start', '-90days')
7e1b55
             tasks.kinit_admin(host)
7e1b55
 
7e1b55
     @pytest.mark.skipif(skip_certbot_tests, reason='certbot not available')
7e1b55
-- 
7e1b55
2.31.1
7e1b55