Skip to content

Commit

Permalink
tests: adapt tests to new passthrough format
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloegea committed Sep 30, 2024
1 parent 01b7c1d commit ac0fb98
Show file tree
Hide file tree
Showing 4 changed files with 401 additions and 162 deletions.
12 changes: 7 additions & 5 deletions tests/cli/test_get_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,17 @@ def test_set_delete_nm_passthrough(self):
networkmanager:
name: "myid with spaces"
passthrough:
connection.permissions: ""
ipv4.dns-search: ""''')
connection:
permissions: ""
ipv4:
dns-search: ""''')
ap_key = 'network.wifis.wlan0.access-points.SOME-SSID'
self._set([ap_key+'.networkmanager.passthrough.connection\\.permissions=null'])
self._set([ap_key+'.networkmanager.passthrough.connection.permissions=null'])
with open(self.path, 'r') as f:
out = yaml.safe_load(f)
ap = out['network']['wifis']['wlan0']['access-points']['SOME-SSID']
self.assertNotIn('connection.permissions', ap['networkmanager']['passthrough'])
self.assertEqual('', ap['networkmanager']['passthrough']['ipv4.dns-search'])
self.assertNotIn('permissions', ap['networkmanager']['passthrough']['connection'])
self.assertEqual('', ap['networkmanager']['passthrough']['ipv4']['dns-search'])

def test_set_delete_bridge_subparams(self):
with open(self.path, 'w') as f:
Expand Down
38 changes: 21 additions & 17 deletions tests/generator/test_modems.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,21 @@ def test_modem_nm_integration_gsm_cdma(self):
uuid: a08c5805-7cf5-43f7-afb9-12cb30f6eca3
name: "T-Mobile Funkadelic 2"
passthrough:
connection.type: "bluetooth"
gsm.apn: "internet2.voicestream.com"
gsm.device-id: "da812de91eec16620b06cd0ca5cbc7ea25245222"
gsm.username: "george.clinton.again"
gsm.sim-operator-id: "310260"
gsm.pin: "123456"
gsm.sim-id: "89148000000060671234"
gsm.password: "parliament2"
gsm.network-id: "254098"
ipv4.method: "auto"
ipv6.method: "auto"''')
connection:
type: bluetooth
gsm:
apn: internet2.voicestream.com
device-id: da812de91eec16620b06cd0ca5cbc7ea25245222
username: george.clinton.again
sim-operator-id: 310260
pin: 123456
sim-id: 89148000000060671234
password: parliament2
network-id: 254098
ipv4:
method: auto
ipv6:
method: auto''')
self.assert_nm({'NM-a08c5805-7cf5-43f7-afb9-12cb30f6eca3': '''[connection]
id=T-Mobile Funkadelic 2
#Netplan: passthrough override
Expand All @@ -400,19 +404,19 @@ def test_modem_nm_integration_gsm_cdma(self):
[gsm]
apn=internet2.voicestream.com
#Netplan: passthrough setting
device-id=da812de91eec16620b06cd0ca5cbc7ea25245222
password=parliament2
#Netplan: passthrough setting
username=george.clinton.again
network-id=254098
#Netplan: passthrough setting
sim-operator-id=310260
sim-id=89148000000060671234
#Netplan: passthrough setting
pin=123456
#Netplan: passthrough setting
sim-id=89148000000060671234
username=george.clinton.again
#Netplan: passthrough setting
password=parliament2
sim-operator-id=310260
#Netplan: passthrough setting
network-id=254098
device-id=da812de91eec16620b06cd0ca5cbc7ea25245222
[ipv4]
#Netplan: passthrough override
Expand Down
177 changes: 169 additions & 8 deletions tests/generator/test_passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,42 @@ def test_passthrough_basic(self):
passthrough:
connection.uuid: 87749f1d-334f-40b2-98d4-55db58965f5f
connection.type: ethernet
connection.permissions: ""''')
connection.permissions: ""''', skip_generated_yaml_validation=True)

self.assert_nm({'NM-87749f1d-334f-40b2-98d4-55db58965f5f': '''[connection]
id=some NM id
type=ethernet
uuid=87749f1d-334f-40b2-98d4-55db58965f5f
#Netplan: passthrough setting
permissions=
[ethernet]
wake-on-lan=0
[ipv4]
method=link-local
[ipv6]
method=ignore
'''}, '''[device-netplan.ethernets.NM-87749f1d-334f-40b2-98d4-55db58965f5f]
match-device=type:ethernet
managed=1\n\n''')

def test_passthrough_basic_new_format(self):
self.generate('''network:
version: 2
ethernets:
NM-87749f1d-334f-40b2-98d4-55db58965f5f:
renderer: NetworkManager
match: {}
networkmanager:
uuid: 87749f1d-334f-40b2-98d4-55db58965f5f
name: some NM id
passthrough:
connection:
uuid: 87749f1d-334f-40b2-98d4-55db58965f5f
type: ethernet
permissions: ""''')

self.assert_nm({'NM-87749f1d-334f-40b2-98d4-55db58965f5f': '''[connection]
id=some NM id
Expand Down Expand Up @@ -75,6 +110,61 @@ def test_passthrough_wifi(self):
passthrough:
connection.permissions: ""
wifi.ssid: SOME-SSID
"OTHER-SSID":
hidden: true''', skip_generated_yaml_validation=True)

self.assert_nm({'NM-87749f1d-334f-40b2-98d4-55db58965f5f-SOME-SSID': '''[connection]
id=myid with spaces
type=wifi
uuid=87749f1d-334f-40b2-98d4-55db58965f5f
#Netplan: passthrough setting
permissions=
[ipv4]
method=link-local
[ipv6]
method=ignore
[wifi]
ssid=SOME-SSID
mode=infrastructure
''',
'NM-87749f1d-334f-40b2-98d4-55db58965f5f-OTHER-SSID': '''[connection]
id=netplan-NM-87749f1d-334f-40b2-98d4-55db58965f5f-OTHER-SSID
type=wifi
[ipv4]
method=link-local
[ipv6]
method=ignore
[wifi]
ssid=OTHER-SSID
mode=infrastructure
hidden=true
'''}, '''[device-netplan.wifis.NM-87749f1d-334f-40b2-98d4-55db58965f5f]
match-device=type:wifi
managed=1\n\n''')

def test_passthrough_wifi_new_format(self):
self.generate('''network:
version: 2
wifis:
NM-87749f1d-334f-40b2-98d4-55db58965f5f:
renderer: NetworkManager
match: {}
access-points:
"SOME-SSID":
networkmanager:
uuid: 87749f1d-334f-40b2-98d4-55db58965f5f
name: myid with spaces
passthrough:
connection:
permissions: ""
wifi:
ssid: SOME-SSID
"OTHER-SSID":
hidden: true''')

Expand Down Expand Up @@ -121,8 +211,9 @@ def test_passthrough_type_nm_devices(self):
match: {}
networkmanager:
passthrough:
connection.uuid: 87749f1d-334f-40b2-98d4-55db58965f5f
connection.type: dummy''') # wokeignore:rule=dummy
connection:
uuid: 87749f1d-334f-40b2-98d4-55db58965f5f
type: dummy''') # wokeignore:rule=dummy

self.assert_nm({'NM-87749f1d-334f-40b2-98d4-55db58965f5f': '''[connection]
id=netplan-NM-87749f1d-334f-40b2-98d4-55db58965f5f
Expand All @@ -149,7 +240,38 @@ def test_passthrough_dotted_group(self):
networkmanager:
passthrough:
connection.type: "wireguard"
wireguard-peer.some-key.endpoint: 1.2.3.4''')
wireguard-peer.some-key.endpoint: 1.2.3.4''', skip_generated_yaml_validation=True)

