| 1 |
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv) |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2013 Red Hat, Inc. |
| 5 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 |
|
| 7 |
|
| 8 |
import re |
| 9 |
import time |
| 10 |
|
| 11 |
import packagelib |
| 12 |
import submanlib |
| 13 |
import testlib |
| 14 |
|
| 15 |
os_release = """ |
| 16 |
NAME="Foobar Adventure Linux Server" |
| 17 |
VERSION="2.0 (Day of Doom)" |
| 18 |
ID="foobar" |
| 19 |
VERSION_ID="2.0" |
| 20 |
PRETTY_NAME="Foobar Adventure Linux Server 2.0 (Day of Doom)" |
| 21 |
""" |
| 22 |
|
| 23 |
lscpu = """#!/bin/sh |
| 24 |
echo 'CPU(s): 8' |
| 25 |
echo 'On-line CPU(s) list: 0-7' |
| 26 |
echo 'Thread(s) per core: {0}' |
| 27 |
echo 'Core(s) per socket: 4' |
| 28 |
echo 'Socket(s): 1' |
| 29 |
""" |
| 30 |
|
| 31 |
# Helper for MB size when handling raw bytes. |
| 32 |
MB = 1024**2 |
| 33 |
|
| 34 |
|
| 35 |
def ssh_reconnect(machine, timeout_sec=120): |
| 36 |
start_time = time.time() |
| 37 |
error = None |
| 38 |
while (time.time() - start_time) < timeout_sec: |
| 39 |
try: |
| 40 |
machine.execute("true", quiet=True) |
| 41 |
return |
| 42 |
except Exception as e: |
| 43 |
error = e |
| 44 |
time.sleep(0.5) |
| 45 |
|
| 46 |
raise error |
| 47 |
|
| 48 |
|
| 49 |
class TestSystemInfo(testlib.MachineCase): |
| 50 |
def setUp(self): |
| 51 |
super().setUp() |
| 52 |
|
| 53 |
# Most OSes don't set nosmt by default, but there are some exceptions |
| 54 |
self.expect_smt_default = self.machine.image in ["fedora-coreos"] |
| 55 |
|
| 56 |
# Switching into and out of FIPS mode is not supported anymore in newer OSes. |
| 57 |
self.supportsFIPS = self.machine.image.startswith(("rhel-8", "rhel-9", "centos-9")) |
| 58 |
|
| 59 |
@testlib.skipImage("TODO: fix for OpenSUSE", "opensuse-tumbleweed") |
| 60 |
def testBasic(self): |
| 61 |
m = self.machine |
| 62 |
b = self.browser |
| 63 |
|
| 64 |
# /etc/os-release might be a symlink and file watching doesn't |
| 65 |
# follow symlinks, so we remove it and then create a regular |
| 66 |
# file. |
| 67 |
# |
| 68 |
# In addition hostnamed does not expect os-release to change so |
| 69 |
# we force a restart. Usually any such changes to os-release are |
| 70 |
# expected to happen during reboot, or picked up after a reboot. |
| 71 |
# |
| 72 |
# subscription-manager also screws with os-release so set it |
| 73 |
# to immutable |
| 74 |
# |
| 75 |
m.execute("rm /etc/os-release") |
| 76 |
m.write("/etc/os-release", os_release) |
| 77 |
m.execute("chattr +i /etc/os-release; (systemctl restart systemd-hostnamed || systemctl restart hostnamed)") |
| 78 |
|
| 79 |
# set static machine ID, as they have different lengths which disturbs the pixel test |
| 80 |
m.execute("mv /etc/machine-id /etc/machine-id.orig") |
| 81 |
m.write("/etc/machine-id", "123456789abcdef123456789abcdef00") |
| 82 |
# avoid "Last logged in" health card message, it breaks pixel tests and is too unpredictable |
| 83 |
m.execute("rm -f /var/log/lastlog /var/lib/lastlog/lastlog2.db /var/lib/wtmpdb/wtmp.db") |
| 84 |
|
| 85 |
self.login_and_go("/system") |
| 86 |
|
| 87 |
b.wait_visible('#system_information_os_text') |
| 88 |
|
| 89 |
# Health card can contain only one item - it normally is "Loading available updates fail" |
| 90 |
# But sometimes it also contains information about failed services which breaks mobile pixel tests |
| 91 |
m.execute("systemctl reset-failed") |
| 92 |
b.wait_not_present("#page_status_notification_system_services") |
| 93 |
|
| 94 |
# ensure general page/card layout without the changing specifics |
| 95 |
# need to wait until CPU usage settles down, to avoid a layout-shifting error/warning icon |
| 96 |
b.wait_not_present("#system-usage-cpu-progress + td .pf-v6-c-progress__status-icon") |
| 97 |
testlib.wait(lambda: b.get_pf_progress_value("#system-usage-cpu-progress + td") < 30) |
| 98 |
if b.pixels_label: |
| 99 |
# Wait for tuned text to appear, even thought we ignore it we need to button to have some text. |
| 100 |
recommended_profile = m.execute("tuned-adm recommend").strip() |
| 101 |
b.wait_text("#tuned-status-button", recommended_profile) |
| 102 |
# Wait for there to be no warning icons in the usage. |
| 103 |
b.wait_not_present('#system-usage .pf-v6-c-progress__status-icon') |
| 104 |
b.assert_pixels("#overview", "overview", ignore=[ |
| 105 |
".system-health .pf-v6-c-card__body", |
| 106 |
"#system_uptime", |
| 107 |
# #system_information_systime_button is not enough, need to grab the icon as well |
| 108 |
"td[data-label='system-time']", |
| 109 |
# CPU/memory metrics |
| 110 |
"#system-usage-cpu-progress + td", |
| 111 |
"#system-usage-memory-progress + td", |
| 112 |
"#tuned-status-button", |
| 113 |
]) |
| 114 |
|
| 115 |
m.execute("mv /etc/machine-id.orig /etc/machine-id") |
| 116 |
|
| 117 |
# Generate a new rsa key and change the config |
| 118 |
m.execute("ssh-keygen -f /etc/ssh/weirdname -t rsa -N ''") |
| 119 |
m.execute("chmod 600 /etc/ssh/weirdname") |
| 120 |
m.execute("restorecon /etc/ssh/weirdname || true") |
| 121 |
|
| 122 |
new_default = m.execute("ssh-keygen -l -f /etc/ssh/weirdname -E md5 | cut -d' ' -f2 | tr -d '\n'") |
| 123 |
new_alt = m.execute("ssh-keygen -l -f /etc/ssh/weirdname -E sha256 | cut -d' ' -f2 | tr -d '\n'") |
| 124 |
old_default = m.execute("ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key -E md5 | cut -d' ' -f2 | tr -d '\n'") |
| 125 |
old_alt = m.execute("ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key -E sha256 | cut -d' ' -f2 | tr -d '\n'") |
| 126 |
|
| 127 |
b.click("#system-ssh-keys-link") |
| 128 |
b.wait_in_text("#system_information_ssh_keys .pf-v6-c-list", "ED25519") |
| 129 |
b.wait_in_text("#system_information_ssh_keys .pf-v6-c-list", "RSA") |
| 130 |
b.wait_in_text("#system_information_ssh_keys .pf-v6-c-list", "ECDSA") |
| 131 |
b.wait_not_in_text("#system_information_ssh_keys .pf-v6-c-list", new_default) |
| 132 |
b.wait_in_text("#system_information_ssh_keys .pf-v6-c-list", old_default) |
| 133 |
b.wait_not_in_text("#system_information_ssh_keys .pf-v6-c-list", new_alt) |
| 134 |
b.wait_in_text("#system_information_ssh_keys .pf-v6-c-list", old_alt) |
| 135 |
|
| 136 |
b.click("#system_information_ssh_keys button:contains('Close')") |
| 137 |
b.wait_not_present("#system_information_ssh_keys") |
| 138 |
|
| 139 |
# Change ssh config and restart |
| 140 |
self.sed_file(r"s,.*HostKey *,#,; $ a HostKey /etc/ssh/weirdname", "/etc/ssh/sshd_config", |
| 141 |
self.restart_sshd) |
| 142 |
ssh_reconnect(m) |
| 143 |
|
| 144 |
b.click("#system-ssh-keys-link") |
| 145 |
b.wait_visible("#system_information_ssh_keys") |
| 146 |
b.wait_not_in_text("#system_information_ssh_keys .pf-v6-c-list", "ED25519") |
| 147 |
b.wait_in_text("#system_information_ssh_keys .pf-v6-c-list", "RSA") |
| 148 |
b.wait_not_in_text("#system_information_ssh_keys .pf-v6-c-list", "ECDSA") |
| 149 |
b.wait_in_text("#system_information_ssh_keys .pf-v6-c-list", new_default) |
| 150 |
b.wait_not_in_text("#system_information_ssh_keys .pf-v6-c-list", old_default) |
| 151 |
b.wait_not_in_text("#system_information_ssh_keys .pf-v6-c-list", old_alt) |
| 152 |
b.wait_in_text("#system_information_ssh_keys .pf-v6-c-list", new_alt) |
| 153 |
|
| 154 |
b.wait_in_text('#system_information_os_text', |
| 155 |
"Foobar Adventure Linux Server 2.0 (Day of Doom)") |
| 156 |
|
| 157 |
b.click("#system_information_ssh_keys button:contains('Close')") |
| 158 |
b.wait_not_present("#system_information_ssh_keys") |
| 159 |
|
| 160 |
m.execute("hostnamectl set-hostname --static --pretty 'Adventure Box'") |
| 161 |
b.wait_in_text('#system_information_hostname_text', "Adventure Box") |
| 162 |
|
| 163 |
b.click('#system_information_hostname_button') |
| 164 |
b.wait_visible("#system_information_change_hostname") |
| 165 |
b.wait_val("#sich-pretty-hostname", "Adventure Box") |
| 166 |
# Test setting the pretty hostname, changes the normal hostname |
| 167 |
b.set_input_text("#sich-pretty-hostname", "Adventure Time") |
| 168 |
b.wait_val("#sich-hostname", "adventure-time") |
| 169 |
# Changing the hostname should validate |
| 170 |
b.set_input_text("#sich-hostname", 65 * "x") |
| 171 |
b.wait_in_text("#system_information_change_hostname .pf-v6-c-helper-text__item-text", "64 characters or less") |
| 172 |
b.set_input_text("#sich-hostname", "host1.cockpit.lan$") |
| 173 |
b.wait_in_text("#system_information_change_hostname .pf-v6-c-helper-text__item-text", "Real host name can only contain") |
| 174 |
b.set_input_text("#sich-hostname", "host1.cockpit.lan") |
| 175 |
b.click("#system_information_change_hostname button:contains('Change')") |
| 176 |
b.wait_not_present("#system_information_change_hostname") |
| 177 |
|
| 178 |
b.wait_in_text('#system_information_hostname_text', "Adventure Time (host1.cockpit.lan)") |
| 179 |
self.assertEqual(m.execute("hostname").strip(), "host1.cockpit.lan") |
| 180 |
|
| 181 |
m.execute("hostnamectl set-hostname ''") |
| 182 |
m.execute("hostnamectl set-hostname --transient 'mydhcpname'") |
| 183 |
b.wait_in_text('#system_information_hostname_text', 'mydhcpname') |
| 184 |
|
| 185 |
b.logout() |
| 186 |
m.execute("chattr -i /etc/os-release; rm /etc/os-release") |
| 187 |
m.execute("rm /usr/lib/os-release || true") |
| 188 |
|
| 189 |
self.login_and_go("/system") |
| 190 |
mid = m.execute("cat /etc/machine-id") |
| 191 |
b.wait_text('#system_machine_id', mid) |
| 192 |
|
| 193 |
self.allow_journal_messages("error loading contents of os-release: .*", # C bridge |
| 194 |
".* Neither /etc/os-release nor /usr/lib/os-release exists", # py bridge |
| 195 |
"sudo: unable to resolve host host1.cockpit.lan: .*") |
| 196 |
|
| 197 |
@testlib.nondestructive |
| 198 |
def testUptime(self): |
| 199 |
m = self.machine |
| 200 |
b = self.browser |
| 201 |
|
| 202 |
self.login_and_go("/system") |
| 203 |
b.wait_text_not("#system_uptime", "") |
| 204 |
# replace it with a known value, it should automatically update every minute |
| 205 |
m.write("/tmp/fake_uptime", "2000.12 12345.30\n") |
| 206 |
m.execute("mount -o bind /tmp/fake_uptime /proc/uptime") |
| 207 |
self.addCleanup(m.execute, "umount /proc/uptime") |
| 208 |
with b.wait_timeout(70): |
| 209 |
b.wait_text("#system_uptime", "33 minutes ago") |
| 210 |
# 4 months and a bit, timeformat rounds quite aggressively; also, test a slightly different format |
| 211 |
m.write("/tmp/fake_uptime", "10370000 12345.30\n") |
| 212 |
with b.wait_timeout(70): |
| 213 |
b.wait_text("#system_uptime", "4 months ago") |
| 214 |
|
| 215 |
@testlib.nondestructive |
| 216 |
@testlib.skipImage("TODO: fix for OpenSUSE", "opensuse-tumbleweed") |
| 217 |
def testMotd(self): |
| 218 |
m = self.machine |
| 219 |
b = self.browser |
| 220 |
|
| 221 |
self.restore_file("/etc/motd") |
| 222 |
# run this test with a tight umask to check preserving file permissions |
| 223 |
self.sed_file(r"/^UMASK/ s/0../077/", "/etc/login.defs") |
| 224 |
m.execute("rm -f /etc/motd") |
| 225 |
|
| 226 |
self.login_and_go("/system") |
| 227 |
b.wait_not_present('#motd-box') |
| 228 |
|
| 229 |
m.execute(r"printf '\n \n Hello\n World\n\n' >/etc/motd; chmod 644 /etc/motd") |
| 230 |
b.wait_visible('#motd-box') |
| 231 |
# strips empty lines, but not leading spaces |
| 232 |
b.wait_text('#motd', " Hello\n World") |
| 233 |
|
| 234 |
# For some reason, switching to RTL takes a long time |
| 235 |
# here. Let's increase the delay. |
| 236 |
b.assert_pixels("#motd-box", "motd", wait_delay=2.0) |
| 237 |
|
| 238 |
b.click('#motd-box button:not(#motd-box-edit)') |
| 239 |
b.wait_not_present('#motd-box') |
| 240 |
|
| 241 |
# motd should stay dismissed after a reload |
| 242 |
b.reload() |
| 243 |
b.enter_page("/system") |
| 244 |
b.wait_not_present('#motd-box') |
| 245 |
|
| 246 |
m.execute("echo Hello again >/etc/motd") |
| 247 |
b.wait_visible('#motd-box') |
| 248 |
b.wait_text('#motd', "Hello again") |
| 249 |
|
| 250 |
# Cancel button |
| 251 |
b.click("#motd-box-edit") |
| 252 |
b.click("#motd-box-edit-modal button.pf-m-link") |
| 253 |
b.wait_not_present("motd-box-edit-modal") |
| 254 |
|
| 255 |
b.click("#motd-box-edit") |
| 256 |
b.set_input_text("#motd-box-edit-modal textarea", "Hello cockpit team") |
| 257 |
b.click("#motd-box-edit-modal button.pf-m-primary") |
| 258 |
b.wait_not_present("motd-box-edit-modal") |
| 259 |
b.wait_text('#motd', "Hello cockpit team") |
| 260 |
self.assertEqual("Hello cockpit team", self.machine.execute("cat /etc/motd").rstrip()) |
| 261 |
|
| 262 |
@testlib.nondestructive |
| 263 |
def testHardwareInfo(self): |
| 264 |
b = self.browser |
| 265 |
m = self.machine |
| 266 |
|
| 267 |
self.login_and_go("/system") |
| 268 |
b.wait_in_text('#system_information_hardware_text', "QEMU") |
| 269 |
|
| 270 |
hardware_page_link = '.system-information a' |
| 271 |
b.click(hardware_page_link) |
| 272 |
b.enter_page("/system/hwinfo") |
| 273 |
|
| 274 |
# system info |
| 275 |
b.wait_in_text('#hwinfo-system-info-list', "CPU") |
| 276 |
# QEMU VM type |
| 277 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(1) .pf-v6-c-description-list__group:nth-of-type(1) dd', "Other") |
| 278 |
# Name |
| 279 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(1) .pf-v6-c-description-list__group:nth-of-type(2) dd', "Standard PC") |
| 280 |
# BIOS |
| 281 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v6-c-description-list__group:nth-of-type(1) dd', "SeaBIOS") |
| 282 |
# BIOS date gets parsed |
| 283 |
parsed_bios_date = m.execute("date --date $(cat /sys/class/dmi/id/bios_date) '+%B %-d, %Y'").strip() |
| 284 |
b.wait_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v6-c-description-list__group:nth-of-type(3) dd', parsed_bios_date) |
| 285 |
|
| 286 |
pci_selector = '#hwinfo #pci-listing' |
| 287 |
heading_selector = ' .pf-v6-c-card__title' |
| 288 |
# PCI |
| 289 |
b.wait_in_text(pci_selector + heading_selector, "PCI") |
| 290 |
|
| 291 |
b.wait_in_text(pci_selector + ' tbody:first-of-type td[data-label=Slot]', "0000:00:00.0") |
| 292 |
|
| 293 |
# sorted by device class by default; this makes some assumptions about QEMU devices |
| 294 |
b.wait_in_text(pci_selector + ' tbody:first-of-type td[data-label=Class]', "Bridge") |
| 295 |
b.wait_in_text(pci_selector + ' tbody:last-of-type td[data-label=Class]', "Unclassified") |
| 296 |
|
| 297 |
# sort by model |
| 298 |
b.click(pci_selector + ' thead th:nth-child(2) button') |
| 299 |
b.wait_in_text(pci_selector + ' tbody:first-of-type td[data-label=Model]', "440") |
| 300 |
b.wait_in_text(pci_selector + ' tbody:last-of-type td[data-label=Model]', "Virtio SCSI") |
| 301 |
b.wait_not_in_text(pci_selector + ' tbody:last-of-type td[data-label=Model]', "Unclassified") |
| 302 |
|
| 303 |
# go back to system page |
| 304 |
b.click('.pf-v6-c-breadcrumb li:first-of-type') |
| 305 |
|
| 306 |
b.enter_page("/system") |
| 307 |
|
| 308 |
# now pretend this is a system without DMI |
| 309 |
b.logout() |
| 310 |
m.execute("mount -t tmpfs none /sys/class/dmi/id") |
| 311 |
# check if it's mounted as the memory tests umount it. |
| 312 |
self.addCleanup(m.execute, "! mountpoint -q /sys/class/dmi/id || umount /sys/class/dmi/id") |
| 313 |
self.login_and_go("/system") |
| 314 |
# asset tag should be hidden |
| 315 |
b.wait_not_present('#system_information_asset_tag_text') |
| 316 |
|
| 317 |
# Hardware should be hidden |
| 318 |
b.wait_not_present('#system_information_hardware_text') |
| 319 |
b.click(hardware_page_link) |
| 320 |
b.enter_page("/system/hwinfo") |
| 321 |
|
| 322 |
# CPU should still be shown, but not the DMI fields |
| 323 |
b.wait_in_text('#hwinfo-system-info-list', "CPU") |
| 324 |
self.assertNotIn('Type', b.text('#hwinfo-system-info-list')) |
| 325 |
self.assertNotIn('BIOS', b.text('#hwinfo-system-info-list')) |
| 326 |
|
| 327 |
# PCI should be shown |
| 328 |
b.wait_in_text(pci_selector + heading_selector, "PCI") |
| 329 |
b.wait_in_text(pci_selector + ' tbody:first-of-type td[data-label=Slot]', "0000:00:00.0") |
| 330 |
|
| 331 |
# Check also variants when only some fields are present |
| 332 |
m.write("/sys/class/dmi/id/chassis_type", "10") |
| 333 |
b.go("/system") |
| 334 |
b.enter_page('/system') |
| 335 |
b.wait_not_present('#system_information_hardware_text') |
| 336 |
|
| 337 |
m.write("/sys/class/dmi/id/board_vendor", "VENDOR") |
| 338 |
m.write("/sys/class/dmi/id/board_name", "NAME") |
| 339 |
b.reload() |
| 340 |
b.enter_page('/system') |
| 341 |
b.wait_in_text('#system_information_hardware_text', "VENDOR NAME") |
| 342 |
b.click(hardware_page_link) |
| 343 |
b.enter_page("/system/hwinfo") |
| 344 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(1) .pf-v6-c-description-list__group:nth-of-type(2) dd', "NAME") |
| 345 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(1) .pf-v6-c-description-list__group:nth-of-type(3) dd', "VENDOR") |
| 346 |
|
| 347 |
# Clean up after lazy OEMs, falls back to board vendor/name |
| 348 |
m.write("/sys/class/dmi/id/sys_vendor", "To Be Filled By O.E.M.") |
| 349 |
m.write("/sys/class/dmi/id/product_name", "To Be Filled By O.E.M.") |
| 350 |
m.write("/sys/class/dmi/id/product_serial", "PL1234") |
| 351 |
m.write("/sys/class/dmi/id/board_vendor", "brdven") |
| 352 |
m.write("/sys/class/dmi/id/board_name", "brdnam") |
| 353 |
b.reload() |
| 354 |
b.enter_page("/system/hwinfo") |
| 355 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(1) .pf-v6-c-description-list__group:nth-of-type(2) dd', "brdnam") |
| 356 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(1) .pf-v6-c-description-list__group:nth-of-type(3) dd', "brdven") |
| 357 |
|
| 358 |
b.go("/system") |
| 359 |
b.enter_page('/system') |
| 360 |
b.wait_in_text('#system_information_hardware_text', "brdven brdnam") |
| 361 |
if m.execute("uname -m").strip() == "x86_64": |
| 362 |
b.wait_in_text('#system_information_asset_tag_text', "PL1234") |
| 363 |
else: |
| 364 |
b.wait_not_present('#system_information_asset_tag_text') |
| 365 |
b.click(hardware_page_link) |
| 366 |
|
| 367 |
# /proc/cpuinfo on x86; very incomplete, just what pkg/lib/machine-info.js looks at |
| 368 |
m.write("/tmp/cpuinfo", """processor\t: 0 |
| 369 |
vendor_id\t: GenuineIntel |
| 370 |
model\t\t: 42 |
| 371 |
model name\t: Professor NumberCrunch |
| 372 |
|
| 373 |
processor\t: 1 |
| 374 |
vendor_id\t: GenuineIntel |
| 375 |
model\t\t: 42 |
| 376 |
model name\t: Professor NumberCrunch |
| 377 |
""") |
| 378 |
m.execute("mount -o bind /tmp/cpuinfo /proc/cpuinfo") |
| 379 |
self.addCleanup(m.execute, "umount /proc/cpuinfo") |
| 380 |
|
| 381 |
b.reload() |
| 382 |
b.enter_page('/system/hwinfo') |
| 383 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v6-c-description-list__group:nth-of-type(1) dd', "2x Professor NumberCrunch") |
| 384 |
|
| 385 |
# /proc/cpuinfo on PowerPC; complete info |
| 386 |
m.write("/tmp/cpuinfo", """processor\t: 0 |
| 387 |
cpu\t\t: POWER9 (architected), altivec supported |
| 388 |
clock\t\t: 3000.000000MHz |
| 389 |
revision\t: 2.3 (pvr 004e 1203) |
| 390 |
|
| 391 |
processor\t: 1 |
| 392 |
cpu\t\t: POWER9 (architected), altivec supported |
| 393 |
clock\t\t: 3000.000000MHz |
| 394 |
revision\t: 2.3 (pvr 004e 1203) |
| 395 |
""") |
| 396 |
|
| 397 |
b.reload() |
| 398 |
b.enter_page('/system/hwinfo') |
| 399 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v6-c-description-list__group:nth-of-type(1) dd', "2x POWER9 (architected), altivec supported") |
| 400 |
|
| 401 |
# correct CPU count on overview |
| 402 |
b.go("/system") |
| 403 |
b.enter_page("/system") |
| 404 |
b.wait_in_text("#system-usage-cpu-progress + td", "of 2 CPUs") |
| 405 |
|
| 406 |
# /proc/cpuinfo on s390x (reduced) |
| 407 |
m.write("/tmp/cpuinfo", """vendor_id : IBM/S390 |
| 408 |
# processors : 2 |
| 409 |
bogomips per cpu: 3241.00 |
| 410 |
max thread id : 0 |
| 411 |
features : esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te vx vxd vxe gs vxe2 vxp sort dflt sie |
| 412 |
processor 0: version = FF, identification = 2EB428, machine = 8561 |
| 413 |
processor 1: version = FF, identification = 2EB428, machine = 8561 |
| 414 |
|
| 415 |
cpu number : 0 |
| 416 |
cpu cores : 1 |
| 417 |
version : FF |
| 418 |
identification : 2EB428 |
| 419 |
machine : 8561 |
| 420 |
|
| 421 |
cpu number : 1 |
| 422 |
cpu cores : 1 |
| 423 |
version : FF |
| 424 |
identification : 2EB428 |
| 425 |
machine : 8561 |
| 426 |
""") |
| 427 |
|
| 428 |
b.reload() |
| 429 |
b.enter_page("/system") |
| 430 |
b.wait_in_text("#system-usage-cpu-progress + td", "of 2 CPUs") |
| 431 |
|
| 432 |
b.go('/system/hwinfo') |
| 433 |
b.enter_page('/system/hwinfo') |
| 434 |
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v6-c-description-list__group:nth-of-type(1) dd', "2x IBM/S390") |
| 435 |
|
| 436 |
# umount mocked /sys/class/dmi/id |
| 437 |
m.execute("umount /sys/class/dmi/id") |
| 438 |
m.execute("udevadm trigger --verbose /sys/devices/virtual/dmi/id") |
| 439 |
b.reload() |
| 440 |
b.enter_page('/system/hwinfo') |
| 441 |
|
| 442 |
# Memory details should be shown from our mocked DMI information from systemd's test files. |
| 443 |
b.wait_in_text('#hwinfo #memory-listing' + heading_selector, "Memory") |
| 444 |
b.wait_in_text('#hwinfo #memory-listing table', "DIMM") |
| 445 |
b.wait_in_text('#hwinfo #memory-listing table', "RAM") |
| 446 |
|
| 447 |
tmp_dmi_tables = "/tmp/dmi_tables" |
| 448 |
m.execute(f"mkdir {tmp_dmi_tables}") |
| 449 |
self.addCleanup(m.execute, f"rm -rf {tmp_dmi_tables}") |
| 450 |
m.upload(["verify/files/dmi/smbios_entry_point", "verify/files/dmi/DMI"], tmp_dmi_tables) |
| 451 |
m.execute(f"mount -o bind {tmp_dmi_tables} /sys/firmware/dmi/tables") |
| 452 |
self.addCleanup(m.execute, "umount /sys/firmware/dmi/tables") |
| 453 |
m.execute("udevadm trigger --verbose /sys/devices/virtual/dmi/id") |
| 454 |
|
| 455 |
b.reload() |
| 456 |
b.enter_page('/system/hwinfo') |
| 457 |
distro_without_systemd_memory_dmi = m.image.startswith('rhel-8-') |
| 458 |
|
| 459 |
# Test more specific memory data with a fake dmidecode |
| 460 |
b.wait_in_text('#memory-listing tbody:nth-of-type(1) td[data-label=ID]', "BANK 0: ChannelA-DIMM0") |
| 461 |
b.wait_in_text('#memory-listing tbody:nth-of-type(1) td[data-label=Type]', "DDR4") |
| 462 |
if distro_without_systemd_memory_dmi: |
| 463 |
b.wait_in_text('#memory-listing tbody:nth-of-type(1) td[data-label=Size]', "4 GB") |
| 464 |
else: |
| 465 |
b.wait_in_text('#memory-listing tbody:nth-of-type(1) td[data-label=Size]', "4 GiB") |
| 466 |
b.wait_in_text('#memory-listing tbody:nth-of-type(1) td[data-label=State]', "Present") |
| 467 |
b.wait_text('#memory-listing tbody:nth-of-type(1) td[data-label="Memory technology"]', "Unknown") |
| 468 |
b.wait_text('#memory-listing tbody:nth-of-type(1) td[data-label=Rank]', "Single rank") |
| 469 |
b.wait_in_text('#memory-listing tbody:nth-of-type(1) td[data-label=Speed]', "2400 MT/s") |
| 470 |
|
| 471 |
b.wait_in_text('#memory-listing tbody:nth-of-type(2) td[data-label=ID]', "BANK 2: ChannelB-DIMM0") |
| 472 |
b.wait_in_text('#memory-listing tbody:nth-of-type(2) td[data-label=Type]', "DDR4") |
| 473 |
if distro_without_systemd_memory_dmi: |
| 474 |
b.wait_in_text('#memory-listing tbody:nth-of-type(1) td[data-label=Size]', "4 GB") |
| 475 |
else: |
| 476 |
b.wait_in_text('#memory-listing tbody:nth-of-type(1) td[data-label=Size]', "4 GiB") |
| 477 |
b.wait_in_text('#memory-listing tbody:nth-of-type(2) td[data-label=State]', "Present") |
| 478 |
b.wait_text('#memory-listing tbody:nth-of-type(2) td[data-label="Memory technology"]', "Unknown") |
| 479 |
b.wait_text('#memory-listing tbody:nth-of-type(2) td[data-label=Rank]', "Single rank") |
| 480 |
b.wait_in_text('#memory-listing tbody:nth-of-type(2) td[data-label=Speed]', "2400 MT/s") |
| 481 |
|
| 482 |
@testlib.nondestructive |
| 483 |
def testCPUSecurityMitigationsDetect(self): |
| 484 |
b = self.browser |
| 485 |
m = self.machine |
| 486 |
|
| 487 |
self.restore_dir("/usr/local/bin") |
| 488 |
m.start_cockpit() |
| 489 |
|
| 490 |
def spoof_threads(threads_per_core, expect_link_present, expect_smt_state=None, cmdline=None): |
| 491 |
m.write('/usr/local/bin/lscpu', lscpu.format(threads_per_core)) |
| 492 |
m.execute('chmod +x /usr/local/bin/lscpu') |
| 493 |
if cmdline: |
| 494 |
m.write('/run/cmdline', cmdline) |
| 495 |
m.execute('if selinuxenabled 2>/dev/null; then chcon --reference /proc/cmdline /run/cmdline; fi') |
| 496 |
m.execute('mount --bind /run/cmdline /proc/cmdline; rm /run/cmdline') |
| 497 |
|
| 498 |
try: |
| 499 |
b.login_and_go('/system/hwinfo') |
| 500 |
|
| 501 |
if not expect_link_present: |
| 502 |
b.wait_in_text('#hwinfo-system-info-list', "CPU") |
| 503 |
b.wait_not_in_text('#hwinfo-system-info-list', "CPU security") |
| 504 |
else: |
| 505 |
b.click('#hwinfo button:contains("Mitigations")') |
| 506 |
|
| 507 |
if expect_smt_state is not None: |
| 508 |
b.wait_in_text('#cpu-mitigations-dialog .nosmt-heading', 'nosmt') |
| 509 |
b.wait_visible('#cpu-mitigations-dialog #nosmt-switch input' + |
| 510 |
(":checked" if expect_smt_state else ":not(:checked)")) |
| 511 |
|
| 512 |
b.logout() |
| 513 |
finally: |
| 514 |
if cmdline: |
| 515 |
m.execute('while ! umount /proc/cmdline; do sleep 1; done') |
| 516 |
|
| 517 |
spoof_threads(1, expect_link_present=False) |
| 518 |
spoof_threads(2, expect_link_present=True, expect_smt_state=True, cmdline='param1 param2 nosmt param3=value3') |
| 519 |
spoof_threads(2, expect_link_present=True, expect_smt_state=True, cmdline='param1 param2 nosmt=force param3=value3') |
| 520 |
spoof_threads(2, expect_link_present=True, expect_smt_state=True, cmdline='param1 mitigations=auto,nosmt param3=value3') |
| 521 |
spoof_threads(2, expect_link_present=True, expect_smt_state=True, cmdline='param1 mitigations=nosmt,something param3=value3') |
| 522 |
spoof_threads(2, expect_link_present=True, expect_smt_state=False, cmdline='param1 mitigations=something param3=value3') |
| 523 |
spoof_threads(2, expect_link_present=False, cmdline='param1 nosmt=someunknown param3=value3') |
| 524 |
spoof_threads(2, expect_link_present=True, expect_smt_state=self.expect_smt_default, cmdline=None) |
| 525 |
|
| 526 |
@testlib.skipImage("TODO: add Arch Linux grub entry support", "arch") |
| 527 |
@testlib.timeout(1200) |
| 528 |
def testCPUSecurityMitigationsEnable(self): |
| 529 |
b = self.browser |
| 530 |
m = self.machine |
| 531 |
|
| 532 |
# spoof SMT |
| 533 |
m.write('/usr/local/bin/lscpu', lscpu.format(2)) |
| 534 |
m.execute('chmod +x /usr/local/bin/lscpu') |
| 535 |
|
| 536 |
# Switch nosmt option |
| 537 |
self.login_and_go('/system/hwinfo') |
| 538 |
b.click('#hwinfo button:contains("Mitigations")') |
| 539 |
b.click('#cpu-mitigations-dialog #nosmt-switch input') |
| 540 |
b.wait_visible('#cpu-mitigations-dialog #nosmt-switch input' + |
| 541 |
(':not(:checked)' if self.expect_smt_default else ':checked')) |
| 542 |
b.click('#cpu-mitigations-dialog Button:contains("Save and reboot")') |
| 543 |
|
| 544 |
self.wait_reboot() |
| 545 |
if self.expect_smt_default: |
| 546 |
self.assertNotIn('nosmt', m.execute('cat /proc/cmdline')) |
| 547 |
else: |
| 548 |
self.assertIn('nosmt', m.execute('cat /proc/cmdline')) |
| 549 |
|
| 550 |
# Ensure that future kernel upgrades also retain the option |
| 551 |
# - Debian: no BLS, options go into /etc/default/grub and grub.cfg |
| 552 |
# - BLS, options go directly into entries, or entries use $kernelopt (defined in grubenv) |
| 553 |
if not m.ostree_image: |
| 554 |
m.execute(r""" |
| 555 |
echo dummy > /boot/vmlinuz-42.0.0; mkdir -p /lib/modules/42.0.0/ |
| 556 |
if type update-grub >/dev/null 2>&1; then |
| 557 |
update-grub # Debian/Ubuntu |
| 558 |
grep -q 'linux.*/vmlinuz-42.0.0.*nosmt' /boot/grub*/grub.cfg |
| 559 |
elif type update-bootloader >/dev/null 2>&1; then |
| 560 |
update-bootloader # suse |
| 561 |
grep -q 'linux.*/vmlinuz-42.0.0.*nosmt' /boot/grub*/grub.cfg |
| 562 |
else |
| 563 |
cp -a /boot/grub2/grubenv /boot/grub2/grubenv.prev |
| 564 |
kernel-install add 42.0.0 /boot/vmlinuz-42.0.0 2>/dev/null |
| 565 |
grep -q '^options.*\bnosmt\b' /boot/loader/entries/*42.0.0*.conf || |
| 566 |
( grub2-editenv list | grep -q kernelopts.*nosmt && |
| 567 |
grep -q '^options.*$kernelopts' /boot/loader/entries/*42.0.0*.conf ) |
| 568 |
fi |
| 569 |
""") |
| 570 |
# clean up so that next reboot works |
| 571 |
m.execute(r""" |
| 572 |
rm /boot/vmlinuz-42.0.0 |
| 573 |
if type update-grub >/dev/null 2>&1; then |
| 574 |
update-grub # Debian/Ubuntu |
| 575 |
elif type update-bootloader >/dev/null 2>&1; then |
| 576 |
update-bootloader # suse |
| 577 |
else |
| 578 |
kernel-install remove 42.0.0 /boot/vmlinuz-42.0.0 |
| 579 |
# HACK: https://bugzilla.redhat.com/show_bug.cgi?id=2078359 and https://bugzilla.redhat.com/show_bug.cgi?id=2078379 |
| 580 |
mv /boot/grub2/grubenv.prev /boot/grub2/grubenv |
| 581 |
fi |
| 582 |
""") |
| 583 |
|
| 584 |
# Switch back nosmt option |
| 585 |
self.login_and_go('/system/hwinfo') |
| 586 |
b.click('#hwinfo button:contains("Mitigations")') |
| 587 |
b.wait_in_text('#cpu-mitigations-dialog .nosmt-heading', 'nosmt') |
| 588 |
b.wait_visible('#cpu-mitigations-dialog #nosmt-switch input' + |
| 589 |
(':not(:checked)' if self.expect_smt_default else ':checked')) |
| 590 |
b.click('#cpu-mitigations-dialog #nosmt-switch input') |
| 591 |
b.wait_visible('#cpu-mitigations-dialog #nosmt-switch input' + |
| 592 |
(':checked' if self.expect_smt_default else ':not(:checked)')) |
| 593 |
b.click('#cpu-mitigations-dialog Button:contains("Save and reboot")') |
| 594 |
self.wait_reboot() |
| 595 |
if self.expect_smt_default: |
| 596 |
self.assertIn('nosmt', m.execute('cat /proc/cmdline')) |
| 597 |
else: |
| 598 |
self.assertNotIn('nosmt', m.execute('cat /proc/cmdline')) |
| 599 |
|
| 600 |
# updates mitigations=nosmt when that is present |
| 601 |
m.upload(["../pkg/lib/kernelopt.sh"], "/tmp/") |
| 602 |
if self.expect_smt_default: |
| 603 |
m.execute("/tmp/kernelopt.sh remove nosmt") |
| 604 |
m.execute("/tmp/kernelopt.sh set mitigations=auto,nosmt") |
| 605 |
self.reboot() |
| 606 |
self.login_and_go('/system/hwinfo') |
| 607 |
b.click('#hwinfo button:contains("Mitigations")') |
| 608 |
b.wait_in_text('#cpu-mitigations-dialog .nosmt-heading', 'nosmt') |
| 609 |
b.wait_visible('#cpu-mitigations-dialog #nosmt-switch input:checked') |
| 610 |
b.click('#cpu-mitigations-dialog #nosmt-switch input') |
| 611 |
b.wait_visible('#cpu-mitigations-dialog #nosmt-switch input:not(:checked)') |
| 612 |
b.click('#cpu-mitigations-dialog Button:contains("Save and reboot")') |
| 613 |
self.wait_reboot() |
| 614 |
self.assertNotIn('nosmt', m.execute('cat /proc/cmdline')) |
| 615 |
self.assertIn('mitigations=auto', m.execute('cat /proc/cmdline')) |
| 616 |
|
| 617 |
# Behaviour for non-admins |
| 618 |
self.login_and_go('/system/hwinfo', superuser=False) |
| 619 |
b.wait_visible('#cpu_mitigations[disabled]') |
| 620 |
b.mouse('#tip-cpu-security', 'mouseenter') |
| 621 |
b.wait_text('.pf-v6-c-tooltip', 'The user admin is not permitted to change cpu security mitigations') |
| 622 |
b.mouse('#tip-cpu-security', 'mouseleave') |
| 623 |
b.wait_not_present("div.pf-v6-c-tooltip") |
| 624 |
|
| 625 |
# Behaviour if grub update tools are missing |
| 626 |
b.logout() |
| 627 |
m.execute('mv /etc/default/grub /etc/default/grub.bak || true') |
| 628 |
m.write('/tmp/grubby', '#!/bin/sh\necho 0') |
| 629 |
m.execute('[ ! -f /usr/sbin/grubby ] || mount --bind /tmp/grubby /usr/sbin/grubby') |
| 630 |
m.write('/tmp/update-bootloader', '#!/bin/sh\necho 0') |
| 631 |
m.execute('[ ! -f /usr/sbin/update-bootloader ] || mount --bind /tmp/update-bootloader /usr/sbin/update-bootloader') |
| 632 |
m.execute('systemctl stop rpm-ostreed.service || true; systemctl mask rpm-ostreed.service') |
| 633 |
self.login_and_go('/system/hwinfo') |
| 634 |
b.click('#hwinfo button:contains("Mitigations")') |
| 635 |
b.click('#cpu-mitigations-dialog #nosmt-switch input') |
| 636 |
b.wait_visible('#cpu-mitigations-dialog #nosmt-switch input:checked') |
| 637 |
b.click("#cpu-mitigations-dialog Button:contains('Save and reboot')") |
| 638 |
b.wait_in_text('#cpu-mitigations-dialog .pf-v6-c-alert__title', 'No supported grub update mechanism found') |
| 639 |
|
| 640 |
self.allow_journal_messages('Sourcing file `/etc/default/grub.*', |
| 641 |
'Generating grub configuration file.*', |
| 642 |
'Found linux image.*', |
| 643 |
'Found initrd image.*', |
| 644 |
'.*warning: setlocale: LC_ALL: cannot change locale.*', |
| 645 |
'done') |
| 646 |
|
| 647 |
@testlib.nondestructive |
| 648 |
def testOverview(self): |
| 649 |
m = self.machine |
| 650 |
b = self.browser |
| 651 |
|
| 652 |
# packagekit often eats a lot of CPU; silence it to not screw up the "system is idle" test |
| 653 |
m.execute("systemctl mask packagekit") |
| 654 |
self.addCleanup(m.execute, "systemctl unmask packagekit") |
| 655 |
|
| 656 |
def progressUsage(number): |
| 657 |
return b.get_pf_progress_value(f".system-usage tr:nth-child({number})") |
| 658 |
|
| 659 |
def progressUsageRaw(number): |
| 660 |
return b.get_raw_pf_progress_value(f".system-usage tr:nth-child({number})") |
| 661 |
|
| 662 |
def cpuUsage(raw: bool = False): |
| 663 |
if raw: |
| 664 |
return progressUsageRaw(1) |
| 665 |
else: |
| 666 |
return progressUsage(1) |
| 667 |
|
| 668 |
def memoryUsage(raw: bool = False): |
| 669 |
if raw: |
| 670 |
return progressUsageRaw(2) |
| 671 |
else: |
| 672 |
return progressUsage(2) |
| 673 |
|
| 674 |
self.login_and_go("/system") |
| 675 |
|
| 676 |
# CPU |
| 677 |
# first wait until system settles down |
| 678 |
testlib.wait(lambda: cpuUsage() < 20) |
| 679 |
m.spawn("for i in $(seq $(nproc)); do cat /dev/urandom > /dev/null & done; touch /tmp/cpu_hog", "cpu_hog.log") |
| 680 |
m.execute("while [ ! -e /tmp/cpu_hog ]; do sleep 1; done") |
| 681 |
testlib.wait(lambda: cpuUsage() > 75) |
| 682 |
m.execute("pkill -e -f [c]at.*urandom; rm -f /tmp/cpu_hog") |
| 683 |
# should go back to idle usage |
| 684 |
# HACK: work around pmie CPU usage https://bugzilla.redhat.com/show_bug.cgi?id=2140572 |
| 685 |
testlib.wait(lambda: cpuUsage() < 20, tries=200) |
| 686 |
|
| 687 |
# memory: our test machines should use a reasonable chunk of available memory; MiB or GiB |
| 688 |
b.wait_in_text(".system-usage tr:nth-child(2)", "iB") |
| 689 |
initial_usage = memoryUsage(raw=True) |
| 690 |
max_memory = int(b.attr(".system-usage tr:nth-child(2) .pf-v6-c-progress__bar", "aria-valuemax")) |
| 691 |
self.assertGreater(initial_usage, 10 * MB) |
| 692 |
self.assertLess(initial_usage, max_memory * 0.9) |
| 693 |
# allocate an extra 200 MB; this may cause other stuff to get unmapped, |
| 694 |
# thus not exact addition, but usage should go up |
| 695 |
# |
| 696 |
# The "true" after "sleep" is there to prevent bash from |
| 697 |
# replacing it's own process with the sleep (as a "tail call |
| 698 |
# optimization") and thereby dropping the memory blob too early. |
| 699 |
# |
| 700 |
mem_hog = m.spawn(""" |
| 701 |
awk 'BEGIN { x = sprintf("%200000000s",""); system("touch /tmp/hogged; sleep infinity") }' |
| 702 |
""", "mem_hog.log") |
| 703 |
try: |
| 704 |
m.execute("while [ ! -e /tmp/hogged ]; do sleep 1; done") |
| 705 |
# bars update every 5s |
| 706 |
time.sleep(8) |
| 707 |
testlib.wait(lambda: memoryUsage(raw=True) >= initial_usage + 10 * MB) |
| 708 |
hog_usage = memoryUsage() |
| 709 |
finally: |
| 710 |
m.execute("kill %d" % mem_hog) |
| 711 |
# Should go back to initial_usage, but it doesn't always, for example on fedora. |
| 712 |
# So let's be happy if the usage drops significantly |
| 713 |
try: |
| 714 |
testlib.wait(lambda: memoryUsage() <= hog_usage - 10) |
| 715 |
except testlib.Error: |
| 716 |
print(f"Memory before hogging: {initial_usage}, after hogging: {hog_usage}, now: {memoryUsage()}") |
| 717 |
raise |
| 718 |
|
| 719 |
self.assertGreater(memoryUsage(), 10) |
| 720 |
|
| 721 |
@testlib.nondestructive |
| 722 |
def testShutdownStatus(self): |
| 723 |
m = self.machine |
| 724 |
b = self.browser |
| 725 |
|
| 726 |
self.login_and_go("/system") |
| 727 |
b.wait_not_present("#system-health-shutdown-status") |
| 728 |
|
| 729 |
# Schedule a reboot |
| 730 |
m.execute("shutdown --reboot +10") |
| 731 |
self.addCleanup(m.execute, "shutdown -c") |
| 732 |
|
| 733 |
b.wait_in_text('#system-health-shutdown-status-text', "Scheduled reboot") |
| 734 |
|
| 735 |
# Check that reloading still shows the reboot text |
| 736 |
b.reload() |
| 737 |
b.enter_page("/system") |
| 738 |
b.wait_in_text('#system-health-shutdown-status-text', "Scheduled reboot") |
| 739 |
|
| 740 |
# Cancel |
| 741 |
b.click("#system-health-shutdown-status-cancel-btn") |
| 742 |
b.wait_not_present('#system-health-shutdown-status') |
| 743 |
|
| 744 |
# Schedule a poweroff |
| 745 |
m.execute("shutdown --poweroff +10") |
| 746 |
b.wait_in_text('#system-health-shutdown-status-text', "Scheduled poweroff") |
| 747 |
|
| 748 |
# Cancel |
| 749 |
b.click("#system-health-shutdown-status-cancel-btn") |
| 750 |
b.wait_not_present('#system-health-shutdown-status') |
| 751 |
dbus_call = 'busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager ScheduledShutdown' |
| 752 |
self.assertIn('(st) "" ', m.execute(dbus_call).strip()) |
| 753 |
|
| 754 |
@testlib.skipImage("crypto-policies not available", "debian-*", "ubuntu-*", "arch", "opensuse-tumbleweed") |
| 755 |
@testlib.skipOstree("crypto-policies not available") |
| 756 |
def testCryptoPolicies(self): |
| 757 |
m = self.machine |
| 758 |
b = self.browser |
| 759 |
|
| 760 |
def shown_profile_text(profile): |
| 761 |
return "Default" if profile == "DEFAULT" else profile |
| 762 |
|
| 763 |
def change_profile(profile, new_profile): |
| 764 |
b.click("#crypto-policy-button") |
| 765 |
b.wait_in_text(".pf-v6-c-menu__item.pf-m-selected", shown_profile_text(profile)) |
| 766 |
profile_button_name = shown_profile_text(new_profile) |
| 767 |
b.click(f"#crypto-policy-dialog .pf-v6-c-menu__list-item[data-value='{profile_button_name}'] button") |
| 768 |
b.click("#crypto-policy-save-reboot") |
| 769 |
# Initramfs re-generation takes a while |
| 770 |
self.wait_reboot(timeout_sec=600) |
| 771 |
m.start_cockpit() |
| 772 |
self.login_and_go("/system") |
| 773 |
b.wait_text("#crypto-policy-button", shown_profile_text(new_profile)) |
| 774 |
|
| 775 |
cmd = "update-crypto-policies" |
| 776 |
|
| 777 |
self.login_and_go("/system") |
| 778 |
|
| 779 |
profile = m.execute(cmd + " --show").strip() |
| 780 |
b.wait_text("#crypto-policy-button", shown_profile_text(profile)) |
| 781 |
|
| 782 |
# RHEL 8/10 have no SHA1 policy, so do not show it. |
| 783 |
b.click("#crypto-policy-button") |
| 784 |
func = b.wait_not_present if re.match(r'(centos|rhel)-(8|10).*', m.image) else b.wait_visible |
| 785 |
func(".pf-v6-c-menu__item-main .pf-v6-c-menu__item-text:contains('DEFAULT:SHA1')") |
| 786 |
b.click("#crypto-policy-dialog button:contains('Cancel')") |
| 787 |
b.wait_not_present("#crypto-policy-dialog") |
| 788 |
|
| 789 |
# Test if a new subpolicy can be set |
| 790 |
new_profile = "LEGACY:AD-SUPPORT" |
| 791 |
change_profile(profile, new_profile) |
| 792 |
|
| 793 |
profile = m.execute(cmd + " --show").strip() |
| 794 |
self.assertEqual(profile, new_profile) |
| 795 |
b.wait_text("#crypto-policy-button", shown_profile_text(profile)) |
| 796 |
|
| 797 |
# Select a custom policy (non-selectable option) |
| 798 |
profile = "EMPTY" |
| 799 |
m.execute(cmd + f" --set {profile}") |
| 800 |
b.enter_page("/system") |
| 801 |
b.wait_text("#crypto-policy-button", shown_profile_text(profile)) |
| 802 |
b.click("#crypto-policy-button") |
| 803 |
b.wait_in_text(".pf-v6-c-menu__item.pf-m-selected", shown_profile_text(profile)) |
| 804 |
b.wait_in_text(".pf-v6-c-menu__item.pf-m-selected", "Custom cryptographic policy") |
| 805 |
b.click("#crypto-policy-dialog button.pf-v6-c-button.pf-m-link") |
| 806 |
|
| 807 |
# FIPS mode |
| 808 |
if self.supportsFIPS: |
| 809 |
change_profile(profile, "FIPS") |
| 810 |
else: |
| 811 |
# FIPS is not an available choice |
| 812 |
b.click("#crypto-policy-button") |
| 813 |
b.wait_in_text(".pf-v6-c-menu__item.pf-m-selected", shown_profile_text(profile)) |
| 814 |
self.assertNotIn("FIPS", b.text("#crypto-policy-dialog")) |
| 815 |
b.click("#crypto-policy-dialog button:contains('Cancel')") |
| 816 |
b.wait_not_present("#crypto-policy-dialog") |
| 817 |
|
| 818 |
# pretend the machine already has FIPS enabled, then it can't be disabled |
| 819 |
m.execute(cmd + " --set FIPS") # this is known incomplete/invalid, but suffices to set the UI state |
| 820 |
b.wait_text("#crypto-policy-current", "FIPS") |
| 821 |
self.assertFalse(b.is_present("#crypto-policy-button")) |
| 822 |
m.execute(cmd + f" --set {profile}") # this is known incomplete/invalid, but suffices to set the UI state |
| 823 |
b.wait_text("#crypto-policy-button", shown_profile_text(profile)) |
| 824 |
|
| 825 |
@testlib.skipImage("crypto-policies not available", "debian-*", "ubuntu-*", "arch") |
| 826 |
@testlib.skipOstree("crypto-policies not available") |
| 827 |
def testInconsistentCryptoPolicy(self): |
| 828 |
m = self.machine |
| 829 |
b = self.browser |
| 830 |
cmd = "update-crypto-policies" |
| 831 |
|
| 832 |
# Admin sets FIPS crypto policy in terminal, but FIPS mode is disabled |
| 833 |
m.execute(cmd + " --set FIPS") |
| 834 |
self.login_and_go("/system") |
| 835 |
b.wait_text("#inconsistent_crypto_policy", "FIPS is not properly enabled") |
| 836 |
b.click(".system-health-crypto-policies button.pf-v6-c-button.pf-m-link") |
| 837 |
if self.supportsFIPS: |
| 838 |
# fix the FIPS policy |
| 839 |
b.wait_in_text(".pf-v6-c-menu__item.pf-m-selected .pf-v6-c-label.pf-m-orange", "inconsistent") |
| 840 |
else: |
| 841 |
# pick any valid non-FIPS policy |
| 842 |
b.click("#crypto-policy-dialog .pf-v6-c-menu__list-item[data-value='DEFAULT'] button") |
| 843 |
b.click("#crypto-policy-save-reboot") |
| 844 |
# Initramfs re-generation takes a while |
| 845 |
self.wait_reboot(timeout_sec=600) |
| 846 |
m.start_cockpit() |
| 847 |
self.login_and_go("/system") |
| 848 |
if self.supportsFIPS: |
| 849 |
b.wait_text("#crypto-policy-button", "FIPS") |
| 850 |
self.assertEqual(m.execute("cat /proc/sys/crypto/fips_enabled").strip(), "1") |
| 851 |
else: |
| 852 |
b.wait_text("#crypto-policy-button", "Default") |
| 853 |
# rest of the test does not apply any more |
| 854 |
return |
| 855 |
|
| 856 |
m.execute(cmd + " --set DEFAULT") |
| 857 |
b.wait_text("#inconsistent_crypto_policy", "Cryptographic policy is inconsistent") |
| 858 |
m.execute(cmd + " --set FIPS:OSPP") |
| 859 |
b.wait_text("#crypto-policy-button", "FIPS:OSPP") |
| 860 |
b.wait_not_present("#inconsistent_crypto_policy") |
| 861 |
|
| 862 |
# Setting via dialog |
| 863 |
m.execute(cmd + " --set DEFAULT") |
| 864 |
b.wait_text("#inconsistent_crypto_policy", "Cryptographic policy is inconsistent") |
| 865 |
b.click(".system-health-crypto-policies button.pf-v6-c-button.pf-m-link") |
| 866 |
b.wait_in_text(".pf-v6-c-menu__item.pf-m-selected .pf-v6-c-label.pf-m-orange", "inconsistent") |
| 867 |
b.click("#crypto-policy-save-reboot") |
| 868 |
# Initramfs re-generation takes a while |
| 869 |
self.wait_reboot(timeout_sec=600) |
| 870 |
m.start_cockpit() |
| 871 |
self.login_and_go("/system") |
| 872 |
b.wait_text("#crypto-policy-button", "Default") |
| 873 |
self.assertEqual(m.execute("cat /proc/sys/crypto/fips_enabled").strip(), "0") |
| 874 |
|
| 875 |
|
| 876 |
class TestSystemInfoTime(packagelib.PackageCase): |
| 877 |
def set_change_time_dialog_mode(self, mode: str) -> None: |
| 878 |
b = self.browser |
| 879 |
b.click("#change_systime_btn") |
| 880 |
b.click(f"#change_systime button:contains('{mode}')") |
| 881 |
b.wait_in_text("#system_information_change_systime #change_systime_btn", mode) |
| 882 |
|
| 883 |
def testTime(self): |
| 884 |
m = self.machine |
| 885 |
b = self.browser |
| 886 |
|
| 887 |
def ntp_enabled(): |
| 888 |
return 'true' in m.execute( |
| 889 |
'busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP') |
| 890 |
|
| 891 |
# make sure system is on expected timezone EEST |
| 892 |
m.execute("timedatectl set-timezone Europe/Helsinki") |
| 893 |
|
| 894 |
# Something gets confused when systemd-timesyncd isn't |
| 895 |
# available. This is harmless. |
| 896 |
# |
| 897 |
self.allow_journal_messages( |
| 898 |
"org.freedesktop.systemd1: couldn't get property org.freedesktop.systemd1.Service ExecMain " |
| 899 |
"at /org/freedesktop/systemd1/unit/systemd_2dtimedated_2eservice: " |
| 900 |
"GDBus.Error:org.freedesktop.DBus.Error.UnknownProperty.*") |
| 901 |
# journal gets confused with time jumps |
| 902 |
self.allow_journal_messages(r"Journal file .*\.journal corrupted, ignoring file.*") |
| 903 |
|
| 904 |
self.login_and_go("/system", superuser=False) |
| 905 |
b.wait_text_not("#system_information_systime_button", "") |
| 906 |
b.wait_visible('#system_information_systime_button[disabled]') |
| 907 |
# Gain admin access |
| 908 |
b.become_superuser() |
| 909 |
|
| 910 |
# Change the date |
| 911 |
b.click("#system_information_systime_button") |
| 912 |
b.wait_visible("#system_information_change_systime") |
| 913 |
self.set_change_time_dialog_mode("Manually") |
| 914 |
b.set_input_text("#systime-date-input input", "2037-01-24") |
| 915 |
# invalid time |
| 916 |
b.set_input_text("#systime-time-input-input", "25:61") |
| 917 |
b.click("#system_information_change_systime .apply") |
| 918 |
b.wait_text("#systime-manual-row .dialog-error", "Invalid time format") |
| 919 |
# valid time |
| 920 |
b.set_input_text("#systime-time-input-input", "08:03") |
| 921 |
# wait until icon settles down |
| 922 |
b.wait_visible("#systime-time-input-input[aria-invalid='false']") |
| 923 |
b.wait_not_present("#systime-manual-row .dialog-error") |
| 924 |
b.assert_pixels("#system_information_change_systime", "systime-manual-time") |
| 925 |
b.click("#system_information_change_systime .apply") |
| 926 |
with b.wait_timeout(60): |
| 927 |
b.wait_not_present("#system_information_change_systime") |
| 928 |
|
| 929 |
b.wait_text("#system_information_systime_button", "Jan 24, 2037, 8:03 AM") |
| 930 |
|
| 931 |
self.assertFalse(ntp_enabled()) |
| 932 |
self.assertIn("Sat Jan 24 08:03:", m.execute("date")) |
| 933 |
self.assertIn("EET 2037\n", m.execute("date")) |
| 934 |
|
| 935 |
# Set to NTP |
| 936 |
b.click("#system_information_systime_button") |
| 937 |
b.wait_visible("#system_information_change_systime") |
| 938 |
self.set_change_time_dialog_mode("Automatically using NTP") |
| 939 |
b.click("#system_information_change_systime .apply") |
| 940 |
with b.wait_timeout(60): |
| 941 |
b.wait_not_present("#system_information_change_systime") |
| 942 |
|
| 943 |
testlib.wait(ntp_enabled) |
| 944 |
|
| 945 |
# Change the date |
| 946 |
b.click("#system_information_systime_button") |
| 947 |
b.wait_visible("#system_information_change_systime") |
| 948 |
self.set_change_time_dialog_mode("Manually") |
| 949 |
b.set_input_text("#systime-date-input input", "2050-06-04") |
| 950 |
b.set_input_text("#systime-time-input-input", "06:34") |
| 951 |
b.click("#system_information_change_systime .apply") |
| 952 |
with b.wait_timeout(120): # Changing time on Arch can be slow |
| 953 |
b.wait_not_present("#system_information_change_systime") |
| 954 |
|
| 955 |
self.assertFalse(ntp_enabled()) |
| 956 |
self.assertIn("Sat Jun 4 06:34:", m.execute("date")) |
| 957 |
self.assertIn("EEST 2050\n", m.execute("date")) |
| 958 |
|
| 959 |
@testlib.skipImage("timesyncd not available", "rhel*", "centos-*") |
| 960 |
@testlib.skipImage("TODO: fix for OpenSUSE", "opensuse-tumbleweed") |
| 961 |
def testTimeServersTimesyncd(self): |
| 962 |
m = self.machine |
| 963 |
b = self.browser |
| 964 |
|
| 965 |
# run this test with a tight umask to check proper file permissions (timesyncd runs as non-root) |
| 966 |
self.sed_file(r"/^UMASK/ s/0../077/", "/etc/login.defs") |
| 967 |
|
| 968 |
if m.image.startswith("debian") or m.image.startswith("ubuntu") or m.image == "arch": |
| 969 |
if m.execute("type chronyc || true").strip() != "": |
| 970 |
# chronyd is default, install timesyncd |
| 971 |
self.addPackageSet("timesyncd") |
| 972 |
self.enableRepo() |
| 973 |
m.execute("apt-get update; apt-get install -y systemd-timesyncd") |
| 974 |
m.execute("systemctl restart systemd-timedated; timedatectl set-ntp off; timedatectl set-ntp on") |
| 975 |
else: |
| 976 |
# timesyncd is default |
| 977 |
pass |
| 978 |
else: |
| 979 |
# chronyd is default, give priority to timesyncd |
| 980 |
self.write_file("/etc/systemd/ntp-units.d/10-test.list", "systemd-timesyncd.service") |
| 981 |
|
| 982 |
conf = "/etc/systemd/timesyncd.conf.d/50-cockpit.conf" |
| 983 |
|
| 984 |
self.login_and_go("/system") |
| 985 |
|
| 986 |
# Wait until everything is ready to go... |
| 987 |
b.wait_attr("#system_information_systime_button", "data-timedated-initialized", "true") |
| 988 |
|
| 989 |
b.click("#system_information_systime_button") |
| 990 |
b.wait_visible("#system_information_change_systime") |
| 991 |
|
| 992 |
def get_timesyncd_start(): |
| 993 |
return int(m.execute("systemctl show -p ExecMainStartTimestampMonotonic --value systemd-timesyncd").strip()) |
| 994 |
|
| 995 |
prev_timesyncd_start = get_timesyncd_start() |
| 996 |
|
| 997 |
# Add two NTP servers. |
| 998 |
self.set_change_time_dialog_mode("Automatically using specific NTP servers") |
| 999 |
b.set_input_text("#systime-ntp-servers div:nth-child(1) input", "0.ntp.example.com") |
| 1000 |
b.click('#systime-ntp-servers div:nth-child(1) button') |
| 1001 |
b.set_input_text("#systime-ntp-servers div:nth-child(2) input", "1.ntp.example.com") |
| 1002 |
b.click("#system_information_change_systime .apply") |
| 1003 |
with b.wait_timeout(120): # Changing time on Arch can be slow |
| 1004 |
b.wait_not_present("#system_information_change_systime") |
| 1005 |
|
| 1006 |
self.assertIn("0.ntp.example.com", m.execute(f"grep '^NTP=' {conf}")) |
| 1007 |
self.assertIn("1.ntp.example.com", m.execute(f"grep '^NTP=' {conf}")) |
| 1008 |
# Cockpit created the file with the correct permissions |
| 1009 |
self.assertEqual(m.execute(f"stat --format '%a' {conf}").strip(), "644") |
| 1010 |
|
| 1011 |
# restarts timesyncd to pick up the new config |
| 1012 |
testlib.wait(lambda: get_timesyncd_start() > prev_timesyncd_start, delay=0.2) |
| 1013 |
prev_timesyncd_start = get_timesyncd_start() |
| 1014 |
|
| 1015 |
# not predictable which of 0 or 1 timesyncd picks, but it should be one of those |
| 1016 |
self.assertIn(".ntp.example.com", m.execute("timedatectl timesync-status")) |
| 1017 |
|
| 1018 |
# Set conf from the outside, check that we pick that up, and |
| 1019 |
# switch to default servers. |
| 1020 |
m.write(conf, "[Time]\nNTP=2.ntp.example.com\n") |
| 1021 |
b.wait_attr("#system_information_systime_button", "data-timedated-initialized", "true") |
| 1022 |
b.click("#system_information_systime_button") |
| 1023 |
b.wait_visible("#system_information_change_systime") |
| 1024 |
b.wait_val("#systime-ntp-servers div:nth-child(1) input", "2.ntp.example.com") |
| 1025 |
self.set_change_time_dialog_mode("Automatically using NTP") |
| 1026 |
b.wait_not_present("#systime-ntp-servers") |
| 1027 |
b.click("#system_information_change_systime .apply") |
| 1028 |
with b.wait_timeout(120): # Changing time on Arch can be slow |
| 1029 |
b.wait_not_present("#system_information_change_systime") |
| 1030 |
|
| 1031 |
self.assertIn("2.ntp.example.com", m.execute(f"grep '^#NTP=' {conf}")) |
| 1032 |
|
| 1033 |
# restarts timesyncd to pick up the new config |
| 1034 |
testlib.wait(lambda: get_timesyncd_start() > prev_timesyncd_start, delay=0.2) |
| 1035 |
|
| 1036 |
self.assertNotIn("example.com", m.execute("timedatectl timesync-status")) |
| 1037 |
|
| 1038 |
@testlib.skipImage("chronyd not available", "arch") |
| 1039 |
def testTimeServersChronyd(self): |
| 1040 |
m = self.machine |
| 1041 |
b = self.browser |
| 1042 |
|
| 1043 |
enabled_conf = "/etc/chrony/sources.d/cockpit.sources" |
| 1044 |
disabled_conf = "/etc/chrony/sources.d/cockpit.disabled" |
| 1045 |
|
| 1046 |
if m.image.startswith("debian") or m.image.startswith("ubuntu"): |
| 1047 |
# timesyncd is default, install chronyd |
| 1048 |
self.addPackageSet("chronyd") |
| 1049 |
self.enableRepo() |
| 1050 |
m.execute("apt-get update; apt-get install -y chrony") |
| 1051 |
m.execute("systemctl restart systemd-timedated; timedatectl set-ntp off; timedatectl set-ntp on") |
| 1052 |
else: |
| 1053 |
# chronyd is default |
| 1054 |
pass |
| 1055 |
|
| 1056 |
self.login_and_go("/system") |
| 1057 |
|
| 1058 |
# Wait until everything is ready to go... |
| 1059 |
b.wait_attr("#system_information_systime_button", "data-timedated-initialized", "true") |
| 1060 |
|
| 1061 |
b.click("#system_information_systime_button") |
| 1062 |
b.wait_visible("#system_information_change_systime") |
| 1063 |
|
| 1064 |
def get_chronyd_start(): |
| 1065 |
return int(m.execute("systemctl show -p ExecMainStartTimestampMonotonic --value chronyd").strip()) |
| 1066 |
|
| 1067 |
prev_chronyd_start = get_chronyd_start() |
| 1068 |
|
| 1069 |
# Add two NTP servers. |
| 1070 |
self.set_change_time_dialog_mode("Automatically using additional NTP servers") |
| 1071 |
b.set_input_text("#systime-ntp-servers div:nth-child(1) input", "0.ntp.example.com") |
| 1072 |
b.click('#systime-ntp-servers div:nth-child(1) button') |
| 1073 |
b.set_input_text("#systime-ntp-servers div:nth-child(2) input", "1.ntp.example.com") |
| 1074 |
b.click("#system_information_change_systime .apply") |
| 1075 |
with b.wait_timeout(60): |
| 1076 |
b.wait_not_present("#system_information_change_systime") |
| 1077 |
|
| 1078 |
m.execute(f"grep 0.ntp.example.com {enabled_conf}") |
| 1079 |
m.execute(f"grep 1.ntp.example.com {enabled_conf}") |
| 1080 |
m.execute(f"! test -f {disabled_conf}") |
| 1081 |
|
| 1082 |
# restarts chronyd to pick up the new config |
| 1083 |
testlib.wait(lambda: get_chronyd_start() > prev_chronyd_start, delay=0.2) |
| 1084 |
prev_chronyd_start = get_chronyd_start() |
| 1085 |
|
| 1086 |
# Set conf from the outside, check that we pick that up, and |
| 1087 |
# switch to default servers. |
| 1088 |
m.write(enabled_conf, "server 2.ntp.example.com\n") |
| 1089 |
b.wait_attr("#system_information_systime_button", "data-timedated-initialized", "true") |
| 1090 |
b.click("#system_information_systime_button") |
| 1091 |
b.wait_visible("#system_information_change_systime") |
| 1092 |
b.wait_val("#systime-ntp-servers div:nth-child(1) input", "2.ntp.example.com") |
| 1093 |
self.set_change_time_dialog_mode("Automatically using NTP") |
| 1094 |
b.wait_not_present("#systime-ntp-servers") |
| 1095 |
b.click("#system_information_change_systime .apply") |
| 1096 |
with b.wait_timeout(60): |
| 1097 |
b.wait_not_present("#system_information_change_systime") |
| 1098 |
|
| 1099 |
m.execute(f"! test -f {enabled_conf}") |
| 1100 |
m.execute(f"grep 2.ntp.example.com {disabled_conf}") |
| 1101 |
|
| 1102 |
# restarts timesyncd to pick up the new config |
| 1103 |
testlib.wait(lambda: get_chronyd_start() > prev_chronyd_start, delay=0.2) |
| 1104 |
|
| 1105 |
def testTimeServersUnsupported(self): |
| 1106 |
m = self.machine |
| 1107 |
b = self.browser |
| 1108 |
|
| 1109 |
m.execute("! systemctl is-active chronyd || systemctl stop chronyd") |
| 1110 |
m.execute("! systemctl is-active systemd-timesyncd || systemctl stop systemd-timesyncd") |
| 1111 |
m.execute("systemctl mask chronyd.service || systemctl mask chrony.service") |
| 1112 |
m.execute("systemctl mask systemd-timesyncd.service") |
| 1113 |
|
| 1114 |
self.login_and_go("/system") |
| 1115 |
|
| 1116 |
# Wait until everything is ready to go... |
| 1117 |
b.wait_attr("#system_information_systime_button", "data-timedated-initialized", "true") |
| 1118 |
|
| 1119 |
b.click("#system_information_systime_button") |
| 1120 |
b.wait_visible("#system_information_change_systime") |
| 1121 |
b.click("#system_information_change_systime #change_systime_btn") |
| 1122 |
b.wait_in_text("#change_systime", "Automatically using NTP") |
| 1123 |
b.wait_not_present("#change_systime button:contains('Automatically using specific NTP servers')") |
| 1124 |
b.wait_not_present("#change_systime button:contains('Automatically using additional NTP servers')") |
| 1125 |
|
| 1126 |
|
| 1127 |
class TestSystemInfoSubscribed(submanlib.SubscriptionCase): |
| 1128 |
provision = { |
| 1129 |
"0": {"address": "10.111.112.1/20", "dns": "10.111.112.1"}, |
| 1130 |
"services": {"image": "services"} |
| 1131 |
} |
| 1132 |
|
| 1133 |
@testlib.onlyImage("insights-client is only on RHEL", "rhel*") |
| 1134 |
@testlib.skipBeiboot("no local overrides/config in beiboot mode") |
| 1135 |
def testInsightsStatus(self): |
| 1136 |
m = self.machine |
| 1137 |
b = self.browser |
| 1138 |
|
| 1139 |
# insights-client requires a valid subscription |
| 1140 |
self.setup_candlepin_service(self.machines['services']) |
| 1141 |
self.register_with_candlepin() |
| 1142 |
|
| 1143 |
# insights-client might get started during boot and might then |
| 1144 |
# run concurrently with our explicit "insights-client |
| 1145 |
# --register" below. insights-client is not designed to be |
| 1146 |
# run concurrently and there is no protection against it, |
| 1147 |
# apparently. So let's prevent that. |
| 1148 |
m.execute("systemctl disable --now insights-client") |
| 1149 |
|
| 1150 |
# Pretend that the Subscriptions page can do Insights stuff |
| 1151 |
self.write_file("/etc/cockpit/subscription-manager.override.json", '{ "features": { "insights": true } }') |
| 1152 |
|
| 1153 |
# Run a mock version of the Insights API locally and configure |
| 1154 |
# insights-client to access it. That requires a good enough |
| 1155 |
# TLS mock insights server certificate |
| 1156 |
m.upload(["verify/files/mock-insights", "../src/tls/ca/alice.key", "../src/tls/ca/alice.pem"], self.vm_tmpdir) |
| 1157 |
pid = m.spawn(f"{self.vm_tmpdir}/mock-insights", "mock-insights") |
| 1158 |
self.addCleanup(m.execute, f"kill {pid}") |
| 1159 |
m.execute("while ! ss -tulpn | grep 8443; do sleep 1; done") |
| 1160 |
|
| 1161 |
hostname = m.execute("hostname").rstrip() |
| 1162 |
self.write_file("/etc/insights-client/insights-client.conf", f""" |
| 1163 |
[insights-client] |
| 1164 |
auto_config=False |
| 1165 |
auto_update=False |
| 1166 |
base_url={hostname}:8443/r/insights |
| 1167 |
cert_verify=/var/lib/insights/mock-certs/ca.crt |
| 1168 |
username=admin |
| 1169 |
password=foobar |
| 1170 |
""") |
| 1171 |
|
| 1172 |
# Initially we are not registered |
| 1173 |
self.login_and_go('/system') |
| 1174 |
b.wait_text(".system-health-insights a", "Not connected to Insights") |
| 1175 |
|
| 1176 |
# Enable insights, results should appear automatically |
| 1177 |
m.execute("insights-client --register", timeout=180) |
| 1178 |
self.addCleanup(m.execute, "insights-client --unregister") |
| 1179 |
with b.wait_timeout(60): |
| 1180 |
b.wait_in_text(".system-health-insights a", "Connected to Insights") |
| 1181 |
|
| 1182 |
b.logout() |
| 1183 |
|
| 1184 |
|
| 1185 |
if __name__ == '__main__': |
| 1186 |
testlib.test_main() |