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