tests: Hidden SSID
In addition, add the earlier tests in the new test_ssid.py file that was
forgotten from the previous commit
d78f33030d
.
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
1785d2e912
commit
f19ee5b7f7
2 changed files with 79 additions and 1 deletions
75
tests/hwsim/test_ssid.py
Normal file
75
tests/hwsim/test_ssid.py
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# SSID contents and encoding tests
|
||||||
|
# Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
|
||||||
|
#
|
||||||
|
# This software may be distributed under the terms of the BSD license.
|
||||||
|
# See README for more details.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
import hostapd
|
||||||
|
|
||||||
|
def test_ssid_hex_encoded(dev, apdev):
|
||||||
|
"""SSID configuration using hex encoded version"""
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'], { "ssid2": '68656c6c6f' })
|
||||||
|
dev[0].connect("hello", key_mgmt="NONE", scan_freq="2412")
|
||||||
|
dev[1].connect(ssid2="68656c6c6f", key_mgmt="NONE", scan_freq="2412")
|
||||||
|
|
||||||
|
def test_ssid_printf_encoded(dev, apdev):
|
||||||
|
"""SSID configuration using printf encoded version"""
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'], { "ssid2": 'P"\\0hello\\nthere"' })
|
||||||
|
dev[0].connect(ssid2="0068656c6c6f0a7468657265", key_mgmt="NONE",
|
||||||
|
scan_freq="2412")
|
||||||
|
dev[1].connect(ssid2='P"\\x00hello\\nthere"', key_mgmt="NONE",
|
||||||
|
scan_freq="2412")
|
||||||
|
ssid = dev[0].get_status_field("ssid")
|
||||||
|
bss = dev[1].get_bss(apdev[0]['bssid'])
|
||||||
|
if ssid != bss['ssid']:
|
||||||
|
raise Exception("Unexpected difference in SSID")
|
||||||
|
dev[2].connect(ssid2='P"' + ssid + '"', key_mgmt="NONE", scan_freq="2412")
|
||||||
|
|
||||||
|
def test_ssid_1_octet(dev, apdev):
|
||||||
|
"""SSID with one octet"""
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'], { "ssid": '1' })
|
||||||
|
dev[0].connect("1", key_mgmt="NONE", scan_freq="2412")
|
||||||
|
|
||||||
|
def test_ssid_32_octets(dev, apdev):
|
||||||
|
"""SSID with 32 octets"""
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'],
|
||||||
|
{ "ssid": '1234567890abcdef1234567890ABCDEF' })
|
||||||
|
dev[0].connect("1234567890abcdef1234567890ABCDEF", key_mgmt="NONE",
|
||||||
|
scan_freq="2412")
|
||||||
|
|
||||||
|
def test_ssid_utf8(dev, apdev):
|
||||||
|
"""SSID with UTF8 encoding"""
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'testi-åäöÅÄÖ-testi',
|
||||||
|
"utf8_ssid": "1" })
|
||||||
|
dev[0].connect("testi-åäöÅÄÖ-testi", key_mgmt="NONE", scan_freq="2412")
|
||||||
|
dev[1].connect(ssid2="74657374692dc3a5c3a4c3b6c385c384c3962d7465737469",
|
||||||
|
key_mgmt="NONE", scan_freq="2412")
|
||||||
|
|
||||||
|
def test_ssid_hidden(dev, apdev):
|
||||||
|
"""Hidden SSID"""
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'secret',
|
||||||
|
"ignore_broadcast_ssid": "1" })
|
||||||
|
dev[1].connect("secret", key_mgmt="NONE", scan_freq="2412",
|
||||||
|
wait_connect=False)
|
||||||
|
dev[0].connect("secret", key_mgmt="NONE", scan_freq="2412", scan_ssid="1")
|
||||||
|
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
|
||||||
|
if ev is not None:
|
||||||
|
raise Exception("Unexpected connection")
|
||||||
|
|
||||||
|
def test_ssid_hidden_wpa2(dev, apdev):
|
||||||
|
"""Hidden SSID with WPA2-PSK"""
|
||||||
|
params = hostapd.wpa2_params(ssid="secret", passphrase="12345678")
|
||||||
|
params["ignore_broadcast_ssid"] = "1"
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||||
|
dev[1].connect("secret", psk="12345678", scan_freq="2412",
|
||||||
|
wait_connect=False)
|
||||||
|
dev[0].connect("secret", psk="12345678", scan_freq="2412", scan_ssid="1")
|
||||||
|
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
|
||||||
|
if ev is not None:
|
||||||
|
raise Exception("Unexpected connection")
|
|
@ -570,7 +570,8 @@ class WpaSupplicant:
|
||||||
client_cert=None, private_key=None, peerkey=False, okc=False,
|
client_cert=None, private_key=None, peerkey=False, okc=False,
|
||||||
eapol_flags=None, fragment_size=None,
|
eapol_flags=None, fragment_size=None,
|
||||||
wait_connect=True, only_add_network=False,
|
wait_connect=True, only_add_network=False,
|
||||||
ca_cert2=None, client_cert2=None, private_key2=None):
|
ca_cert2=None, client_cert2=None, private_key2=None,
|
||||||
|
scan_ssid=None):
|
||||||
logger.info("Connect STA " + self.ifname + " to AP")
|
logger.info("Connect STA " + self.ifname + " to AP")
|
||||||
id = self.add_network()
|
id = self.add_network()
|
||||||
if ssid:
|
if ssid:
|
||||||
|
@ -631,6 +632,8 @@ class WpaSupplicant:
|
||||||
self.set_network(id, "eapol_flags", eapol_flags)
|
self.set_network(id, "eapol_flags", eapol_flags)
|
||||||
if fragment_size:
|
if fragment_size:
|
||||||
self.set_network(id, "fragment_size", fragment_size)
|
self.set_network(id, "fragment_size", fragment_size)
|
||||||
|
if scan_ssid:
|
||||||
|
self.set_network(id, "scan_ssid", scan_ssid)
|
||||||
if only_add_network:
|
if only_add_network:
|
||||||
return id
|
return id
|
||||||
if wait_connect:
|
if wait_connect:
|
||||||
|
|
Loading…
Reference in a new issue