| 1 |
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv) |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2026 Red Hat, Inc. |
| 5 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 |
|
| 7 |
import time |
| 8 |
|
| 9 |
import netlib |
| 10 |
import testlib |
| 11 |
from dialoglib import DialogHelpers |
| 12 |
from lib.constants import TEST_OS_DEFAULT |
| 13 |
|
| 14 |
|
| 15 |
@testlib.nondestructive |
| 16 |
@testlib.onlyImage("hostapd/NM-wifi not installed on our test image", TEST_OS_DEFAULT) |
| 17 |
class TestNetworkingWifi(netlib.NetworkCase): |
| 18 |
def setUp(self): |
| 19 |
super().setUp() |
| 20 |
m = self.machine |
| 21 |
|
| 22 |
# firewalld blocks local dnsmasq/hostapd |
| 23 |
m.execute("systemctl stop firewalld") |
| 24 |
self.addCleanup(m.execute, "systemctl start firewalld") |
| 25 |
|
| 26 |
# tell NM to ignore router and BSS interfaces |
| 27 |
self.write_file("/run/udev/rules.d/99-nm-wifi-test.rules", 'ENV{INTERFACE}=="wlan0*", ENV{NM_UNMANAGED}="1"', |
| 28 |
post_restore_action="udevadm control --reload") |
| 29 |
m.execute("udevadm control --reload") |
| 30 |
|
| 31 |
# start fake wifi wlan0/1 pair and wait for it |
| 32 |
m.execute("modprobe mac80211_hwsim; while ! [ -e /sys/class/net/wlan0 ]; do sleep 0.1; done") |
| 33 |
self.addCleanup(m.execute, "rmmod mac80211_hwsim") |
| 34 |
|
| 35 |
# start hostapd with multiple BSSes |
| 36 |
self.write_file("/tmp/hostapd.conf", """ |
| 37 |
interface=wlan0 |
| 38 |
hw_mode=g |
| 39 |
channel=1 |
| 40 |
|
| 41 |
# First network: WPA2-PSK |
| 42 |
ssid=ZE WIFI! |
| 43 |
wpa=2 |
| 44 |
wpa_passphrase=12345678 |
| 45 |
|
| 46 |
# Second network: WPA2-PSK |
| 47 |
bss=wlan0_0 |
| 48 |
ssid=PrivateNet |
| 49 |
wpa=2 |
| 50 |
wpa_passphrase=secret123 |
| 51 |
|
| 52 |
# Third network: Open |
| 53 |
bss=wlan0_1 |
| 54 |
ssid=OpenNet |
| 55 |
|
| 56 |
# Fourth network: second AP for same SSID |
| 57 |
bss=wlan0_2 |
| 58 |
ssid=OpenNet |
| 59 |
|
| 60 |
# Fifth network: Hidden WPA2-PSK |
| 61 |
bss=wlan0_3 |
| 62 |
ssid=HiddenNet |
| 63 |
ignore_broadcast_ssid=1 |
| 64 |
wpa=2 |
| 65 |
wpa_passphrase=hidden99""") |
| 66 |
hostapd_pid = m.spawn("hostapd /tmp/hostapd.conf", "hostapd.log") |
| 67 |
self.addCleanup(m.execute, f"kill {hostapd_pid}") |
| 68 |
|
| 69 |
# give router ends an IP |
| 70 |
m.execute("until [ -e /sys/class/net/wlan0_3 ]; do sleep 0.1; done") |
| 71 |
m.execute("ip addr add 10.0.42.1/24 dev wlan0") |
| 72 |
m.execute("ip addr add 10.0.42.2/24 dev wlan0_0") |
| 73 |
m.execute("ip addr add 10.0.42.3/24 dev wlan0_1") |
| 74 |
m.execute("ip addr add 10.0.42.4/24 dev wlan0_2") |
| 75 |
m.execute("ip addr add 10.0.42.5/24 dev wlan0_3") |
| 76 |
|
| 77 |
# start DNS server |
| 78 |
dnsmasq_pid = m.spawn("dnsmasq --keep-in-foreground --log-queries --log-facility=- " |
| 79 |
"--conf-file=/dev/null --dhcp-leasefile=/tmp/leases " |
| 80 |
"--bind-interfaces --except-interface=lo " |
| 81 |
"--interface=wlan0 --interface=wlan0_0 --interface=wlan0_1 --interface=wlan0_2 --interface=wlan0_3 " |
| 82 |
"--dhcp-range=10.0.42.10,10.0.42.200", "wifi-dnsmasq.log") |
| 83 |
self.addCleanup(m.execute, f"kill {dnsmasq_pid}") |
| 84 |
|
| 85 |
# client-side interface |
| 86 |
self.iface = "wlan1" |
| 87 |
|
| 88 |
def testWifi(self): |
| 89 |
m = self.machine |
| 90 |
b = self.browser |
| 91 |
d = DialogHelpers(b, "#network-wifi-connect-dialog") |
| 92 |
|
| 93 |
self.login_and_go("/network") |
| 94 |
b.wait_visible("#networking") |
| 95 |
|
| 96 |
self.wait_for_iface(self.iface, active=False) |
| 97 |
|
| 98 |
# Details column shows correct number of networks (hidden networks not counted) |
| 99 |
with b.wait_timeout(30): |
| 100 |
b.wait_text(f"tr[data-interface='{self.iface}'] [data-label='Details']", "3 networks") |
| 101 |
# Not connected to anything |
| 102 |
b.wait_not_present(f"tr[data-interface='{self.iface}'] .pf-m-success") |
| 103 |
|
| 104 |
self.select_iface(self.iface) |
| 105 |
b.wait_visible("#network-interface") |
| 106 |
self.wait_for_iface_setting("Status", "Inactive") |
| 107 |
|
| 108 |
# detects our three visible wifis (plus one hidden) |
| 109 |
b.wait_in_text("table[aria-label='Available networks'] tbody:first-of-type", "ZE WIFI!") |
| 110 |
b.wait_text("tr[data-ssid='ZE WIFI!'] th", "ZE WIFI!") |
| 111 |
self.assertEqual(b.get_pf_progress_value("tr[data-ssid='ZE WIFI!'] [data-label='Signal']"), 100) |
| 112 |
# sadly, mac80211_hwsim's data rate reporting is flaky, so just ensure at least one of our networks is correct |
| 113 |
b.wait_in_text("table[aria-label='Available networks']", "54 Mbps") |
| 114 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] [data-label='Mode'] [aria-label='secured']") |
| 115 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 116 |
# No known network yet |
| 117 |
b.wait_not_present(".nm-icon-known") |
| 118 |
|
| 119 |
b.wait_visible("tr[data-ssid='PrivateNet'] [data-label='Mode'] [aria-label='secured']") |
| 120 |
b.wait_visible("tr[data-ssid='PrivateNet'] button[aria-label='Connect']") |
| 121 |
|
| 122 |
# only one OpenNet row for the two APs |
| 123 |
b.wait_count("tr[data-ssid='OpenNet']", 1) |
| 124 |
b.wait_visible("tr[data-ssid='OpenNet'] [data-label='Mode'] [aria-label='open']") |
| 125 |
b.wait_visible("tr[data-ssid='OpenNet'] button[aria-label='Connect']") |
| 126 |
|
| 127 |
# Filter networks |
| 128 |
b.set_input_text("#network-interface-wifi-networks input[placeholder='Filter']", "wifi") |
| 129 |
# Should show only "ZE WIFI!" |
| 130 |
b.wait_visible("tr[data-ssid='ZE WIFI!']") |
| 131 |
b.wait_not_present("tr[data-ssid='PrivateNet']") |
| 132 |
b.wait_not_present("tr[data-ssid='OpenNet']") |
| 133 |
|
| 134 |
# Search for network that doesn't exist |
| 135 |
b.set_input_text("#network-interface-wifi-networks input[placeholder='Filter']", "NoSuchNetwork") |
| 136 |
b.wait_not_present("tr[data-ssid='ZE WIFI!']") |
| 137 |
b.wait_not_present("tr[data-ssid='PrivateNet']") |
| 138 |
b.wait_not_present("tr[data-ssid='OpenNet']") |
| 139 |
|
| 140 |
# Clear search |
| 141 |
b.click("#network-interface-wifi-networks button[aria-label='Reset']") |
| 142 |
b.wait_visible("tr[data-ssid='ZE WIFI!']") |
| 143 |
b.wait_visible("tr[data-ssid='PrivateNet']") |
| 144 |
b.wait_visible("tr[data-ssid='OpenNet']") |
| 145 |
|
| 146 |
# Connect to OpenNet |
| 147 |
b.click("tr[data-ssid='OpenNet'] button[aria-label='Connect']") |
| 148 |
b.wait_visible("tr[data-ssid='OpenNet'] button[aria-label='Disconnect']") |
| 149 |
# gets a "connected" icon |
| 150 |
b.wait_visible("tr[data-ssid='OpenNet'] .nm-icon-connected") |
| 151 |
# gets an IP |
| 152 |
self.wait_for_iface_setting("Status", "10.0.42") |
| 153 |
# moves to top of table |
| 154 |
b.wait_in_text("table[aria-label='Available networks'] tbody:first-of-type", "OpenNet") |
| 155 |
|
| 156 |
# Overview shows connected network |
| 157 |
b.click("#network-interface nav a:contains('Networking')") |
| 158 |
b.wait_visible("#networking") |
| 159 |
b.wait_in_text(f"tr[data-interface='{self.iface}'] [data-label='Details']", "3 networks") |
| 160 |
b.wait_in_text(f"tr[data-interface='{self.iface}'] [data-label='Details'] .pf-v6-c-label.pf-m-success", "OpenNet") |
| 161 |
self.select_iface(self.iface) |
| 162 |
|
| 163 |
# Disconnect |
| 164 |
b.click("tr[data-ssid='OpenNet'] button[aria-label='Disconnect']") |
| 165 |
b.wait_visible("tr[data-ssid='OpenNet'] button[aria-label='Connect']") |
| 166 |
# icon moves to "known" state |
| 167 |
b.wait_visible("tr[data-ssid='OpenNet'] .nm-icon-known") |
| 168 |
b.wait_not_present("tr[data-ssid='OpenNet'] .nm-icon-connected") |
| 169 |
# loses IP |
| 170 |
self.wait_for_iface_setting("Status", "Inactive") |
| 171 |
# still a known network, stays at the top of the table |
| 172 |
b.wait_in_text("table[aria-label='Available networks'] tbody:nth-of-type(1)", "OpenNet") |
| 173 |
|
| 174 |
# Overview shows disconnected |
| 175 |
b.click("#network-interface nav a:contains('Networking')") |
| 176 |
b.wait_visible("#networking") |
| 177 |
b.wait_text(f"tr[data-interface='{self.iface}'] [data-label='Details']", "3 networks") |
| 178 |
b.wait_not_present(f"tr[data-interface='{self.iface}'] .pf-v6-c-label.pf-m-success") |
| 179 |
self.select_iface(self.iface) |
| 180 |
|
| 181 |
# Connect to ZE WIFI! |
| 182 |
b.click("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 183 |
b.wait_in_text("#network-wifi-connect-dialog", "Connect to ZE WIFI!") |
| 184 |
# Validation: Empty password |
| 185 |
d.wait_TextInput("password", "") |
| 186 |
b.click(d.apply_button()) |
| 187 |
b.wait_visible(d.apply_button() + ":disabled") |
| 188 |
# Test password reveal |
| 189 |
d.set_TextInput("password", "wrong123") |
| 190 |
b.wait_visible(d.apply_button() + ":not(:disabled)") |
| 191 |
self.assertEqual(b.attr(d.field("password"), "type"), "password") |
| 192 |
b.click("#network-wifi-connect-dialog button[aria-label='Show password']") |
| 193 |
self.assertEqual(b.attr(d.field("password"), "type"), "text") |
| 194 |
self.assertEqual(d.get_TextInput("password"), "wrong123") |
| 195 |
b.click("#network-wifi-connect-dialog button[aria-label='Hide password']") |
| 196 |
self.assertEqual(b.attr(d.field("password"), "type"), "password") |
| 197 |
# Submit with wrong password |
| 198 |
b.click(d.apply_button()) |
| 199 |
b.wait_visible(d.apply_button() + ".pf-m-in-progress") |
| 200 |
b.wait_visible(d.apply_button() + ":disabled") |
| 201 |
b.wait_in_text("#network-wifi-connect-dialog", "Check your password") |
| 202 |
# correct password |
| 203 |
d.set_TextInput("password", "12345678") |
| 204 |
b.click(d.apply_button()) |
| 205 |
b.wait_not_present("#network-wifi-connect-dialog") |
| 206 |
|
| 207 |
# connects, action changes |
| 208 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] button[aria-label='Disconnect']") |
| 209 |
# gets a "connected" icon |
| 210 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] .nm-icon-connected") |
| 211 |
# gets an IP |
| 212 |
self.wait_for_iface_setting("Status", "10.0.42") |
| 213 |
|
| 214 |
# Disconnect |
| 215 |
b.click("tr[data-ssid='ZE WIFI!'] button[aria-label='Disconnect']") |
| 216 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 217 |
# icon moves to "known" state |
| 218 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] .nm-icon-known") |
| 219 |
b.wait_not_present("tr[data-ssid='ZE WIFI!'] .nm-icon-connected") |
| 220 |
# loses IP |
| 221 |
self.wait_for_iface_setting("Status", "Inactive") |
| 222 |
|
| 223 |
# NM now knows the connection and can re-connect without password query |
| 224 |
b.click("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 225 |
# icon moves to "connected" state |
| 226 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] .nm-icon-connected") |
| 227 |
b.wait_not_present("tr[data-ssid='ZE WIFI!'] .nm-icon-known") |
| 228 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] button[aria-label='Disconnect']") |
| 229 |
self.wait_for_iface_setting("Status", "10.0.42") |
| 230 |
# OpenNet is known but not connected |
| 231 |
b.wait_visible("tr[data-ssid='OpenNet'] .nm-icon-known") |
| 232 |
|
| 233 |
# Test connection failure when password is not stored |
| 234 |
# Disconnect first |
| 235 |
b.click("tr[data-ssid='ZE WIFI!'] button[aria-label='Disconnect']") |
| 236 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 237 |
# Remove the password from the connection file and restart NM |
| 238 |
m.execute("sed -i '/^psk=/d' /etc/NetworkManager/system-connections/'ZE WIFI!.nmconnection'") |
| 239 |
m.execute("systemctl restart NetworkManager") |
| 240 |
b.reload() |
| 241 |
b.enter_page("/network") |
| 242 |
# Try to connect - shows error about missing password |
| 243 |
b.click("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 244 |
b.wait_in_text("#error-popup", "Failed to connect to ZE WIFI!") |
| 245 |
b.wait_in_text("#error-popup", "Network password is not stored") |
| 246 |
b.click("#error-popup button:contains('Close')") |
| 247 |
b.wait_not_present("#error-popup") |
| 248 |
# Restore the connection with password for subsequent tests |
| 249 |
b.click("tr[data-ssid='ZE WIFI!'] button.pf-v6-c-menu-toggle") |
| 250 |
b.click(".pf-v6-c-menu button[aria-label='Forget']") |
| 251 |
b.wait_not_present("tr[data-ssid='ZE WIFI!'] .nm-icon-known") |
| 252 |
b.click("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 253 |
b.wait_in_text("#network-wifi-connect-dialog", "Connect to ZE WIFI!") |
| 254 |
d.set_TextInput("password", "12345678") |
| 255 |
b.click(d.apply_button()) |
| 256 |
b.wait_not_present("#network-wifi-connect-dialog") |
| 257 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] button[aria-label='Disconnect']") |
| 258 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] .nm-icon-connected") |
| 259 |
|
| 260 |
# connecting to OpenNet disconnects from ZE WIFI! |
| 261 |
self.assertIn("ZE WIFI!", m.execute("nmcli d show wlan1 | grep GENERAL.CONNECTION")) |
| 262 |
b.click("tr[data-ssid='OpenNet'] button[aria-label='Connect']") |
| 263 |
b.wait_visible("tr[data-ssid='OpenNet'] button[aria-label='Disconnect']") |
| 264 |
# OpenNet moves to top of the table |
| 265 |
b.wait_in_text("table[aria-label='Available networks'] tbody:first-of-type", "OpenNet") |
| 266 |
# OpenNet icon moves to "connected" state |
| 267 |
b.wait_visible("tr[data-ssid='OpenNet'] .nm-icon-connected") |
| 268 |
b.wait_not_present("tr[data-ssid='OpenNet'] .nm-icon-known") |
| 269 |
self.wait_for_iface_setting("Status", "10.0.42") |
| 270 |
# ZE WIFI! moves to "known" state |
| 271 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 272 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] .nm-icon-known") |
| 273 |
b.wait_not_present("tr[data-ssid='ZE WIFI!'] .nm-icon-connected") |
| 274 |
self.assertIn("OpenNet", m.execute("nmcli d show wlan1 | grep GENERAL.CONNECTION")) |
| 275 |
|
| 276 |
b.click("tr[data-ssid='OpenNet'] button[aria-label='Disconnect']") |
| 277 |
self.wait_for_iface_setting("Status", "Inactive") |
| 278 |
|
| 279 |
# Forget ZE WIFI! network |
| 280 |
b.click("tr[data-ssid='ZE WIFI!'] button.pf-v6-c-menu-toggle") |
| 281 |
b.click(".pf-v6-c-menu button[aria-label='Forget']") |
| 282 |
# Known icon disappears |
| 283 |
b.wait_not_present("tr[data-ssid='ZE WIFI!'] .nm-icon-known") |
| 284 |
b.wait_not_present("tr[data-ssid='ZE WIFI!'] button.pf-v6-c-menu-toggle") |
| 285 |
# Try to connect again - should ask for password; cancel |
| 286 |
b.click("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 287 |
b.wait_in_text("#network-wifi-connect-dialog", "Connect to ZE WIFI!") |
| 288 |
b.click(d.cancel_button()) |
| 289 |
b.wait_not_present("#network-wifi-connect-dialog") |
| 290 |
# Cancelling does not create a known connection |
| 291 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 292 |
b.wait_not_present("tr[data-ssid='ZE WIFI!'] button.pf-v6-c-menu-toggle") |
| 293 |
|
| 294 |
# Cancel during connection attempt |
| 295 |
b.click("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 296 |
b.wait_in_text("#network-wifi-connect-dialog", "Connect to ZE WIFI!") |
| 297 |
# Use a wrong password. Otherwise connecting might happen faster than we can click "cancel". |
| 298 |
d.set_TextInput("password", "12345679") |
| 299 |
b.click(d.apply_button()) |
| 300 |
b.wait_visible(d.apply_button() + ".pf-m-in-progress") |
| 301 |
b.wait_visible(d.cancel_button() + ":not(:disabled)") |
| 302 |
b.click(d.cancel_button()) |
| 303 |
b.wait_not_present("#network-wifi-connect-dialog") |
| 304 |
# Cancelling did not create or deleted the known connection |
| 305 |
# This tests a negative -- ensure the connection does not get created in the background |
| 306 |
time.sleep(3) |
| 307 |
b.wait_visible("tr[data-ssid='ZE WIFI!'] button[aria-label='Connect']") |
| 308 |
b.wait_not_present("tr[data-ssid='ZE WIFI!'] button.pf-v6-c-menu-toggle") |
| 309 |
self.wait_for_iface_setting("Status", "Inactive") |
| 310 |
|
| 311 |
# WiFi kill switch: detected networks disappear |
| 312 |
m.execute("nmcli radio wifi off") |
| 313 |
self.addCleanup(m.execute, "nmcli radio wifi on") |
| 314 |
self.wait_for_iface_setting("Status", "Not available") |
| 315 |
b.wait_not_present("table[aria-label='Available networks']") |
| 316 |
b.click("#network-interface nav a:contains('Networking')") |
| 317 |
b.wait_not_present(f"tr[data-interface='{self.iface}'] [data-label='Details']") |
| 318 |
|
| 319 |
m.execute("nmcli radio wifi on") |
| 320 |
# in theory, NM will now connect to OpenNet automatically; however, kill switch messes up |
| 321 |
# mac80211_hwsim/hostapd's state, and they become unpredictable. So just assert that we get any life sign |
| 322 |
b.wait_in_text(f"tr[data-interface='{self.iface}'] [data-label='Details']", "networks") |
| 323 |
self.select_iface(self.iface) |
| 324 |
b.wait_visible("table[aria-label='Available networks']") |
| 325 |
|
| 326 |
def testHidden(self): |
| 327 |
b = self.browser |
| 328 |
d = DialogHelpers(b, "#network-wifi-connect-dialog") |
| 329 |
|
| 330 |
self.login_and_go("/network") |
| 331 |
b.wait_visible("#networking") |
| 332 |
|
| 333 |
self.wait_for_iface(self.iface, active=False) |
| 334 |
self.select_iface(self.iface) |
| 335 |
b.wait_visible("#network-interface") |
| 336 |
|
| 337 |
# Hidden networks are aggregated at the bottom as "N hidden networks" with no actions |
| 338 |
# They are not broadcast very often especially after initial hostapd setup |
| 339 |
with b.wait_timeout(60): |
| 340 |
b.wait_text("tr[data-hidden]", "1 hidden network") |
| 341 |
|
| 342 |
# Connect to hidden network via manual connection dialog |
| 343 |
b.click("button:contains('Connect to hidden network')") |
| 344 |
b.wait_in_text("#network-wifi-connect-dialog", "Connect to hidden network") |
| 345 |
|
| 346 |
# Validation: SSID and password are required |
| 347 |
b.click(d.apply_button()) |
| 348 |
b.wait_visible(d.apply_button() + ":disabled") |
| 349 |
b.wait_in_text(d.helper_text("ssid"), "SSID can not be empty") |
| 350 |
b.wait_in_text(d.helper_text("password"), "Password can not be empty") |
| 351 |
d.set_TextInput("ssid", "SomeNetwork") |
| 352 |
d.set_TextInput("password", "foobarfoo") |
| 353 |
b.wait_visible(d.apply_button() + ":not(:disabled)") |
| 354 |
b.wait_not_present(d.helper_text("ssid")) |
| 355 |
b.wait_not_present(d.helper_text("password")) |
| 356 |
d.set_TextInput("password", "") |
| 357 |
b.wait_visible(d.apply_button() + ":disabled") |
| 358 |
b.wait_in_text(d.helper_text("password"), "Password can not be empty") |
| 359 |
|
| 360 |
# Validation: No password required for open networks |
| 361 |
d.set_DropdownSelect("security", "none") |
| 362 |
b.wait_not_present(d.field("password")) |
| 363 |
b.wait_visible(d.apply_button() + ":not(:disabled)") |
| 364 |
|
| 365 |
# Validation: Password required for WPA networks |
| 366 |
d.set_DropdownSelect("security", "wpa-psk") |
| 367 |
b.wait_visible(d.field("password")) |
| 368 |
b.wait_visible(d.apply_button() + ":disabled") |
| 369 |
|
| 370 |
# Error case 1: Wrong SSID |
| 371 |
d.set_TextInput("ssid", "WrongSSID") |
| 372 |
self.assertEqual(d.get_DropdownSelect("security"), "wpa-psk") |
| 373 |
d.set_TextInput("password", "password") |
| 374 |
b.click(d.apply_button()) |
| 375 |
b.wait_visible(d.apply_button() + ".pf-m-in-progress") |
| 376 |
with b.wait_timeout(30): |
| 377 |
b.wait_in_text("#network-wifi-connect-dialog", "Failed to connect") |
| 378 |
b.wait_not_present(d.apply_button() + ".pf-m-in-progress") |
| 379 |
|
| 380 |
# Error case 2: Wrong security (open instead of WPA) |
| 381 |
d.set_TextInput("ssid", "HiddenNet") |
| 382 |
d.set_DropdownSelect("security", "none") |
| 383 |
b.wait_not_present(d.field("password")) |
| 384 |
b.click(d.apply_button()) |
| 385 |
b.wait_visible(d.apply_button() + ".pf-m-in-progress") |
| 386 |
with b.wait_timeout(30): |
| 387 |
b.wait_in_text("#network-wifi-connect-dialog", "Failed to connect") |
| 388 |
b.wait_not_present(d.apply_button() + ".pf-m-in-progress") |
| 389 |
|
| 390 |
# Error case 3: Wrong password |
| 391 |
d.set_DropdownSelect("security", "wpa-psk") |
| 392 |
b.wait_visible(d.field("password")) |
| 393 |
d.set_TextInput("password", "wrongpassword") |
| 394 |
b.click(d.apply_button()) |
| 395 |
b.wait_visible(d.apply_button() + ".pf-m-in-progress") |
| 396 |
b.wait_in_text("#network-wifi-connect-dialog", "Failed to connect") |
| 397 |
b.wait_not_present(d.apply_button() + ".pf-m-in-progress") |
| 398 |
|
| 399 |
# Success case: Correct credentials |
| 400 |
d.set_TextInput("password", "hidden99") |
| 401 |
b.click(d.apply_button()) |
| 402 |
b.wait_not_present("#network-wifi-connect-dialog") |
| 403 |
# Hidden network connects and shows its real SSID |
| 404 |
b.wait_visible("tr[data-ssid='HiddenNet'] button[aria-label='Disconnect']") |
| 405 |
b.wait_visible("tr[data-ssid='HiddenNet'] .nm-icon-connected") |
| 406 |
self.wait_for_iface_setting("Status", "10.0.42") |
| 407 |
# Should not show (hidden network) anymore, only HiddenNet |
| 408 |
b.wait_not_present("tr[data-hidden]") |
| 409 |
|
| 410 |
# Disconnect from hidden network - it remains known with its SSID |
| 411 |
b.click("tr[data-ssid='HiddenNet'] button[aria-label='Disconnect']") |
| 412 |
self.wait_for_iface_setting("Status", "Inactive") |
| 413 |
b.wait_visible("tr[data-ssid='HiddenNet'] button[aria-label='Connect']") |
| 414 |
b.wait_visible("tr[data-ssid='HiddenNet'] .nm-icon-known") |
| 415 |
b.wait_not_present("tr[data-ssid='HiddenNet'] .nm-icon-connected") |
| 416 |
|
| 417 |
# Forget hidden network - it disappears |
| 418 |
b.click("tr[data-ssid='HiddenNet'] button.pf-v6-c-menu-toggle") |
| 419 |
b.click(".pf-v6-c-menu button[aria-label='Forget']") |
| 420 |
b.wait_not_present("tr[data-ssid='HiddenNet']") |
| 421 |
b.wait_not_present("tr[data-ssid='HiddenNet'] .nm-icon-known") |
| 422 |
# ... and becomes unknown again in the hidden networks row |
| 423 |
b.wait_text("tr[data-hidden]", "1 hidden network") |
| 424 |
|
| 425 |
|
| 426 |
if __name__ == '__main__': |
| 427 |
testlib.test_main() |