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 | |
| 19 | from acts.test_utils.net import connectivity_const as cconsts |
| 20 | from acts.test_utils.wifi.aware import aware_const as aconsts |
| 21 | from acts.test_utils.wifi.aware import aware_test_utils as autils |
| 22 | from acts.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest |
| 23 | |
| 24 | |
| 25 | class DataPathTest(AwareBaseTest): |
| 26 | """Set of tests for Wi-Fi Aware discovery.""" |
| 27 | |
| 28 | # configuration parameters used by tests |
| 29 | ENCR_TYPE_OPEN = 0 |
| 30 | ENCR_TYPE_PASSPHRASE = 1 |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 31 | ENCR_TYPE_PMK = 2 |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 32 | |
| 33 | PASSPHRASE = "This is some random passphrase - very very secure!!" |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 34 | PASSPHRASE_MIN = "01234567" |
| 35 | PASSPHRASE_MAX = "012345678901234567890123456789012345678901234567890123456789012" |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 36 | PMK = "ODU0YjE3YzdmNDJiNWI4NTQ2NDJjNDI3M2VkZTQyZGU=" |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame^] | 37 | PASSPHRASE2 = "This is some random passphrase - very very secure - but diff!!" |
| 38 | PMK2 = "NjRhZGJiMmJkZWQyYTZhNjZhMmZjYzVlNTA3MmM3YTANCg==" |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 39 | |
| 40 | PING_MSG = "ping" |
| 41 | |
| 42 | # message re-transmit counter (increases reliability in open-environment) |
| 43 | # Note: reliability of message transmission is tested elsewhere |
| 44 | MSG_RETX_COUNT = 5 # hard-coded max value, internal API |
| 45 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 46 | # number of second to 'reasonably' wait to make sure that devices synchronize |
| 47 | # with each other - useful for OOB test cases, where the OOB discovery would |
| 48 | # take some time |
| 49 | WAIT_FOR_CLUSTER = 5 |
| 50 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 51 | def __init__(self, controllers): |
| 52 | AwareBaseTest.__init__(self, controllers) |
| 53 | |
| 54 | def create_config(self, dtype): |
| 55 | """Create a base configuration based on input parameters. |
| 56 | |
| 57 | Args: |
| 58 | dtype: Publish or Subscribe discovery type |
| 59 | |
| 60 | Returns: |
| 61 | Discovery configuration object. |
| 62 | """ |
| 63 | config = {} |
| 64 | config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = dtype |
| 65 | config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = "GoogleTestServiceDataPath" |
| 66 | return config |
| 67 | |
| 68 | def request_network(self, dut, ns): |
| 69 | """Request a Wi-Fi Aware network. |
| 70 | |
| 71 | Args: |
| 72 | dut: Device |
| 73 | ns: Network specifier |
| 74 | Returns: the request key |
| 75 | """ |
| 76 | network_req = {"TransportType": 5, "NetworkSpecifier": ns} |
| 77 | return dut.droid.connectivityRequestWifiAwareNetwork(network_req) |
| 78 | |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 79 | def run_ib_data_path_test(self, |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame^] | 80 | ptype, |
| 81 | stype, |
| 82 | encr_type, |
| 83 | use_peer_id, |
| 84 | passphrase_to_use=None): |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 85 | """Runs the in-band data-path tests. |
| 86 | |
| 87 | Args: |
| 88 | ptype: Publish discovery type |
| 89 | stype: Subscribe discovery type |
| 90 | encr_type: Encryption type, one of ENCR_TYPE_* |
| 91 | use_peer_id: On Responder (publisher): True to use peer ID, False to |
| 92 | accept any request |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 93 | passphrase_to_use: The passphrase to use if encr_type=ENCR_TYPE_PASSPHRASE |
| 94 | If None then use self.PASSPHRASE |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 95 | """ |
| 96 | p_dut = self.android_devices[0] |
| 97 | p_dut.pretty_name = "Publisher" |
| 98 | s_dut = self.android_devices[1] |
| 99 | s_dut.pretty_name = "Subscriber" |
| 100 | |
| 101 | # Publisher+Subscriber: attach and wait for confirmation |
| 102 | p_id = p_dut.droid.wifiAwareAttach() |
| 103 | autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 104 | s_id = s_dut.droid.wifiAwareAttach() |
| 105 | autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 106 | |
| 107 | # Publisher: start publish and wait for confirmation |
| 108 | p_disc_id = p_dut.droid.wifiAwarePublish(p_id, self.create_config(ptype)) |
| 109 | autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
| 110 | |
| 111 | # Subscriber: start subscribe and wait for confirmation |
| 112 | s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id, self.create_config(stype)) |
| 113 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED) |
| 114 | |
| 115 | # Subscriber: wait for service discovery |
| 116 | discovery_event = autils.wait_for_event( |
| 117 | s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) |
| 118 | peer_id_on_sub = discovery_event["data"][aconsts.SESSION_CB_KEY_PEER_ID] |
| 119 | |
| 120 | if use_peer_id: # only need message to receive peer ID |
| 121 | # Subscriber: send message to peer (Publisher - so it knows our address) |
| 122 | s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub, |
| 123 | self.get_next_msg_id(), self.PING_MSG, |
| 124 | self.MSG_RETX_COUNT) |
| 125 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT) |
| 126 | |
| 127 | # Publisher: wait for received message |
| 128 | pub_rx_msg_event = autils.wait_for_event( |
| 129 | p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED) |
| 130 | peer_id_on_pub = pub_rx_msg_event["data"][aconsts.SESSION_CB_KEY_PEER_ID] |
| 131 | |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 132 | key = None |
| 133 | if encr_type == self.ENCR_TYPE_PASSPHRASE: |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 134 | key = self.PASSPHRASE if passphrase_to_use == None else passphrase_to_use |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 135 | elif encr_type == self.ENCR_TYPE_PMK: |
| 136 | key = self.PMK |
| 137 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 138 | # Publisher: request network |
| 139 | p_req_key = self.request_network( |
| 140 | p_dut, |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 141 | p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, peer_id_on_pub if |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame^] | 142 | use_peer_id else None, key)) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 143 | |
| 144 | # Subscriber: request network |
| 145 | s_req_key = self.request_network( |
| 146 | s_dut, |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 147 | s_dut.droid.wifiAwareCreateNetworkSpecifier(s_disc_id, peer_id_on_sub, |
| 148 | key)) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 149 | |
| 150 | # Publisher & Subscriber: wait for network formation |
| 151 | p_net_event = autils.wait_for_event_with_keys( |
| 152 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 153 | autils.EVENT_TIMEOUT, |
| 154 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 155 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 156 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 157 | s_net_event = autils.wait_for_event_with_keys( |
| 158 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 159 | autils.EVENT_TIMEOUT, |
| 160 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 161 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 162 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
| 163 | |
| 164 | p_aware_if = p_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 165 | s_aware_if = s_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 166 | self.log.info("Interface names: p=%s, s=%s", p_aware_if, s_aware_if) |
| 167 | |
| 168 | p_ipv6 = p_dut.droid.connectivityGetLinkLocalIpv6Address(p_aware_if).split( |
| 169 | "%")[0] |
| 170 | s_ipv6 = s_dut.droid.connectivityGetLinkLocalIpv6Address(s_aware_if).split( |
| 171 | "%")[0] |
| 172 | self.log.info("Interface addresses (IPv6): p=%s, s=%s", p_ipv6, s_ipv6) |
| 173 | |
| 174 | # TODO: possibly send messages back and forth, prefer to use netcat/nc |
| 175 | |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 176 | # terminate sessions and wait for ON_LOST callbacks |
| 177 | p_dut.droid.wifiAwareDestroy(p_id) |
| 178 | s_dut.droid.wifiAwareDestroy(s_id) |
| 179 | |
| 180 | autils.wait_for_event_with_keys( |
| 181 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT, |
| 182 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 183 | cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 184 | autils.wait_for_event_with_keys( |
| 185 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT, |
| 186 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 187 | cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
| 188 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 189 | # clean-up |
| 190 | p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key) |
| 191 | s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key) |
| 192 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 193 | def run_oob_data_path_test(self, encr_type, use_peer_id): |
| 194 | """Runs the out-of-band data-path tests. |
| 195 | |
| 196 | Args: |
| 197 | encr_type: Encryption type, one of ENCR_TYPE_* |
| 198 | use_peer_id: On Responder: True to use peer ID, False to accept any |
| 199 | request |
| 200 | """ |
| 201 | init_dut = self.android_devices[0] |
| 202 | init_dut.pretty_name = "Initiator" |
| 203 | resp_dut = self.android_devices[1] |
| 204 | resp_dut.pretty_name = "Responder" |
| 205 | |
| 206 | # Publisher+Subscriber: attach and wait for confirmation & identity |
| 207 | init_id = init_dut.droid.wifiAwareAttach(True) |
| 208 | autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 209 | init_ident_event = autils.wait_for_event( |
| 210 | init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 211 | init_mac = init_ident_event["data"]["mac"] |
| 212 | resp_id = resp_dut.droid.wifiAwareAttach(True) |
| 213 | autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 214 | resp_ident_event = autils.wait_for_event( |
| 215 | resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 216 | resp_mac = resp_ident_event["data"]["mac"] |
| 217 | |
| 218 | # wait for for devices to synchronize with each other - there are no other |
| 219 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 220 | # to execute the data-path request) |
| 221 | time.sleep(self.WAIT_FOR_CLUSTER) |
| 222 | |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 223 | key = None |
| 224 | if encr_type == self.ENCR_TYPE_PASSPHRASE: |
| 225 | key = self.PASSPHRASE |
| 226 | elif encr_type == self.ENCR_TYPE_PMK: |
| 227 | key = self.PMK |
| 228 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 229 | # Responder: request network |
| 230 | resp_req_key = self.request_network( |
| 231 | resp_dut, |
| 232 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 233 | resp_id, aconsts.DATA_PATH_RESPONDER, init_mac |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 234 | if use_peer_id else None, key)) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 235 | |
| 236 | # Initiator: request network |
| 237 | init_req_key = self.request_network( |
| 238 | init_dut, |
| 239 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 240 | init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, key)) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 241 | |
| 242 | # Initiator & Responder: wait for network formation |
| 243 | init_net_event = autils.wait_for_event_with_keys( |
| 244 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 245 | autils.EVENT_TIMEOUT, |
| 246 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 247 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 248 | (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 249 | resp_net_event = autils.wait_for_event_with_keys( |
| 250 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, |
| 251 | autils.EVENT_TIMEOUT, |
| 252 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 253 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 254 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
| 255 | |
| 256 | init_aware_if = init_net_event["data"][ |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame^] | 257 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 258 | resp_aware_if = resp_net_event["data"][ |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame^] | 259 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 260 | self.log.info("Interface names: I=%s, R=%s", init_aware_if, resp_aware_if) |
| 261 | |
| 262 | init_ipv6 = init_dut.droid.connectivityGetLinkLocalIpv6Address( |
| 263 | init_aware_if).split("%")[0] |
| 264 | resp_ipv6 = resp_dut.droid.connectivityGetLinkLocalIpv6Address( |
| 265 | resp_aware_if).split("%")[0] |
| 266 | self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6, |
| 267 | resp_ipv6) |
| 268 | |
| 269 | # TODO: possibly send messages back and forth, prefer to use netcat/nc |
| 270 | |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 271 | # terminate sessions and wait for ON_LOST callbacks |
| 272 | init_dut.droid.wifiAwareDestroy(init_id) |
| 273 | resp_dut.droid.wifiAwareDestroy(resp_id) |
| 274 | |
| 275 | autils.wait_for_event_with_keys( |
| 276 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT, |
| 277 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 278 | cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 279 | autils.wait_for_event_with_keys( |
| 280 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT, |
| 281 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 282 | cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
| 283 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 284 | # clean-up |
| 285 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 286 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
| 287 | |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame^] | 288 | def run_mismatched_oob_data_path_test(self, |
| 289 | init_mismatch_mac=False, |
| 290 | resp_mismatch_mac=False, |
| 291 | init_encr_type=ENCR_TYPE_OPEN, |
| 292 | resp_encr_type=ENCR_TYPE_OPEN): |
| 293 | """Runs the negative out-of-band data-path tests: mismatched information |
| 294 | between Responder and Initiator. |
| 295 | |
| 296 | Args: |
| 297 | init_mismatch_mac: True to mismatch the Initiator MAC address |
| 298 | resp_mismatch_mac: True to mismatch the Responder MAC address |
| 299 | init_encr_type: Encryption type of Initiator - ENCR_TYPE_* |
| 300 | resp_encr_type: Encryption type of Responder - ENCR_TYPE_* |
| 301 | """ |
| 302 | init_dut = self.android_devices[0] |
| 303 | init_dut.pretty_name = "Initiator" |
| 304 | resp_dut = self.android_devices[1] |
| 305 | resp_dut.pretty_name = "Responder" |
| 306 | |
| 307 | # Publisher+Subscriber: attach and wait for confirmation & identity |
| 308 | init_id = init_dut.droid.wifiAwareAttach(True) |
| 309 | autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 310 | init_ident_event = autils.wait_for_event( |
| 311 | init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 312 | init_mac = init_ident_event["data"]["mac"] |
| 313 | resp_id = resp_dut.droid.wifiAwareAttach(True) |
| 314 | autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 315 | resp_ident_event = autils.wait_for_event( |
| 316 | resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 317 | resp_mac = resp_ident_event["data"]["mac"] |
| 318 | |
| 319 | if init_mismatch_mac: # assumes legit ones don't start with "00" |
| 320 | init_mac = "00" + init_mac[2:] |
| 321 | if resp_mismatch_mac: |
| 322 | resp_mac = "00" + resp_mac[2:] |
| 323 | |
| 324 | # wait for for devices to synchronize with each other - there are no other |
| 325 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 326 | # to execute the data-path request) |
| 327 | time.sleep(self.WAIT_FOR_CLUSTER) |
| 328 | |
| 329 | # set up separate keys: even if types are the same we want a mismatch |
| 330 | init_key = None |
| 331 | if init_encr_type == self.ENCR_TYPE_PASSPHRASE: |
| 332 | init_key = self.PASSPHRASE |
| 333 | elif init_encr_type == self.ENCR_TYPE_PMK: |
| 334 | init_key = self.PMK |
| 335 | |
| 336 | resp_key = None |
| 337 | if resp_encr_type == self.ENCR_TYPE_PASSPHRASE: |
| 338 | resp_key = self.PASSPHRASE2 |
| 339 | elif resp_encr_type == self.ENCR_TYPE_PMK: |
| 340 | resp_key = self.PMK2 |
| 341 | |
| 342 | # Responder: request network |
| 343 | resp_req_key = self.request_network( |
| 344 | resp_dut, |
| 345 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 346 | resp_id, aconsts.DATA_PATH_RESPONDER, init_mac, resp_key)) |
| 347 | |
| 348 | # Initiator: request network |
| 349 | init_req_key = self.request_network( |
| 350 | init_dut, |
| 351 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 352 | init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, init_key)) |
| 353 | |
| 354 | # Initiator & Responder: fail on network formation |
| 355 | time.sleep(autils.EVENT_TIMEOUT) |
| 356 | autils.fail_on_event(init_dut, cconsts.EVENT_NETWORK_CALLBACK, timeout=0) |
| 357 | autils.fail_on_event(resp_dut, cconsts.EVENT_NETWORK_CALLBACK, timeout=0) |
| 358 | |
| 359 | # clean-up |
| 360 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 361 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
| 362 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 363 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 364 | ####################################### |
| 365 | # Positive In-Band (IB) tests key: |
| 366 | # |
| 367 | # names is: test_ib_<pub_type>_<sub_type>_<encr_type>_<peer_spec> |
| 368 | # where: |
| 369 | # |
| 370 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 371 | # sub_type: Type of subscribe discovery session: passive or active. |
| 372 | # encr_type: Encription type: open, passphrase |
| 373 | # peer_spec: Peer specification method: any or specific |
| 374 | # |
| 375 | # Note: In-Band means using Wi-Fi Aware for discovery and referring to the |
| 376 | # peer using the Aware-provided peer handle (as opposed to a MAC address). |
| 377 | ####################################### |
| 378 | |
| 379 | def test_ib_unsolicited_passive_open_specific(self): |
| 380 | """Data-path: in-band, unsolicited/passive, open encryption, specific peer |
| 381 | |
| 382 | Verifies end-to-end discovery + data-path creation. |
| 383 | """ |
| 384 | self.run_ib_data_path_test( |
| 385 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 386 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 387 | encr_type=self.ENCR_TYPE_OPEN, |
| 388 | use_peer_id=True) |
| 389 | |
| 390 | def test_ib_unsolicited_passive_open_any(self): |
| 391 | """Data-path: in-band, unsolicited/passive, open encryption, any peer |
| 392 | |
| 393 | Verifies end-to-end discovery + data-path creation. |
| 394 | """ |
| 395 | self.run_ib_data_path_test( |
| 396 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 397 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 398 | encr_type=self.ENCR_TYPE_OPEN, |
| 399 | use_peer_id=False) |
| 400 | |
| 401 | def test_ib_unsolicited_passive_passphrase_specific(self): |
| 402 | """Data-path: in-band, unsolicited/passive, passphrase, specific peer |
| 403 | |
| 404 | Verifies end-to-end discovery + data-path creation. |
| 405 | """ |
| 406 | self.run_ib_data_path_test( |
| 407 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 408 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 409 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 410 | use_peer_id=True) |
| 411 | |
| 412 | def test_ib_unsolicited_passive_passphrase_any(self): |
| 413 | """Data-path: in-band, unsolicited/passive, passphrase, any peer |
| 414 | |
| 415 | Verifies end-to-end discovery + data-path creation. |
| 416 | """ |
| 417 | self.run_ib_data_path_test( |
| 418 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 419 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 420 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 421 | use_peer_id=False) |
| 422 | |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 423 | def test_ib_unsolicited_passive_pmk_specific(self): |
| 424 | """Data-path: in-band, unsolicited/passive, PMK, specific peer |
| 425 | |
| 426 | Verifies end-to-end discovery + data-path creation. |
| 427 | """ |
| 428 | self.run_ib_data_path_test( |
| 429 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 430 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 431 | encr_type=self.ENCR_TYPE_PMK, |
| 432 | use_peer_id=True) |
| 433 | |
| 434 | def test_ib_unsolicited_passive_pmk_any(self): |
| 435 | """Data-path: in-band, unsolicited/passive, PMK, any peer |
| 436 | |
| 437 | Verifies end-to-end discovery + data-path creation. |
| 438 | """ |
| 439 | self.run_ib_data_path_test( |
| 440 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 441 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 442 | encr_type=self.ENCR_TYPE_PMK, |
| 443 | use_peer_id=False) |
| 444 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 445 | def test_ib_solicited_active_open_specific(self): |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 446 | """Data-path: in-band, solicited/active, open encryption, specific peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 447 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 448 | Verifies end-to-end discovery + data-path creation. |
| 449 | """ |
| 450 | self.run_ib_data_path_test( |
| 451 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 452 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 453 | encr_type=self.ENCR_TYPE_OPEN, |
| 454 | use_peer_id=True) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 455 | |
| 456 | def test_ib_solicited_active_open_any(self): |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 457 | """Data-path: in-band, solicited/active, open encryption, any peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 458 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 459 | Verifies end-to-end discovery + data-path creation. |
| 460 | """ |
| 461 | self.run_ib_data_path_test( |
| 462 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 463 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 464 | encr_type=self.ENCR_TYPE_OPEN, |
| 465 | use_peer_id=False) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 466 | |
| 467 | def test_ib_solicited_active_passphrase_specific(self): |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 468 | """Data-path: in-band, solicited/active, passphrase, specific peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 469 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 470 | Verifies end-to-end discovery + data-path creation. |
| 471 | """ |
| 472 | self.run_ib_data_path_test( |
| 473 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 474 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 475 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 476 | use_peer_id=True) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 477 | |
| 478 | def test_ib_solicited_active_passphrase_any(self): |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 479 | """Data-path: in-band, solicited/active, passphrase, any peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 480 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 481 | Verifies end-to-end discovery + data-path creation. |
| 482 | """ |
| 483 | self.run_ib_data_path_test( |
| 484 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 485 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 486 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 487 | use_peer_id=False) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 488 | |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 489 | def test_ib_solicited_active_pmk_specific(self): |
| 490 | """Data-path: in-band, solicited/active, PMK, specific peer |
| 491 | |
| 492 | Verifies end-to-end discovery + data-path creation. |
| 493 | """ |
| 494 | self.run_ib_data_path_test( |
| 495 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 496 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 497 | encr_type=self.ENCR_TYPE_PMK, |
| 498 | use_peer_id=True) |
| 499 | |
| 500 | def test_ib_solicited_active_pmk_any(self): |
| 501 | """Data-path: in-band, solicited/active, PMK, any peer |
| 502 | |
| 503 | Verifies end-to-end discovery + data-path creation. |
| 504 | """ |
| 505 | self.run_ib_data_path_test( |
| 506 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 507 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 508 | encr_type=self.ENCR_TYPE_PMK, |
| 509 | use_peer_id=False) |
| 510 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 511 | ####################################### |
| 512 | # Positive Out-of-Band (OOB) tests key: |
| 513 | # |
| 514 | # names is: test_oob_<encr_type>_<peer_spec> |
| 515 | # where: |
| 516 | # |
| 517 | # encr_type: Encription type: open, passphrase |
| 518 | # peer_spec: Peer specification method: any or specific |
| 519 | # |
| 520 | # Note: Out-of-Band means using a non-Wi-Fi Aware mechanism for discovery and |
| 521 | # exchange of MAC addresses and then Wi-Fi Aware for data-path. |
| 522 | ####################################### |
| 523 | |
| 524 | def test_oob_open_specific(self): |
| 525 | """Data-path: out-of-band, open encryption, specific peer |
| 526 | |
| 527 | Verifies end-to-end discovery + data-path creation. |
| 528 | """ |
| 529 | self.run_oob_data_path_test( |
| 530 | encr_type=self.ENCR_TYPE_OPEN, |
| 531 | use_peer_id=True) |
| 532 | |
| 533 | def test_oob_open_any(self): |
| 534 | """Data-path: out-of-band, open encryption, any peer |
| 535 | |
| 536 | Verifies end-to-end discovery + data-path creation. |
| 537 | """ |
| 538 | self.run_oob_data_path_test( |
| 539 | encr_type=self.ENCR_TYPE_OPEN, |
| 540 | use_peer_id=False) |
| 541 | |
| 542 | def test_oob_passphrase_specific(self): |
| 543 | """Data-path: out-of-band, passphrase, specific peer |
| 544 | |
| 545 | Verifies end-to-end discovery + data-path creation. |
| 546 | """ |
| 547 | self.run_oob_data_path_test( |
| 548 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 549 | use_peer_id=True) |
| 550 | |
| 551 | def test_oob_passphrase_any(self): |
| 552 | """Data-path: out-of-band, passphrase, any peer |
| 553 | |
| 554 | Verifies end-to-end discovery + data-path creation. |
| 555 | """ |
| 556 | self.run_oob_data_path_test( |
| 557 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 558 | use_peer_id=False) |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 559 | |
| 560 | def test_oob_pmk_specific(self): |
| 561 | """Data-path: out-of-band, PMK, specific peer |
| 562 | |
| 563 | Verifies end-to-end discovery + data-path creation. |
| 564 | """ |
| 565 | self.run_oob_data_path_test( |
| 566 | encr_type=self.ENCR_TYPE_PMK, |
| 567 | use_peer_id=True) |
| 568 | |
| 569 | def test_oob_pmk_any(self): |
| 570 | """Data-path: out-of-band, PMK, any peer |
| 571 | |
| 572 | Verifies end-to-end discovery + data-path creation. |
| 573 | """ |
| 574 | self.run_oob_data_path_test( |
| 575 | encr_type=self.ENCR_TYPE_PMK, |
| 576 | use_peer_id=False) |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 577 | |
| 578 | ############################################################## |
| 579 | |
| 580 | def test_passphrase_min(self): |
| 581 | """Data-path: minimum passphrase length |
| 582 | |
| 583 | Use in-band, unsolicited/passive, any peer combination |
| 584 | """ |
| 585 | self.run_ib_data_path_test(ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 586 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 587 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 588 | use_peer_id=False, |
| 589 | passphrase_to_use=self.PASSPHRASE_MIN) |
| 590 | |
| 591 | def test_passphrase_max(self): |
| 592 | """Data-path: maximum passphrase length |
| 593 | |
| 594 | Use in-band, unsolicited/passive, any peer combination |
| 595 | """ |
| 596 | self.run_ib_data_path_test(ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 597 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 598 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 599 | use_peer_id=False, |
| 600 | passphrase_to_use=self.PASSPHRASE_MAX) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame^] | 601 | |
| 602 | def test_negative_mismatch_init_mac(self): |
| 603 | """Data-path: failure when Initiator MAC address mismatch""" |
| 604 | self.run_mismatched_oob_data_path_test( |
| 605 | init_mismatch_mac=True, |
| 606 | resp_mismatch_mac=False) |
| 607 | |
| 608 | def test_negative_mismatch_resp_mac(self): |
| 609 | """Data-path: failure when Responder MAC address mismatch""" |
| 610 | self.run_mismatched_oob_data_path_test( |
| 611 | init_mismatch_mac=False, |
| 612 | resp_mismatch_mac=True) |
| 613 | |
| 614 | def test_negative_mismatch_passphrase(self): |
| 615 | """Data-path: failure when passphrases mismatch""" |
| 616 | self.run_mismatched_oob_data_path_test( |
| 617 | init_encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 618 | resp_encr_type=self.ENCR_TYPE_PASSPHRASE) |
| 619 | |
| 620 | def test_negative_mismatch_pmk(self): |
| 621 | """Data-path: failure when PMK mismatch""" |
| 622 | self.run_mismatched_oob_data_path_test( |
| 623 | init_encr_type=self.ENCR_TYPE_PMK, |
| 624 | resp_encr_type=self.ENCR_TYPE_PMK) |
| 625 | |
| 626 | def test_negative_mismatch_open_passphrase(self): |
| 627 | """Data-path: failure when initiator is open, and responder passphrase""" |
| 628 | self.run_mismatched_oob_data_path_test( |
| 629 | init_encr_type=self.ENCR_TYPE_OPEN, |
| 630 | resp_encr_type=self.ENCR_TYPE_PASSPHRASE) |
| 631 | |
| 632 | def test_negative_mismatch_open_pmk(self): |
| 633 | """Data-path: failure when initiator is open, and responder PMK""" |
| 634 | self.run_mismatched_oob_data_path_test( |
| 635 | init_encr_type=self.ENCR_TYPE_OPEN, |
| 636 | resp_encr_type=self.ENCR_TYPE_PMK) |
| 637 | |
| 638 | def test_negative_mismatch_pmk_passphrase(self): |
| 639 | """Data-path: failure when initiator is pmk, and responder passphrase""" |
| 640 | self.run_mismatched_oob_data_path_test( |
| 641 | init_encr_type=self.ENCR_TYPE_PMK, |
| 642 | resp_encr_type=self.ENCR_TYPE_PASSPHRASE) |
| 643 | |
| 644 | def test_negative_mismatch_passphrase_open(self): |
| 645 | """Data-path: failure when initiator is passphrase, and responder open""" |
| 646 | self.run_mismatched_oob_data_path_test( |
| 647 | init_encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 648 | resp_encr_type=self.ENCR_TYPE_OPEN) |
| 649 | |
| 650 | def test_negative_mismatch_pmk_open(self): |
| 651 | """Data-path: failure when initiator is PMK, and responder open""" |
| 652 | self.run_mismatched_oob_data_path_test( |
| 653 | init_encr_type=self.ENCR_TYPE_PMK, |
| 654 | resp_encr_type=self.ENCR_TYPE_OPEN) |
| 655 | |
| 656 | def test_negative_mismatch_passphrase_pmk(self): |
| 657 | """Data-path: failure when initiator is passphrase, and responder pmk""" |
| 658 | self.run_mismatched_oob_data_path_test( |
| 659 | init_encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 660 | resp_encr_type=self.ENCR_TYPE_OPEN) |