Browse Source

tests: Fix eap_fast_tlv_nak_oom and eap_fast_proto_phase2

Something broke eap_fast_tlv_nak_oom when moving from Ubuntu 14.04 to
16.04. OpenSSL.SSL.Connection() state_string() returns None in these
cases and the debug log prints for that were causing the case to fail.
For now, work around this by checking whether the state string is None
before trying to print it.

Signed-off-by: Jouni Malinen <j@w1.fi>
Jouni Malinen 8 years ago
parent
commit
6219943d57
1 changed files with 18 additions and 6 deletions
  1. 18 6
      tests/hwsim/test_eap_proto.py

+ 18 - 6
tests/hwsim/test_eap_proto.py

@@ -8037,31 +8037,43 @@ def run_eap_fast_phase2(dev, test_payload, test_failure=True):
         ctx['sslctx'].set_cipher_list("ADH-AES128-SHA")
         ctx['sslctx'].set_cipher_list("ADH-AES128-SHA")
         ctx['conn'] = OpenSSL.SSL.Connection(ctx['sslctx'], None)
         ctx['conn'] = OpenSSL.SSL.Connection(ctx['sslctx'], None)
         ctx['conn'].set_accept_state()
         ctx['conn'].set_accept_state()
-        logger.info("State: " + ctx['conn'].state_string())
+        state = ctx['conn'].state_string()
+        if state:
+            logger.info("State: " + state)
         ctx['conn'].bio_write(payload)
         ctx['conn'].bio_write(payload)
         try:
         try:
             ctx['conn'].do_handshake()
             ctx['conn'].do_handshake()
         except OpenSSL.SSL.WantReadError:
         except OpenSSL.SSL.WantReadError:
             pass
             pass
-        logger.info("State: " + ctx['conn'].state_string())
+        state = ctx['conn'].state_string()
+        if state:
+            logger.info("State: " + state)
         data = ctx['conn'].bio_read(4096)
         data = ctx['conn'].bio_read(4096)
-        logger.info("State: " + ctx['conn'].state_string())
+        state = ctx['conn'].state_string()
+        if state:
+            logger.info("State: " + state)
         return struct.pack(">BBHBB", EAP_CODE_REQUEST, ctx['id'],
         return struct.pack(">BBHBB", EAP_CODE_REQUEST, ctx['id'],
                            4 + 1 + 1 + len(data),
                            4 + 1 + 1 + len(data),
                            EAP_TYPE_FAST, 0x01) + data
                            EAP_TYPE_FAST, 0x01) + data
 
 
     def process_clientkeyexchange(ctx, payload, appl_data):
     def process_clientkeyexchange(ctx, payload, appl_data):
         logger.info("Process ClientKeyExchange")
         logger.info("Process ClientKeyExchange")
-        logger.info("State: " + ctx['conn'].state_string())
+        state = ctx['conn'].state_string()
+        if state:
+            logger.info("State: " + state)
         ctx['conn'].bio_write(payload)
         ctx['conn'].bio_write(payload)
         try:
         try:
             ctx['conn'].do_handshake()
             ctx['conn'].do_handshake()
         except OpenSSL.SSL.WantReadError:
         except OpenSSL.SSL.WantReadError:
             pass
             pass
         ctx['conn'].send(appl_data)
         ctx['conn'].send(appl_data)
-        logger.info("State: " + ctx['conn'].state_string())
+        state = ctx['conn'].state_string()
+        if state:
+            logger.info("State: " + state)
         data = ctx['conn'].bio_read(4096)
         data = ctx['conn'].bio_read(4096)
-        logger.info("State: " + ctx['conn'].state_string())
+        state = ctx['conn'].state_string()
+        if state:
+            logger.info("State: " + state)
         return struct.pack(">BBHBB", EAP_CODE_REQUEST, ctx['id'],
         return struct.pack(">BBHBB", EAP_CODE_REQUEST, ctx['id'],
                            4 + 1 + 1 + len(data),
                            4 + 1 + 1 + len(data),
                            EAP_TYPE_FAST, 0x01) + data
                            EAP_TYPE_FAST, 0x01) + data