On 07/28/2016 08:16 AM, Lenka Doudova wrote:



On 07/20/2016 04:51 PM, Pavel Vomacka wrote:
Please review attached patches, which add tests for new certificate widget in WebUI.

https://fedorahosted.org/freeipa/ticket/6064



Hi,
thanks for patches.
Functionally ok, but you have lots of PEP8 errors in patches 78, 80, 81 and 82 -> NACK. Also in patch 82, method test_arbitrary_certificate, comment says user needs to have "arbitrary_cert" configured, but the property in config file is correctly "arbitrary_cert_path", so it's a bit misleading.

Patch 79 is OK, ACK.

Lenka


Thank you for review. Attaching patches which have fixed all pep8 erros. Bad property of config file was also mentioned in patch 81. These are also fixed.

--
Pavel^3 Vomacka

From d0731af7431ecba96b5a7df943bbd97b1a7bb5b2 Mon Sep 17 00:00:00 2001
From: tester <t...@example.com>
Date: Wed, 20 Jul 2016 12:59:27 +0200
Subject: [PATCH 1/5] Add possibility to choose parent element by css

Part of: https://fedorahosted.org/freeipa/ticket/6064
---
 ipatests/test_webui/ui_driver.py | 43 +++++++++++++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index 7c4ca75efa3e642f4a2c0cdcd72be3cafa3c305a..f7f990a605ab8e1b595d457732be9170fa0f4130 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -615,12 +615,17 @@ class UI_driver(object):
         s = "a[name='%s'].action-button" % name
         self._button_click(s, parent, name)
 
-    def button_click(self, name, parent=None):
+    def button_click(self, name, parent=None,
+                     parents_css_sel=None):
         """
         Click on .ui-button
         """
         if not parent:
-            parent = self.get_form()
+            if parents_css_sel:
+                parent = self.find(parents_css_sel, By.CSS_SELECTOR,
+                                   strict=True)
+            else:
+                parent = self.get_form()
 
         s = "[name='%s'].btn" % name
         self._button_click(s, parent, name)
@@ -1413,14 +1418,25 @@ class UI_driver(object):
             for key in pkeys:
                 self.assert_record(key, parent, table_name, negative=True)
 
-    def action_list_action(self, name, confirm=True, confirm_btn="ok"):
+    def action_list_action(self, name, confirm=True, confirm_btn="ok",
+                           parents_css_sel=None):
         """
         Execute action list action
         """
-        cont = self.find(".active-facet .facet-actions", By.CSS_SELECTOR, strict=True)
-        expand = self.find(".dropdown-toggle", By.CSS_SELECTOR, cont, strict=True)
+        context = None
+
+        if not parents_css_sel:
+            context = self.find(".active-facet .facet-actions",
+                                By.CSS_SELECTOR, strict=True)
+        else:
+            context = self.find(parents_css_sel, By.CSS_SELECTOR,
+                                strict=True)
+
+        expand = self.find(".dropdown-toggle", By.CSS_SELECTOR, context,
+                           strict=True)
         expand.click()
-        action_link = self.find("li[data-name=%s] a" % name, By.CSS_SELECTOR, cont, strict=True)
+        action_link = self.find("li[data-name=%s] a" % name, By.CSS_SELECTOR,
+                                context, strict=True)
         action_link.click()
         if confirm:
             self.wait(0.5)  # wait for dialog
@@ -1739,17 +1755,26 @@ class UI_driver(object):
             assert is_enabled == enabled, ('Invalid enabled state of action button %s. '
                                            'Expected: %s') % (action, str(visible))
 
-    def assert_action_list_action(self, action, visible=True, enabled=True, parent=None):
+    def assert_action_list_action(self, action, visible=True, enabled=True,
+                                  parent=None, parents_css_sel=None,
+                                  facet_actions=True):
         """
         Assert that action dropdown action is visible/hidden, and enabled/disabled
 
         Enabled is checked only if action is visible.
         """
+
+        li_s = " li[data-name='%s']" % action
+
         if not parent:
             parent = self.get_form()
 
