test_wep.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # WEP 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. import hwsim_utils
  8. def test_wep_open_auth(dev, apdev):
  9. """WEP Open System authentication"""
  10. hostapd.add_ap(apdev[0]['ifname'],
  11. { "ssid": "wep-open",
  12. "wep_key0": '"hello"' })
  13. dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"',
  14. scan_freq="2412")
  15. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  16. def test_wep_shared_key_auth(dev, apdev):
  17. """WEP Shared Key authentication"""
  18. hostapd.add_ap(apdev[0]['ifname'],
  19. { "ssid": "wep-shared-key",
  20. "wep_key0": '"hello12345678"',
  21. "auth_algs": "2" })
  22. dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
  23. wep_key0='"hello12345678"',
  24. scan_freq="2412")
  25. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  26. dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED",
  27. wep_key0='"hello12345678"',
  28. scan_freq="2412")
  29. def test_wep_shared_key_auth_not_allowed(dev, apdev):
  30. """WEP Shared Key authentication not allowed"""
  31. hostapd.add_ap(apdev[0]['ifname'],
  32. { "ssid": "wep-shared-key",
  33. "wep_key0": '"hello12345678"',
  34. "auth_algs": "1" })
  35. dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
  36. wep_key0='"hello12345678"',
  37. scan_freq="2412", wait_connect=False)
  38. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
  39. if ev is not None:
  40. raise Exception("Unexpected association")