From 75e390466fe4433547e38e0dac203080db7d8505 Mon Sep 17 00:00:00 2001 From: Luna D Dragon Date: Thu, 19 Feb 2026 12:44:10 +0530 Subject: [PATCH 1/4] testlib: add absent_content to sed_file absent_content is an argument to sed_file that will if the specified path does not exist, create a file with the contents passed to it. --- test/common/testlib.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/common/testlib.py b/test/common/testlib.py index 6c1c608a49bd..27c83be40ee8 100644 --- a/test/common/testlib.py +++ b/test/common/testlib.py @@ -2402,15 +2402,20 @@ def settle_cpu(self) -> None: break time.sleep(3) - def sed_file(self, expr: str, path: str, apply_change_action: str | None = None) -> None: + def sed_file(self, expr: str, path: str, apply_change_action: str | None = None, absent_content: str | None = None) -> None: """sed a file on primary machine This is safe for @nondestructive tests, the file will be restored during cleanup. The optional apply_change_action will be run both after sedding and after restoring the file. + + The optional absent_content will create a file in path with the specified contents should the file not exist """ m = self.machine - m.execute(f"sed -i.cockpittest '{expr}' {path}") + if absent_content and not self.file_exists(path): + m.write(path, absent_content) + else: + m.execute(f"sed -i.cockpittest '{expr}' {path}") if apply_change_action: m.execute(apply_change_action) From 5218b633f65cdc99632933c64923a5f64e6ad05b Mon Sep 17 00:00:00 2001 From: Luna D Dragon Date: Thu, 19 Feb 2026 12:46:53 +0530 Subject: [PATCH 2/4] test: set useradd defaults on suse images --- test/verify/check-users | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/verify/check-users b/test/verify/check-users index 9f79ba6b24f4..bbd18ee3ffff 100755 --- a/test/verify/check-users +++ b/test/verify/check-users @@ -94,7 +94,6 @@ def createUser( @testlib.nondestructive -@testlib.skipImage("TODO: fix for OpenSUSE", "opensuse-tumbleweed") class TestAccounts(testlib.MachineCase): def testBasic(self): @@ -212,7 +211,8 @@ class TestAccounts(testlib.MachineCase): b.wait_visible("#accounts-create") # Create a user from the UI - self.sed_file('s@^SHELL=.*$@SHELL=/bin/true@', '/etc/default/useradd') + self.sed_file('s@^SHELL=.*$@SHELL=/bin/true@', '/etc/default/useradd', absent_content="SHELL=/bin/true") + b.click('#accounts-create') b.wait_visible('#accounts-create-dialog') b.set_input_text('#accounts-create-user-name', "Berta") @@ -455,7 +455,7 @@ class TestAccounts(testlib.MachineCase): self.login_and_go("/users") # Create a locked user with weak password - self.sed_file('s/^SHELL=.*$/SHELL=/', '/etc/default/useradd') + self.sed_file('s/^SHELL=.*$/SHELL=/', '/etc/default/useradd', absent_content="SHELL=") self.allow_journal_messages(".*required to change your password immediately.*") self.allow_journal_messages(".*user account or password has expired.*") From dabe2c0261069f8251a704ab15a8bc8dc502bf6c Mon Sep 17 00:00:00 2001 From: Alice Brooks Date: Tue, 11 Jun 2024 08:04:44 +0100 Subject: [PATCH 3/4] test: SUSE Images have different path for password complexity requirements --- test/verify/check-static-login | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/verify/check-static-login b/test/verify/check-static-login index 584faa290366..8df8370276e0 100755 --- a/test/verify/check-static-login +++ b/test/verify/check-static-login @@ -271,7 +271,6 @@ account required pam_succeed_if.so user ingroup %s""" % m.get_admin_group verify_correct(has_last=True, n_fail=0) @testlib.skipImage("Arch Linux has no pwquality by default", "arch") - @testlib.skipImage("TODO: fix for OpenSUSE", "opensuse-tumbleweed") def testExpired(self): m = self.machine b = self.browser @@ -292,7 +291,8 @@ account required pam_succeed_if.so user ingroup %s""" % m.get_admin_group # test steps below assume a pam_pwquality config with retry > 1; on some images authselect drops that setting if not m.image.startswith('debian') and not m.image.startswith('ubuntu') and not m.image.startswith("arch"): - self.sed_file("/password.*requisite.*pam_pwquality/ s/$/ retry=3/", "/etc/pam.d/password-auth") + self.sed_file("/password.*requisite.*pam_pwquality/ s/$/ retry=3/", + path="/etc/pam.d/common-password-pc" if "suse" in m.image else "/etc/pam.d/password-auth") m.execute("chage -d 0 admin") m.start_cockpit() From a934db1f650156902c8ce0a93754ba1ec2131a38 Mon Sep 17 00:00:00 2001 From: Luna D Dragon Date: Thu, 19 Feb 2026 11:30:04 +0530 Subject: [PATCH 4/4] test: use port 51234 over 5000 since 5000 is now used for mrt --- test/verify/check-networkmanager-firewall | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/verify/check-networkmanager-firewall b/test/verify/check-networkmanager-firewall index 736633a0ef0a..06dd9d347245 100755 --- a/test/verify/check-networkmanager-firewall +++ b/test/verify/check-networkmanager-firewall @@ -392,10 +392,10 @@ class TestFirewall(netlib.NetworkCase): set_field("#tcp-ports", "", "") set_field("#tcp-ports", "80,7", "custom--http-echo") set_field("#udp-ports", "123", "custom--http-echo-ntp") - set_field("#udp-ports", "123, 50000", "custom--http-echo-ntp-50000") - set_field("#tcp-ports", "", "custom--ntp-50000") - set_field("#tcp-ports", "https", "custom--https-ntp-50000") - save("custom--https-ntp-50000", "443", "123, 50000") + set_field("#udp-ports", "123, 51234", "custom--http-echo-ntp-51234") + set_field("#tcp-ports", "", "custom--ntp-51234") + set_field("#tcp-ports", "https", "custom--https-ntp-51234") + save("custom--https-ntp-51234", "443", "123, 51234") open_dialog() set_field("#tcp-ports", "80-82", "custom--80-82")