tests: Add test cases for per-STA PSK in P2P group

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-09-01 11:56:55 +03:00
parent 5bf9a6c859
commit b162675fd9
3 changed files with 63 additions and 0 deletions

View file

@ -33,6 +33,11 @@ def test_connectivity_p2p(dev1, dev2):
ifname2 = dev2.group_ifname if dev2.group_ifname else dev2.ifname ifname2 = dev2.group_ifname if dev2.group_ifname else dev2.ifname
test_connectivity(ifname1, ifname2) test_connectivity(ifname1, ifname2)
def test_connectivity_p2p_sta(dev1, dev2):
ifname1 = dev1.group_ifname if dev1.group_ifname else dev1.ifname
ifname2 = dev2.ifname
test_connectivity(ifname1, ifname2)
def test_connectivity_sta(dev1, dev2): def test_connectivity_sta(dev1, dev2):
ifname1 = dev1.ifname ifname1 = dev1.ifname
ifname2 = dev2.ifname ifname2 = dev2.ifname

View file

@ -76,6 +76,7 @@ def go_neg_pin_authorized(i_dev, r_dev, i_intent=None, r_intent=None, expect_fai
return return
logger.info("Group formed") logger.info("Group formed")
hwsim_utils.test_connectivity_p2p(r_dev, i_dev) hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
return [i_res, r_res]
def go_neg_init_pbc(i_dev, r_dev, i_intent, res): def go_neg_init_pbc(i_dev, r_dev, i_intent, res):
logger.debug("Initiate GO Negotiation from i_dev") logger.debug("Initiate GO Negotiation from i_dev")
@ -158,3 +159,53 @@ def test_both_go_neg_display(dev):
def test_both_go_neg_enter(dev): def test_both_go_neg_enter(dev):
"""P2P GO Negotiation with both devices trying to enter PIN""" """P2P GO Negotiation with both devices trying to enter PIN"""
go_neg_pin_authorized(i_dev=dev[0], r_dev=dev[1], expect_failure=True, i_go_neg_status=10, i_method='enter', r_method='enter') go_neg_pin_authorized(i_dev=dev[0], r_dev=dev[1], expect_failure=True, i_go_neg_status=10, i_method='enter', r_method='enter')
def test_grpform_per_sta_psk(dev):
"""P2P group formation with per-STA PSKs"""
dev[0].request("P2P_SET per_sta_psk 1")
[i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
check_grpform_results(i_res, r_res)
pin = dev[2].wps_read_pin()
dev[0].p2p_go_authorize_client(pin)
c_res = dev[2].p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60)
check_grpform_results(i_res, c_res)
if r_res['psk'] == c_res['psk']:
raise Exception("Same PSK assigned for both clients")
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
dev[0].remove_group()
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=2)
if ev is None:
raise Exception("Group removal event timed out")
if "reason=GO_ENDING_SESSION" not in ev:
raise Exception("Unexpected group removal reason")
ev = dev[2].wait_event(["P2P-GROUP-REMOVED"], timeout=2)
if ev is None:
raise Exception("Group removal event timed out")
if "reason=GO_ENDING_SESSION" not in ev:
raise Exception("Unexpected group removal reason")
def test_grpform_per_sta_psk_wps(dev):
"""P2P group formation with per-STA PSKs with non-P2P WPS STA"""
dev[0].request("P2P_SET per_sta_psk 1")
[i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
check_grpform_results(i_res, r_res)
dev[0].p2p_go_authorize_client_pbc()
dev[2].request("WPS_PBC")
ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None:
raise Exception("Association with the GO timed out")
hwsim_utils.test_connectivity_p2p_sta(dev[1], dev[2])
dev[0].remove_group()
dev[2].request("DISCONNECT")
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=2)
if ev is None:
raise Exception("Group removal event timed out")
if "reason=GO_ENDING_SESSION" not in ev:
raise Exception("Unexpected group removal reason")

View file

@ -53,6 +53,7 @@ class WpaSupplicant:
def reset(self): def reset(self):
self.request("FLUSH") self.request("FLUSH")
self.request("SET ignore_old_scan_res 0") self.request("SET ignore_old_scan_res 0")
self.request("P2P_SET per_sta_psk 0")
self.group_ifname = None self.group_ifname = None
self.dump_monitor() self.dump_monitor()
@ -336,6 +337,12 @@ class WpaSupplicant:
raise Exception("Failed to authorize client connection on GO") raise Exception("Failed to authorize client connection on GO")
return None return None
def p2p_go_authorize_client_pbc(self):
cmd = "WPS_PBC"
if "FAIL" in self.group_request(cmd):
raise Exception("Failed to authorize client connection on GO")
return None
def p2p_connect_group(self, go_addr, pin, timeout=0): def p2p_connect_group(self, go_addr, pin, timeout=0):
self.dump_monitor() self.dump_monitor()
if not self.discover_peer(go_addr, social=False): if not self.discover_peer(go_addr, social=False):