-        s = ".facet-actions li[data-name='%s']" % action
-        li = self.find(s, By.CSS_SELECTOR, parent)
+        if facet_actions:
+            li_s = ".facet-actions" + li_s
+        else:
+            li_s = parents_css_sel + li_s
+
+        li = self.find(li_s, By.CSS_SELECTOR, parent)
         link = self.find("a", By.CSS_SELECTOR, li)
 
         is_visible = li is not None and link is not None
-- 
2.7.4

From 22c0f8c5b2cd961795770662d22b3bb35573eb07 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Wed, 20 Jul 2016 16:28:38 +0200
Subject: [PATCH 6/9] Add function which check whether the field is empty

Part of: https://fedorahosted.org/freeipa/ticket/6064
---
 ipatests/test_webui/ui_driver.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index c82164c53095d8552aef665c5091deeb3bd71437..9c8380056ebee8feab6435e4383009ae6a9aeb9f 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -1566,6 +1566,17 @@ class UI_driver(object):
         s = "div[name='%s'] %s[name='%s']" % (name, element, name)
         self.assert_text(s, value, parent)
 
+    def assert_empty_value(self, selector, parent=None, negative=False):
+        """
+        Assert empty value of some field in details page or in a form
+        """
+        value = self.get_value(selector, parent)
+
+        if negative:
+            assert not value == ''
+        else:
+            assert value == ''
+
     def assert_no_dialog(self):
         """
         Assert that no dialog is opened
-- 
2.5.5

From 83e86a410112480a331ce058cdccf3c4e4c1c96c Mon Sep 17 00:00:00 2001
From: tester <t...@example.com>
Date: Wed, 20 Jul 2016 14:49:31 +0200
Subject: [PATCH 3/5] TEST: managing user certificates

Part of: https://fedorahosted.org/freeipa/ticket/6064
---
 ipatests/test_webui/test_user.py | 111 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/ipatests/test_webui/test_user.py b/ipatests/test_webui/test_user.py
index e926c22123ab449db2c3c061e500fa6e137d875d..a1fc7076ab123dcaf3152d1cd28ae3fa739b8a3c 100644
--- a/ipatests/test_webui/test_user.py
+++ b/ipatests/test_webui/test_user.py
@@ -38,7 +38,15 @@ except ImportError:
 
 
 @pytest.mark.tier1
-class test_user(UI_driver):
+class user_tasks(UI_driver):
+    def load_file(self, path):
+        with open(path, 'r') as file_d:
+            content = file_d.read()
+        return content
+
+
+@pytest.mark.tier1
+class test_user(user_tasks):
 
     @screenshot
     def test_crud(self):
@@ -164,6 +172,107 @@ class test_user(UI_driver):
         self.delete_action(user.ENTITY, user.PKEY, action='delete_active_user')
 
     @screenshot
+    def test_certificates(self):
+        """
+        Test user certificate actions
+
+        Requires to have CA installed and 'user_csr_path' configuration option
+        set.
+        """
+
+        if not self.has_ca():
+            self.skip('CA is not configured')
+
+        csr_path = self.config.get('user_csr_path')
+        if not csr_path:
+            self.skip('CSR file is not configured')
+
+        self.init_app()
+        # ENHANCEMENT: generate csr dynamically
+        csr = self.load_file(csr_path)
+        realm = self.config.get('ipa_realm')
+        cert_widget_sel = "div.certificate-widget"
+
+        self.add_record(user.ENTITY, user.DATA)
+        self.navigate_to_record(user.PKEY)
+
+        # cert request
+        self.action_list_action('request_cert', confirm=False)
+        self.assert_dialog()
+        self.fill_text("textarea[name='csr']", csr)
+        self.dialog_button_click('issue')
+        self.wait_for_request(n=2, d=3)
+        self.assert_visible(cert_widget_sel)
+
+        # cert view
+        self.action_list_action('view', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.assert_dialog()
+        self.dialog_button_click('close')
+
+        # cert get
+        self.action_list_action('get', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.assert_dialog()
+        # check that the textarea is not empty
+        self.assert_empty_value('textarea.certificate', negative=True)
+        self.dialog_button_click('close')
+
+        # cert download - we can only try to click the download action
+        self.action_list_action('download', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+
+        # check that revoke action is enabled
+        self.assert_action_list_action('revoke',
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is not enabled
+        self.assert_action_list_action('remove_hold', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # cert revoke
+        self.action_list_action('revoke', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.wait()
+        self.select('select', '6')
+        self.dialog_button_click('ok')
+        self.wait_for_request(n=2, d=3)
+        self.assert_visible(cert_widget_sel + " div.watermark")
+
+        # check that revoke action is not enabled
+        self.assert_action_list_action('revoke', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is enabled
+        self.assert_action_list_action('remove_hold',
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # cert remove hold
+        self.action_list_action('remove_hold', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.wait()
+        self.dialog_button_click('ok')
+        self.wait_for_request(n=2)
+
+        # check that revoke action is enabled
+        self.assert_action_list_action('revoke',
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is not enabled
+        self.assert_action_list_action('remove_hold', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # cleanup
+        self.navigate_to_entity(user.ENTITY, 'search')
+        self.delete_record(user.PKEY, user.DATA.get('del'))
+
+    @screenshot
     def test_password_expiration_notification(self):
         """
         Test password expiration notification
