1#!/usr/bin/env python3.4 2# 3# Copyright 2019 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import acts_contrib.test_utils.wifi.wifi_test_utils as wutils 18 19from acts.test_decorators import test_tracker_info 20from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest 21 22 23class WifiWpa3OweTest(WifiBaseTest): 24 """Tests for APIs in Android's WifiManager class. 25 26 Test Bed Requirement: 27 * At least one Android device and atleast two Access Points. 28 * Several Wi-Fi networks visible to the device. 29 """ 30 def __init__(self, configs): 31 super().__init__(configs) 32 self.enable_packet_log = True 33 34 def setup_class(self): 35 super().setup_class() 36 37 self.dut = self.android_devices[0] 38 opt_params = ["owe_networks", "sae_networks"] 39 req_params = ["wpa3_sae_gcmp_128", "wpa3_sae_gcmp_256", "wifi6_models"] 40 self.unpack_userparams(opt_param_names=opt_params, 41 req_param_names=req_params) 42 if "OpenWrtAP" in self.user_params: 43 self.configure_openwrt_ap_and_start(owe_network=True, 44 sae_network=True) 45 self.owe_2g = self.owe_networks[0]["2g"] 46 self.owe_5g = self.owe_networks[0]["5g"] 47 self.wpa3_personal_2g = self.sae_networks[0]["2g"] 48 self.wpa3_personal_5g = self.sae_networks[0]["5g"] 49 50 def setup_test(self): 51 super().setup_test() 52 for ad in self.android_devices: 53 ad.droid.wakeLockAcquireBright() 54 ad.droid.wakeUpNow() 55 wutils.wifi_toggle_state(ad, True) 56 57 def teardown_test(self): 58 super().teardown_test() 59 for ad in self.android_devices: 60 ad.droid.wakeLockRelease() 61 ad.droid.goToSleepNow() 62 wutils.reset_wifi(self.dut) 63 64 ### Test cases ### 65 66 @test_tracker_info(uuid="a7755f1f-5740-4d45-8c29-3711172b1bd7") 67 def test_connect_to_owe_2g(self): 68 wutils.connect_to_wifi_network(self.dut, self.owe_2g) 69 70 @test_tracker_info(uuid="9977765e-03da-4614-ab96-4c1597101118") 71 def test_connect_to_owe_5g(self): 72 wutils.connect_to_wifi_network(self.dut, self.owe_5g) 73 74 @test_tracker_info(uuid="3670702a-3d78-4184-b5e1-7fcf5fa48fd8") 75 def test_connect_to_wpa3_personal_2g(self): 76 wutils.connect_to_wifi_network(self.dut, self.wpa3_personal_2g) 77 wutils.verify_11ax_wifi_connection( 78 self.dut, self.wifi6_models, "wifi6_ap" in self.user_params) 79 80 @test_tracker_info(uuid="c4528eaf-7960-4ecd-8f11-d5439bdf1c58") 81 def test_connect_to_wpa3_personal_5g(self): 82 wutils.connect_to_wifi_network(self.dut, self.wpa3_personal_5g) 83 wutils.verify_11ax_wifi_connection( 84 self.dut, self.wifi6_models, "wifi6_ap" in self.user_params) 85 86 @test_tracker_info(uuid="a8fb46be-3487-4dc8-a393-5af992b27f45") 87 def test_connect_to_wpa3_personal_reconnection(self): 88 """ This is to catch auth reject which is caused by PMKSA cache. 89 Steps: 90 ------------------------------ 91 1. Connect STA to WPA3 AP 92 2. Turn off the WiFi or connect to a different AP 93 3. Turn on the WiFi or connect back to WPA3 AP. 94 4. Initial connect request fails 95 Second connect request from framework succeeds. 96 """ 97 wutils.connect_to_wifi_network(self.dut, self.wpa3_personal_2g) 98 wutils.verify_11ax_wifi_connection( 99 self.dut, self.wifi6_models, "wifi6_ap" in self.user_params) 100 wutils.toggle_wifi_off_and_on(self.dut) 101 wutils.connect_to_wifi_network(self.dut, self.wpa3_personal_2g) 102 wutils.verify_11ax_wifi_connection( 103 self.dut, self.wifi6_models, "wifi6_ap" in self.user_params) 104 105 @test_tracker_info(uuid="b1502202-10c3-4834-a899-5023947fb21d") 106 def test_connect_to_wpa3_personal_gcmp_128(self): 107 """Test connect to WPA3 SAE GCMP 128.""" 108 wutils.connect_to_wifi_network(self.dut, self.wpa3_sae_gcmp_128) 109 110 @test_tracker_info(uuid="4d8c3c63-75bf-4131-bb07-fe3f6020389c") 111 def test_connect_to_wpa3_personal_gcmp_256(self): 112 """Test connect to WPA3 SAE GCMP 256.""" 113 wutils.connect_to_wifi_network(self.dut, self.wpa3_sae_gcmp_256) 114