URL: https://github.com/freeipa/freeipa/pull/2748
Author: serg-cymbaluk
 Title: #2748: Fix certificate revocation tests for Web UI
Action: opened

PR body:
"""
- correct revocation date before search
- increase timeouts

https://pagure.io/freeipa/issue/7834
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/2748/head:pr2748
git checkout pr2748
From 035d79f126d2373cbe381f901729094dfced1a04 Mon Sep 17 00:00:00 2001
From: Serhii Tsymbaliuk <stsym...@redhat.com>
Date: Fri, 11 Jan 2019 14:30:22 +0100
Subject: [PATCH 1/2] Fix certificate revocation tests for Web UI

- correct revocation date before search
- increase timeouts

https://pagure.io/freeipa/issue/7834
---
 ipatests/test_webui/test_cert.py    | 84 +++++++++++++++++++----------
 ipatests/test_webui/test_host.py    |  2 +-
 ipatests/test_webui/test_service.py |  2 +-
 3 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/ipatests/test_webui/test_cert.py b/ipatests/test_webui/test_cert.py
index c5e05bcab1..9d9ddf318f 100644
--- a/ipatests/test_webui/test_cert.py
+++ b/ipatests/test_webui/test_cert.py
@@ -44,26 +44,6 @@ def search_pkey(self, pkey):
     self.wait_for_request(n=2)
 
 
-def add_cert(self, principal, csr):
-    self.facet_button_click('request_cert')
-    self.fill_textbox('principal', principal)
-    self.check_option('add', 'checked')
-    self.fill_textarea('csr', csr)
-    self.dialog_button_click('issue')
-    self.assert_notification(assert_text='Certificate requested')
-    self.navigate_to_entity(ENTITY)
-    rows = self.get_rows()
-    return rows[-1]
-
-
-def revoke_cert(self, record, reason):
-    self.navigate_to_entity(ENTITY)
-    self.navigate_to_row_record(record)
-    self.action_list_action('revoke_cert', False)
-    self.select('select[name=revocation_reason]', reason)
-    self.dialog_button_click('ok')
-
-
 def check_option_negative(self, date, option):
     self.navigate_to_entity(ENTITY)
     self.select('select[name=search_option]', option)
@@ -109,6 +89,28 @@ def setup(self, *args, **kwargs):
         if not self.has_ca():
             self.skip('CA not configured')
 
+    def _add_and_revoke_cert(self, reason='1'):
+        hostname = self.config.get('ipa_server')
+        csr = generate_csr(hostname)
+
+        self.facet_button_click('request_cert')
+        self.fill_textbox('principal', 'HTTP/{}'.format(hostname))
+        self.check_option('add', 'checked')
+        self.fill_textarea('csr', csr)
+        self.dialog_button_click('issue')
+        self.assert_notification(assert_text='Certificate requested')
+        self.navigate_to_entity(ENTITY)
+        rows = self.get_rows()
+        cert = rows[-1]
+
+        self.navigate_to_row_record(cert)
+        self.action_list_action('revoke_cert', False)
+        self.select('select[name=revocation_reason]', reason)
+        self.dialog_button_click('ok')
+        self.navigate_to_entity(ENTITY)
+
+        return cert
+
     @screenshot
     def test_read(self):
         """
@@ -162,16 +164,10 @@ def test_search_revocation_reason(self):
         self.init_app()
         self.navigate_to_entity(ENTITY)
 
-        # add a new cert
-        hostname = self.config.get('ipa_server')
-        csr = generate_csr(hostname)
-        record = add_cert(self, 'HTTP/{}'.format(hostname), csr)
-
-        # revoke added cert
-        revoke_cert(self, record, '1')
+        # revoke new certificate
+        self._add_and_revoke_cert()
 
         # search cert by revocation reason
-        self.navigate_to_entity(ENTITY)
         self.select('select[name=search_option]', 'revocation_reason')
         search_pkey(self, '1')
         rows = self.get_rows()
@@ -249,6 +245,10 @@ def test_search_valid_not_after_from(self):
         today = date.today()
         self.init_app()
         self.navigate_to_entity(ENTITY)
+
+        # revoke new certificate
+        self._add_and_revoke_cert()
+
         self.select('select[name=search_option]', 'validnotafter_from')
         search_pkey(self, str(today))
         rows = self.get_rows()
@@ -285,6 +285,10 @@ def test_search_valid_not_after_to(self):
         today = date.today()
         self.init_app()
         self.navigate_to_entity(ENTITY)
+
+        # revoke new certificate
+        self._add_and_revoke_cert()
+
         self.select('select[name=search_option]', 'validnotafter_to')
         search_pkey(self, str(today + timedelta(weeks=52 * 30)))
         rows = self.get_rows()