-- 
2.7.4

From 866118481a1fba9f321907686dcbb0444f1df4b8 Mon Sep 17 00:00:00 2001
From: tester <t...@example.com>
Date: Wed, 20 Jul 2016 14:00:29 +0200
Subject: [PATCH 4/5] TEST: managing host certificates

Parf of: https://fedorahosted.org/freeipa/ticket/6064
---
 ipatests/test_webui/test_host.py | 154 +++++++++++++++++++++++++++++++--------
 1 file changed, 124 insertions(+), 30 deletions(-)

diff --git a/ipatests/test_webui/test_host.py b/ipatests/test_webui/test_host.py
index 7ee6b4bac959958330ede11093cf9189cfcb47c8..a87d509895d54daaf2bd7abfc9794e721f7ae199 100644
--- a/ipatests/test_webui/test_host.py
+++ b/ipatests/test_webui/test_host.py
@@ -98,11 +98,10 @@ class host_tasks(UI_driver):
         ip.append(str(last + 1))
         return '.'.join(ip)
 
-    def load_csr(self, path):
-        # ENHANCEMENT: generate csr dynamically
-        with open(path, 'r') as csr_file:
-            csr = csr_file.read()
-        return csr
+    def load_file(self, path):
+        with open(path, 'r') as file_d:
+            content = file_d.read()
+        return content
 
 
 @pytest.mark.tier1
@@ -133,49 +132,149 @@ class test_host(host_tasks):
             self.skip('CSR file is not configured')
 
         self.init_app()
-        csr = self.load_csr(csr_path)
-        panel = 'cert_actions'
+        # ENHANCEMENT: generate csr dynamically
+        csr = self.load_file(csr_path)
         realm = self.config.get('ipa_realm')
+        cert_widget_sel = "div.certificate-widget"
 
         self.add_record(ENTITY, self.data)
         self.navigate_to_record(self.pkey)
 
-        self.assert_visible("div[name='certificate-missing']")
-
         # cert request
         self.action_list_action('request_cert', confirm=False)
-        self.fill_text('textarea.certificate', csr)
+        self.assert_dialog()
+        self.fill_text("textarea[name='csr']", csr)
         self.dialog_button_click('issue')
-        self.wait_for_request(n=2, d=0.5)
-        self.assert_visible("div[name='certificate-valid']")
+        self.wait_for_request(n=2, d=3)
+        self.assert_visible(cert_widget_sel)
 
         # cert view
