]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: WEP
authorJouni Malinen <j@w1.fi>
Fri, 31 Jan 2014 21:34:09 +0000 (23:34 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 4 Feb 2014 11:10:57 +0000 (13:10 +0200)
Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/test_wep.py [new file with mode: 0644]
tests/hwsim/wpasupplicant.py

diff --git a/tests/hwsim/test_wep.py b/tests/hwsim/test_wep.py
new file mode 100644 (file)
index 0000000..7b70484
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+#
+# WEP tests
+# Copyright (c) 2014, Jouni Malinen <j@w1.fi>
+#
+# This software may be distributed under the terms of the BSD license.
+# See README for more details.
+
+import hostapd
+import hwsim_utils
+
+def test_wep_open_auth(dev, apdev):
+    """WEP Open System authentication"""
+    hostapd.add_ap(apdev[0]['ifname'],
+                   { "ssid": "wep-open",
+                     "wep_key0": '"hello"' })
+    dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"',
+                   scan_freq="2412")
+    hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
+
+def test_wep_shared_key_auth(dev, apdev):
+    """WEP Shared Key authentication"""
+    hostapd.add_ap(apdev[0]['ifname'],
+                   { "ssid": "wep-shared-key",
+                     "wep_key0": '"hello12345678"',
+                     "auth_algs": "2" })
+    dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
+                   wep_key0='"hello12345678"',
+                   scan_freq="2412")
+    hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
+    dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED",
+                   wep_key0='"hello12345678"',
+                   scan_freq="2412")
+
+def test_wep_shared_key_auth_not_allowed(dev, apdev):
+    """WEP Shared Key authentication not allowed"""
+    hostapd.add_ap(apdev[0]['ifname'],
+                   { "ssid": "wep-shared-key",
+                     "wep_key0": '"hello12345678"',
+                     "auth_algs": "1" })
+    dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
+                   wep_key0='"hello12345678"',
+                   scan_freq="2412", wait_connect=False)
+    ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
+    if ev is not None:
+        raise Exception("Unexpected association")
index 3707cbb54acd2fc058d07c5a5a5f9b9d8c988490..ee4f9890c0a560c2b34e711b3c229122f10a6f39 100644 (file)
@@ -594,7 +594,7 @@ class WpaSupplicant:
                 ca_cert2=None, client_cert2=None, private_key2=None,
                 scan_ssid=None, raw_psk=None, pac_file=None,
                 subject_match=None, altsubject_match=None,
-                private_key_passwd=None, ocsp=None):
+                private_key_passwd=None, ocsp=None, auth_alg=None):
         logger.info("Connect STA " + self.ifname + " to AP")
         id = self.add_network()
         if ssid:
@@ -672,6 +672,8 @@ class WpaSupplicant:
             self.set_network_quoted(id, "pac_file", pac_file)
         if ocsp:
             self.set_network(id, "ocsp", str(ocsp))
+        if auth_alg:
+            self.set_network(id, "auth_alg", auth_alg)
         if only_add_network:
             return id
         if wait_connect: