Skip to content

Commit dc47342

Browse files
committed
Add unit test
1 parent 28e59a0 commit dc47342

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

tests/generator/test_wifis.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,27 @@ def test_wifi_wowlan_default(self):
275275
self.assertTrue(os.path.islink(os.path.join(
276276
self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wl0.service')))
277277

278+
def test_wifi_wpa_sha256(self):
279+
self.generate('''network:
280+
version: 2
281+
wifis:
282+
wl0:
283+
access-points:
284+
homenet:
285+
auth:
286+
key-management: psk-sha256
287+
password: "********"''')
288+
289+
self.assert_wpa_supplicant("wl0", """ctrl_interface=/run/wpa_supplicant
290+
291+
network={
292+
ssid=P"homenet"
293+
key_mgmt=WPA-PSK WPA-PSK-SHA256
294+
ieee80211w=1
295+
psk="********"
296+
}
297+
""")
298+
278299
def test_wifi_wpa3_personal(self):
279300
self.generate('''network:
280301
version: 2
@@ -794,6 +815,39 @@ def test_wifi_adhoc_wpa_5ghz(self):
794815
}
795816
""")
796817

818+
def test_wifi_wpa2_sha256(self):
819+
self.generate('''network:
820+
version: 2
821+
renderer: NetworkManager
822+
wifis:
823+
wl0:
824+
access-points:
825+
homenet:
826+
auth:
827+
key-management: psk-sha256
828+
password: "********"''')
829+
830+
self.assert_nm({'wl0-homenet': '''[connection]
831+
id=netplan-wl0-homenet
832+
type=wifi
833+
interface-name=wl0
834+
835+
[ipv4]
836+
method=link-local
837+
838+
[ipv6]
839+
method=ignore
840+
841+
[wifi]
842+
ssid=homenet
843+
mode=infrastructure
844+
845+
[wifi-security]
846+
key-mgmt=wpa-psk
847+
pmf=1
848+
psk=********
849+
'''})
850+
797851
def test_wifi_wpa3_personal(self):
798852
self.generate('''network:
799853
version: 2

tests/parser/test_keyfile.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,56 @@ def test_keyfile_wpa3_sae(self):
15051505
name: "test2"
15061506
'''.format(UUID, UUID)})
15071507

1508+
def test_keyfile_wpa_sha256(self):
1509+
self.generate_from_keyfile('''[connection]
1510+
id=test2
1511+
uuid={}
1512+
type=wifi
1513+
interface-name=wlan0
1514+
1515+
[wifi]
1516+
mode=infrastructure
1517+
ssid=ubuntu-wpa-sha256
1518+
1519+
[wifi-security]
1520+
key-mgmt=wpa-psk
1521+
psk=test1234
1522+
1523+
[ipv4]
1524+
method=auto
1525+
1526+
[ipv6]
1527+
addr-gen-mode=stable-privacy
1528+
method=auto
1529+
1530+
[proxy]
1531+
'''.format(UUID))
1532+
self.assert_netplan({UUID: '''network:
1533+
version: 2
1534+
wifis:
1535+
NM-{}:
1536+
renderer: NetworkManager
1537+
match:
1538+
name: "wlan0"
1539+
dhcp4: true
1540+
dhcp6: true
1541+
ipv6-address-generation: "stable-privacy"
1542+
access-points:
1543+
"ubuntu-wpa-sha256":
1544+
auth:
1545+
key-management: "wpa-psk-sha256"
1546+
password: "test1234"
1547+
networkmanager:
1548+
uuid: "ff9d6ebc-226d-4f82-a485-b7ff83b9607f"
1549+
name: "test2"
1550+
passthrough:
1551+
ipv6.ip6-privacy: "-1"
1552+
proxy._: ""
1553+
networkmanager:
1554+
uuid: "{}"
1555+
name: "test2"
1556+
'''.format(UUID, UUID)})
1557+
15081558
def test_keyfile_wpa3_enterprise_eap_sha256(self):
15091559
self.generate_from_keyfile('''[connection]
15101560
id=test2

0 commit comments

Comments
 (0)