Skip to content

Commit 67048e9

Browse files
committed
[airos] make flake happier
1 parent 8782688 commit 67048e9

2 files changed

Lines changed: 103 additions & 4 deletions

File tree

netjsonconfig/backends/airos/radius.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .interface import encryption, mode, protocol
22

3+
34
def ap_authentication(interface):
45
"""
56
Returns the ``radius.auth`` dict for ``access_point`` interface
@@ -15,7 +16,7 @@ def ap_authentication(interface):
1516
result.update({
1617
'ip': enc.get('server', ''),
1718
'port': enc.get('port', 1812),
18-
'secret': enc.get('key',''),
19+
'secret': enc.get('key', ''),
1920
'status': 'enabled',
2021
})
2122
return result
@@ -42,7 +43,6 @@ def authentication(interface):
4243
result = {
4344
'port': 1812,
4445
}
45-
mod = mode(interface)
4646
result.update(_authentication_from_mode[mode(interface)](interface))
4747
return result
4848

@@ -61,6 +61,7 @@ def ap_accounting(interface):
6161
})
6262
return result
6363

64+
6465
def sta_accounting(interface):
6566
"""
6667
Returns the ``acct`` dict for ``station`` interfaces
@@ -86,7 +87,6 @@ def accounting(interface):
8687
return result
8788

8889

89-
9090
def radius_from_interface(interface):
9191
"""
9292
Return the ``radius`` configuration for

tests/airos/test_aaa.py

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .mock import AaaAirOs, ConverterTest
22

33

4-
class TestAaaConverter(ConverterTest):
4+
class TestAaaConverterAccess(ConverterTest):
55

66
backend = AaaAirOs
77

@@ -92,6 +92,64 @@ def test_ap_psk_authentication(self):
9292
]
9393
self.assertEqualConfig(o.intermediate_data['aaa'], expected)
9494

95+
def test_ap_eap_authentication(self):
96+
o = self.backend({
97+
"interfaces": [
98+
{
99+
"type": "wireless",
100+
"name": "wlan0",
101+
"wireless": {
102+
"mode": "access_point",
103+
"radio": "ath0",
104+
"ssid": "i-like-pasta",
105+
"encryption": {
106+
"protocol": "wpa2_enterprise",
107+
"key": "secret-radius-key",
108+
"server": "192.168.1.1",
109+
"acct_server": "192.168.1.2",
110+
},
111+
},
112+
},
113+
{
114+
"type": "bridge",
115+
"name": "br0",
116+
"bridge_members": [
117+
"wlan0",
118+
],
119+
},
120+
],
121+
})
122+
o.to_intermediate()
123+
expected = [
124+
{
125+
'status': 'enabled',
126+
},
127+
{
128+
'1.br.devname': 'br0', # only in bridge mode?
129+
'1.devname': 'ath0',
130+
'1.driver': 'madwifi',
131+
'1.radius.acct.1.port': 1813,
132+
'1.radius.acct.1.status': 'enabled',
133+
'1.radius.acct.1.ip': '192.168.1.2',
134+
'1.radius.auth.1.ip': '192.168.1.1',
135+
'1.radius.auth.1.port': 1812,
136+
'1.radius.auth.1.secret': 'secret-radius-key',
137+
'1.radius.auth.1.status': 'enabled',
138+
'1.radius.macacl.status': 'disabled',
139+
'1.ssid': 'i-like-pasta',
140+
'1.status': 'enabled',
141+
'1.wpa.1.pairwise': 'CCMP',
142+
'1.wpa.key.1.mgmt': 'WPA-EAP',
143+
'1.wpa.mode': 2,
144+
}
145+
]
146+
self.assertEqualConfig(o.intermediate_data['aaa'], expected)
147+
148+
149+
class TestAaaConverterStation(ConverterTest):
150+
151+
backend = AaaAirOs
152+
95153
def test_sta_no_authentication(self):
96154
o = self.backend({
97155
"interfaces": [
@@ -171,3 +229,44 @@ def test_sta_psk_authentication(self):
171229
},
172230
]
173231
self.assertEqualConfig(o.intermediate_data['aaa'], expected)
232+
233+
def test_sta_eap_authentication(self):
234+
o = self.backend({
235+
"interfaces": [
236+
{
237+
"type": "wireless",
238+
"name": "wlan0",
239+
"wireless": {
240+
"mode": "station",
241+
"radio": "ath0",
242+
"ssid": "i-like-pasta",
243+
"bssid": "00:11:22:33:44:55",
244+
"encryption": {
245+
"protocol": "wpa2_enterprise",
246+
"identity": "some-fake-identity",
247+
"password": "password1234",
248+
},
249+
},
250+
},
251+
{
252+
"type": "bridge",
253+
"name": "br0",
254+
"bridge_members": [
255+
"wlan0",
256+
],
257+
},
258+
],
259+
})
260+
o.to_intermediate()
261+
expected = [
262+
{
263+
'status': 'disabled',
264+
},
265+
{
266+
'1.radius.acct.1.port': 1813,
267+
'1.radius.acct.1.status': 'disabled',
268+
'1.radius.auth.1.port': 1812,
269+
'1.status': 'disabled',
270+
},
271+
]
272+
self.assertEqualConfig(o.intermediate_data['aaa'], expected)

0 commit comments

Comments
 (0)