-        self.action_list_action('view_cert', confirm=False)
-        self.wait()
-        self.assert_text("tbody tr:nth-child(2) td:nth-child(2)", self.pkey)
-        self.assert_text("tbody tr:nth-child(3) td:nth-child(2)", realm)
+        self.action_list_action('view', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.assert_dialog()
         self.dialog_button_click('close')
 
         # cert get
-        self.action_list_action('get_cert', confirm=False)
-        self.wait()
-        # We don't know the cert text, so at least open and close the dialog
+        self.action_list_action('get', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.assert_dialog()
+        # check that the textarea is not empty
+        self.assert_empty_value('textarea.certificate', negative=True)
         self.dialog_button_click('close')
 
+        # cert download - we can only try to click the download action
+        self.action_list_action('download', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+
+        # check that revoke action is enabled
+        self.assert_action_list_action('revoke',
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is not enabled
+        self.assert_action_list_action('remove_hold', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
         # cert revoke
-        self.action_list_action('revoke_cert', confirm=False)
+        self.action_list_action('revoke', confirm=False,
+                                parents_css_sel=cert_widget_sel)
         self.wait()
         self.select('select', '6')
         self.dialog_button_click('ok')
-        self.wait_for_request(n=2)
-        self.assert_visible("div[name='certificate-revoked']")
+        self.wait_for_request(n=2, d=3)
+        self.assert_visible(cert_widget_sel + " div.watermark")
 
-        # cert restore
-        self.action_list_action('restore_cert', confirm=False)
+        # check that revoke action is not enabled
+        self.assert_action_list_action('revoke', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is enabled
+        self.assert_action_list_action('remove_hold',
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # cert remove hold
+        self.action_list_action('remove_hold', confirm=False,
+                                parents_css_sel=cert_widget_sel)
         self.wait()
         self.dialog_button_click('ok')
         self.wait_for_request(n=2)
-        self.assert_visible("div[name='certificate-valid']")
+
+        # check that revoke action is enabled
+        self.assert_action_list_action('revoke',
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is not enabled
+        self.assert_action_list_action('remove_hold', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # cleanup
+        self.navigate_to_entity(ENTITY, 'search')
+        self.delete_record(self.pkey, self.data.get('del'))
+
+    @screenshot
+    def test_arbitrary_certificates(self):
+        """
+        Test managing host arbitrary certificate.
+
+        Requires to have 'arbitrary_cert_path' configuration set.
+        """
+        cert_path = self.config.get('arbitrary_cert_path')
+        if not cert_path:
+            self.skip('Arbitrary certificate file is not configured')
+
+        self.init_app()
+        cert = self.load_file(cert_path)
+        realm = self.config.get('ipa_realm')
+        self.add_record(ENTITY, self.data)
+
+        self.navigate_to_record(self.pkey)
+
+        # check whether certificate section is present
+        self.assert_visible("div[name='certificate']")
+
+        # add certificate
+        self.button_click('add', parents_css_sel="div[name='certificate']")
+        self.assert_dialog()
+        self.fill_textarea('new_cert', cert)
+        self.dialog_button_click('add')
+
+        self.assert_visible("div.certificate-widget")
+
+        # cert view
+        self.action_list_action('view', confirm=False,
+                                parents_css_sel="div.certificate-widget")
+        self.assert_dialog()
+        self.dialog_button_click('close')
+
+        # cert get
+        self.action_list_action('get', confirm=False,
+                                parents_css_sel="div.certificate-widget")
+        self.assert_dialog()
+
+        # check that the textarea is not empty
+        self.assert_empty_value('textarea.certificate', negative=True)
+        self.dialog_button_click('close')
+
+        # cert download - we can only try to click the download action
+        self.action_list_action('download', confirm=False,
+                                parents_css_sel="div.certificate-widget")
+
+        # check that revoke action is not enabled
+        self.assert_action_list_action(
+            'revoke', enabled=False,
+            parents_css_sel="div.certificate-widget",
+            facet_actions=False)
+
+        # check that remove_hold action is not enabled
+        self.assert_action_list_action(
+            'remove_hold', enabled=False,
+            parents_css_sel="div.certificate-widget",
+            facet_actions=False)
 
         # cleanup
         self.navigate_to_entity(ENTITY, 'search')
@@ -195,11 +294,6 @@ class test_host(host_tasks):
         self.navigate_to_record(self.pkey)
 
         self.assert_action_list_action('request_cert', visible=False)
-        self.assert_action_list_action('revoke_cert', visible=False)
-        self.assert_action_list_action('restore_cert', visible=False)
-
-        self.assert_action_list_action('view_cert', enabled=False)
-        self.assert_action_list_action('get_cert', enabled=False)
 
         self.navigate_by_breadcrumb('Hosts')
         self.delete_record(self.pkey, self.data.get('del'))
-- 
2.7.4

From e1d2442e30d6d171d1fe7a07d01d130e8b8973cd Mon Sep 17 00:00:00 2001
From: tester <t...@example.com>
Date: Wed, 20 Jul 2016 14:02:00 +0200
Subject: [PATCH 5/5] TEST: managing service certificates

Part of: https://fedorahosted.org/freeipa/ticket/6064
---
 ipatests/test_webui/test_service.py | 159 ++++++++++++++++++++++++++++--------
 1 file changed, 123 insertions(+), 36 deletions(-)

diff --git a/ipatests/test_webui/test_service.py b/ipatests/test_webui/test_service.py
index f582b688cea7e07b4228ffb4333837e4a0139445..5b1849baea1457a676db967dc4225ddefb3aeb3f 100644
--- a/ipatests/test_webui/test_service.py
+++ b/ipatests/test_webui/test_service.py
@@ -48,11 +48,11 @@ class sevice_tasks(UI_driver):
             ],
         }
 
-    def load_csr(self, path):
+    def load_file(self, path):
         # ENHANCEMENT: generate csr dynamically
-        with open(path, 'r') as csr_file:
-            csr = csr_file.read()
-        return csr
+        with open(path, 'r') as file_d:
+            content = file_d.read()
+        return content
 
     def get_http_pkey(self):
         host = self.config.get('ipa_server')
@@ -92,49 +92,149 @@ class test_service(sevice_tasks):
         self.init_app()
         data = self.prep_data()
         pkey = data.get('pkey')
-        csr = self.load_csr(csr_path)
+        csr = self.load_file(csr_path)
         host = self.config.get('ipa_server')
         realm = self.config.get('ipa_realm')
+        cert_widget_sel = "div.certificate-widget"
 
         self.add_record(ENTITY, data)
         self.navigate_to_record(pkey)
 
-        self.assert_visible("div[name='certificate-missing']")
-
         # cert request
         self.action_list_action('request_cert', confirm=False)
-        self.fill_text('textarea.certificate', csr)
+        self.assert_dialog()
+        self.fill_text("textarea[name='csr'", csr)
         self.dialog_button_click('issue')
-        self.wait_for_request(n=2, d=0.5)
-        self.assert_visible("div[name='certificate-valid']")
+        self.wait_for_request(n=2, d=3)
+        self.assert_visible(cert_widget_sel)
 
         # cert view
-        self.action_list_action('view_cert', confirm=False)
-        self.wait()
-        self.assert_text("tbody tr:nth-child(2) td:nth-child(2)", host)
-        self.assert_text("tbody tr:nth-child(3) td:nth-child(2)", realm)
+        self.action_list_action('view', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.assert_dialog()
         self.dialog_button_click('close')
 
         # cert get
-        self.action_list_action('get_cert', confirm=False)
-        self.wait()
-        # We don't know the cert text, so at least open and close the dialog
+        self.action_list_action('get', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.assert_dialog()
+        # check that text area is not empty
+        self.assert_empty_value('textarea.certificate', negative=True)
         self.dialog_button_click('close')
 
+        # cert download - we can only try to click the download action
+        self.action_list_action('download', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        # check that revoke action is enabled
+        self.assert_action_list_action('revoke',
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is not enabled
+        self.assert_action_list_action('remove_hold', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
         # cert revoke
-        self.action_list_action('revoke_cert', confirm=False)
+        self.action_list_action('revoke', confirm=False,
+                                parents_css_sel=cert_widget_sel)
         self.wait()
         self.select('select', '6')
         self.dialog_button_click('ok')
-        self.wait_for_request(n=2)
-        self.assert_visible("div[name='certificate-revoked']")
+        self.wait_for_request(n=2, d=3)
+        self.assert_visible(cert_widget_sel + " div.watermark")
 
-        # cert restore
-        self.action_list_action('restore_cert', confirm=False)
+        # check that revoke action is not enabled
+        self.assert_action_list_action('revoke', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is enabled
+        self.assert_action_list_action('remove_hold',
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # cert remove hold
+        self.action_list_action('remove_hold', confirm=False,
+                                parents_css_sel=cert_widget_sel)
         self.wait()
         self.dialog_button_click('ok')
         self.wait_for_request(n=2)
-        self.assert_visible("div[name='certificate-valid']")
+
+        # check that revoke action is enabled
+        self.assert_action_list_action('revoke',
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is not enabled
+        self.assert_action_list_action('remove_hold', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # cleanup
+        self.navigate_to_entity(ENTITY, 'search')
+        self.delete_record(pkey, data.get('del'))
+
+    @screenshot
+    def test_arbitrary_certificates(self):
+        """
+        Test managing service arbitrary certificate.
+
+        Requires to have 'arbitrary_cert_path' configuration set.
+        """
+        cert_path = self.config.get('arbitrary_cert_path')
+        if not cert_path:
+            self.skip('Arbitrary certificate file is not configured')
+
+        self.init_app()
+        data = self.prep_data()
+        pkey = data.get('pkey')
+        cert = self.load_file(cert_path)
+        realm = self.config.get('ipa_realm')
+        cert_widget_sel = "div.certificate-widget"
+
+        self.add_record(ENTITY, data)
+        self.navigate_to_record(pkey)
+
+        # check whether certificate section is present
+        self.assert_visible("div[name='certificate']")
+
+        # add certificate
+        self.button_click('add', parents_css_sel="div[name='certificate']")
+        self.assert_dialog()
+        self.fill_textarea('new_cert', cert)
+        self.dialog_button_click('add')
+
+        self.assert_visible(cert_widget_sel)
+
+        # cert view
+        self.action_list_action('view', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.assert_dialog()
+        self.dialog_button_click('close')
+
+        # cert get
+        self.action_list_action('get', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+        self.assert_dialog()
+
+        # check that the textarea is not empty
+        self.assert_empty_value('textarea.certificate', negative=True)
+        self.dialog_button_click('close')
+
+        # cert download - we can only try to click the download action
+        self.action_list_action('download', confirm=False,
+                                parents_css_sel=cert_widget_sel)
+
+        # check that revoke action is not enabled
+        self.assert_action_list_action('revoke', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
+
+        # check that remove_hold action is not enabled
+        self.assert_action_list_action('remove_hold', enabled=False,
+                                       parents_css_sel=cert_widget_sel,
+                                       facet_actions=False)
 
         # cleanup
         self.navigate_to_entity(ENTITY, 'search')
@@ -158,23 +258,10 @@ class test_service(sevice_tasks):
         self.navigate_to_record(pkey)
 
         self.assert_action_list_action('request_cert', visible=False)
-        self.assert_action_list_action('revoke_cert', visible=False)
-        self.assert_action_list_action('restore_cert', visible=False)
-
-        self.assert_action_list_action('view_cert', enabled=False)
-        self.assert_action_list_action('get_cert', enabled=False)
 
         self.navigate_by_breadcrumb('Services')
         self.delete_record(pkey, data.get('del'))
 
-        # test HTTP, which should have cert set by default and so 'view' and 'get'
-        # actions visible and enabled
-        pkey = self.get_http_pkey()
-
-        self.navigate_to_record(pkey)
-        self.assert_action_list_action('view_cert')
-        self.assert_action_list_action('get_cert')
-
     @screenshot
     def test_kerberos_flags(self):
         """
-- 
2.7.4

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to