Skip to content

Commit a0a1e0d

Browse files
committed
[wpasupplicant] last test needed and last changes to make test pass
1 parent f2e740e commit a0a1e0d

3 files changed

Lines changed: 80 additions & 13 deletions

File tree

netjsonconfig/backends/airos/converters.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,28 +720,41 @@ def _access_point_intermediate(self, original):
720720
result = []
721721
ap_auth_protocols = available_mode_authentication['access_point']
722722

723+
temp_dev = {
724+
'profile': 'AUTO',
725+
'status': 'disabled',
726+
}
727+
723728
if original:
724729
head = original[0]
725730

726731
if 'encryption' in head:
727732
network = ap_auth_protocols.get(head['encryption']['protocol'])(head)
733+
result.append({
734+
'status': 'disabled',
735+
})
728736

729737
else:
730738
network = ap_auth_protocols['none'](head)
739+
temp_dev['status'] = 'enabled'
740+
result.append({
741+
'status': 'enabled',
742+
})
731743

732744
result.append({
745+
'device': [
746+
temp_dev,
747+
],
733748
'profile': [
734749
{
750+
'name': 'AUTO',
735751
'network': [
736752
network,
737753
self.secondary_network(),
738754
],
739755
},
740756
],
741757
})
742-
result.append({
743-
'status': 'enabled',
744-
})
745758

746759
return (('wpasupplicant', result),)
747760

netjsonconfig/backends/airos/wpasupplicant.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ def ap_no_encryption(interface):
55
"""
66
return {
77
'ssid': interface['wireless']['ssid'],
8+
'priority': 100,
89
'key_mgmt': [
910
{
1011
'name': 'NONE',
@@ -22,6 +23,12 @@ def ap_wpa2_personal(interface):
2223
return {
2324
'psk': interface['encryption']['key'],
2425
'ssid': interface['wireless']['ssid'],
26+
'key_mgmt': [
27+
{
28+
'name': 'NONE',
29+
},
30+
],
31+
'priority': 100,
2532
}
2633

2734

tests/airos/test_wpasupplicant.py

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def test_no_encryption(self):
5454
"ssid": "ap-ssid-example",
5555
"bssid": "00:11:22:33:44:55",
5656
},
57-
"encryption": {
58-
"protocol": "none",
59-
},
57+
# "encryption": {
58+
# "protocol": "none",
59+
# },
6060
}
6161
]
6262
})
@@ -130,7 +130,7 @@ def test_wpa2_personal(self):
130130
},
131131
{
132132
'status': 'enabled',
133-
}
133+
},
134134
]
135135

136136
self.assertEqualConfig(o.intermediate_data['wpasupplicant'], expected)
@@ -163,6 +163,9 @@ def test_wpa2_enterprise(self):
163163
o.to_intermediate()
164164

165165
expected = [
166+
{
167+
'status': 'enabled',
168+
},
166169
{
167170
'device.1.profile': 'AUTO',
168171
'device.1.status': 'enabled',
@@ -185,9 +188,6 @@ def test_wpa2_enterprise(self):
185188
'profile.1.network.2.priority': 2,
186189
'profile.1.network.2.status': 'disabled',
187190
},
188-
{
189-
'status': 'enabled',
190-
}
191191
]
192192

193193
self.assertEqualConfig(o.intermediate_data['wpasupplicant'], expected)
@@ -203,6 +203,50 @@ class TestWpasupplicantAccess(ConverterTest):
203203

204204
def test_no_encryption(self):
205205

206+
o = self.backend({
207+
"interfaces": [
208+
{
209+
"type": "wireless",
210+
"name": "wlan0",
211+
"mac": "de:9f:db:30:c9:c5",
212+
"mtu": 1500,
213+
"txqueuelen": 1000,
214+
"autostart": True,
215+
"wireless": {
216+
"radio": "radio0",
217+
"mode": "access_point",
218+
"ssid": "ap-ssid-example",
219+
},
220+
# "encryption": {
221+
# "protocol": "none",
222+
# },
223+
},
224+
]
225+
})
226+
227+
o.to_intermediate()
228+
229+
expected = [
230+
{
231+
'status': 'enabled',
232+
},
233+
{
234+
'device.1.profile': 'AUTO',
235+
'device.1.status': 'enabled',
236+
'profile.1.name': 'AUTO',
237+
'profile.1.network.1.priority': 100,
238+
'profile.1.network.1.ssid': 'ap-ssid-example',
239+
'profile.1.network.1.key_mgmt.1.name': 'NONE',
240+
'profile.1.network.2.key_mgmt.1.name': 'NONE',
241+
'profile.1.network.2.priority': 2,
242+
'profile.1.network.2.status': 'disabled',
243+
},
244+
]
245+
246+
self.assertEqualConfig(o.intermediate_data['wpasupplicant'], expected)
247+
248+
def test_wpa2_personal(self):
249+
206250
o = self.backend({
207251
"interfaces": [
208252
{
@@ -218,7 +262,8 @@ def test_no_encryption(self):
218262
"ssid": "ap-ssid-example",
219263
},
220264
"encryption": {
221-
"protocol": "none",
265+
"protocol": "wpa2_personal",
266+
"key": "cucumber",
222267
},
223268
}
224269
]
@@ -228,13 +273,15 @@ def test_no_encryption(self):
228273

229274
expected = [
230275
{
231-
'status': 'enabled',
276+
'status': 'disabled',
232277
},
233278
{
234279
'device.1.profile': 'AUTO',
235-
'device.1.status': 'enabled',
280+
'device.1.status': 'disabled',
281+
'profile.1.name': 'AUTO',
236282
'profile.1.network.1.priority': 100,
237283
'profile.1.network.1.ssid': 'ap-ssid-example',
284+
'profile.1.network.1.psk': 'cucumber',
238285
'profile.1.network.1.key_mgmt.1.name': 'NONE',
239286
'profile.1.network.2.key_mgmt.1.name': 'NONE',
240287
'profile.1.network.2.priority': 2,

0 commit comments

Comments
 (0)