tests: Pending EAP peer processing with VENDOR-TEST
authorJouni Malinen <j@w1.fi>
Tue, 27 Jan 2015 23:39:35 +0000 (01:39 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 28 Jan 2015 11:09:31 +0000 (13:09 +0200)
This extends the VENDOR-TEST EAP method peer implementation to allow
pending processing case to be selected at run time. The
ap_wpa2_eap_vendor_test test case is similarly extended to include this
option as the second case for full coverage.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/eap_peer/eap_vendor_test.c
tests/hwsim/test_ap_eap.py

index 040d1e7..b61057e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * EAP peer method: Test method for vendor specific (expanded) EAP type
- * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2005-2015, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
 
 #include "common.h"
 #include "eap_i.h"
-#ifdef TEST_PENDING_REQUEST
 #include "eloop.h"
-#endif /* TEST_PENDING_REQUEST */
 
 
 #define EAP_VENDOR_ID EAP_VENDOR_HOSTAP
 #define EAP_VENDOR_TYPE 0xfcfbfaf9
 
 
-/* #define TEST_PENDING_REQUEST */
-
 struct eap_vendor_test_data {
        enum { INIT, CONFIRM, SUCCESS } state;
        int first_try;
+       int test_pending_req;
 };
 
 
 static void * eap_vendor_test_init(struct eap_sm *sm)
 {
        struct eap_vendor_test_data *data;
+       const u8 *password;
+       size_t password_len;
+
        data = os_zalloc(sizeof(*data));
        if (data == NULL)
                return NULL;
        data->state = INIT;
        data->first_try = 1;
+
+       password = eap_get_config_password(sm, &password_len);
+       data->test_pending_req = password && password_len == 7 &&
+               os_memcmp(password, "pending", 7) == 0;
+
        return data;
 }
 
@@ -50,7 +55,6 @@ static void eap_vendor_test_deinit(struct eap_sm *sm, void *priv)
 }
 
 
-#ifdef TEST_PENDING_REQUEST
 static void eap_vendor_ready(void *eloop_ctx, void *timeout_ctx)
 {
        struct eap_sm *sm = eloop_ctx;
@@ -58,7 +62,6 @@ static void eap_vendor_ready(void *eloop_ctx, void *timeout_ctx)
                   "request");
        eap_notify_pending(sm);
 }
-#endif /* TEST_PENDING_REQUEST */
 
 
 static struct wpabuf * eap_vendor_test_process(struct eap_sm *sm, void *priv,
@@ -98,8 +101,7 @@ static struct wpabuf * eap_vendor_test_process(struct eap_sm *sm, void *priv,
        }
 
        if (data->state == CONFIRM) {
-#ifdef TEST_PENDING_REQUEST
-               if (data->first_try) {
+               if (data->test_pending_req && data->first_try) {
                        data->first_try = 0;
                        wpa_printf(MSG_DEBUG, "EAP-VENDOR-TEST: Testing "
                                   "pending request");
@@ -108,7 +110,6 @@ static struct wpabuf * eap_vendor_test_process(struct eap_sm *sm, void *priv,
                                               NULL);
                        return NULL;
                }
-#endif /* TEST_PENDING_REQUEST */
        }
 
        ret->ignore = FALSE;
index 71f9a65..600fcfa 100644 (file)
@@ -1870,6 +1870,8 @@ def test_ap_wpa2_eap_vendor_test(dev, apdev):
     hostapd.add_ap(apdev[0]['ifname'], params)
     eap_connect(dev[0], apdev[0], "VENDOR-TEST", "vendor-test")
     eap_reauth(dev[0], "VENDOR-TEST")
+    eap_connect(dev[1], apdev[0], "VENDOR-TEST", "vendor-test",
+                password="pending")
 
 def test_ap_wpa2_eap_fast_mschapv2_unauth_prov(dev, apdev):
     """WPA2-Enterprise connection using EAP-FAST/MSCHAPv2 and unauthenticated provisioning"""