test_ap_config.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # hostapd configuration tests
  2. # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. from remotehost import remote_compatible
  7. import hostapd
  8. @remote_compatible
  9. def test_ap_config_errors(dev, apdev):
  10. """Various hostapd configuration errors"""
  11. # IEEE 802.11d without country code
  12. params = { "ssid": "foo", "ieee80211d": "1" }
  13. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  14. if "FAIL" not in hapd.request("ENABLE"):
  15. raise Exception("Unexpected ENABLE success (ieee80211d without country_code)")
  16. hostapd.remove_bss(apdev[0])
  17. # IEEE 802.11h without IEEE 802.11d
  18. params = { "ssid": "foo", "ieee80211h": "1" }
  19. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  20. if "FAIL" not in hapd.request("ENABLE"):
  21. raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d")
  22. hostapd.remove_bss(apdev[0])
  23. # Power Constraint without IEEE 802.11d
  24. params = { "ssid": "foo", "local_pwr_constraint": "1" }
  25. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  26. if "FAIL" not in hapd.request("ENABLE"):
  27. raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)")
  28. hostapd.remove_bss(apdev[0])
  29. # Spectrum management without Power Constraint
  30. params = { "ssid": "foo", "spectrum_mgmt_required": "1" }
  31. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  32. if "FAIL" not in hapd.request("ENABLE"):
  33. raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)")
  34. hostapd.remove_bss(apdev[0])
  35. # IEEE 802.1X without authentication server
  36. params = { "ssid": "foo", "ieee8021x": "1" }
  37. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  38. if "FAIL" not in hapd.request("ENABLE"):
  39. raise Exception("Unexpected ENABLE success (ieee8021x)")
  40. hostapd.remove_bss(apdev[0])
  41. # RADIUS-PSK without macaddr_acl=2
  42. params = hostapd.wpa2_params(ssid="foo", passphrase="12345678")
  43. params["wpa_psk_radius"] = "1"
  44. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  45. if "FAIL" not in hapd.request("ENABLE"):
  46. raise Exception("Unexpected ENABLE success (wpa_psk_radius)")
  47. hostapd.remove_bss(apdev[0])
  48. # FT without NAS-Identifier
  49. params = { "wpa": "2",
  50. "wpa_key_mgmt": "FT-PSK",
  51. "rsn_pairwise": "CCMP",
  52. "wpa_passphrase": "12345678" }
  53. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  54. if "FAIL" not in hapd.request("ENABLE"):
  55. raise Exception("Unexpected ENABLE success (FT without nas_identifier)")
  56. hostapd.remove_bss(apdev[0])
  57. # Hotspot 2.0 without WPA2/CCMP
  58. params = hostapd.wpa2_params(ssid="foo")
  59. params['wpa_key_mgmt'] = "WPA-EAP"
  60. params['ieee8021x'] = "1"
  61. params['auth_server_addr'] = "127.0.0.1"
  62. params['auth_server_port'] = "1812"
  63. params['auth_server_shared_secret'] = "radius"
  64. params['interworking'] = "1"
  65. params['hs20'] = "1"
  66. params['wpa'] = "1"
  67. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  68. if "FAIL" not in hapd.request("ENABLE"):
  69. raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)")
  70. hostapd.remove_bss(apdev[0])