test_ap_config.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. import hostapd
  7. def test_ap_config_errors(dev, apdev):
  8. """Various hostapd configuration errors"""
  9. # IEEE 802.11d without country code
  10. params = { "ssid": "foo", "ieee80211d": "1" }
  11. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  12. if "FAIL" not in hapd.request("ENABLE"):
  13. raise Exception("Unexpected ENABLE success (ieee80211d without country_code)")
  14. hostapd.remove_bss(apdev[0])
  15. # IEEE 802.11h without IEEE 802.11d
  16. params = { "ssid": "foo", "ieee80211h": "1" }
  17. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  18. if "FAIL" not in hapd.request("ENABLE"):
  19. raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d")
  20. hostapd.remove_bss(apdev[0])
  21. # Power Constraint without IEEE 802.11d
  22. params = { "ssid": "foo", "local_pwr_constraint": "1" }
  23. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  24. if "FAIL" not in hapd.request("ENABLE"):
  25. raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)")
  26. hostapd.remove_bss(apdev[0])
  27. # Spectrum management without Power Constraint
  28. params = { "ssid": "foo", "spectrum_mgmt_required": "1" }
  29. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  30. if "FAIL" not in hapd.request("ENABLE"):
  31. raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)")
  32. hostapd.remove_bss(apdev[0])
  33. # IEEE 802.1X without authentication server
  34. params = { "ssid": "foo", "ieee8021x": "1" }
  35. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  36. if "FAIL" not in hapd.request("ENABLE"):
  37. raise Exception("Unexpected ENABLE success (ieee8021x)")
  38. hostapd.remove_bss(apdev[0])
  39. # RADIUS-PSK without macaddr_acl=2
  40. params = hostapd.wpa2_params(ssid="foo", passphrase="12345678")
  41. params["wpa_psk_radius"] = "1"
  42. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  43. if "FAIL" not in hapd.request("ENABLE"):
  44. raise Exception("Unexpected ENABLE success (wpa_psk_radius)")
  45. hostapd.remove_bss(apdev[0])
  46. # FT without NAS-Identifier
  47. params = { "wpa": "2",
  48. "wpa_key_mgmt": "FT-PSK",
  49. "rsn_pairwise": "CCMP",
  50. "wpa_passphrase": "12345678" }
  51. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  52. if "FAIL" not in hapd.request("ENABLE"):
  53. raise Exception("Unexpected ENABLE success (FT without nas_identifier)")
  54. hostapd.remove_bss(apdev[0])
  55. # Hotspot 2.0 without WPA2/CCMP
  56. params = hostapd.wpa2_params(ssid="foo")
  57. params['wpa_key_mgmt'] = "WPA-EAP"
  58. params['ieee8021x'] = "1"
  59. params['auth_server_addr'] = "127.0.0.1"
  60. params['auth_server_port'] = "1812"
  61. params['auth_server_shared_secret'] = "radius"
  62. params['interworking'] = "1"
  63. params['hs20'] = "1"
  64. params['wpa'] = "1"
  65. hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
  66. if "FAIL" not in hapd.request("ENABLE"):
  67. raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)")
  68. hostapd.remove_bss(apdev[0])