Skip to content

Commit ae16a60

Browse files
author
Ritwick DSouza
committed
[raspbian] Addded tests for macaddr acl
1 parent d9961e8 commit ae16a60

1 file changed

Lines changed: 126 additions & 0 deletions

File tree

tests/raspbian/test_hostapd.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,131 @@ def test_no_encryption(self):
301301
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
302302
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
303303
304+
'''
305+
self.assertEqual(o.render(), expected)
306+
307+
def test_macaddracl_accept(self):
308+
o = Raspbian({
309+
"radios": [
310+
{
311+
"name": "radio0",
312+
"phy": "phy0",
313+
"driver": "mac80211",
314+
"protocol": "802.11n",
315+
"channel": 3,
316+
"channel_width": 20,
317+
"tx_power": 3
318+
},
319+
],
320+
"interfaces": [
321+
{
322+
"name": "wlan0",
323+
"type": "wireless",
324+
"wireless": {
325+
"radio": "radio0",
326+
"mode": "access_point",
327+
"ssid": "MyWifiAP",
328+
"macfilter": "accept",
329+
"maclist": [
330+
"E8:94:F6:33:8C:1D",
331+
"42:6c:8f:95:0f:00"
332+
]
333+
}
334+
}
335+
]
336+
})
337+
338+
expected = '''# config: /etc/hostapd/hostapd.conf
339+
340+
interface=wlan0
341+
driver=nl80211
342+
hw_mode=g
343+
channel=3
344+
ieee80211n=1
345+
ssid=MyWifiAP
346+
macaddr_acl=1
347+
accept_mac_file=/etc/hostapd.accept
348+
349+
# config: /etc/hostapd.accept
350+
351+
E8:94:F6:33:8C:1D
352+
42:6c:8f:95:0f:00
353+
354+
# config: /etc/network/interfaces
355+
356+
auto wlan0
357+
iface wlan0 inet manual
358+
359+
# script: /scripts/ipv4_forwarding.sh
360+
361+
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
362+
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
363+
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
364+
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
365+
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
366+
367+
'''
368+
self.assertEqual(o.render(), expected)
369+
370+
def test_macaddracl_deny(self):
371+
o = Raspbian({
372+
"radios": [
373+
{
374+
"name": "radio0",
375+
"phy": "phy0",
376+
"driver": "mac80211",
377+
"protocol": "802.11n",
378+
"channel": 3,
379+
"channel_width": 20,
380+
"tx_power": 3
381+
},
382+
],
383+
"interfaces": [
384+
{
385+
"name": "wlan0",
386+
"type": "wireless",
387+
"wireless": {
388+
"radio": "radio0",
389+
"mode": "access_point",
390+
"ssid": "MyWifiAP",
391+
"macfilter": "deny",
392+
"maclist": [
393+
"E8:94:F6:33:8C:1D",
394+
"42:6c:8f:95:0f:00"
395+
]
396+
}
397+
}
398+
]
399+
})
400+
401+
expected = '''# config: /etc/hostapd/hostapd.conf
402+
403+
interface=wlan0
404+
driver=nl80211
405+
hw_mode=g
406+
channel=3
407+
ieee80211n=1
408+
ssid=MyWifiAP
409+
macaddr_acl=0
410+
deny_mac_file=/etc/hostapd.deny
411+
412+
# config: /etc/hostapd.deny
413+
414+
E8:94:F6:33:8C:1D
415+
42:6c:8f:95:0f:00
416+
417+
# config: /etc/network/interfaces
418+
419+
auto wlan0
420+
iface wlan0 inet manual
421+
422+
# script: /scripts/ipv4_forwarding.sh
423+
424+
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
425+
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
426+
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
427+
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
428+
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
429+
304430
'''
305431
self.assertEqual(o.render(), expected)

0 commit comments

Comments
 (0)