JSON: TTLSTest: gains more options for set_wifi_extra, fixes help

This commit is contained in:
Jed Reynolds
2020-10-19 22:44:58 -07:00
parent 11ee71e595
commit 69791a1cce

View File

@@ -20,10 +20,46 @@ import pprint
class TTLSTest(LFCliBase):
def __init__(self, host, port, ssid, security, password, sta_list=None, number_template="00000", _debug_on=False,
_exit_on_error=False, radio="wiphy0", key_mgmt="WPA-EAP", eap="TTLS", identity="testuser",
ttls_passwd="testpasswd", ttls_realm="localhost.localdomain", domain="localhost.localdomain",
hessid="00:00:00:00:00:01", _exit_on_fail=False):
def __init__(self, host, port,
ssid="[BLANK]",
security="wpa2",
password="[BLANK]",
radio="wiphy0",
key_mgmt="WPA-EAP",
pairwise="NA",
group="NA",
wpa_psk="DEFAULT",
wep_key="NA",
ca_cert="NA",
eap="TTLS",
identity="testuser",
anonymous_identity="NA",
phase1="NA",
phase2="NA",
ttls_passwd="testpasswd",
pin="NA",
pac_file="NA",
private_key="NA",
pk_passwd="NA",
hessid="00:00:00:00:00:01",
ttls_realm="localhost.localdomain",
client_cert="NA",
imsi="NA",
milenage="NA",
domain="localhost.localdomain",
roaming_consortium="NA",
venue_group="NA",
network_type="NA",
ipaddr_type_avail="NA",
network_auth_type="NA",
anqp_3gpp_cell_net="NA",
ieee80211w=1,
enable_pkc=False,
number_template="00000",
sta_list=None,
_debug_on=False,
_exit_on_error=False,
_exit_on_fail=False):
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
self.host = host
self.port = port
@@ -32,13 +68,40 @@ class TTLSTest(LFCliBase):
self.security = security
self.password = password
self.sta_list = sta_list
self.key_mgmt = key_mgmt
self.pairwise = pairwise
self.group = group
self.wpa_psk = wpa_psk
self.key = wep_key
self.ca_cert = ca_cert
self.eap = eap
self.identity = identity
self.ttls_passwd = ttls_passwd
self.ttls_realm = ttls_realm
self.domain = domain
self.identity = identity # eap identity
self.anonymous_identity = anonymous_identity
self.phase1 = phase1
self.phase2 = phase2
self.ttls_passwd = ttls_passwd #eap passwd
self.pin = pin
self.pac_file = pac_file
self.private_key = private_key
self.pk_passwd = pk_passwd
self.hessid = hessid
self.ttls_realm = ttls_realm
self.client_cert = client_cert
self.imsi = imsi
self.milenage = milenage
self.domain = domain
self.roaming_consortium = roaming_consortium
self.venue_group = venue_group
self.network_type = network_type
self.ipaddr_type_avail = ipaddr_type_avail
self.network_auth_type = network_auth_type
self.anqp_3gpp_cell_net = anqp_3gpp_cell_net
self.ieee80211w = ieee80211w
self.enable_pkc = enable_pkc
self.timeout = 120
self.number_template = number_template
self.debug = _debug_on
@@ -55,6 +118,8 @@ class TTLSTest(LFCliBase):
def build(self):
# Build stations
keyphrase = "[BLANK]"
self.station_profile.use_security(self.security, self.ssid, passwd="[BLANK]")
self.vap_profile.use_security(self.security, self.ssid, passwd="[BLANK]")
self.station_profile.set_number_template(self.number_template)
@@ -62,15 +127,34 @@ class TTLSTest(LFCliBase):
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
self.station_profile.set_command_param("set_port", "report_timer", 1500)
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
self.station_profile.set_wifi_extra(key_mgmt=self.key_mgmt, eap=self.eap, identity=self.identity, passwd=self.ttls_passwd,
realm=self.ttls_realm, domain=self.domain,
hessid=self.hessid)
self.vap_profile.set_wifi_extra(key_mgmt=self.key_mgmt, eap=self.eap, identity=self.identity, passwd=self.ttls_passwd,
realm=self.ttls_realm, domain=self.domain,
hessid=self.hessid)
self.vap_profile.create(resource=1, radio=self.radio, channel=36, up_=True, debug=False, suppress_related_commands_=True, wifi_extra=True)
self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug, wifi_extra=True)
self._pass("PASS: Station build finished")
self.station_profile.set_wifi_extra(key_mgmt=self.key_mgmt,
eap=self.eap,
identity=self.identity,
passwd=self.ttls_passwd,
realm=self.ttls_realm,
domain=self.domain,
hessid=self.hessid
)
self.vap_profile.set_wifi_extra(key_mgmt=self.key_mgmt,
eap=self.eap,
identity=self.identity,
passwd=self.ttls_passwd,
realm=self.ttls_realm,
domain=self.domain,
hessid=self.hessid)
self.vap_profile.create(resource=1,
radio=self.radio,
channel=36,
up_=True,
debug=False,
suppress_related_commands_=True,
wifi_extra=True)
self.station_profile.create(radio=self.radio,
sta_names_=self.sta_list,
debug=self.debug,
wifi_extra=True)
self._pass("Station build finished")
def start(self, sta_list, print_pass, print_fail):
self.station_profile.admin_up()
@@ -125,47 +209,60 @@ def main():
lfjson_port = 8080
parser = LFCliBase.create_basic_argparse(
prog='test_ipv4_connection.py',
prog='test_ipv4_ttls.py',
#formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=argparse.RawTextHelpFormatter,
epilog='''\
Useful Information:
1. TBD
''',
epilog='''Demonstration showing wpa2-ent ttls authentication''',
description='''\
test_ipv4_variable_time.py:
test_ipv4_ttls.py:
--------------------
TBD
Generic command layout:
python ./test_ipv4_variable_time.py --upstream_port <port> --radio <radio 0> <stations> <ssid> <ssid password> <security type: wpa2, open, wpa3> --debug
Note: multiple --radio switches may be entered up to the number of radios available:
--radio <radio 0> <stations> <ssid> <ssid password> --radio <radio 01> <number of last station> <ssid> <ssid password>
python3 ./test_ipv4_variable_time.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2
python ./test_ipv4_ttls.py --upstream_port <port>
--radio <radio 0>
--num_stations <stations>
--ssid <ssid>
--keyphrase <ssid password>
--security <security type: wpa2, open, wpa3>
--debug
''')
parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
parser.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000)
parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m")
parser.add_argument('--key_mgmt', help='--key_mgmt key management type to use', default="WPA-EAP")
parser.add_argument('--key-mgmt', help="--key-mgt: { %s }"%", ".join(realm.wpa_ent_list()), default="CCMP TKIP")
parser.add_argument('--wpa_psk', help='wpa-ent pre shared key', default="[BLANK]")
parser.add_argument('--eap', help='--eap eap method to use', default="TTLS")
parser.add_argument('--identity', help='--identity eap identity string', default="testuser")
parser.add_argument('--ttls_passwd', help='--ttls_passwd eap password string', default="testpasswd")
parser.add_argument('--ttls_realm', help='--ttls_realm 802.11u realm to use', default="localhost.localdomain")
parser.add_argument('--ttls_realm', help='--ttls_realm 802.11u home realm to use', default="localhost.localdomain")
parser.add_argument('--domain', help='--domain 802.11 domain to use', default="localhost.localdomain")
parser.add_argument('--hessid', help='--hessid 802.11u HESSID (MAC address format) (or peer for WDS stations)',
default="00:00:00:00:00:01")
parser.add_argument('--hessid', help='--hessid 802.11u HESSID (MAC addr format/peer for WDS)', default="00:00:00:00:00:01")
parser.add_argument('--ieee80211w', help='--ieee80211w <disabled(0),optional(1),required(2)', default='1')
parser.add_argument('--use_hs20', help='use HotSpot 2.0', default=False)
parser.add_argument('--enable_pkc', help='enable opportunistic PMKSA WPA2 key caching', default=False)
args = parser.parse_args()
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
ttls_test = TTLSTest(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd,
security=args.security, sta_list=station_list, radio=args.radio, key_mgmt=args.key_mgmt,
eap=args.eap, identity=args.identity, ttls_passwd=args.ttls_passwd, ttls_realm=args.ttls_realm,
domain=args.domain, hessid=args.hessid)
ttls_test = TTLSTest(lfjson_host, lfjson_port,
ssid=args.ssid,
password=args.passwd,
security=args.security,
sta_list=station_list,
radio=args.radio,
key_mgmt=args.key_mgmt,
wpa_psk=args.wpa_psk,
eap=args.eap,
identity=args.identity,
ttls_passwd=args.ttls_passwd,
ttls_realm=args.ttls_realm,
domain=args.domain,
hessid=args.hessid,
ieee80211w=args.ieee80211w,
enable_pkc=args.enable_pkc
)
ttls_test.cleanup(station_list)
#ttls_test.timeout = 60
ttls_test.build()