From: Jouni Malinen Date: Sun, 7 Mar 2021 15:58:14 +0000 (+0200) Subject: tests: EAP-SIM DB error cases (SQLite) X-Git-Tag: hostap_2_10~445 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf47a433358d856f32bfd78833992457ed59b2aa;p=thirdparty%2Fhostap.git tests: EAP-SIM DB error cases (SQLite) Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index d3f140323..9efa2b47d 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -6715,6 +6715,62 @@ def test_ap_wpa2_eap_sim_db(dev, apdev, params): dev[0].request("DISCONNECT") dev[0].wait_disconnected() +def test_ap_wpa2_eap_sim_db_sqlite(dev, apdev, params): + """EAP-SIM DB error cases (SQLite)""" + sockpath = '/tmp/hlr_auc_gw.sock-test' + try: + os.remove(sockpath) + except: + pass + hparams = int_eap_server_params() + hparams['eap_sim_db'] = 'unix:' + sockpath + hapd = hostapd.add_ap(apdev[0], hparams) + + fname = params['prefix'] + ".milenage_db.sqlite" + cmd = subprocess.Popen(['../../hostapd/hlr_auc_gw', + '-D', fname, "FOO"], + stdout=subprocess.PIPE) + res = cmd.stdout.read().decode().strip() + cmd.stdout.close() + logger.debug("hlr_auc_gw response: " + res) + + try: + import sqlite3 + except ImportError: + raise HwsimSkip("No sqlite3 module available") + con = sqlite3.connect(fname) + with con: + cur = con.cursor() + try: + cur.execute("INSERT INTO milenage(imsi,ki,opc,amf,sqn) VALUES ('232010000000000', '90dca4eda45b53cf0f12d7c9c3bc6a89', 'cb9cccc4b9258e6dca4760379fb82581', '61df', '000000000000')") + except sqlite3.IntegrityError as e: + pass + + class test_handler3(SocketServer.DatagramRequestHandler): + def handle(self): + data = self.request[0].decode().strip() + socket = self.request[1] + logger.debug("Received hlr_auc_gw request: " + data) + cmd = subprocess.Popen(['../../hostapd/hlr_auc_gw', + '-D', fname, data], + stdout=subprocess.PIPE) + res = cmd.stdout.read().decode().strip() + cmd.stdout.close() + logger.debug("hlr_auc_gw response: " + res) + socket.sendto(res.encode(), self.client_address) + + server = SocketServer.UnixDatagramServer(sockpath, test_handler3) + server.timeout = 1 + + id = dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP WPA-EAP-SHA256", + eap="SIM", identity="1232010000000000", + password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581", + scan_freq="2412", wait_connect=False) + server.handle_request() + dev[0].wait_connected() + dev[0].request("DISCONNECT") + dev[0].wait_disconnected() + def test_eap_tls_sha512(dev, apdev, params): """EAP-TLS with SHA512 signature""" params = int_eap_server_params()