From b9ab2f2e5c9f48a9458c2cb11192a8fd4b8003cb Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 21 Oct 2013 17:43:26 +0300 Subject: [PATCH] tests: Add pre-authorized invitation-to-active-group test_p2p_go_invite_auth is similar to test_p2p_go_invite with the main difference being in the peer device pre-authorizing the invitation instead of processing invitation at upper layers after having received it. Signed-hostap: Jouni Malinen --- tests/hwsim/test_p2p_invitation.py | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/hwsim/test_p2p_invitation.py b/tests/hwsim/test_p2p_invitation.py index 1a4971a4b..7d53a1af8 100644 --- a/tests/hwsim/test_p2p_invitation.py +++ b/tests/hwsim/test_p2p_invitation.py @@ -54,3 +54,53 @@ def test_p2p_go_invite(dev): logger.info("Terminate group") dev[0].remove_group() dev[1].wait_go_ending_session() + +def test_p2p_go_invite_auth(dev): + """P2P GO inviting a client to join (authorized invitation)""" + addr0 = dev[0].p2p_dev_addr() + addr1 = dev[1].p2p_dev_addr() + + logger.info("Generate BSS table entry for old group") + # this adds more coverage to testing by forcing the GO to be found with an + # older entry in the BSS table and with that entry having a different + # operating channel. + dev[0].p2p_start_go(freq=2432) + dev[1].scan() + dev[0].remove_group() + dev[0].dump_monitor() + dev[1].dump_monitor() + + logger.info("Discover peer") + dev[1].p2p_listen() + if not dev[0].discover_peer(addr1, social=True): + raise Exception("Peer " + addr1 + " not found") + dev[0].p2p_listen() + if not dev[1].discover_peer(addr0, social=True): + raise Exception("Peer " + addr0 + " not found") + dev[1].p2p_listen() + + logger.info("Authorize invitation") + pin = dev[1].wps_read_pin() + dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join auth") + + logger.info("Start GO on non-social channel") + res = dev[0].p2p_start_go(freq=2427) + logger.debug("res: " + str(res)) + + logger.info("Invite peer to join the group") + dev[0].p2p_go_authorize_client(pin) + dev[0].global_request("P2P_INVITE group=" + dev[0].group_ifname + " peer=" + addr1) + ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED", + "P2P-GROUP-STARTED"], timeout=20) + if ev is None: + raise Exception("Timeout on invitation on peer") + if "P2P-INVITATION-RECEIVED" in ev: + raise Exception("Unexpected request to accept pre-authorized invitaton") + dev[0].dump_monitor() + + logger.info("Client connected") + hwsim_utils.test_connectivity_p2p(dev[0], dev[1]) + + logger.info("Terminate group") + dev[0].remove_group() + dev[1].wait_go_ending_session()