@@ -321,6 +325,10 @@ def test_search_valid_not_before_from(self):
         today = date.today()
         self.init_app()
         self.navigate_to_entity(ENTITY)
+
+        # revoke new certificate
+        self._add_and_revoke_cert()
+
         self.select('select[name=search_option]', 'validnotbefore_from')
         search_pkey(self, str(today))
         rows = self.get_rows()
@@ -357,6 +365,10 @@ def test_search_valid_not_before_to(self):
         today = date.today()
         self.init_app()
         self.navigate_to_entity(ENTITY)
+
+        # revoke new certificate
+        self._add_and_revoke_cert()
+
         self.select('select[name=search_option]', 'validnotbefore_to')
         search_pkey(self, str(today + timedelta(weeks=52 * 30)))
         rows = self.get_rows()
@@ -393,6 +405,10 @@ def test_search_issued_on_from(self):
         today = date.today()
         self.init_app()
         self.navigate_to_entity(ENTITY)
+
+        # revoke new certificate
+        self._add_and_revoke_cert()
+
         self.select('select[name=search_option]', 'issuedon_from')
         search_pkey(self, str(today))
         rows = self.get_rows()
@@ -425,6 +441,10 @@ def test_search_issued_on_to(self):
         today = date.today()
         self.init_app()
         self.navigate_to_entity(ENTITY)
+
+        # revoke new certificate
+        self._add_and_revoke_cert()
+
         self.select('select[name=search_option]', 'issuedon_to')
         search_pkey(self, str(today))
         rows = self.get_rows()
@@ -457,6 +477,10 @@ def test_search_revoked_on_from(self):
         today = date.today()
         self.init_app()
         self.navigate_to_entity(ENTITY)
+
+        # revoke new certificate
+        self._add_and_revoke_cert()
+
         self.select('select[name=search_option]', 'revokedon_from')
         search_pkey(self, str(today))
         rows = self.get_rows()
@@ -489,6 +513,10 @@ def test_search_revoked_on_to(self):
         today = date.today()
         self.init_app()
         self.navigate_to_entity(ENTITY)
+
+        # revoke new certificate
+        self._add_and_revoke_cert()
+
         self.select('select[name=search_option]', 'revokedon_to')
         search_pkey(self, str(today))
         rows = self.get_rows()
diff --git a/ipatests/test_webui/test_host.py b/ipatests/test_webui/test_host.py
index 07c8656b41..a52a16dc74 100644
--- a/ipatests/test_webui/test_host.py
+++ b/ipatests/test_webui/test_host.py
@@ -216,7 +216,7 @@ def test_certificates(self):
         self.wait()
         self.select('select', '6')
         self.dialog_button_click('ok')
-        self.wait_for_request(n=2, d=3)
+        self.wait_for_request(0.5, n=2, d=3)
         self.assert_visible(cert_widget_sel + " div.watermark")
 
         # check that revoke action is not enabled
diff --git a/ipatests/test_webui/test_service.py b/ipatests/test_webui/test_service.py
index aa849476c2..f1209c71a0 100644
--- a/ipatests/test_webui/test_service.py
+++ b/ipatests/test_webui/test_service.py
@@ -218,7 +218,7 @@ def test_certificates(self):
         self.wait()
         self.select('select', '6')
         self.dialog_button_click('ok')
-        self.wait_for_request(n=2, d=3)
+        self.wait_for_request(0.5, n=2, d=3)
         self.assert_visible(cert_widget_sel + " div.watermark")
 
         # check that revoke action is not enabled

From 473ed6146a6700ef0495139f82558abdc6214370 Mon Sep 17 00:00:00 2001
From: Serhii Tsymbaliuk <stsym...@redhat.com>
Date: Fri, 11 Jan 2019 14:46:13 +0100
Subject: [PATCH 2/2] Temp commit

---
 ipatests/prci_definitions/temp_commit.yaml | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/ipatests/prci_definitions/temp_commit.yaml b/ipatests/prci_definitions/temp_commit.yaml
index d5c2b59ae7..d5599f5bcb 100644
--- a/ipatests/prci_definitions/temp_commit.yaml
+++ b/ipatests/prci_definitions/temp_commit.yaml
@@ -49,10 +49,13 @@ jobs:
     requires: [fedora-29/build]
     priority: 50
     job:
-      class: RunPytest
+      class: RunWebuiTests
       args:
         build_url: '{fedora-29/build_url}'
-        test_suite: test_integration/test_REPLACEME.py
+        test_suite: >-
+          test_webui/test_cert.py
+          test_webui/test_host.py::test_host::test_certificates
+          test_webui/test_service.py::test_service::test_certificates
         template: *ci-master-f29
         timeout: 3600
-        topology: *master_1repl_1client
+        topology: *ipaserver
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org

Reply via email to