Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
seankingyang committed Dec 16, 2024
1 parent 28e59a0 commit 52fd4b1
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/generator/test_wifis.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,27 @@ def test_wifi_wowlan_default(self):
self.assertTrue(os.path.islink(os.path.join(
self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wl0.service')))

def test_wifi_wpa_sha256(self):
self.generate('''network:
version: 2
wifis:
wl0:
access-points:
homenet:
auth:
key-management: psk-sha256
password: "********"''')

self.assert_wpa_supplicant("wl0", """ctrl_interface=/run/wpa_supplicant
network={
ssid=P"homenet"
key_mgmt=WPA-PSK WPA-PSK-SHA256
ieee80211w=1
psk="********"
}
""")

def test_wifi_wpa3_personal(self):
self.generate('''network:
version: 2
Expand Down Expand Up @@ -794,6 +815,39 @@ def test_wifi_adhoc_wpa_5ghz(self):
}
""")

def test_wifi_wpa2_sha256(self):
self.generate('''network:
version: 2
renderer: NetworkManager
wifis:
wl0:
access-points:
homenet:
auth:
key-management: psk-sha256
password: "********"''')

self.assert_nm({'wl0-homenet': '''[connection]
id=netplan-wl0-homenet
type=wifi
interface-name=wl0
[ipv4]
method=link-local
[ipv6]
method=ignore
[wifi]
ssid=homenet
mode=infrastructure
[wifi-security]
key-mgmt=wpa-psk
pmf=1
psk=********
'''})

def test_wifi_wpa3_personal(self):
self.generate('''network:
version: 2
Expand Down
51 changes: 51 additions & 0 deletions tests/parser/test_keyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,57 @@ def test_keyfile_wpa3_sae(self):
name: "test2"
'''.format(UUID, UUID)})

def test_keyfile_wpa_sha256(self):
self.generate_from_keyfile('''[connection]
id=test2
uuid={}
type=wifi
interface-name=wlan0
[wifi]
mode=infrastructure
ssid=ubuntu-wpa-sha256
[wifi-security]
key-mgmt=wpa-psk
pmf=2
psk=test1234
[ipv4]
method=auto
[ipv6]
addr-gen-mode=stable-privacy
method=auto
[proxy]
'''.format(UUID))
self.assert_netplan({UUID: '''network:
version: 2
wifis:
NM-{}:
renderer: NetworkManager
match:
name: "wlan0"
dhcp4: true
dhcp6: true
ipv6-address-generation: "stable-privacy"
access-points:
"ubuntu-wpa-sha256":
auth:
key-management: "wpa-psk-sha256"
password: "test1234"
networkmanager:
uuid: "ff9d6ebc-226d-4f82-a485-b7ff83b9607f"
name: "test2"
passthrough:
ipv6.ip6-privacy: "-1"
proxy._: ""
networkmanager:
uuid: "{}"
name: "test2"
'''.format(UUID, UUID)})

def test_keyfile_wpa3_enterprise_eap_sha256(self):
self.generate_from_keyfile('''[connection]
id=test2
Expand Down

0 comments on commit 52fd4b1

Please sign in to comment.