self.assert_nm({'dotted-group-test': '''[connection]
id=netplan-dotted-group-test
#Netplan: passthrough setting
type=wireguard
[ipv4]
method=link-local
[ipv6]
method=ignore
[wireguard-peer.some-key]
#Netplan: passthrough setting
endpoint=1.2.3.4
'''}, '''[device-netplan.nm-devices.dotted-group-test]
match-device=type:wireguard
managed=1\n\n''')

def test_passthrough_dotted_group_new_format(self):
self.generate('''network:
nm-devices:
dotted-group-test:
renderer: NetworkManager
match: {}
networkmanager:
passthrough:
connection:
type: "wireguard"
wireguard-peer.some-key:
endpoint: 1.2.3.4''')

self.assert_nm({'dotted-group-test': '''[connection]
id=netplan-dotted-group-test
Expand Down Expand Up @@ -179,7 +301,7 @@ def test_passthrough_dotted_key(self):
passthrough:
tc.qdisc.root: something
tc.qdisc.fff1: ":abc"
tc.filters.test: "test"''')
tc.filters.test: "test"''', skip_generated_yaml_validation=True)

self.assert_nm({'dotted-key-test': '''[connection]
id=netplan-dotted-key-test
Expand All @@ -198,9 +320,46 @@ def test_passthrough_dotted_key(self):
#Netplan: passthrough setting
qdisc.root=something
#Netplan: passthrough setting
filters.test=test
#Netplan: passthrough setting
qdisc.fff1=:abc
'''}, '''[device-netplan.ethernets.dotted-key-test]
match-device=type:ethernet
managed=1\n\n''')

def test_passthrough_dotted_key_new_format(self):
self.generate('''network:
ethernets:
dotted-key-test:
renderer: NetworkManager
match: {}
networkmanager:
passthrough:
tc:
qdisc.root: something
qdisc.fff1: ":abc"
filters.test: "test"''')

self.assert_nm({'dotted-key-test': '''[connection]
id=netplan-dotted-key-test
type=ethernet
[ethernet]
wake-on-lan=0
[ipv4]
method=link-local
[ipv6]
method=ignore
[tc]
#Netplan: passthrough setting
qdisc.root=something
#Netplan: passthrough setting
filters.test=test
#Netplan: passthrough setting
qdisc.fff1=:abc
'''}, '''[device-netplan.ethernets.dotted-key-test]
match-device=type:ethernet
managed=1\n\n''')
Expand All @@ -215,7 +374,8 @@ def test_passthrough_unsupported_setting(self):
"SOME-SSID": # implicit "mode: infrasturcutre"
networkmanager:
passthrough:
wifi.mode: "mesh"''')
wifi:
mode: "mesh"''')

self.assert_nm({'test-SOME-SSID': '''[connection]
id=netplan-test-SOME-SSID
Expand Down Expand Up @@ -243,7 +403,7 @@ def test_passthrough_empty_group(self):
match: {}
networkmanager:
passthrough:
proxy._: ""''')
proxy: {}''')

self.assert_nm({'test': '''[connection]
id=netplan-test
Expand Down Expand Up @@ -311,7 +471,8 @@ def test_passthrough_ip6_privacy_default(self):
uuid: 626dd384-8b3d-3690-9511-192b2c79b3fd
name: "netplan-eth0"
passthrough:
"ipv6.ip6-privacy": "-1"
ipv6:
ip6-privacy: -1
''')

self.assert_nm({'eth0': '''[connection]
Expand Down
Loading

0 comments on commit ac0fb98

Please sign in to comment.