networks: Fix editing wireless connections with SSID field

Fixes: #2447.

- When editing an existing wireless connection, SSID field shows as "b'myap'"
instead of "myap". Fix this.

Tests:

- On a machine with a wireless connection, edit the connection. Without the
patch, form show SSID incorrectly. With the patch, it shows the correct value.

- Unit tests in test_network.py pass when run as root.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2024-11-04 10:11:05 -08:00 committed by Veiko Aasa
parent ff4250f24e
commit bfdb05bf0d
No known key found for this signature in database
GPG Key ID: 478539CAE680674E
2 changed files with 4 additions and 1 deletions

View File

@ -307,7 +307,8 @@ def edit(request, uuid):
form = GenericForm(form_data)
elif settings_connection.get_connection_type() == '802-11-wireless':
settings_wireless = connection.get_setting_wireless()
form_data['ssid'] = settings_wireless.get_ssid().get_data()
form_data['ssid'] = settings_wireless.get_ssid().get_data().decode(
)
form_data['mode'] = settings_wireless.get_mode()
form_data['band'] = settings_wireless.get_band() or 'auto'
form_data['channel'] = settings_wireless.get_channel()

View File

@ -239,6 +239,8 @@ def test_edit_wifi_connection(network, wifi_uuid):
settings_wireless = connection.get_setting_wireless()
assert settings_wireless.get_ssid().get_data() == b'plinthtestwifi2'
assert settings_wireless.get_ssid().get_data().decode(
) == 'plinthtestwifi2'
assert settings_wireless.get_mode() == 'infrastructure'
wifi_sec = connection.get_setting_wireless_security()