Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 1 | #!/usr/bin/python3.4 |
| 2 | # |
| 3 | # Copyright 2017 - 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 | |
| 17 | import time |
| 18 | |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 19 | from acts import asserts |
Etan Cohen | f02703c | 2017-08-24 11:11:44 -0700 | [diff] [blame] | 20 | from acts.test_decorators import test_tracker_info |
Xianyuan Jia | 63751fb | 2020-11-17 00:07:40 +0000 | [diff] [blame^] | 21 | from acts_contrib.test_utils.net import connectivity_const as cconsts |
| 22 | from acts_contrib.test_utils.wifi import wifi_test_utils as wutils |
| 23 | from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest |
| 24 | from acts_contrib.test_utils.wifi.aware import aware_const as aconsts |
| 25 | from acts_contrib.test_utils.wifi.aware import aware_test_utils as autils |
| 26 | from acts_contrib.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 27 | |
| 28 | |
| 29 | class DataPathTest(AwareBaseTest): |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 30 | """Set of tests for Wi-Fi Aware data-path.""" |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 31 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 32 | # configuration parameters used by tests |
| 33 | ENCR_TYPE_OPEN = 0 |
| 34 | ENCR_TYPE_PASSPHRASE = 1 |
| 35 | ENCR_TYPE_PMK = 2 |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 36 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 37 | PASSPHRASE = "This is some random passphrase - very very secure!!" |
| 38 | PASSPHRASE_MIN = "01234567" |
| 39 | PASSPHRASE_MAX = "012345678901234567890123456789012345678901234567890123456789012" |
| 40 | PMK = "ODU0YjE3YzdmNDJiNWI4NTQ2NDJjNDI3M2VkZTQyZGU=" |
| 41 | PASSPHRASE2 = "This is some random passphrase - very very secure - but diff!!" |
| 42 | PMK2 = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=" |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 43 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 44 | PING_MSG = "ping" |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 45 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 46 | # message re-transmit counter (increases reliability in open-environment) |
| 47 | # Note: reliability of message transmission is tested elsewhere |
| 48 | MSG_RETX_COUNT = 5 # hard-coded max value, internal API |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 49 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 50 | # number of second to 'reasonably' wait to make sure that devices synchronize |
| 51 | # with each other - useful for OOB test cases, where the OOB discovery would |
| 52 | # take some time |
| 53 | WAIT_FOR_CLUSTER = 5 |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 54 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 55 | def create_config(self, dtype): |
| 56 | """Create a base configuration based on input parameters. |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 57 | |
| 58 | Args: |
| 59 | dtype: Publish or Subscribe discovery type |
| 60 | |
| 61 | Returns: |
| 62 | Discovery configuration object. |
| 63 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 64 | config = {} |
| 65 | config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = dtype |
| 66 | config[ |
| 67 | aconsts.DISCOVERY_KEY_SERVICE_NAME] = "GoogleTestServiceDataPath" |
| 68 | return config |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 69 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 70 | def request_network(self, dut, ns): |
| 71 | """Request a Wi-Fi Aware network. |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 72 | |
| 73 | Args: |
| 74 | dut: Device |
| 75 | ns: Network specifier |
| 76 | Returns: the request key |
| 77 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 78 | network_req = {"TransportType": 5, "NetworkSpecifier": ns} |
| 79 | return dut.droid.connectivityRequestWifiAwareNetwork(network_req) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 80 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 81 | def set_up_discovery(self, |
| 82 | ptype, |
| 83 | stype, |
| 84 | get_peer_id, |
| 85 | pub_on_both=False, |
| 86 | pub_on_both_same=True): |
| 87 | """Set up discovery sessions and wait for service discovery. |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 88 | |
| 89 | Args: |
| 90 | ptype: Publish discovery type |
| 91 | stype: Subscribe discovery type |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 92 | get_peer_id: Send a message across to get the peer's id |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 93 | pub_on_both: If True then set up a publisher on both devices. The second |
| 94 | publisher isn't used (existing to test use-case). |
| 95 | pub_on_both_same: If True then the second publish uses an identical |
| 96 | service name, otherwise a different service name. |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 97 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 98 | p_dut = self.android_devices[0] |
| 99 | p_dut.pretty_name = "Publisher" |
| 100 | s_dut = self.android_devices[1] |
| 101 | s_dut.pretty_name = "Subscriber" |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 102 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 103 | # Publisher+Subscriber: attach and wait for confirmation |
| 104 | p_id = p_dut.droid.wifiAwareAttach() |
| 105 | autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 106 | time.sleep(self.device_startup_offset) |
| 107 | s_id = s_dut.droid.wifiAwareAttach() |
| 108 | autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 109 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 110 | # Publisher: start publish and wait for confirmation |
| 111 | p_disc_id = p_dut.droid.wifiAwarePublish(p_id, |
| 112 | self.create_config(ptype)) |
| 113 | autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 114 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 115 | # Optionally set up a publish session on the Subscriber device |
| 116 | if pub_on_both: |
| 117 | p2_config = self.create_config(ptype) |
| 118 | if not pub_on_both_same: |
| 119 | p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = ( |
| 120 | p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] + "-XYZXYZ") |
| 121 | s_dut.droid.wifiAwarePublish(s_id, p2_config) |
| 122 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 123 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 124 | # Subscriber: start subscribe and wait for confirmation |
| 125 | s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id, |
| 126 | self.create_config(stype)) |
| 127 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 128 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 129 | # Subscriber: wait for service discovery |
| 130 | discovery_event = autils.wait_for_event( |
| 131 | s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) |
| 132 | peer_id_on_sub = discovery_event["data"][ |
| 133 | aconsts.SESSION_CB_KEY_PEER_ID] |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 134 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 135 | peer_id_on_pub = None |
| 136 | if get_peer_id: # only need message to receive peer ID |
| 137 | # Subscriber: send message to peer (Publisher - so it knows our address) |
| 138 | s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub, |
| 139 | self.get_next_msg_id(), |
| 140 | self.PING_MSG, |
| 141 | self.MSG_RETX_COUNT) |
| 142 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 143 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 144 | # Publisher: wait for received message |
| 145 | pub_rx_msg_event = autils.wait_for_event( |
| 146 | p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED) |
| 147 | peer_id_on_pub = pub_rx_msg_event["data"][ |
| 148 | aconsts.SESSION_CB_KEY_PEER_ID] |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 149 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 150 | return (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub, |
| 151 | peer_id_on_pub) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 152 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 153 | def run_ib_data_path_test(self, |
| 154 | ptype, |
| 155 | stype, |
| 156 | encr_type, |
| 157 | use_peer_id, |
| 158 | passphrase_to_use=None, |
| 159 | pub_on_both=False, |
| 160 | pub_on_both_same=True, |
| 161 | expect_failure=False): |
| 162 | """Runs the in-band data-path tests. |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 163 | |
| 164 | Args: |
| 165 | ptype: Publish discovery type |
| 166 | stype: Subscribe discovery type |
| 167 | encr_type: Encryption type, one of ENCR_TYPE_* |
| 168 | use_peer_id: On Responder (publisher): True to use peer ID, False to |
| 169 | accept any request |
| 170 | passphrase_to_use: The passphrase to use if encr_type=ENCR_TYPE_PASSPHRASE |
| 171 | If None then use self.PASSPHRASE |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 172 | pub_on_both: If True then set up a publisher on both devices. The second |
| 173 | publisher isn't used (existing to test use-case). |
| 174 | pub_on_both_same: If True then the second publish uses an identical |
| 175 | service name, otherwise a different service name. |
Etan Cohen | 7922a31 | 2018-01-23 13:34:55 -0800 | [diff] [blame] | 176 | expect_failure: If True then don't expect NDP formation, otherwise expect |
| 177 | NDP setup to succeed. |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 178 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 179 | (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub, |
| 180 | peer_id_on_pub) = self.set_up_discovery( |
| 181 | ptype, |
| 182 | stype, |
| 183 | use_peer_id, |
| 184 | pub_on_both=pub_on_both, |
| 185 | pub_on_both_same=pub_on_both_same) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 186 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 187 | passphrase = None |
| 188 | pmk = None |
| 189 | if encr_type == self.ENCR_TYPE_PASSPHRASE: |
| 190 | passphrase = (self.PASSPHRASE |
| 191 | if passphrase_to_use == None else passphrase_to_use) |
| 192 | elif encr_type == self.ENCR_TYPE_PMK: |
| 193 | pmk = self.PMK |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 194 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 195 | port = 1234 |
| 196 | transport_protocol = 6 # TCP/IP |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 197 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 198 | # Publisher: request network |
| 199 | if encr_type == self.ENCR_TYPE_OPEN: |
| 200 | p_req_key = self.request_network( |
| 201 | p_dut, |
| 202 | p_dut.droid.wifiAwareCreateNetworkSpecifier( |
| 203 | p_disc_id, peer_id_on_pub |
| 204 | if use_peer_id else None, passphrase, pmk)) |
| 205 | else: |
| 206 | p_req_key = self.request_network( |
| 207 | p_dut, |
| 208 | p_dut.droid.wifiAwareCreateNetworkSpecifier( |
| 209 | p_disc_id, peer_id_on_pub if use_peer_id else None, |
| 210 | passphrase, pmk, port, transport_protocol)) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 211 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 212 | # Subscriber: request network |
| 213 | s_req_key = self.request_network( |
| 214 | s_dut, |
| 215 | s_dut.droid.wifiAwareCreateNetworkSpecifier( |
| 216 | s_disc_id, peer_id_on_sub, passphrase, pmk)) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 217 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 218 | if expect_failure: |
| 219 | # Publisher & Subscriber: expect unavailable callbacks |
| 220 | autils.wait_for_event_with_keys( |
| 221 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 222 | autils.EVENT_NDP_TIMEOUT, |
| 223 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) |
| 224 | autils.wait_for_event_with_keys( |
| 225 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 226 | autils.EVENT_NDP_TIMEOUT, |
| 227 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) |
| 228 | else: |
| 229 | # Publisher & Subscriber: wait for network formation |
| 230 | p_net_event_nc = autils.wait_for_event_with_keys( |
| 231 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 232 | autils.EVENT_NDP_TIMEOUT, |
| 233 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 234 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 235 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 236 | s_net_event_nc = autils.wait_for_event_with_keys( |
| 237 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 238 | autils.EVENT_NDP_TIMEOUT, |
| 239 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 240 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 241 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 242 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 243 | # validate no leak of information |
| 244 | asserts.assert_false( |
| 245 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[ |
| 246 | "data"], "Network specifier leak!") |
| 247 | asserts.assert_false( |
| 248 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[ |
| 249 | "data"], "Network specifier leak!") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 250 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 251 | # note that Pub <-> Sub since IPv6 are of peer's! |
| 252 | s_ipv6 = p_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
| 253 | p_ipv6 = s_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 254 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 255 | self.verify_network_info( |
| 256 | p_net_event_nc["data"], s_net_event_nc["data"], |
| 257 | encr_type == self.ENCR_TYPE_OPEN, port, transport_protocol) |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 258 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 259 | p_net_event_lp = autils.wait_for_event_with_keys( |
| 260 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 261 | autils.EVENT_NDP_TIMEOUT, |
| 262 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 263 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 264 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 265 | s_net_event_lp = autils.wait_for_event_with_keys( |
| 266 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 267 | autils.EVENT_NDP_TIMEOUT, |
| 268 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 269 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 270 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 271 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 272 | p_aware_if = p_net_event_lp["data"][ |
| 273 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 274 | s_aware_if = s_net_event_lp["data"][ |
| 275 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 276 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 277 | self.log.info("Interface names: p=%s, s=%s", p_aware_if, |
| 278 | s_aware_if) |
| 279 | self.log.info("Interface addresses (IPv6): p=%s, s=%s", p_ipv6, |
| 280 | s_ipv6) |
| 281 | |
| 282 | # open sockets to test connection |
| 283 | asserts.assert_true( |
| 284 | autils.verify_socket_connect(p_dut, s_dut, p_ipv6, s_ipv6, 0), |
| 285 | "Failed socket link with Pub as Server") |
| 286 | asserts.assert_true( |
| 287 | autils.verify_socket_connect(s_dut, p_dut, s_ipv6, p_ipv6, 0), |
| 288 | "Failed socket link with Sub as Server") |
| 289 | |
| 290 | # terminate sessions and wait for ON_LOST callbacks |
| 291 | p_dut.droid.wifiAwareDestroy(p_id) |
| 292 | s_dut.droid.wifiAwareDestroy(s_id) |
| 293 | |
| 294 | autils.wait_for_event_with_keys( |
| 295 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 296 | autils.EVENT_NDP_TIMEOUT, |
| 297 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST), |
| 298 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 299 | autils.wait_for_event_with_keys( |
| 300 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 301 | autils.EVENT_NDP_TIMEOUT, |
| 302 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST), |
| 303 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
| 304 | |
| 305 | # clean-up |
| 306 | p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key) |
| 307 | s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key) |
| 308 | |
| 309 | def run_oob_data_path_test(self, |
| 310 | encr_type, |
| 311 | use_peer_id, |
| 312 | setup_discovery_sessions=False, |
| 313 | expect_failure=False): |
| 314 | """Runs the out-of-band data-path tests. |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 315 | |
| 316 | Args: |
| 317 | encr_type: Encryption type, one of ENCR_TYPE_* |
| 318 | use_peer_id: On Responder: True to use peer ID, False to accept any |
| 319 | request |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame] | 320 | setup_discovery_sessions: If True also set up a (spurious) discovery |
| 321 | session (pub on both sides, sub on Responder side). Validates a corner |
| 322 | case. |
Etan Cohen | 7922a31 | 2018-01-23 13:34:55 -0800 | [diff] [blame] | 323 | expect_failure: If True then don't expect NDP formation, otherwise expect |
| 324 | NDP setup to succeed. |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 325 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 326 | init_dut = self.android_devices[0] |
| 327 | init_dut.pretty_name = "Initiator" |
| 328 | resp_dut = self.android_devices[1] |
| 329 | resp_dut.pretty_name = "Responder" |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 330 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 331 | # Initiator+Responder: attach and wait for confirmation & identity |
| 332 | init_id = init_dut.droid.wifiAwareAttach(True) |
| 333 | autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 334 | init_ident_event = autils.wait_for_event( |
| 335 | init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 336 | init_mac = init_ident_event["data"]["mac"] |
| 337 | time.sleep(self.device_startup_offset) |
| 338 | resp_id = resp_dut.droid.wifiAwareAttach(True) |
| 339 | autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 340 | resp_ident_event = autils.wait_for_event( |
| 341 | resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 342 | resp_mac = resp_ident_event["data"]["mac"] |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 343 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 344 | # wait for for devices to synchronize with each other - there are no other |
| 345 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 346 | # to execute the data-path request) |
| 347 | time.sleep(self.WAIT_FOR_CLUSTER) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 348 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 349 | if setup_discovery_sessions: |
| 350 | init_dut.droid.wifiAwarePublish( |
| 351 | init_id, self.create_config(aconsts.PUBLISH_TYPE_UNSOLICITED)) |
| 352 | autils.wait_for_event(init_dut, |
| 353 | aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
| 354 | resp_dut.droid.wifiAwarePublish( |
| 355 | resp_id, self.create_config(aconsts.PUBLISH_TYPE_UNSOLICITED)) |
| 356 | autils.wait_for_event(resp_dut, |
| 357 | aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
| 358 | resp_dut.droid.wifiAwareSubscribe( |
| 359 | resp_id, self.create_config(aconsts.SUBSCRIBE_TYPE_PASSIVE)) |
| 360 | autils.wait_for_event(resp_dut, |
| 361 | aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED) |
| 362 | autils.wait_for_event(resp_dut, |
| 363 | aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame] | 364 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 365 | passphrase = None |
| 366 | pmk = None |
| 367 | if encr_type == self.ENCR_TYPE_PASSPHRASE: |
| 368 | passphrase = self.PASSPHRASE |
| 369 | elif encr_type == self.ENCR_TYPE_PMK: |
| 370 | pmk = self.PMK |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 371 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 372 | # Responder: request network |
| 373 | resp_req_key = self.request_network( |
| 374 | resp_dut, |
| 375 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 376 | resp_id, aconsts.DATA_PATH_RESPONDER, init_mac |
| 377 | if use_peer_id else None, passphrase, pmk)) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 378 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 379 | # Initiator: request network |
| 380 | init_req_key = self.request_network( |
| 381 | init_dut, |
| 382 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 383 | init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase, |
| 384 | pmk)) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 385 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 386 | if expect_failure: |
| 387 | # Initiator & Responder: expect unavailable callbacks |
| 388 | autils.wait_for_event_with_keys( |
| 389 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 390 | autils.EVENT_NDP_TIMEOUT, |
| 391 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) |
| 392 | autils.wait_for_event_with_keys( |
| 393 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 394 | autils.EVENT_NDP_TIMEOUT, |
| 395 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) |
| 396 | else: |
| 397 | # Initiator & Responder: wait for network formation |
| 398 | init_net_event_nc = autils.wait_for_event_with_keys( |
| 399 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 400 | autils.EVENT_NDP_TIMEOUT, |
| 401 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 402 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 403 | (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 404 | resp_net_event_nc = autils.wait_for_event_with_keys( |
| 405 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 406 | autils.EVENT_NDP_TIMEOUT, |
| 407 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 408 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 409 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 410 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 411 | # validate no leak of information |
| 412 | asserts.assert_false( |
| 413 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in init_net_event_nc[ |
| 414 | "data"], "Network specifier leak!") |
| 415 | asserts.assert_false( |
| 416 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in resp_net_event_nc[ |
| 417 | "data"], "Network specifier leak!") |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 418 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 419 | # note that Init <-> Resp since IPv6 are of peer's! |
| 420 | init_ipv6 = resp_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
| 421 | resp_ipv6 = init_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 422 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 423 | init_net_event_lp = autils.wait_for_event_with_keys( |
| 424 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 425 | autils.EVENT_NDP_TIMEOUT, |
| 426 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 427 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 428 | (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 429 | resp_net_event_lp = autils.wait_for_event_with_keys( |
| 430 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 431 | autils.EVENT_NDP_TIMEOUT, |
| 432 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 433 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 434 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 435 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 436 | init_aware_if = init_net_event_lp["data"][ |
| 437 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 438 | resp_aware_if = resp_net_event_lp["data"][ |
| 439 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 440 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 441 | self.log.info("Interface names: I=%s, R=%s", init_aware_if, |
| 442 | resp_aware_if) |
| 443 | self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6, |
| 444 | resp_ipv6) |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 445 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 446 | # open sockets to test connection |
| 447 | asserts.assert_true( |
| 448 | autils.verify_socket_connect(init_dut, resp_dut, init_ipv6, |
| 449 | resp_ipv6, 0), |
| 450 | "Failed socket link with Initiator as Server") |
| 451 | asserts.assert_true( |
| 452 | autils.verify_socket_connect(resp_dut, init_dut, resp_ipv6, |
| 453 | init_ipv6, 0), |
| 454 | "Failed socket link with Responder as Server") |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 455 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 456 | # terminate sessions and wait for ON_LOST callbacks |
| 457 | init_dut.droid.wifiAwareDestroy(init_id) |
| 458 | resp_dut.droid.wifiAwareDestroy(resp_id) |
| 459 | |
| 460 | autils.wait_for_event_with_keys( |
| 461 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 462 | autils.EVENT_NDP_TIMEOUT, |
| 463 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST), |
| 464 | (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 465 | autils.wait_for_event_with_keys( |
| 466 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 467 | autils.EVENT_NDP_TIMEOUT, |
| 468 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST), |
| 469 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
| 470 | |
| 471 | # clean-up |
| 472 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 473 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
| 474 | |
| 475 | def run_mismatched_ib_data_path_test(self, pub_mismatch, sub_mismatch): |
| 476 | """Runs the negative in-band data-path tests: mismatched peer ID. |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 477 | |
| 478 | Args: |
| 479 | pub_mismatch: Mismatch the publisher's ID |
| 480 | sub_mismatch: Mismatch the subscriber's ID |
| 481 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 482 | (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub, |
| 483 | peer_id_on_pub) = self.set_up_discovery( |
| 484 | aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 485 | True) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 486 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 487 | if pub_mismatch: |
| 488 | peer_id_on_pub = peer_id_on_pub - 1 |
| 489 | if sub_mismatch: |
| 490 | peer_id_on_sub = peer_id_on_sub - 1 |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 491 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 492 | # Publisher: request network |
| 493 | p_req_key = self.request_network( |
| 494 | p_dut, |
| 495 | p_dut.droid.wifiAwareCreateNetworkSpecifier( |
| 496 | p_disc_id, peer_id_on_pub, None)) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 497 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 498 | # Subscriber: request network |
| 499 | s_req_key = self.request_network( |
| 500 | s_dut, |
| 501 | s_dut.droid.wifiAwareCreateNetworkSpecifier( |
| 502 | s_disc_id, peer_id_on_sub, None)) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 503 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 504 | # Publisher & Subscriber: |
| 505 | # - expect unavailable callbacks on the party with the bad ID |
| 506 | # - also expect unavailable on the Initiator party (i.e. the |
| 507 | # Subscriber) if the Publisher has a bad ID |
| 508 | # - but a Publisher with a valid ID will keep waiting ... |
| 509 | autils.wait_for_event_with_keys( |
| 510 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 511 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) |
| 512 | if pub_mismatch: |
| 513 | autils.wait_for_event_with_keys( |
| 514 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 515 | autils.EVENT_NDP_TIMEOUT, |
| 516 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) |
| 517 | else: |
| 518 | time.sleep(autils.EVENT_NDP_TIMEOUT) |
| 519 | autils.fail_on_event_with_keys( |
| 520 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, 0, |
| 521 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 522 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 523 | # clean-up |
| 524 | p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key) |
| 525 | s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 526 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 527 | def run_mismatched_oob_data_path_test(self, |
| 528 | init_mismatch_mac=False, |
| 529 | resp_mismatch_mac=False, |
| 530 | init_encr_type=ENCR_TYPE_OPEN, |
| 531 | resp_encr_type=ENCR_TYPE_OPEN): |
| 532 | """Runs the negative out-of-band data-path tests: mismatched information |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 533 | between Responder and Initiator. |
| 534 | |
| 535 | Args: |
| 536 | init_mismatch_mac: True to mismatch the Initiator MAC address |
| 537 | resp_mismatch_mac: True to mismatch the Responder MAC address |
| 538 | init_encr_type: Encryption type of Initiator - ENCR_TYPE_* |
| 539 | resp_encr_type: Encryption type of Responder - ENCR_TYPE_* |
| 540 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 541 | init_dut = self.android_devices[0] |
| 542 | init_dut.pretty_name = "Initiator" |
| 543 | resp_dut = self.android_devices[1] |
| 544 | resp_dut.pretty_name = "Responder" |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 545 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 546 | # Initiator+Responder: attach and wait for confirmation & identity |
| 547 | init_id = init_dut.droid.wifiAwareAttach(True) |
| 548 | autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 549 | init_ident_event = autils.wait_for_event( |
| 550 | init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 551 | init_mac = init_ident_event["data"]["mac"] |
| 552 | time.sleep(self.device_startup_offset) |
| 553 | resp_id = resp_dut.droid.wifiAwareAttach(True) |
| 554 | autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 555 | resp_ident_event = autils.wait_for_event( |
| 556 | resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 557 | resp_mac = resp_ident_event["data"]["mac"] |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 558 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 559 | if init_mismatch_mac: # assumes legit ones don't start with "00" |
| 560 | init_mac = "00" + init_mac[2:] |
| 561 | if resp_mismatch_mac: |
| 562 | resp_mac = "00" + resp_mac[2:] |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 563 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 564 | # wait for for devices to synchronize with each other - there are no other |
| 565 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 566 | # to execute the data-path request) |
| 567 | time.sleep(self.WAIT_FOR_CLUSTER) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 568 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 569 | # set up separate keys: even if types are the same we want a mismatch |
| 570 | init_passphrase = None |
| 571 | init_pmk = None |
| 572 | if init_encr_type == self.ENCR_TYPE_PASSPHRASE: |
| 573 | init_passphrase = self.PASSPHRASE |
| 574 | elif init_encr_type == self.ENCR_TYPE_PMK: |
| 575 | init_pmk = self.PMK |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 576 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 577 | resp_passphrase = None |
| 578 | resp_pmk = None |
| 579 | if resp_encr_type == self.ENCR_TYPE_PASSPHRASE: |
| 580 | resp_passphrase = self.PASSPHRASE2 |
| 581 | elif resp_encr_type == self.ENCR_TYPE_PMK: |
| 582 | resp_pmk = self.PMK2 |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 583 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 584 | # Responder: request network |
| 585 | resp_req_key = self.request_network( |
| 586 | resp_dut, |
| 587 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 588 | resp_id, aconsts.DATA_PATH_RESPONDER, init_mac, |
| 589 | resp_passphrase, resp_pmk)) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 590 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 591 | # Initiator: request network |
| 592 | init_req_key = self.request_network( |
| 593 | init_dut, |
| 594 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 595 | init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, |
| 596 | init_passphrase, init_pmk)) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 597 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 598 | # Initiator & Responder: |
| 599 | # - expect unavailable on the Initiator party if the |
Nate Jiang | 40f5d7b | 2020-05-19 17:04:18 -0700 | [diff] [blame] | 600 | # Initiator and Responder with mac or encryption mismatch |
| 601 | # - For responder: |
| 602 | # - If mac mismatch, responder will keep waiting ... |
| 603 | # - If encryption mismatch, responder expect unavailable |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 604 | autils.wait_for_event_with_keys( |
| 605 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 606 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) |
| 607 | time.sleep(autils.EVENT_NDP_TIMEOUT) |
Nate Jiang | 40f5d7b | 2020-05-19 17:04:18 -0700 | [diff] [blame] | 608 | if init_mismatch_mac or resp_mismatch_mac: |
| 609 | autils.fail_on_event_with_keys( |
| 610 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, 0, |
| 611 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
| 612 | else: |
| 613 | autils.wait_for_event_with_keys( |
| 614 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 615 | (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 616 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 617 | # clean-up |
| 618 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 619 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 620 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 621 | def verify_network_info(self, p_data, s_data, open, port, |
| 622 | transport_protocol): |
| 623 | """Verify that the port and transport protocol information is correct. |
| 624 | - should only exist on subscriber (received from publisher) |
| 625 | and match transmitted values |
| 626 | - should only exist on an encrypted NDP |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 627 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 628 | Args: |
| 629 | p_data, s_data: Pub and Sub (respectively) net cap event data. |
| 630 | open: True if NDP unencrypted, False if encrypted. |
| 631 | port: Expected port value. |
| 632 | transport_protocol: Expected transport protocol value. |
| 633 | """ |
| 634 | asserts.assert_true(aconsts.NET_CAP_PORT not in p_data, |
| 635 | "port info not expected on Pub") |
| 636 | asserts.assert_true(aconsts.NET_CAP_TRANSPORT_PROTOCOL not in p_data, |
| 637 | "transport protocol info not expected on Pub") |
| 638 | if open: |
| 639 | asserts.assert_true(aconsts.NET_CAP_PORT not in s_data, |
| 640 | "port info not expected on Sub (open NDP)") |
| 641 | asserts.assert_true( |
| 642 | aconsts.NET_CAP_TRANSPORT_PROTOCOL not in s_data, |
| 643 | "transport protocol info not expected on Sub (open NDP)") |
| 644 | else: |
| 645 | asserts.assert_equal(s_data[aconsts.NET_CAP_PORT], port, |
| 646 | "Port info does not match on Sub (from Pub)") |
| 647 | asserts.assert_equal( |
| 648 | s_data[aconsts.NET_CAP_TRANSPORT_PROTOCOL], transport_protocol, |
| 649 | "Transport protocol info does not match on Sub (from Pub)") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 650 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 651 | ####################################### |
| 652 | # Positive In-Band (IB) tests key: |
| 653 | # |
| 654 | # names is: test_ib_<pub_type>_<sub_type>_<encr_type>_<peer_spec> |
| 655 | # where: |
| 656 | # |
| 657 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 658 | # sub_type: Type of subscribe discovery session: passive or active. |
| 659 | # encr_type: Encription type: open, passphrase |
| 660 | # peer_spec: Peer specification method: any or specific |
| 661 | # |
| 662 | # Note: In-Band means using Wi-Fi Aware for discovery and referring to the |
| 663 | # peer using the Aware-provided peer handle (as opposed to a MAC address). |
| 664 | ####################################### |
| 665 | |
| 666 | @test_tracker_info(uuid="fa30bedc-d1de-4440-bf25-ec00d10555af") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 667 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 668 | def test_ib_unsolicited_passive_open_specific(self): |
| 669 | """Data-path: in-band, unsolicited/passive, open encryption, specific peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 670 | |
| 671 | Verifies end-to-end discovery + data-path creation. |
| 672 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 673 | self.run_ib_data_path_test( |
| 674 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 675 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 676 | encr_type=self.ENCR_TYPE_OPEN, |
| 677 | use_peer_id=True) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 678 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 679 | @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 680 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 681 | def test_ib_unsolicited_passive_open_any(self): |
| 682 | """Data-path: in-band, unsolicited/passive, open encryption, any peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 683 | |
| 684 | Verifies end-to-end discovery + data-path creation. |
| 685 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 686 | self.run_ib_data_path_test( |
| 687 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 688 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 689 | encr_type=self.ENCR_TYPE_OPEN, |
| 690 | use_peer_id=False) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 691 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 692 | @test_tracker_info(uuid="93b2a23d-8579-448a-936c-7812929464cf") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 693 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 694 | def test_ib_unsolicited_passive_passphrase_specific(self): |
| 695 | """Data-path: in-band, unsolicited/passive, passphrase, specific peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 696 | |
| 697 | Verifies end-to-end discovery + data-path creation. |
| 698 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 699 | self.run_ib_data_path_test( |
| 700 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 701 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 702 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 703 | use_peer_id=True) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 704 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 705 | @test_tracker_info(uuid="1736126f-a0ff-4712-acc4-f89b4eef5716") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 706 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 707 | def test_ib_unsolicited_passive_passphrase_any(self): |
| 708 | """Data-path: in-band, unsolicited/passive, passphrase, any peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 709 | |
| 710 | Verifies end-to-end discovery + data-path creation. |
| 711 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 712 | self.run_ib_data_path_test( |
| 713 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 714 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 715 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 716 | use_peer_id=False) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 717 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 718 | @test_tracker_info(uuid="b9353d5b-3f77-46bf-bfd9-65d56a7c939a") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 719 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 720 | def test_ib_unsolicited_passive_pmk_specific(self): |
| 721 | """Data-path: in-band, unsolicited/passive, PMK, specific peer |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 722 | |
| 723 | Verifies end-to-end discovery + data-path creation. |
| 724 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 725 | self.run_ib_data_path_test( |
| 726 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 727 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 728 | encr_type=self.ENCR_TYPE_PMK, |
| 729 | use_peer_id=True) |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 730 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 731 | @test_tracker_info(uuid="06f3b2ab-4a10-4398-83a4-6a23851b1662") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 732 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 733 | def test_ib_unsolicited_passive_pmk_any(self): |
| 734 | """Data-path: in-band, unsolicited/passive, PMK, any peer |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 735 | |
| 736 | Verifies end-to-end discovery + data-path creation. |
| 737 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 738 | self.run_ib_data_path_test( |
| 739 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 740 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 741 | encr_type=self.ENCR_TYPE_PMK, |
| 742 | use_peer_id=False) |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 743 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 744 | @test_tracker_info(uuid="0ed7d8b3-a69e-46ba-aeb7-13e507ecf290") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 745 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 746 | def test_ib_solicited_active_open_specific(self): |
| 747 | """Data-path: in-band, solicited/active, open encryption, specific peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 748 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 749 | Verifies end-to-end discovery + data-path creation. |
| 750 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 751 | self.run_ib_data_path_test( |
| 752 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 753 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 754 | encr_type=self.ENCR_TYPE_OPEN, |
| 755 | use_peer_id=True) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 756 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 757 | @test_tracker_info(uuid="c7ba6d28-5ef6-45d9-95d5-583ad6d981f3") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 758 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 759 | def test_ib_solicited_active_open_any(self): |
| 760 | """Data-path: in-band, solicited/active, open encryption, any peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 761 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 762 | Verifies end-to-end discovery + data-path creation. |
| 763 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 764 | self.run_ib_data_path_test( |
| 765 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 766 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 767 | encr_type=self.ENCR_TYPE_OPEN, |
| 768 | use_peer_id=False) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 769 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 770 | @test_tracker_info(uuid="388cea99-0e2e-49ea-b00e-f3e56b6236e5") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 771 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 772 | def test_ib_solicited_active_passphrase_specific(self): |
| 773 | """Data-path: in-band, solicited/active, passphrase, specific peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 774 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 775 | Verifies end-to-end discovery + data-path creation. |
| 776 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 777 | self.run_ib_data_path_test( |
| 778 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 779 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 780 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 781 | use_peer_id=True) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 782 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 783 | @test_tracker_info(uuid="fcd3e28a-5eab-4169-8a0c-dc7204dcdc13") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 784 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 785 | def test_ib_solicited_active_passphrase_any(self): |
| 786 | """Data-path: in-band, solicited/active, passphrase, any peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 787 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 788 | Verifies end-to-end discovery + data-path creation. |
| 789 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 790 | self.run_ib_data_path_test( |
| 791 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 792 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 793 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 794 | use_peer_id=False) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 795 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 796 | @test_tracker_info(uuid="9d4eaad7-ba53-4a06-8ce0-e308daea3309") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 797 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 798 | def test_ib_solicited_active_pmk_specific(self): |
| 799 | """Data-path: in-band, solicited/active, PMK, specific peer |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 800 | |
| 801 | Verifies end-to-end discovery + data-path creation. |
| 802 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 803 | self.run_ib_data_path_test( |
| 804 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 805 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 806 | encr_type=self.ENCR_TYPE_PMK, |
| 807 | use_peer_id=True) |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 808 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 809 | @test_tracker_info(uuid="129d850e-c312-4137-a67b-05ae95fe66cc") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 810 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 811 | def test_ib_solicited_active_pmk_any(self): |
| 812 | """Data-path: in-band, solicited/active, PMK, any peer |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 813 | |
| 814 | Verifies end-to-end discovery + data-path creation. |
| 815 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 816 | self.run_ib_data_path_test( |
| 817 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 818 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 819 | encr_type=self.ENCR_TYPE_PMK, |
| 820 | use_peer_id=False) |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 821 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 822 | ####################################### |
| 823 | # Positive In-Band (IB) with a publish session running on the subscriber |
| 824 | # tests key: |
| 825 | # |
| 826 | # names is: test_ib_extra_pub_<same|diff>_<pub_type>_<sub_type> |
| 827 | # _<encr_type>_<peer_spec> |
| 828 | # where: |
| 829 | # |
| 830 | # same|diff: Whether the extra publish session (on the subscriber) is the same |
| 831 | # or different from the primary session. |
| 832 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 833 | # sub_type: Type of subscribe discovery session: passive or active. |
| 834 | # encr_type: Encryption type: open, passphrase |
| 835 | # peer_spec: Peer specification method: any or specific |
| 836 | # |
| 837 | # Note: In-Band means using Wi-Fi Aware for discovery and referring to the |
| 838 | # peer using the Aware-provided peer handle (as opposed to a MAC address). |
| 839 | ####################################### |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 840 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 841 | @test_tracker_info(uuid="e855dd81-45c8-4bb2-a204-7687c48ff843") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 842 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 843 | def test_ib_extra_pub_same_unsolicited_passive_open_specific(self): |
| 844 | """Data-path: in-band, unsolicited/passive, open encryption, specific peer. |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 845 | |
| 846 | Configuration contains a publisher (for the same service) running on *both* |
| 847 | devices. |
| 848 | |
| 849 | Verifies end-to-end discovery + data-path creation. |
| 850 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 851 | self.run_ib_data_path_test( |
| 852 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 853 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 854 | encr_type=self.ENCR_TYPE_OPEN, |
| 855 | use_peer_id=True, |
| 856 | pub_on_both=True, |
| 857 | pub_on_both_same=True) |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 858 | |
Girish Moturu | c0f87bc | 2020-05-23 21:20:05 -0700 | [diff] [blame] | 859 | @test_tracker_info(uuid="228ea657-82e6-44bc-8369-a2c719a5e252") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 860 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 861 | def test_ib_extra_pub_same_unsolicited_passive_open_any(self): |
| 862 | """Data-path: in-band, unsolicited/passive, open encryption, any peer. |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 863 | |
| 864 | Configuration contains a publisher (for the same service) running on *both* |
| 865 | devices. |
| 866 | |
| 867 | Verifies end-to-end discovery + data-path creation. |
| 868 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 869 | self.run_ib_data_path_test( |
| 870 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 871 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 872 | encr_type=self.ENCR_TYPE_OPEN, |
| 873 | use_peer_id=False, |
| 874 | pub_on_both=True, |
| 875 | pub_on_both_same=True) |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 876 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 877 | @test_tracker_info(uuid="7a32f439-d745-4716-a75e-b54109aaaf82") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 878 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 879 | def test_ib_extra_pub_diff_unsolicited_passive_open_specific(self): |
| 880 | """Data-path: in-band, unsolicited/passive, open encryption, specific peer. |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 881 | |
| 882 | Configuration contains a publisher (for a different service) running on |
| 883 | *both* devices. |
| 884 | |
| 885 | Verifies end-to-end discovery + data-path creation. |
| 886 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 887 | self.run_ib_data_path_test( |
| 888 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 889 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 890 | encr_type=self.ENCR_TYPE_OPEN, |
| 891 | use_peer_id=True, |
| 892 | pub_on_both=True, |
| 893 | pub_on_both_same=False) |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 894 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 895 | @test_tracker_info(uuid="a14ddc66-88fd-4b49-ab37-225533867c63") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 896 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 897 | def test_ib_extra_pub_diff_unsolicited_passive_open_any(self): |
| 898 | """Data-path: in-band, unsolicited/passive, open encryption, any peer. |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 899 | |
| 900 | Configuration contains a publisher (for a different service) running on |
| 901 | *both* devices. |
| 902 | |
| 903 | Verifies end-to-end discovery + data-path creation. |
| 904 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 905 | self.run_ib_data_path_test( |
| 906 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 907 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 908 | encr_type=self.ENCR_TYPE_OPEN, |
| 909 | use_peer_id=False, |
| 910 | pub_on_both=True, |
| 911 | pub_on_both_same=False) |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 912 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 913 | ####################################### |
| 914 | # Positive Out-of-Band (OOB) tests key: |
| 915 | # |
| 916 | # names is: test_oob_<encr_type>_<peer_spec> |
| 917 | # where: |
| 918 | # |
| 919 | # encr_type: Encryption type: open, passphrase |
| 920 | # peer_spec: Peer specification method: any or specific |
| 921 | # |
| 922 | # Optionally set up an extra discovery session to test coexistence. If so |
| 923 | # add "ib_coex" to test name. |
| 924 | # |
| 925 | # Note: Out-of-Band means using a non-Wi-Fi Aware mechanism for discovery and |
| 926 | # exchange of MAC addresses and then Wi-Fi Aware for data-path. |
| 927 | ####################################### |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 928 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 929 | @test_tracker_info(uuid="7db17d8c-1dce-4084-b695-215bbcfe7d41") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 930 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 931 | def test_oob_open_specific(self): |
| 932 | """Data-path: out-of-band, open encryption, specific peer |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 933 | |
| 934 | Verifies end-to-end discovery + data-path creation. |
| 935 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 936 | self.run_oob_data_path_test( |
| 937 | encr_type=self.ENCR_TYPE_OPEN, use_peer_id=True) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 938 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 939 | @test_tracker_info(uuid="ad416d89-cb95-4a07-8d29-ee213117450b") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 940 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 941 | def test_oob_open_any(self): |
| 942 | """Data-path: out-of-band, open encryption, any peer |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 943 | |
| 944 | Verifies end-to-end discovery + data-path creation. |
| 945 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 946 | self.run_oob_data_path_test( |
| 947 | encr_type=self.ENCR_TYPE_OPEN, use_peer_id=False) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 948 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 949 | @test_tracker_info(uuid="74937a3a-d524-43e2-8979-4449271cab52") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 950 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 951 | def test_oob_passphrase_specific(self): |
| 952 | """Data-path: out-of-band, passphrase, specific peer |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 953 | |
| 954 | Verifies end-to-end discovery + data-path creation. |
| 955 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 956 | self.run_oob_data_path_test( |
| 957 | encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=True) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 958 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 959 | @test_tracker_info(uuid="afcbdc7e-d3a9-465b-b1da-ce2e42e3941e") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 960 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 961 | def test_oob_passphrase_any(self): |
| 962 | """Data-path: out-of-band, passphrase, any peer |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 963 | |
| 964 | Verifies end-to-end discovery + data-path creation. |
| 965 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 966 | self.run_oob_data_path_test( |
| 967 | encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=False) |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 968 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 969 | @test_tracker_info(uuid="0d095031-160a-4537-aab5-41b6ad5d55f8") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 970 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 971 | def test_oob_pmk_specific(self): |
| 972 | """Data-path: out-of-band, PMK, specific peer |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 973 | |
| 974 | Verifies end-to-end discovery + data-path creation. |
| 975 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 976 | self.run_oob_data_path_test( |
| 977 | encr_type=self.ENCR_TYPE_PMK, use_peer_id=True) |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 978 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 979 | @test_tracker_info(uuid="e45477bd-66cc-4eb7-88dd-4518c8aa2a74") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 980 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 981 | def test_oob_pmk_any(self): |
| 982 | """Data-path: out-of-band, PMK, any peer |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 983 | |
| 984 | Verifies end-to-end discovery + data-path creation. |
| 985 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 986 | self.run_oob_data_path_test( |
| 987 | encr_type=self.ENCR_TYPE_PMK, use_peer_id=False) |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 988 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 989 | @test_tracker_info(uuid="dd464f24-b404-4eea-955c-d10c9e8adefc") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 990 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 991 | def test_oob_ib_coex_open_specific(self): |
| 992 | """Data-path: out-of-band, open encryption, specific peer - in-band coex: |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame] | 993 | set up a concurrent discovery session to verify no impact. The session |
| 994 | consists of Publisher on both ends, and a Subscriber on the Responder. |
| 995 | |
| 996 | Verifies end-to-end discovery + data-path creation. |
| 997 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 998 | self.run_oob_data_path_test( |
| 999 | encr_type=self.ENCR_TYPE_OPEN, |
| 1000 | use_peer_id=True, |
| 1001 | setup_discovery_sessions=True) |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame] | 1002 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1003 | @test_tracker_info(uuid="088fcd3a-b015-4179-a9a5-91f782b03e3b") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1004 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1005 | def test_oob_ib_coex_open_any(self): |
| 1006 | """Data-path: out-of-band, open encryption, any peer - in-band coex: |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame] | 1007 | set up a concurrent discovery session to verify no impact. The session |
| 1008 | consists of Publisher on both ends, and a Subscriber on the Responder. |
| 1009 | |
| 1010 | Verifies end-to-end discovery + data-path creation. |
| 1011 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1012 | self.run_oob_data_path_test( |
| 1013 | encr_type=self.ENCR_TYPE_OPEN, |
| 1014 | use_peer_id=False, |
| 1015 | setup_discovery_sessions=True) |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame] | 1016 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1017 | ############################################################## |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 1018 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1019 | @test_tracker_info(uuid="1c2c9805-dc1e-43b5-a1b8-315e8c9a4337") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1020 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1021 | def test_passphrase_min(self): |
| 1022 | """Data-path: minimum passphrase length |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 1023 | |
| 1024 | Use in-band, unsolicited/passive, any peer combination |
| 1025 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1026 | self.run_ib_data_path_test( |
| 1027 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 1028 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 1029 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 1030 | use_peer_id=False, |
| 1031 | passphrase_to_use=self.PASSPHRASE_MIN) |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 1032 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1033 | @test_tracker_info(uuid="e696e2b9-87a9-4521-b337-61b9efaa2057") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1034 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1035 | def test_passphrase_max(self): |
| 1036 | """Data-path: maximum passphrase length |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 1037 | |
| 1038 | Use in-band, unsolicited/passive, any peer combination |
| 1039 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1040 | self.run_ib_data_path_test( |
| 1041 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 1042 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 1043 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 1044 | use_peer_id=False, |
| 1045 | passphrase_to_use=self.PASSPHRASE_MAX) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1046 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1047 | @test_tracker_info(uuid="533cd44c-ff30-4283-ac28-f71fd7b4f02d") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1048 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1049 | def test_negative_mismatch_publisher_peer_id(self): |
| 1050 | """Data-path: failure when publisher peer ID is mismatched""" |
| 1051 | self.run_mismatched_ib_data_path_test( |
| 1052 | pub_mismatch=True, sub_mismatch=False) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 1053 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1054 | @test_tracker_info(uuid="682f275e-722a-4f8b-85e7-0dcea9d25532") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1055 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1056 | def test_negative_mismatch_subscriber_peer_id(self): |
| 1057 | """Data-path: failure when subscriber peer ID is mismatched""" |
| 1058 | self.run_mismatched_ib_data_path_test( |
| 1059 | pub_mismatch=False, sub_mismatch=True) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 1060 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1061 | @test_tracker_info(uuid="7fa82796-7fc9-4d9e-bbbb-84b751788943") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1062 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1063 | def test_negative_mismatch_init_mac(self): |
| 1064 | """Data-path: failure when Initiator MAC address mismatch""" |
| 1065 | self.run_mismatched_oob_data_path_test( |
| 1066 | init_mismatch_mac=True, resp_mismatch_mac=False) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1067 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1068 | @test_tracker_info(uuid="edeae959-4644-44f9-8d41-bdeb5216954e") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1069 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1070 | def test_negative_mismatch_resp_mac(self): |
| 1071 | """Data-path: failure when Responder MAC address mismatch""" |
| 1072 | self.run_mismatched_oob_data_path_test( |
| 1073 | init_mismatch_mac=False, resp_mismatch_mac=True) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1074 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1075 | @test_tracker_info(uuid="91f46949-c47f-49f9-a90f-6fae699613a7") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1076 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1077 | def test_negative_mismatch_passphrase(self): |
| 1078 | """Data-path: failure when passphrases mismatch""" |
| 1079 | self.run_mismatched_oob_data_path_test( |
| 1080 | init_encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 1081 | resp_encr_type=self.ENCR_TYPE_PASSPHRASE) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1082 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1083 | @test_tracker_info(uuid="01c49c2e-dc92-4a27-bb47-c4fc67617c23") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1084 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1085 | def test_negative_mismatch_pmk(self): |
| 1086 | """Data-path: failure when PMK mismatch""" |
| 1087 | self.run_mismatched_oob_data_path_test( |
| 1088 | init_encr_type=self.ENCR_TYPE_PMK, |
| 1089 | resp_encr_type=self.ENCR_TYPE_PMK) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1090 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1091 | @test_tracker_info(uuid="4d651797-5fbb-408e-a4b6-a6e1944136da") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1092 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1093 | def test_negative_mismatch_open_passphrase(self): |
| 1094 | """Data-path: failure when initiator is open, and responder passphrase""" |
| 1095 | self.run_mismatched_oob_data_path_test( |
| 1096 | init_encr_type=self.ENCR_TYPE_OPEN, |
| 1097 | resp_encr_type=self.ENCR_TYPE_PASSPHRASE) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1098 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1099 | @test_tracker_info(uuid="1ae697f4-5987-4187-aeef-1e22d07d4a7c") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1100 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1101 | def test_negative_mismatch_open_pmk(self): |
| 1102 | """Data-path: failure when initiator is open, and responder PMK""" |
| 1103 | self.run_mismatched_oob_data_path_test( |
| 1104 | init_encr_type=self.ENCR_TYPE_OPEN, |
| 1105 | resp_encr_type=self.ENCR_TYPE_PMK) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1106 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1107 | @test_tracker_info(uuid="f027b1cc-0e7a-4075-b880-5e64b288afbd") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1108 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1109 | def test_negative_mismatch_pmk_passphrase(self): |
| 1110 | """Data-path: failure when initiator is pmk, and responder passphrase""" |
| 1111 | self.run_mismatched_oob_data_path_test( |
| 1112 | init_encr_type=self.ENCR_TYPE_PMK, |
| 1113 | resp_encr_type=self.ENCR_TYPE_PASSPHRASE) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1114 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1115 | @test_tracker_info(uuid="0819bbd4-72ae-49c4-bd46-5448db2b0a06") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1116 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1117 | def test_negative_mismatch_passphrase_open(self): |
| 1118 | """Data-path: failure when initiator is passphrase, and responder open""" |
| 1119 | self.run_mismatched_oob_data_path_test( |
| 1120 | init_encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 1121 | resp_encr_type=self.ENCR_TYPE_OPEN) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1122 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1123 | @test_tracker_info(uuid="7ef24f62-8e6b-4732-88a3-80a43584dda4") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1124 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1125 | def test_negative_mismatch_pmk_open(self): |
| 1126 | """Data-path: failure when initiator is PMK, and responder open""" |
| 1127 | self.run_mismatched_oob_data_path_test( |
| 1128 | init_encr_type=self.ENCR_TYPE_PMK, |
| 1129 | resp_encr_type=self.ENCR_TYPE_OPEN) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 1130 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1131 | @test_tracker_info(uuid="7b9c9efc-1c06-465e-8a5e-d6a22ac1da97") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1132 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1133 | def test_negative_mismatch_passphrase_pmk(self): |
| 1134 | """Data-path: failure when initiator is passphrase, and responder pmk""" |
| 1135 | self.run_mismatched_oob_data_path_test( |
| 1136 | init_encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 1137 | resp_encr_type=self.ENCR_TYPE_OPEN) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1138 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1139 | ########################################################################## |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1140 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1141 | def wait_for_request_responses(self, dut, req_keys, aware_ifs, aware_ipv6): |
| 1142 | """Wait for network request confirmation for all request keys. |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1143 | |
| 1144 | Args: |
| 1145 | dut: Device under test |
| 1146 | req_keys: (in) A list of the network requests |
| 1147 | aware_ifs: (out) A list into which to append the network interface |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1148 | aware_ipv6: (out) A list into which to append the network ipv6 address |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1149 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1150 | num_events = 0 # looking for 2 events per NDP: link-prop + net-cap |
| 1151 | while num_events != 2 * len(req_keys): |
| 1152 | event = autils.wait_for_event( |
| 1153 | dut, |
| 1154 | cconsts.EVENT_NETWORK_CALLBACK, |
| 1155 | timeout=autils.EVENT_NDP_TIMEOUT) |
| 1156 | if (event["data"][cconsts.NETWORK_CB_KEY_EVENT] == |
| 1157 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED): |
| 1158 | if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys: |
| 1159 | num_events = num_events + 1 |
| 1160 | aware_ifs.append( |
| 1161 | event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME]) |
| 1162 | else: |
| 1163 | self.log.info( |
| 1164 | "Received an unexpected connectivity, the revoked " |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1165 | "network request probably went through -- %s", event) |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1166 | elif (event["data"][cconsts.NETWORK_CB_KEY_EVENT] == |
| 1167 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED): |
| 1168 | if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys: |
| 1169 | num_events = num_events + 1 |
| 1170 | aware_ipv6.append(event["data"][aconsts.NET_CAP_IPV6]) |
| 1171 | else: |
| 1172 | self.log.info( |
| 1173 | "Received an unexpected connectivity, the revoked " |
| 1174 | "network request probably went through -- %s", event) |
| 1175 | # validate no leak of information |
| 1176 | asserts.assert_false( |
| 1177 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in event["data"], |
| 1178 | "Network specifier leak!") |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1179 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1180 | @test_tracker_info(uuid="2e325e2b-d552-4890-b470-20b40284395d") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1181 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1182 | def test_multiple_identical_networks(self): |
| 1183 | """Validate that creating multiple networks between 2 devices, each network |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1184 | with identical configuration is supported over a single NDP. |
| 1185 | |
| 1186 | Verify that the interface and IPv6 address is the same for all networks. |
| 1187 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1188 | init_dut = self.android_devices[0] |
| 1189 | init_dut.pretty_name = "Initiator" |
| 1190 | resp_dut = self.android_devices[1] |
| 1191 | resp_dut.pretty_name = "Responder" |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1192 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1193 | N = 2 # first iteration (must be 2 to give us a chance to cancel the first) |
| 1194 | M = 5 # second iteration |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1195 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1196 | init_ids = [] |
| 1197 | resp_ids = [] |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1198 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1199 | # Initiator+Responder: attach and wait for confirmation & identity |
| 1200 | # create N+M sessions to be used in the different (but identical) NDPs |
| 1201 | for i in range(N + M): |
| 1202 | id, init_mac = autils.attach_with_identity(init_dut) |
| 1203 | init_ids.append(id) |
| 1204 | id, resp_mac = autils.attach_with_identity(resp_dut) |
| 1205 | resp_ids.append(id) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1206 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1207 | # wait for for devices to synchronize with each other - there are no other |
| 1208 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 1209 | # to execute the data-path request) |
| 1210 | time.sleep(autils.WAIT_FOR_CLUSTER) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1211 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1212 | resp_req_keys = [] |
| 1213 | init_req_keys = [] |
| 1214 | resp_aware_ifs = [] |
| 1215 | init_aware_ifs = [] |
| 1216 | resp_aware_ipv6 = [] |
| 1217 | init_aware_ipv6 = [] |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1218 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1219 | # issue N quick requests for identical NDPs - without waiting for result |
| 1220 | # tests whether pre-setup multiple NDP procedure |
| 1221 | for i in range(N): |
| 1222 | # Responder: request network |
| 1223 | resp_req_keys.append( |
| 1224 | autils.request_network( |
| 1225 | resp_dut, |
| 1226 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1227 | resp_ids[i], aconsts.DATA_PATH_RESPONDER, init_mac, |
| 1228 | None))) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1229 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1230 | # Initiator: request network |
| 1231 | init_req_keys.append( |
| 1232 | autils.request_network( |
| 1233 | init_dut, |
| 1234 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1235 | init_ids[i], aconsts.DATA_PATH_INITIATOR, resp_mac, |
| 1236 | None))) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1237 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1238 | # remove the first request (hopefully before completed) testing that NDP |
| 1239 | # is still created |
| 1240 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_keys[0]) |
| 1241 | resp_req_keys.remove(resp_req_keys[0]) |
| 1242 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_keys[0]) |
| 1243 | init_req_keys.remove(init_req_keys[0]) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1244 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1245 | # wait for network formation for all initial requests |
| 1246 | # note: for IPv6 Init <--> Resp since each reports the other's IPv6 address |
| 1247 | # in it's transport-specific network info |
| 1248 | self.wait_for_request_responses(resp_dut, resp_req_keys, |
| 1249 | resp_aware_ifs, init_aware_ipv6) |
| 1250 | self.wait_for_request_responses(init_dut, init_req_keys, |
| 1251 | init_aware_ifs, resp_aware_ipv6) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1252 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1253 | # issue M more requests for the same NDPs - tests post-setup multiple NDP |
| 1254 | for i in range(M): |
| 1255 | # Responder: request network |
| 1256 | resp_req_keys.append( |
| 1257 | autils.request_network( |
| 1258 | resp_dut, |
| 1259 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1260 | resp_ids[N + i], aconsts.DATA_PATH_RESPONDER, init_mac, |
| 1261 | None))) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1262 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1263 | # Initiator: request network |
| 1264 | init_req_keys.append( |
| 1265 | autils.request_network( |
| 1266 | init_dut, |
| 1267 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1268 | init_ids[N + i], aconsts.DATA_PATH_INITIATOR, resp_mac, |
| 1269 | None))) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1270 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1271 | # wait for network formation for all subsequent requests |
| 1272 | self.wait_for_request_responses(resp_dut, resp_req_keys[N - 1:], |
| 1273 | resp_aware_ifs, init_aware_ipv6) |
| 1274 | self.wait_for_request_responses(init_dut, init_req_keys[N - 1:], |
| 1275 | init_aware_ifs, resp_aware_ipv6) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1276 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1277 | # determine whether all interfaces and ipv6 addresses are identical |
| 1278 | # (single NDP) |
| 1279 | init_aware_ifs = list(set(init_aware_ifs)) |
| 1280 | resp_aware_ifs = list(set(resp_aware_ifs)) |
| 1281 | init_aware_ipv6 = list(set(init_aware_ipv6)) |
| 1282 | resp_aware_ipv6 = list(set(resp_aware_ipv6)) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1283 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1284 | self.log.info("Interface names: I=%s, R=%s", init_aware_ifs, |
| 1285 | resp_aware_ifs) |
| 1286 | self.log.info("Interface IPv6: I=%s, R=%s", init_aware_ipv6, |
| 1287 | resp_aware_ipv6) |
| 1288 | self.log.info("Initiator requests: %s", init_req_keys) |
| 1289 | self.log.info("Responder requests: %s", resp_req_keys) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1290 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1291 | asserts.assert_equal( |
| 1292 | len(init_aware_ifs), 1, "Multiple initiator interfaces") |
| 1293 | asserts.assert_equal( |
| 1294 | len(resp_aware_ifs), 1, "Multiple responder interfaces") |
| 1295 | asserts.assert_equal( |
| 1296 | len(init_aware_ipv6), 1, "Multiple initiator IPv6 addresses") |
| 1297 | asserts.assert_equal( |
| 1298 | len(resp_aware_ipv6), 1, "Multiple responder IPv6 addresses") |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1299 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1300 | for i in range( |
| 1301 | init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]): |
| 1302 | # note: using get_ipv6_addr (ifconfig method) since want to verify |
| 1303 | # that interfaces which do not have any NDPs on them do not have |
| 1304 | # an IPv6 link-local address. |
| 1305 | if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i) |
| 1306 | init_ipv6 = autils.get_ipv6_addr(init_dut, if_name) |
| 1307 | resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1308 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1309 | asserts.assert_equal( |
| 1310 | init_ipv6 is None, if_name not in init_aware_ifs, |
| 1311 | "Initiator interface %s in unexpected state" % if_name) |
| 1312 | asserts.assert_equal( |
| 1313 | resp_ipv6 is None, if_name not in resp_aware_ifs, |
| 1314 | "Responder interface %s in unexpected state" % if_name) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1315 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1316 | # release requests |
| 1317 | for resp_req_key in resp_req_keys: |
| 1318 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 1319 | for init_req_key in init_req_keys: |
| 1320 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 1321 | |
Girish Moturu | c0f87bc | 2020-05-23 21:20:05 -0700 | [diff] [blame] | 1322 | @test_tracker_info(uuid="34cf12e8-5df6-49bd-b384-e9935d89a5b7") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1323 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1324 | def test_identical_network_from_both_sides(self): |
| 1325 | """Validate that requesting two identical NDPs (Open) each being initiated |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1326 | from a different side, results in the same/single NDP. |
| 1327 | |
| 1328 | Verify that the interface and IPv6 address is the same for all networks. |
| 1329 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1330 | dut1 = self.android_devices[0] |
| 1331 | dut2 = self.android_devices[1] |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1332 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1333 | id1, mac1 = autils.attach_with_identity(dut1) |
| 1334 | id2, mac2 = autils.attach_with_identity(dut2) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1335 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1336 | # wait for for devices to synchronize with each other - there are no other |
| 1337 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 1338 | # to execute the data-path request) |
| 1339 | time.sleep(autils.WAIT_FOR_CLUSTER) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1340 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1341 | # first NDP: DUT1 (Init) -> DUT2 (Resp) |
| 1342 | req_a_resp = autils.request_network( |
| 1343 | dut2, |
| 1344 | dut2.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1345 | id2, aconsts.DATA_PATH_RESPONDER, mac1)) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1346 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1347 | req_a_init = autils.request_network( |
| 1348 | dut1, |
| 1349 | dut1.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1350 | id1, aconsts.DATA_PATH_INITIATOR, mac2)) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1351 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1352 | req_a_resp_event_nc = autils.wait_for_event_with_keys( |
| 1353 | dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1354 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1355 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1356 | (cconsts.NETWORK_CB_KEY_ID, req_a_resp)) |
| 1357 | req_a_init_event_nc = autils.wait_for_event_with_keys( |
| 1358 | dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1359 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1360 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1361 | (cconsts.NETWORK_CB_KEY_ID, req_a_init)) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1362 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1363 | # validate no leak of information |
| 1364 | asserts.assert_false( |
| 1365 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_a_resp_event_nc[ |
| 1366 | "data"], "Network specifier leak!") |
| 1367 | asserts.assert_false( |
| 1368 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_a_init_event_nc[ |
| 1369 | "data"], "Network specifier leak!") |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1370 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1371 | # note that Init <-> Resp since IPv6 are of peer's! |
| 1372 | req_a_ipv6_init = req_a_resp_event_nc["data"][aconsts.NET_CAP_IPV6] |
| 1373 | req_a_ipv6_resp = req_a_init_event_nc["data"][aconsts.NET_CAP_IPV6] |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1374 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1375 | req_a_resp_event_lp = autils.wait_for_event_with_keys( |
| 1376 | dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1377 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1378 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1379 | (cconsts.NETWORK_CB_KEY_ID, req_a_resp)) |
| 1380 | req_a_init_event_lp = autils.wait_for_event_with_keys( |
| 1381 | dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1382 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1383 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1384 | (cconsts.NETWORK_CB_KEY_ID, req_a_init)) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1385 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1386 | req_a_if_resp = req_a_resp_event_lp["data"][ |
| 1387 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 1388 | req_a_if_init = req_a_init_event_lp["data"][ |
| 1389 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1390 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1391 | self.log.info("Interface names for A: I=%s, R=%s", req_a_if_init, |
| 1392 | req_a_if_resp) |
| 1393 | self.log.info("Interface addresses (IPv6) for A: I=%s, R=%s", |
| 1394 | req_a_ipv6_init, req_a_ipv6_resp) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1395 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1396 | # second NDP: DUT2 (Init) -> DUT1 (Resp) |
| 1397 | req_b_resp = autils.request_network( |
| 1398 | dut1, |
| 1399 | dut1.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1400 | id1, aconsts.DATA_PATH_RESPONDER, mac2)) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1401 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1402 | req_b_init = autils.request_network( |
| 1403 | dut2, |
| 1404 | dut2.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1405 | id2, aconsts.DATA_PATH_INITIATOR, mac1)) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1406 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1407 | req_b_resp_event_nc = autils.wait_for_event_with_keys( |
| 1408 | dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1409 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1410 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1411 | (cconsts.NETWORK_CB_KEY_ID, req_b_resp)) |
| 1412 | req_b_init_event_nc = autils.wait_for_event_with_keys( |
| 1413 | dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1414 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1415 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1416 | (cconsts.NETWORK_CB_KEY_ID, req_b_init)) |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1417 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1418 | # validate no leak of information |
| 1419 | asserts.assert_false( |
| 1420 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_b_resp_event_nc[ |
| 1421 | "data"], "Network specifier leak!") |
| 1422 | asserts.assert_false( |
| 1423 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_b_init_event_nc[ |
| 1424 | "data"], "Network specifier leak!") |
Etan Cohen | ef38a7f | 2017-11-09 14:26:43 -0800 | [diff] [blame] | 1425 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1426 | # note that Init <-> Resp since IPv6 are of peer's! |
| 1427 | req_b_ipv6_init = req_b_resp_event_nc["data"][aconsts.NET_CAP_IPV6] |
| 1428 | req_b_ipv6_resp = req_b_init_event_nc["data"][aconsts.NET_CAP_IPV6] |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1429 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1430 | req_b_resp_event_lp = autils.wait_for_event_with_keys( |
| 1431 | dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1432 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1433 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1434 | (cconsts.NETWORK_CB_KEY_ID, req_b_resp)) |
| 1435 | req_b_init_event_lp = autils.wait_for_event_with_keys( |
| 1436 | dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1437 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1438 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1439 | (cconsts.NETWORK_CB_KEY_ID, req_b_init)) |
| 1440 | |
| 1441 | req_b_if_resp = req_b_resp_event_lp["data"][ |
| 1442 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 1443 | req_b_if_init = req_b_init_event_lp["data"][ |
| 1444 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 1445 | |
| 1446 | self.log.info("Interface names for B: I=%s, R=%s", req_b_if_init, |
| 1447 | req_b_if_resp) |
| 1448 | self.log.info("Interface addresses (IPv6) for B: I=%s, R=%s", |
| 1449 | req_b_ipv6_init, req_b_ipv6_resp) |
| 1450 | |
| 1451 | # validate equality of NDPs (using interface names & ipv6) |
| 1452 | asserts.assert_equal(req_a_if_init, req_b_if_resp, |
| 1453 | "DUT1 NDPs are on different interfaces") |
| 1454 | asserts.assert_equal(req_a_if_resp, req_b_if_init, |
| 1455 | "DUT2 NDPs are on different interfaces") |
| 1456 | asserts.assert_equal(req_a_ipv6_init, req_b_ipv6_resp, |
| 1457 | "DUT1 NDPs are using different IPv6 addresses") |
| 1458 | asserts.assert_equal(req_a_ipv6_resp, req_b_ipv6_init, |
| 1459 | "DUT2 NDPs are using different IPv6 addresses") |
| 1460 | |
| 1461 | # release requests |
| 1462 | dut1.droid.connectivityUnregisterNetworkCallback(req_a_init) |
| 1463 | dut1.droid.connectivityUnregisterNetworkCallback(req_b_resp) |
| 1464 | dut2.droid.connectivityUnregisterNetworkCallback(req_a_resp) |
| 1465 | dut2.droid.connectivityUnregisterNetworkCallback(req_b_init) |
| 1466 | |
| 1467 | ######################################################################## |
| 1468 | |
| 1469 | def run_multiple_ndi(self, sec_configs, flip_init_resp=False): |
| 1470 | """Validate that the device can create and use multiple NDIs. |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1471 | |
| 1472 | The security configuration can be: |
| 1473 | - None: open |
| 1474 | - String: passphrase |
| 1475 | - otherwise: PMK (byte array) |
| 1476 | |
| 1477 | Args: |
| 1478 | sec_configs: list of security configurations |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1479 | flip_init_resp: if True the roles of Initiator and Responder are flipped |
| 1480 | between the 2 devices, otherwise same devices are always |
| 1481 | configured in the same role. |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1482 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1483 | dut1 = self.android_devices[0] |
| 1484 | dut2 = self.android_devices[1] |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1485 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1486 | asserts.skip_if( |
| 1487 | dut1.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < |
| 1488 | len(sec_configs) |
| 1489 | or dut2.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < |
| 1490 | len(sec_configs), "DUTs do not support enough NDIs") |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1491 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1492 | id1, mac1 = autils.attach_with_identity(dut1) |
| 1493 | id2, mac2 = autils.attach_with_identity(dut2) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1494 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1495 | # wait for for devices to synchronize with each other - there are no other |
| 1496 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 1497 | # to execute the data-path request) |
| 1498 | time.sleep(autils.WAIT_FOR_CLUSTER) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1499 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1500 | dut2_req_keys = [] |
| 1501 | dut1_req_keys = [] |
| 1502 | dut2_aware_ifs = [] |
| 1503 | dut1_aware_ifs = [] |
| 1504 | dut2_aware_ipv6s = [] |
| 1505 | dut1_aware_ipv6s = [] |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1506 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1507 | dut2_type = aconsts.DATA_PATH_RESPONDER |
| 1508 | dut1_type = aconsts.DATA_PATH_INITIATOR |
| 1509 | dut2_is_responder = True |
| 1510 | for sec in sec_configs: |
| 1511 | if dut2_is_responder: |
| 1512 | # DUT2 (Responder): request network |
| 1513 | dut2_req_key = autils.request_network( |
| 1514 | dut2, |
| 1515 | autils.get_network_specifier(dut2, id2, dut2_type, mac1, |
| 1516 | sec)) |
| 1517 | dut2_req_keys.append(dut2_req_key) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1518 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1519 | # DUT1 (Initiator): request network |
| 1520 | dut1_req_key = autils.request_network( |
| 1521 | dut1, |
| 1522 | autils.get_network_specifier(dut1, id1, dut1_type, mac2, |
| 1523 | sec)) |
| 1524 | dut1_req_keys.append(dut1_req_key) |
| 1525 | else: |
| 1526 | # DUT1 (Responder): request network |
| 1527 | dut1_req_key = autils.request_network( |
| 1528 | dut1, |
| 1529 | autils.get_network_specifier(dut1, id1, dut1_type, mac2, |
| 1530 | sec)) |
| 1531 | dut1_req_keys.append(dut1_req_key) |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1532 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1533 | # DUT2 (Initiator): request network |
| 1534 | dut2_req_key = autils.request_network( |
| 1535 | dut2, |
| 1536 | autils.get_network_specifier(dut2, id2, dut2_type, mac1, |
| 1537 | sec)) |
| 1538 | dut2_req_keys.append(dut2_req_key) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1539 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1540 | # Wait for network |
| 1541 | dut1_net_event_nc = autils.wait_for_event_with_keys( |
| 1542 | dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1543 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1544 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1545 | (cconsts.NETWORK_CB_KEY_ID, dut1_req_key)) |
| 1546 | dut2_net_event_nc = autils.wait_for_event_with_keys( |
| 1547 | dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1548 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1549 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1550 | (cconsts.NETWORK_CB_KEY_ID, dut2_req_key)) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1551 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1552 | # validate no leak of information |
| 1553 | asserts.assert_false( |
| 1554 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in dut1_net_event_nc[ |
| 1555 | "data"], "Network specifier leak!") |
| 1556 | asserts.assert_false( |
| 1557 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in dut2_net_event_nc[ |
| 1558 | "data"], "Network specifier leak!") |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1559 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1560 | # Note: dut1 <--> dut2 IPv6's addresses since it is peer's info |
| 1561 | dut2_aware_ipv6 = dut1_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
| 1562 | dut1_aware_ipv6 = dut2_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1563 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1564 | dut1_net_event_lp = autils.wait_for_event_with_keys( |
| 1565 | dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1566 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1567 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1568 | (cconsts.NETWORK_CB_KEY_ID, dut1_req_key)) |
| 1569 | dut2_net_event_lp = autils.wait_for_event_with_keys( |
| 1570 | dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1571 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1572 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1573 | (cconsts.NETWORK_CB_KEY_ID, dut2_req_key)) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1574 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1575 | dut2_aware_if = dut2_net_event_lp["data"][ |
| 1576 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 1577 | dut1_aware_if = dut1_net_event_lp["data"][ |
| 1578 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1579 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1580 | dut2_aware_ifs.append(dut2_aware_if) |
| 1581 | dut1_aware_ifs.append(dut1_aware_if) |
| 1582 | dut2_aware_ipv6s.append(dut2_aware_ipv6) |
| 1583 | dut1_aware_ipv6s.append(dut1_aware_ipv6) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1584 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1585 | if flip_init_resp: |
| 1586 | if dut2_is_responder: |
| 1587 | dut2_type = aconsts.DATA_PATH_INITIATOR |
| 1588 | dut1_type = aconsts.DATA_PATH_RESPONDER |
| 1589 | else: |
| 1590 | dut2_type = aconsts.DATA_PATH_RESPONDER |
| 1591 | dut1_type = aconsts.DATA_PATH_INITIATOR |
| 1592 | dut2_is_responder = not dut2_is_responder |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1593 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1594 | # check that we are using 2 NDIs & that they have unique IPv6 addresses |
| 1595 | dut1_aware_ifs = list(set(dut1_aware_ifs)) |
| 1596 | dut2_aware_ifs = list(set(dut2_aware_ifs)) |
| 1597 | dut1_aware_ipv6s = list(set(dut1_aware_ipv6s)) |
| 1598 | dut2_aware_ipv6s = list(set(dut2_aware_ipv6s)) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1599 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1600 | self.log.info("Interface names: DUT1=%s, DUT2=%s", dut1_aware_ifs, |
| 1601 | dut2_aware_ifs) |
| 1602 | self.log.info("IPv6 addresses: DUT1=%s, DUT2=%s", dut1_aware_ipv6s, |
| 1603 | dut2_aware_ipv6s) |
| 1604 | self.log.info("DUT1 requests: %s", dut1_req_keys) |
| 1605 | self.log.info("DUT2 requests: %s", dut2_req_keys) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1606 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1607 | asserts.assert_equal( |
| 1608 | len(dut1_aware_ifs), len(sec_configs), "Multiple DUT1 interfaces") |
| 1609 | asserts.assert_equal( |
| 1610 | len(dut2_aware_ifs), len(sec_configs), "Multiple DUT2 interfaces") |
| 1611 | asserts.assert_equal( |
| 1612 | len(dut1_aware_ipv6s), len(sec_configs), |
| 1613 | "Multiple DUT1 IPv6 addresses") |
| 1614 | asserts.assert_equal( |
| 1615 | len(dut2_aware_ipv6s), len(sec_configs), |
| 1616 | "Multiple DUT2 IPv6 addresses") |
| 1617 | |
| 1618 | for i in range(len(sec_configs)): |
| 1619 | # note: using get_ipv6_addr (ifconfig method) since want to verify |
| 1620 | # that the system information is the same as the reported information |
| 1621 | if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i) |
| 1622 | dut1_ipv6 = autils.get_ipv6_addr(dut1, if_name) |
| 1623 | dut2_ipv6 = autils.get_ipv6_addr(dut2, if_name) |
| 1624 | |
| 1625 | asserts.assert_equal( |
| 1626 | dut1_ipv6 is None, if_name not in dut1_aware_ifs, |
| 1627 | "DUT1 interface %s in unexpected state" % if_name) |
| 1628 | asserts.assert_equal( |
| 1629 | dut2_ipv6 is None, if_name not in dut2_aware_ifs, |
| 1630 | "DUT2 interface %s in unexpected state" % if_name) |
| 1631 | |
| 1632 | # release requests |
| 1633 | for dut2_req_key in dut2_req_keys: |
| 1634 | dut2.droid.connectivityUnregisterNetworkCallback(dut2_req_key) |
| 1635 | for dut1_req_key in dut1_req_keys: |
| 1636 | dut1.droid.connectivityUnregisterNetworkCallback(dut1_req_key) |
| 1637 | |
| 1638 | @test_tracker_info(uuid="2d728163-11cc-46ba-a973-c8e1e71397fc") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1639 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1640 | def test_multiple_ndi_open_passphrase(self): |
| 1641 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1642 | configuration (one open, one using passphrase). The result should use two |
| 1643 | different NDIs""" |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1644 | self.run_multiple_ndi([None, self.PASSPHRASE]) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1645 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1646 | @test_tracker_info(uuid="5f2c32aa-20b2-41f0-8b1e-d0b68df73ada") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1647 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1648 | def test_multiple_ndi_open_pmk(self): |
| 1649 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1650 | configuration (one open, one using pmk). The result should use two |
| 1651 | different NDIs""" |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1652 | self.run_multiple_ndi([None, self.PMK]) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1653 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1654 | @test_tracker_info(uuid="34467659-bcfb-40cd-ba25-7e50560fca63") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1655 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1656 | def test_multiple_ndi_passphrase_pmk(self): |
| 1657 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1658 | configuration (one using passphrase, one using pmk). The result should use |
| 1659 | two different NDIs""" |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1660 | self.run_multiple_ndi([self.PASSPHRASE, self.PMK]) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1661 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1662 | @test_tracker_info(uuid="d9194ce6-45b6-41b1-9cc8-ada79968966d") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1663 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1664 | def test_multiple_ndi_passphrases(self): |
| 1665 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1666 | configuration (using different passphrases). The result should use two |
| 1667 | different NDIs""" |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1668 | self.run_multiple_ndi([self.PASSPHRASE, self.PASSPHRASE2]) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1669 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1670 | @test_tracker_info(uuid="879df795-62d2-40d4-a862-bd46d8f7e67f") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1671 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1672 | def test_multiple_ndi_pmks(self): |
| 1673 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1674 | configuration (using different PMKS). The result should use two different |
| 1675 | NDIs""" |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1676 | self.run_multiple_ndi([self.PMK, self.PMK2]) |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1677 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1678 | @test_tracker_info(uuid="397d380a-8e41-466e-9ccb-cf8f413d83ba") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1679 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1680 | def test_multiple_ndi_open_passphrase_flip(self): |
| 1681 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1682 | configuration (one open, one using passphrase). The result should use two |
| 1683 | different NDIs. |
| 1684 | |
| 1685 | Flip Initiator and Responder roles. |
| 1686 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1687 | self.run_multiple_ndi([None, self.PASSPHRASE], flip_init_resp=True) |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1688 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1689 | @test_tracker_info(uuid="b3a4300b-1514-4cb8-a814-9c2baa449700") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1690 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1691 | def test_multiple_ndi_open_pmk_flip(self): |
| 1692 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1693 | configuration (one open, one using pmk). The result should use two |
| 1694 | different NDIs |
| 1695 | |
| 1696 | Flip Initiator and Responder roles. |
| 1697 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1698 | self.run_multiple_ndi([None, self.PMK], flip_init_resp=True) |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1699 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1700 | @test_tracker_info(uuid="0bfea9e4-e57d-417f-8db4-245741e9bbd5") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1701 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1702 | def test_multiple_ndi_passphrase_pmk_flip(self): |
| 1703 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1704 | configuration (one using passphrase, one using pmk). The result should use |
| 1705 | two different NDIs |
| 1706 | |
| 1707 | Flip Initiator and Responder roles. |
| 1708 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1709 | self.run_multiple_ndi([self.PASSPHRASE, self.PMK], flip_init_resp=True) |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1710 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1711 | @test_tracker_info(uuid="74023483-5417-431b-a362-991ad4a03ab8") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1712 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1713 | def test_multiple_ndi_passphrases_flip(self): |
| 1714 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1715 | configuration (using different passphrases). The result should use two |
| 1716 | different NDIs |
| 1717 | |
| 1718 | Flip Initiator and Responder roles. |
| 1719 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1720 | self.run_multiple_ndi( |
| 1721 | [self.PASSPHRASE, self.PASSPHRASE2], flip_init_resp=True) |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1722 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1723 | @test_tracker_info(uuid="873b2d91-28a1-403f-ae9c-d756bb2f59ee") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1724 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1725 | def test_multiple_ndi_pmks_flip(self): |
| 1726 | """Verify that between 2 DUTs can create 2 NDPs with different security |
Etan Cohen | d6923f2 | 2017-11-09 15:37:16 -0800 | [diff] [blame] | 1727 | configuration (using different PMKS). The result should use two different |
| 1728 | NDIs |
| 1729 | |
| 1730 | Flip Initiator and Responder roles. |
| 1731 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1732 | self.run_multiple_ndi([self.PMK, self.PMK2], flip_init_resp=True) |
Etan Cohen | 7922a31 | 2018-01-23 13:34:55 -0800 | [diff] [blame] | 1733 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1734 | ####################################### |
Etan Cohen | 7922a31 | 2018-01-23 13:34:55 -0800 | [diff] [blame] | 1735 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1736 | @test_tracker_info(uuid="2f10a9df-7fbd-490d-a238-3523f47ab54c") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1737 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1738 | def test_ib_responder_any_usage(self): |
| 1739 | """Verify that configuring an in-band (Aware discovery) Responder to receive |
Etan Cohen | 7922a31 | 2018-01-23 13:34:55 -0800 | [diff] [blame] | 1740 | an NDP request from any peer is not permitted by current API level. Override |
| 1741 | API check to validate that possible (i.e. that failure at current API level |
| 1742 | is due to an API check and not some underlying failure). |
| 1743 | """ |
| 1744 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1745 | # configure all devices to override API check and allow a Responder from ANY |
| 1746 | for ad in self.android_devices: |
| 1747 | autils.configure_ndp_allow_any_override(ad, True) |
| 1748 | self.run_ib_data_path_test( |
| 1749 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 1750 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 1751 | encr_type=self.ENCR_TYPE_OPEN, |
| 1752 | use_peer_id=False) |
Etan Cohen | 7922a31 | 2018-01-23 13:34:55 -0800 | [diff] [blame] | 1753 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1754 | # configure all devices to respect API check - i.e. disallow a Responder |
| 1755 | # from ANY |
| 1756 | for ad in self.android_devices: |
| 1757 | autils.configure_ndp_allow_any_override(ad, False) |
| 1758 | self.run_ib_data_path_test( |
| 1759 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 1760 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 1761 | encr_type=self.ENCR_TYPE_OPEN, |
| 1762 | use_peer_id=False, |
| 1763 | expect_failure=True) |
Etan Cohen | 7922a31 | 2018-01-23 13:34:55 -0800 | [diff] [blame] | 1764 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1765 | @test_tracker_info(uuid="5889cd41-0a72-4b7b-ab82-5b9168b9b5b8") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1766 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1767 | def test_oob_responder_any_usage(self): |
| 1768 | """Verify that configuring an out-of-band (Aware discovery) Responder to |
Etan Cohen | 7922a31 | 2018-01-23 13:34:55 -0800 | [diff] [blame] | 1769 | receive an NDP request from any peer is not permitted by current API level. |
| 1770 | Override API check to validate that possible (i.e. that failure at current |
| 1771 | API level is due to an API check and not some underlying failure). |
| 1772 | """ |
| 1773 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1774 | # configure all devices to override API check and allow a Responder from ANY |
| 1775 | for ad in self.android_devices: |
| 1776 | autils.configure_ndp_allow_any_override(ad, True) |
| 1777 | self.run_oob_data_path_test( |
| 1778 | encr_type=self.ENCR_TYPE_OPEN, use_peer_id=False) |
Etan Cohen | 7922a31 | 2018-01-23 13:34:55 -0800 | [diff] [blame] | 1779 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1780 | # configure all devices to respect API check - i.e. disallow a Responder |
| 1781 | # from ANY |
| 1782 | for ad in self.android_devices: |
| 1783 | autils.configure_ndp_allow_any_override(ad, False) |
| 1784 | self.run_oob_data_path_test( |
| 1785 | encr_type=self.ENCR_TYPE_OPEN, |
| 1786 | use_peer_id=False, |
| 1787 | expect_failure=True) |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1788 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1789 | ####################################### |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1790 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1791 | def run_multiple_regulatory_domains(self, use_ib, init_domain, |
| 1792 | resp_domain): |
| 1793 | """Verify that a data-path setup with two conflicting regulatory domains |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1794 | works (the result should be run in Channel 6 - but that is not tested). |
| 1795 | |
| 1796 | Args: |
| 1797 | use_ib: True to use in-band discovery, False to use out-of-band discovery. |
| 1798 | init_domain: The regulatory domain of the Initiator/Subscriber. |
| 1799 | resp_domain: The regulator domain of the Responder/Publisher. |
| 1800 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1801 | init_dut = self.android_devices[0] |
| 1802 | resp_dut = self.android_devices[1] |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1803 | |
Roshan Pius | 48df08c | 2019-09-13 08:07:30 -0700 | [diff] [blame] | 1804 | wutils.set_wifi_country_code(init_dut, init_domain) |
| 1805 | wutils.set_wifi_country_code(resp_dut, resp_domain) |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1806 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1807 | if use_ib: |
| 1808 | (resp_req_key, init_req_key, resp_aware_if, init_aware_if, |
| 1809 | resp_ipv6, init_ipv6) = autils.create_ib_ndp( |
| 1810 | resp_dut, init_dut, |
| 1811 | autils.create_discovery_config( |
| 1812 | "GoogleTestXyz", aconsts.PUBLISH_TYPE_UNSOLICITED), |
| 1813 | autils.create_discovery_config( |
| 1814 | "GoogleTestXyz", aconsts.SUBSCRIBE_TYPE_PASSIVE), |
| 1815 | self.device_startup_offset) |
| 1816 | else: |
| 1817 | (init_req_key, resp_req_key, init_aware_if, resp_aware_if, |
| 1818 | init_ipv6, resp_ipv6) = autils.create_oob_ndp(init_dut, resp_dut) |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1819 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1820 | self.log.info("Interface names: I=%s, R=%s", init_aware_if, |
| 1821 | resp_aware_if) |
| 1822 | self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6, |
| 1823 | resp_ipv6) |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1824 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1825 | # clean-up |
| 1826 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 1827 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1828 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1829 | @test_tracker_info(uuid="eff53739-35c5-47a6-81f0-d70b51d89c3b") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1830 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1831 | def test_multiple_regulator_domains_ib_us_jp(self): |
| 1832 | """Verify data-path setup across multiple regulator domains. |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1833 | |
| 1834 | - Uses in-band discovery |
| 1835 | - Subscriber=US, Publisher=JP |
| 1836 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1837 | self.run_multiple_regulatory_domains( |
| 1838 | use_ib=True, |
| 1839 | init_domain=wutils.WifiEnums.CountryCode.US, |
| 1840 | resp_domain=wutils.WifiEnums.CountryCode.JAPAN) |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1841 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1842 | @test_tracker_info(uuid="19af47cc-3204-40ef-b50f-14cf7b89cf4a") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1843 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1844 | def test_multiple_regulator_domains_ib_jp_us(self): |
| 1845 | """Verify data-path setup across multiple regulator domains. |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1846 | |
| 1847 | - Uses in-band discovery |
| 1848 | - Subscriber=JP, Publisher=US |
| 1849 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1850 | self.run_multiple_regulatory_domains( |
| 1851 | use_ib=True, |
| 1852 | init_domain=wutils.WifiEnums.CountryCode.JAPAN, |
| 1853 | resp_domain=wutils.WifiEnums.CountryCode.US) |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1854 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1855 | @test_tracker_info(uuid="65285ab3-977f-4dbd-b663-d5a02f4fc663") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1856 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1857 | def test_multiple_regulator_domains_oob_us_jp(self): |
| 1858 | """Verify data-path setup across multiple regulator domains. |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1859 | |
| 1860 | - Uses out-f-band discovery |
| 1861 | - Initiator=US, Responder=JP |
| 1862 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1863 | self.run_multiple_regulatory_domains( |
| 1864 | use_ib=False, |
| 1865 | init_domain=wutils.WifiEnums.CountryCode.US, |
| 1866 | resp_domain=wutils.WifiEnums.CountryCode.JAPAN) |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1867 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1868 | @test_tracker_info(uuid="8a417e24-aaf6-44b9-a089-a07c3ba8d954") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 1869 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1870 | def test_multiple_regulator_domains_oob_jp_us(self): |
| 1871 | """Verify data-path setup across multiple regulator domains. |
Etan Cohen | c803dcc | 2018-02-02 15:14:04 -0800 | [diff] [blame] | 1872 | |
| 1873 | - Uses out-of-band discovery |
| 1874 | - Initiator=JP, Responder=US |
| 1875 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1876 | self.run_multiple_regulatory_domains( |
| 1877 | use_ib=False, |
| 1878 | init_domain=wutils.WifiEnums.CountryCode.JAPAN, |
| 1879 | resp_domain=wutils.WifiEnums.CountryCode.US) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1880 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1881 | ######################################################################## |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1882 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1883 | def run_mix_ib_oob(self, same_request, ib_first, inits_on_same_dut): |
| 1884 | """Validate that multiple network requests issued using both in-band and |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1885 | out-of-band discovery behave as expected. |
| 1886 | |
| 1887 | The same_request parameter controls whether identical single NDP is |
| 1888 | expected, if True, or whether multiple NDPs on different NDIs are expected, |
| 1889 | if False. |
| 1890 | |
| 1891 | Args: |
| 1892 | same_request: Issue canonically identical requests (same NMI peer, same |
| 1893 | passphrase) if True, if False use different passphrases. |
| 1894 | ib_first: If True then the in-band network is requested first, otherwise |
| 1895 | (if False) then the out-of-band network is requested first. |
| 1896 | inits_on_same_dut: If True then the Initiators are run on the same device, |
| 1897 | otherwise (if False) then the Initiators are run on |
| 1898 | different devices. Note that Subscribe == Initiator. |
| 1899 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1900 | if not same_request: |
| 1901 | asserts.skip_if( |
| 1902 | self.android_devices[0] |
| 1903 | .aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < 2 |
| 1904 | or self.android_devices[1] |
| 1905 | .aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < 2, |
| 1906 | "DUTs do not support enough NDIs") |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1907 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1908 | (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub, |
| 1909 | peer_id_on_pub_null) = self.set_up_discovery( |
| 1910 | aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 1911 | False) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1912 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1913 | p_id2, p_mac = autils.attach_with_identity(p_dut) |
| 1914 | s_id2, s_mac = autils.attach_with_identity(s_dut) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1915 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1916 | if inits_on_same_dut: |
| 1917 | resp_dut = p_dut |
| 1918 | resp_id = p_id2 |
| 1919 | resp_mac = p_mac |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1920 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1921 | init_dut = s_dut |
| 1922 | init_id = s_id2 |
| 1923 | init_mac = s_mac |
| 1924 | else: |
| 1925 | resp_dut = s_dut |
| 1926 | resp_id = s_id2 |
| 1927 | resp_mac = s_mac |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1928 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1929 | init_dut = p_dut |
| 1930 | init_id = p_id2 |
| 1931 | init_mac = p_mac |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1932 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1933 | passphrase = None if same_request else self.PASSPHRASE |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1934 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1935 | if ib_first: |
| 1936 | # request in-band network (to completion) |
| 1937 | p_req_key = self.request_network( |
| 1938 | p_dut, |
| 1939 | p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, None)) |
| 1940 | s_req_key = self.request_network( |
| 1941 | s_dut, |
| 1942 | s_dut.droid.wifiAwareCreateNetworkSpecifier( |
| 1943 | s_disc_id, peer_id_on_sub)) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1944 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1945 | # Publisher & Subscriber: wait for network formation |
| 1946 | p_net_event_nc = autils.wait_for_event_with_keys( |
| 1947 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 1948 | autils.EVENT_NDP_TIMEOUT, |
| 1949 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1950 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1951 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 1952 | s_net_event_nc = autils.wait_for_event_with_keys( |
| 1953 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 1954 | autils.EVENT_NDP_TIMEOUT, |
| 1955 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1956 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1957 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
| 1958 | p_net_event_lp = autils.wait_for_event_with_keys( |
| 1959 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 1960 | autils.EVENT_NDP_TIMEOUT, |
| 1961 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1962 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1963 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 1964 | s_net_event_lp = autils.wait_for_event_with_keys( |
| 1965 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 1966 | autils.EVENT_NDP_TIMEOUT, |
| 1967 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1968 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1969 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1970 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1971 | # validate no leak of information |
| 1972 | asserts.assert_false( |
| 1973 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[ |
| 1974 | "data"], "Network specifier leak!") |
| 1975 | asserts.assert_false( |
| 1976 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[ |
| 1977 | "data"], "Network specifier leak!") |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1978 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1979 | # request out-of-band network |
| 1980 | resp_req_key = autils.request_network( |
| 1981 | resp_dut, |
| 1982 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1983 | resp_id, aconsts.DATA_PATH_RESPONDER, init_mac, passphrase)) |
| 1984 | init_req_key = autils.request_network( |
| 1985 | init_dut, |
| 1986 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1987 | init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase)) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 1988 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 1989 | resp_net_event_nc = autils.wait_for_event_with_keys( |
| 1990 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1991 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1992 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1993 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
| 1994 | init_net_event_nc = autils.wait_for_event_with_keys( |
| 1995 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 1996 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1997 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 1998 | (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 1999 | resp_net_event_lp = autils.wait_for_event_with_keys( |
| 2000 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 2001 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 2002 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 2003 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
| 2004 | init_net_event_lp = autils.wait_for_event_with_keys( |
| 2005 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
| 2006 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 2007 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 2008 | (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2009 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2010 | # validate no leak of information |
| 2011 | asserts.assert_false( |
| 2012 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in resp_net_event_nc[ |
| 2013 | "data"], "Network specifier leak!") |
| 2014 | asserts.assert_false( |
| 2015 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in init_net_event_nc[ |
| 2016 | "data"], "Network specifier leak!") |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2017 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2018 | if not ib_first: |
| 2019 | # request in-band network (to completion) |
| 2020 | p_req_key = self.request_network( |
| 2021 | p_dut, |
| 2022 | p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, None)) |
| 2023 | s_req_key = self.request_network( |
| 2024 | s_dut, |
| 2025 | s_dut.droid.wifiAwareCreateNetworkSpecifier( |
| 2026 | s_disc_id, peer_id_on_sub)) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2027 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2028 | # Publisher & Subscriber: wait for network formation |
| 2029 | p_net_event_nc = autils.wait_for_event_with_keys( |
| 2030 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 2031 | autils.EVENT_NDP_TIMEOUT, |
| 2032 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 2033 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 2034 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 2035 | s_net_event_nc = autils.wait_for_event_with_keys( |
| 2036 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 2037 | autils.EVENT_NDP_TIMEOUT, |
| 2038 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 2039 | cconsts.NETWORK_CB_CAPABILITIES_CHANGED), |
| 2040 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
| 2041 | p_net_event_lp = autils.wait_for_event_with_keys( |
| 2042 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 2043 | autils.EVENT_NDP_TIMEOUT, |
| 2044 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 2045 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 2046 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 2047 | s_net_event_lp = autils.wait_for_event_with_keys( |
| 2048 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 2049 | autils.EVENT_NDP_TIMEOUT, |
| 2050 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 2051 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 2052 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2053 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2054 | # validate no leak of information |
| 2055 | asserts.assert_false( |
| 2056 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[ |
| 2057 | "data"], "Network specifier leak!") |
| 2058 | asserts.assert_false( |
| 2059 | cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[ |
| 2060 | "data"], "Network specifier leak!") |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2061 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2062 | # note that Init <-> Resp & Pub <--> Sub since IPv6 are of peer's! |
| 2063 | init_ipv6 = resp_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
| 2064 | resp_ipv6 = init_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
| 2065 | pub_ipv6 = s_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
| 2066 | sub_ipv6 = p_net_event_nc["data"][aconsts.NET_CAP_IPV6] |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2067 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2068 | # extract net info |
| 2069 | pub_interface = p_net_event_lp["data"][ |
| 2070 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 2071 | sub_interface = s_net_event_lp["data"][ |
| 2072 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 2073 | resp_interface = resp_net_event_lp["data"][ |
| 2074 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 2075 | init_interface = init_net_event_lp["data"][ |
| 2076 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2077 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2078 | self.log.info("Interface names: Pub=%s, Sub=%s, Resp=%s, Init=%s", |
| 2079 | pub_interface, sub_interface, resp_interface, |
| 2080 | init_interface) |
| 2081 | self.log.info( |
| 2082 | "Interface addresses (IPv6): Pub=%s, Sub=%s, Resp=%s, Init=%s", |
| 2083 | pub_ipv6, sub_ipv6, resp_ipv6, init_ipv6) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2084 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2085 | # validate NDP/NDI conditions (using interface names & ipv6) |
| 2086 | if same_request: |
| 2087 | asserts.assert_equal( |
| 2088 | pub_interface, resp_interface if inits_on_same_dut else |
| 2089 | init_interface, "NDP interfaces don't match on Pub/other") |
| 2090 | asserts.assert_equal( |
| 2091 | sub_interface, init_interface if inits_on_same_dut else |
| 2092 | resp_interface, "NDP interfaces don't match on Sub/other") |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2093 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2094 | asserts.assert_equal(pub_ipv6, resp_ipv6 |
| 2095 | if inits_on_same_dut else init_ipv6, |
| 2096 | "NDP IPv6 don't match on Pub/other") |
| 2097 | asserts.assert_equal(sub_ipv6, init_ipv6 |
| 2098 | if inits_on_same_dut else resp_ipv6, |
| 2099 | "NDP IPv6 don't match on Sub/other") |
| 2100 | else: |
| 2101 | asserts.assert_false( |
| 2102 | pub_interface == (resp_interface |
| 2103 | if inits_on_same_dut else init_interface), |
| 2104 | "NDP interfaces match on Pub/other") |
| 2105 | asserts.assert_false( |
| 2106 | sub_interface == (init_interface |
| 2107 | if inits_on_same_dut else resp_interface), |
| 2108 | "NDP interfaces match on Sub/other") |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2109 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2110 | asserts.assert_false( |
| 2111 | pub_ipv6 == (resp_ipv6 if inits_on_same_dut else init_ipv6), |
| 2112 | "NDP IPv6 match on Pub/other") |
| 2113 | asserts.assert_false( |
| 2114 | sub_ipv6 == (init_ipv6 if inits_on_same_dut else resp_ipv6), |
| 2115 | "NDP IPv6 match on Sub/other") |
| 2116 | |
| 2117 | # release requests |
| 2118 | p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key) |
| 2119 | s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key) |
| 2120 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 2121 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
| 2122 | |
| 2123 | @test_tracker_info(uuid="d8a0839d-4ba0-43f2-af93-3cf1382f9f16") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 2124 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2125 | def test_identical_ndps_mix_ib_oob_ib_first_same_polarity(self): |
| 2126 | """Validate that a single NDP is created for multiple identical requests |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2127 | which are issued through either in-band (ib) or out-of-band (oob) APIs. |
| 2128 | |
| 2129 | The in-band request is issued first. Both Initiators (Sub == Initiator) are |
| 2130 | run on the same device. |
| 2131 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2132 | self.run_mix_ib_oob( |
| 2133 | same_request=True, ib_first=True, inits_on_same_dut=True) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2134 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2135 | @test_tracker_info(uuid="70bbb811-0bed-4a19-96b3-f2446e777c8a") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 2136 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2137 | def test_identical_ndps_mix_ib_oob_oob_first_same_polarity(self): |
| 2138 | """Validate that a single NDP is created for multiple identical requests |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2139 | which are issued through either in-band (ib) or out-of-band (oob) APIs. |
| 2140 | |
| 2141 | The out-of-band request is issued first. Both Initiators (Sub == Initiator) |
| 2142 | are run on the same device. |
| 2143 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2144 | self.run_mix_ib_oob( |
| 2145 | same_request=True, ib_first=False, inits_on_same_dut=True) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2146 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2147 | @test_tracker_info(uuid="d9796da5-f96a-4a51-be0f-89d6f5bfe3ad") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 2148 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2149 | def test_identical_ndps_mix_ib_oob_ib_first_diff_polarity(self): |
| 2150 | """Validate that a single NDP is created for multiple identical requests |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2151 | which are issued through either in-band (ib) or out-of-band (oob) APIs. |
| 2152 | |
| 2153 | The in-band request is issued first. Initiators (Sub == Initiator) are |
| 2154 | run on different devices. |
| 2155 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2156 | self.run_mix_ib_oob( |
| 2157 | same_request=True, ib_first=True, inits_on_same_dut=False) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2158 | |
Girish Moturu | c0f87bc | 2020-05-23 21:20:05 -0700 | [diff] [blame] | 2159 | @test_tracker_info(uuid="48b9005b-7851-4222-b41c-1fcbefbc704d") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 2160 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2161 | def test_identical_ndps_mix_ib_oob_oob_first_diff_polarity(self): |
| 2162 | """Validate that a single NDP is created for multiple identical requests |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2163 | which are issued through either in-band (ib) or out-of-band (oob) APIs. |
| 2164 | |
| 2165 | The out-of-band request is issued first. Initiators (Sub == Initiator) are |
| 2166 | run on different devices. |
| 2167 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2168 | self.run_mix_ib_oob( |
| 2169 | same_request=True, ib_first=False, inits_on_same_dut=False) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2170 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2171 | @test_tracker_info(uuid="51f9581e-c5ee-48a7-84d2-adff4876c3d7") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 2172 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2173 | def test_multiple_ndis_mix_ib_oob_ib_first_same_polarity(self): |
| 2174 | """Validate that multiple NDIs are created for NDPs which are requested with |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2175 | different security configurations. Use a mix of in-band and out-of-band APIs |
| 2176 | to request the different NDPs. |
| 2177 | |
| 2178 | The in-band request is issued first. Initiators (Sub == Initiator) are |
| 2179 | run on the same device. |
| 2180 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2181 | self.run_mix_ib_oob( |
| 2182 | same_request=False, ib_first=True, inits_on_same_dut=True) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2183 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2184 | @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 2185 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2186 | def test_multiple_ndis_mix_ib_oob_oob_first_same_polarity(self): |
| 2187 | """Validate that multiple NDIs are created for NDPs which are requested with |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2188 | different security configurations. Use a mix of in-band and out-of-band APIs |
| 2189 | to request the different NDPs. |
| 2190 | |
| 2191 | The out-of-band request is issued first. Initiators (Sub == Initiator) are |
| 2192 | run on the same device. |
| 2193 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2194 | self.run_mix_ib_oob( |
| 2195 | same_request=False, ib_first=False, inits_on_same_dut=True) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2196 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2197 | @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 2198 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2199 | def test_multiple_ndis_mix_ib_oob_ib_first_diff_polarity(self): |
| 2200 | """Validate that multiple NDIs are created for NDPs which are requested with |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2201 | different security configurations. Use a mix of in-band and out-of-band APIs |
| 2202 | to request the different NDPs. |
| 2203 | |
| 2204 | The in-band request is issued first. Initiators (Sub == Initiator) are |
| 2205 | run on different devices. |
| 2206 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2207 | self.run_mix_ib_oob( |
| 2208 | same_request=False, ib_first=True, inits_on_same_dut=False) |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2209 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2210 | @test_tracker_info(uuid="596caadf-028e-494b-bbce-8304ccec2cbb") |
Girish Moturu | aac2f21 | 2020-05-15 21:20:46 -0700 | [diff] [blame] | 2211 | @WifiBaseTest.wifi_test_wrap |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2212 | def test_multiple_ndis_mix_ib_oob_oob_first_diff_polarity(self): |
| 2213 | """Validate that multiple NDIs are created for NDPs which are requested with |
Etan Cohen | 0ead455 | 2017-12-27 16:17:50 -0800 | [diff] [blame] | 2214 | different security configurations. Use a mix of in-band and out-of-band APIs |
| 2215 | to request the different NDPs. |
| 2216 | |
| 2217 | The out-of-band request is issued first. Initiators (Sub == Initiator) are |
| 2218 | run on different devices. |
| 2219 | """ |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2220 | self.run_mix_ib_oob( |
| 2221 | same_request=False, ib_first=False, inits_on_same_dut=False) |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2222 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2223 | ######################################################################## |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2224 | |
Girish Moturu | c0f87bc | 2020-05-23 21:20:05 -0700 | [diff] [blame] | 2225 | @test_tracker_info(uuid="5ec10bf9-bfda-4093-8344-7ccc7764737e") |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2226 | def test_ndp_loop(self): |
| 2227 | """Validate that can create a loop (chain) of N NDPs between N devices, |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2228 | where N >= 3, e.g. |
| 2229 | |
| 2230 | A - B |
| 2231 | B - C |
| 2232 | C - A |
| 2233 | |
| 2234 | The NDPs are all OPEN (no encryption). |
| 2235 | """ |
Girish Moturu | ee45437 | 2019-10-14 11:23:02 -0700 | [diff] [blame] | 2236 | asserts.skip_if( |
| 2237 | len(self.android_devices) < 3, |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2238 | 'A minimum of 3 devices is needed to run the test, have %d' % len( |
| 2239 | self.android_devices)) |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2240 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2241 | duts = self.android_devices |
| 2242 | loop_len = len(duts) |
| 2243 | ids = [] |
| 2244 | macs = [] |
| 2245 | reqs = [] |
| 2246 | ifs = [] |
| 2247 | ipv6s = [] |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2248 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2249 | for i in range(loop_len): |
| 2250 | duts[i].pretty_name = chr(ord("A") + i) |
| 2251 | reqs.append([]) |
| 2252 | ifs.append([]) |
| 2253 | ipv6s.append([]) |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2254 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2255 | # start-up 3 devices (attach w/ identity) |
| 2256 | for i in range(loop_len): |
| 2257 | ids.append(duts[i].droid.wifiAwareAttach(True)) |
| 2258 | autils.wait_for_event(duts[i], aconsts.EVENT_CB_ON_ATTACHED) |
| 2259 | ident_event = autils.wait_for_event( |
| 2260 | duts[i], aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 2261 | macs.append(ident_event['data']['mac']) |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2262 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2263 | # wait for for devices to synchronize with each other - there are no other |
| 2264 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 2265 | # to execute the data-path request) |
| 2266 | time.sleep(autils.WAIT_FOR_CLUSTER) |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2267 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2268 | # create the N NDPs: i to (i+1) % N |
| 2269 | for i in range(loop_len): |
| 2270 | peer_device = (i + 1) % loop_len |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2271 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2272 | (init_req_key, resp_req_key, init_aware_if, resp_aware_if, |
| 2273 | init_ipv6, resp_ipv6) = autils.create_oob_ndp_on_sessions( |
| 2274 | duts[i], duts[peer_device], ids[i], macs[i], ids[peer_device], |
| 2275 | macs[peer_device]) |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2276 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2277 | reqs[i].append(init_req_key) |
| 2278 | reqs[peer_device].append(resp_req_key) |
| 2279 | ifs[i].append(init_aware_if) |
| 2280 | ifs[peer_device].append(resp_aware_if) |
| 2281 | ipv6s[i].append(init_ipv6) |
| 2282 | ipv6s[peer_device].append(resp_ipv6) |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2283 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2284 | # clean-up |
| 2285 | for i in range(loop_len): |
| 2286 | for req in reqs[i]: |
| 2287 | duts[i].droid.connectivityUnregisterNetworkCallback(req) |
Etan Cohen | dbb49c9 | 2018-04-19 15:32:38 -0700 | [diff] [blame] | 2288 | |
Jaineel | 7e67a3f | 2019-08-28 15:58:49 -0700 | [diff] [blame] | 2289 | # info |
| 2290 | self.log.info("MACs: %s", macs) |
| 2291 | self.log.info("Interface names: %s", ifs) |
| 2292 | self.log.info("IPv6 addresses: %s", ipv6s) |
| 2293 | asserts.explicit_pass( |
| 2294 | "NDP loop test", extras={ |
| 2295 | "macs": macs, |
| 2296 | "ifs": ifs, |
| 2297 | "ipv6s": ipv6s |
| 2298 | }) |