From aeebe38270c9bb63c9abb11a5cd3d038f1f1d68a Mon Sep 17 00:00:00 2001
From: Michal Polovka <mpolovka@redhat.com>
Date: Tue, 16 Feb 2021 16:53:56 +0100
Subject: [PATCH 1/2] WebUI: test_user_caless: test if user is enabled

Test checks if the user is enabled, able to reset their password and
authentication types in CA-less environment.

Related: https://pagure.io/freeipa/issue/8203

Signed-off-by: Michal Polovka <mpolovka@redhat.com>
---
 ipatests/test_webui/test_user_caless.py | 30 ++++++++++++++++
 ipatests/test_webui/ui_driver.py        | 48 +++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
 create mode 100644 ipatests/test_webui/test_user_caless.py

diff --git a/ipatests/test_webui/test_user_caless.py b/ipatests/test_webui/test_user_caless.py
new file mode 100644
index 00000000000..d8f402ebf97
--- /dev/null
+++ b/ipatests/test_webui/test_user_caless.py
@@ -0,0 +1,30 @@
+import pytest
+
+import ipatests.test_webui.data_user as user
+from ipatests.test_webui.ui_driver import UI_driver
+from ipatests.test_webui.ui_driver import screenshot
+
+
+@pytest.mark.tier1
+class TestUserCaless(UI_driver):
+
+    @screenshot
+    def test_enabled(self):
+        """
+        Test if valid user is enabled by default.
+        Test for https://pagure.io/freeipa/issue/8203
+        """
+        self.init_app()
+
+        # check if the user is enabled
+        self.add_record(user.ENTITY, user.DATA, navigate=False)
+        self.assert_record_value("Enabled", user.ENTITY, "nsaccountlock")
+
+        self.navigate_to_record(user.ENTITY)
+        self.assert_action_list_action("disable", visible=True, enabled=False)
+        self.assert_action_list_action("reset_password",
+                                       visible=True, enabled=True)
+
+        # add OTP authentication type and verify the change is persistent
+        self.add_user_auth_type("otp", save=True)
+        self.assert_user_auth_type("otp", enabled=True)
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index a5a082830e7..7654ec63f80 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -2007,6 +2007,43 @@ def run_cmd_on_ui_host(self, cmd):
             cmd=cmd
         )
 
+    def add_user_auth_type(self, auth_type, save=False):
+        """
+        Select user auth type
+        :param auth_type: one of password, radius, otp, pkinit or hardened
+        """
+        s_checkbox = 'div[name="ipauserauthtype"] input[value="{}"]'.format(
+            auth_type)
+        checkbox = self.find(s_checkbox, By.CSS_SELECTOR, strict=True)
+        if not checkbox.is_selected():
+            checkbox.click()
+        if save:
+            self.facet_button_click('save')
+
+    def remove_user_auth_type(self, auth_type, save=False):
+        """
+        Deselect user auth type
+        :param auth_type: one of password, radius, otp, pkinit or hardened
+        """
+        s_checkbox = 'div[name="ipauserauthtype"] input[value="{}"]'.format(
+            auth_type)
+        checkbox = self.find(s_checkbox, By.CSS_SELECTOR, strict=True)
+        if checkbox.is_selected():
+            checkbox.click()
+        if save:
+            self.facet_button_click('save')
+
+    def undo_user_auth_type(self, save=False):
+        """
+        Undo user auth type selection
+        """
+        s_undo = 'div[name="ipauserauthtype" button[name="undo"]'
+        undo = self.find(s_undo, By.CSS_SELECTOR, strict=True)
+        undo.click()
+        self.wait(0.6)
+        if save:
+            self.facet_button_click('save')
+
     @dismiss_unexpected_alert
     def has_class(self, el, cls):
         """
@@ -2369,3 +2406,14 @@ def assert_value_checked(self, values, name, negative=False):
             else:
                 assert value in checked_values, ('{} NOT checked while it '
                                                  'should be'.format(value))
+
+    def assert_user_auth_type(self, auth_type, enabled=True):
+        """
+        Check if provided auth type is enabled or disabled for the user
+        :param auth_type: one of password, radius, otp, pkinit or hardened
+        :param enabled: check if enabled if True, check for disabled if False
+        """
+        s_checkbox = 'div[name="ipauserauthtype"] input[value="{}"]'.format(
+            auth_type)
+        checkbox = self.find(s_checkbox, By.CSS_SELECTOR, strict=True)
+        assert checkbox.is_selected() == enabled

From 25f37a81827604d050f7694f948868f3cbb2ab1f Mon Sep 17 00:00:00 2001
From: Michal Polovka <mpolovka@redhat.com>
Date: Tue, 16 Feb 2021 17:01:48 +0100
Subject: [PATCH 2/2] temp commit

Signed-off-by: Michal Polovka <mpolovka@redhat.com>
---
 .freeipa-pr-ci.yaml                        |  2 +-
 ipatests/prci_definitions/temp_commit.yaml | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/.freeipa-pr-ci.yaml b/.freeipa-pr-ci.yaml
index abcf8c5b634..80656690080 120000
--- a/.freeipa-pr-ci.yaml
+++ b/.freeipa-pr-ci.yaml
@@ -1 +1 @@
-ipatests/prci_definitions/gating.yaml
\ No newline at end of file
+ipatests/prci_definitions/temp_commit.yaml
\ No newline at end of file
diff --git a/ipatests/prci_definitions/temp_commit.yaml b/ipatests/prci_definitions/temp_commit.yaml
index 8f8a357acd1..9cc0ddbea50 100644
--- a/ipatests/prci_definitions/temp_commit.yaml
+++ b/ipatests/prci_definitions/temp_commit.yaml
@@ -45,6 +45,10 @@ topologies:
     name: adroot_adchild_adtree_master_1client
     cpu: 8
     memory: 14500
+  ipaserver_caless: &ipaserver_caless
+    name: ipaserver_caless
+    cpu: 2
+    memory: 2400
 
 jobs:
   fedora-latest/build:
@@ -65,10 +69,10 @@ jobs:
     requires: [fedora-latest/build]
     priority: 50
     job:
-      class: RunPytest
+      class: RunWebuiTests
       args:
         build_url: '{fedora-latest/build_url}'
-        test_suite: test_integration/test_REPLACEME.py
+        test_suite: test_webui/test_user_caless.py
         template: *ci-master-latest
         timeout: 3600
-        topology: *master_1repl_1client
+        topology: *ipaserver_caless
