From bfdb05bf0dde013b6845841baf4e426747b6a0ff Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 4 Nov 2024 10:11:05 -0800 Subject: [PATCH] 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 Reviewed-by: Veiko Aasa --- plinth/modules/networks/views.py | 3 ++- plinth/tests/test_network.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plinth/modules/networks/views.py b/plinth/modules/networks/views.py index 5074b796f..7ebc68700 100644 --- a/plinth/modules/networks/views.py +++ b/plinth/modules/networks/views.py @@ -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() diff --git a/plinth/tests/test_network.py b/plinth/tests/test_network.py index 1c6742a6d..7ec388bee 100644 --- a/plinth/tests/test_network.py +++ b/plinth/tests/test_network.py @@ -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()