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 9d9d3bb
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/generator/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def test_auth_wifi_detailed(self):
auth:
key-management: psk
password: "db3b0acf5653aeaddd5fe034fb9f07175b2864f847b005aaa2f09182d9411b04"
"Isaac's Home":
auth:
key-management: psk-sha256
password: "d3cryptPr1v4t3K3y"
workplace:
auth:
key-management: eap
Expand Down Expand Up @@ -118,6 +122,14 @@ def test_auth_wifi_detailed(self):
key_mgmt=WPA-PSK
psk=db3b0acf5653aeaddd5fe034fb9f07175b2864f847b005aaa2f09182d9411b04
}
''', new_config)
self.assertIn('''
network={
ssid=P"Isaac's Home"
key_mgmt=WPA-PSK WPA-PSK-SHA256
ieee80211w=1
psk=d3cryptPr1v4t3K3y
}
''', new_config)
self.assertIn('''
network={
Expand Down Expand Up @@ -246,6 +258,10 @@ def test_auth_wifi_detailed(self):
auth:
key-management: psk
password: "4lsos3kr1t"
"Isaac's Home":
auth:
key-management: psk-sha256
password: "d3cryptPr1v4t3K3y"
workplace:
auth:
key-management: eap
Expand Down Expand Up @@ -326,6 +342,26 @@ def test_auth_wifi_detailed(self):
[wifi-security]
key-mgmt=wpa-psk
psk=4lsos3kr1t
''',
'wl0-Isaac%27s%20Home': '''[connection]
id=netplan-wl0-Isaac's Home
type=wifi
interface-name=wl0
[ipv4]
method=auto
[ipv6]
method=ignore
[wifi]
ssid=Isaac's Home
mode=infrastructure
[wifi-security]
key-mgmt=wpa-psk
pmf=1
psk=d3cryptPr1v4t3K3y
''',
'wl0-workplace': '''[connection]
id=netplan-wl0-workplace
Expand Down
50 changes: 50 additions & 0 deletions tests/parser/test_keyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,56 @@ def test_keyfile_wpa3_sae(self):
name: "test2"
'''.format(UUID, UUID)})

def test_keyfile_wpa2_sae(self):
self.generate_from_keyfile('''[connection]
id=test2
uuid={}
type=wifi
interface-name=wlan0
[wifi]
mode=infrastructure
ssid=ubuntu-wpa2-only
[wifi-security]
key-mgmt=wpa-psk
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-wpa2-only":
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 9d9d3bb

Please sign in to comment.