|
|
@@ -209,6 +209,25 @@ def test_wifi_key_sensor_qr_attribute():
|
|
|
assert attrs["qr"] == "WIFI:S:MyNet;T:WPA;P:hunter2;;"
|
|
|
|
|
|
|
|
|
+def test_wifi_key_sensor_qr_attribute_open_network():
|
|
|
+ """An empty-string wifi_key (open network default) should produce a nopass QR string."""
|
|
|
+ res = ReservationData(wifi_ssid="MyNet", wifi_key="")
|
|
|
+ coord = _coordinator(current=res)
|
|
|
+ s = _sensor(WiFiKeySensor, coord, field="wifi_key")
|
|
|
+ attrs = s.extra_state_attributes
|
|
|
+ assert attrs is not None
|
|
|
+ assert attrs["qr"] == "WIFI:S:MyNet;T:nopass;;"
|
|
|
+
|
|
|
+
|
|
|
+def test_wifi_key_sensor_qr_attribute_escapes_special_chars():
|
|
|
+ res = ReservationData(wifi_ssid="Guest;Net,\"A\"", wifi_key="p:a\\ss;w,ord")
|
|
|
+ coord = _coordinator(current=res)
|
|
|
+ s = _sensor(WiFiKeySensor, coord, field="wifi_key")
|
|
|
+ attrs = s.extra_state_attributes
|
|
|
+ assert attrs is not None
|
|
|
+ assert attrs["qr"] == 'WIFI:S:Guest\\;Net\\,\\"A\\";T:WPA;P:p\\:a\\\\ss\\;w\\,ord;;'
|
|
|
+
|
|
|
+
|
|
|
def test_wifi_key_sensor_no_attrs_when_ssid_missing():
|
|
|
res = ReservationData(wifi_ssid=None, wifi_key="hunter2")
|
|
|
coord = _coordinator(current=res)
|