From 31bd8ea2e974a9823fc959d40ab8485d3bf0fba4 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 19 Jun 2015 01:14:35 +0300 Subject: [PATCH] tests: NFC static handover with invalid contents This adds test coverage to p2p_procesS_nfc_connection_handover() error paths. This is also a regression test case for a memory leak on two of these error paths. Signed-off-by: Jouni Malinen --- tests/hwsim/test_nfc_p2p.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/hwsim/test_nfc_p2p.py b/tests/hwsim/test_nfc_p2p.py index 88f6a57c3..3d2f7c940 100644 --- a/tests/hwsim/test_nfc_p2p.py +++ b/tests/hwsim/test_nfc_p2p.py @@ -721,3 +721,20 @@ def test_nfc_p2p_tag_enable_disable(dev): raise Exception("Failed to enable NFC Tag for P2P static handover") if "OK" not in dev[0].request("P2P_SET nfc_tag 0"): raise Exception("Failed to disable NFC Tag for P2P static handover") + +def test_nfc_p2p_static_handover_invalid(dev): + """NFC static handover with invalid contents""" + logger.info("Unknown OOB GO Neg channel") + sel = "D217A36170706C69636174696F6E2F766E642E7766612E7032700071102100012010230001201024000120102C0036C3B2ADB8D26F53CE1CB7F000BEEDA762922FF5307E87CCE484EF4B5DAD440D0A4752579767610AD1293F7A76A66B09A7C9D58A66994E103C000103104200012010470010572CF82FC95756539B16B5CFB298ABF11049000600372A000120002E02020025000D1D000200000001001108000000000000000000101100084465766963652042130600585804ff0B00" + if "FAIL" not in dev[0].global_request("WPS_NFC_TAG_READ " + sel): + raise Exception("Invalid tag contents accepted (1)") + + logger.info("No OOB GO Neg channel attribute") + sel = "D2179A6170706C69636174696F6E2F766E642E7766612E7032700071102100012010230001201024000120102C0036C3B2ADB8D26F53CE1CB7F000BEEDA762922FF5307E87CCE484EF4B5DAD440D0A4752579767610AD1293F7A76A66B09A7C9D58A66994E103C000103104200012010470010572CF82FC95756539B16B5CFB298ABF11049000600372A000120002502020025000D1D000200000001001108000000000000000000101100084465766963652042" + if "FAIL" not in dev[0].global_request("WPS_NFC_TAG_READ " + sel): + raise Exception("Invalid tag contents accepted (2)") + + logger.info("No Device Info attribute") + sel = "D217836170706C69636174696F6E2F766E642E7766612E7032700071102100012010230001201024000120102C0036C3B2ADB8D26F53CE1CB7F000BEEDA762922FF5307E87CCE484EF4B5DAD440D0A4752579767610AD1293F7A76A66B09A7C9D58A66994E103C000103104200012010470010572CF82FC95756539B16B5CFB298ABF11049000600372A000120000E0202002500130600585804510B00" + if "FAIL" not in dev[0].global_request("WPS_NFC_TAG_READ " + sel): + raise Exception("Invalid tag contents accepted (3)")