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 |
| 22 | from acts.test_utils.wifi.aware import aware_const as aconsts |
| 23 | from acts.test_utils.wifi.aware import aware_test_utils as autils |
| 24 | from acts.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest |
| 25 | |
| 26 | |
| 27 | class DataPathTest(AwareBaseTest): |
Etan Cohen | bfb149f | 2017-06-06 10:13:17 -0700 | [diff] [blame] | 28 | """Set of tests for Wi-Fi Aware data-path.""" |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 29 | |
| 30 | # configuration parameters used by tests |
| 31 | ENCR_TYPE_OPEN = 0 |
| 32 | ENCR_TYPE_PASSPHRASE = 1 |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 33 | ENCR_TYPE_PMK = 2 |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 34 | |
| 35 | PASSPHRASE = "This is some random passphrase - very very secure!!" |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 36 | PASSPHRASE_MIN = "01234567" |
| 37 | PASSPHRASE_MAX = "012345678901234567890123456789012345678901234567890123456789012" |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 38 | PMK = "ODU0YjE3YzdmNDJiNWI4NTQ2NDJjNDI3M2VkZTQyZGU=" |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 39 | PASSPHRASE2 = "This is some random passphrase - very very secure - but diff!!" |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 40 | PMK2 = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=" |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 41 | |
| 42 | PING_MSG = "ping" |
| 43 | |
| 44 | # message re-transmit counter (increases reliability in open-environment) |
| 45 | # Note: reliability of message transmission is tested elsewhere |
| 46 | MSG_RETX_COUNT = 5 # hard-coded max value, internal API |
| 47 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 48 | # number of second to 'reasonably' wait to make sure that devices synchronize |
| 49 | # with each other - useful for OOB test cases, where the OOB discovery would |
| 50 | # take some time |
| 51 | WAIT_FOR_CLUSTER = 5 |
| 52 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 53 | def __init__(self, controllers): |
| 54 | AwareBaseTest.__init__(self, controllers) |
| 55 | |
| 56 | def create_config(self, dtype): |
| 57 | """Create a base configuration based on input parameters. |
| 58 | |
| 59 | Args: |
| 60 | dtype: Publish or Subscribe discovery type |
| 61 | |
| 62 | Returns: |
| 63 | Discovery configuration object. |
| 64 | """ |
| 65 | config = {} |
| 66 | config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = dtype |
| 67 | config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = "GoogleTestServiceDataPath" |
| 68 | return config |
| 69 | |
| 70 | def request_network(self, dut, ns): |
| 71 | """Request a Wi-Fi Aware network. |
| 72 | |
| 73 | Args: |
| 74 | dut: Device |
| 75 | ns: Network specifier |
| 76 | Returns: the request key |
| 77 | """ |
| 78 | network_req = {"TransportType": 5, "NetworkSpecifier": ns} |
| 79 | return dut.droid.connectivityRequestWifiAwareNetwork(network_req) |
| 80 | |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 81 | def set_up_discovery(self, ptype, stype, get_peer_id, pub_on_both=False, |
| 82 | pub_on_both_same=True): |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 83 | """Set up discovery sessions and wait for service discovery. |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 84 | |
| 85 | Args: |
| 86 | ptype: Publish discovery type |
| 87 | stype: Subscribe discovery type |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 88 | 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] | 89 | pub_on_both: If True then set up a publisher on both devices. The second |
| 90 | publisher isn't used (existing to test use-case). |
| 91 | pub_on_both_same: If True then the second publish uses an identical |
| 92 | service name, otherwise a different service name. |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 93 | """ |
| 94 | p_dut = self.android_devices[0] |
| 95 | p_dut.pretty_name = "Publisher" |
| 96 | s_dut = self.android_devices[1] |
| 97 | s_dut.pretty_name = "Subscriber" |
| 98 | |
| 99 | # Publisher+Subscriber: attach and wait for confirmation |
| 100 | p_id = p_dut.droid.wifiAwareAttach() |
| 101 | autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED) |
Etan Cohen | 76ff801 | 2017-06-16 13:13:44 -0700 | [diff] [blame] | 102 | time.sleep(self.device_startup_offset) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 103 | s_id = s_dut.droid.wifiAwareAttach() |
| 104 | autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 105 | |
| 106 | # Publisher: start publish and wait for confirmation |
| 107 | p_disc_id = p_dut.droid.wifiAwarePublish(p_id, self.create_config(ptype)) |
| 108 | autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
| 109 | |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 110 | # Optionally set up a publish session on the Subscriber device |
| 111 | if pub_on_both: |
| 112 | p2_config = self.create_config(ptype) |
| 113 | if not pub_on_both_same: |
| 114 | p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = ( |
| 115 | p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] + "-XYZXYZ") |
| 116 | s_dut.droid.wifiAwarePublish(s_id, p2_config) |
| 117 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
| 118 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 119 | # Subscriber: start subscribe and wait for confirmation |
| 120 | s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id, self.create_config(stype)) |
| 121 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED) |
| 122 | |
| 123 | # Subscriber: wait for service discovery |
| 124 | discovery_event = autils.wait_for_event( |
| 125 | s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) |
| 126 | peer_id_on_sub = discovery_event["data"][aconsts.SESSION_CB_KEY_PEER_ID] |
| 127 | |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 128 | peer_id_on_pub = None |
| 129 | if get_peer_id: # only need message to receive peer ID |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 130 | # Subscriber: send message to peer (Publisher - so it knows our address) |
| 131 | s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub, |
| 132 | self.get_next_msg_id(), self.PING_MSG, |
| 133 | self.MSG_RETX_COUNT) |
| 134 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT) |
| 135 | |
| 136 | # Publisher: wait for received message |
| 137 | pub_rx_msg_event = autils.wait_for_event( |
| 138 | p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED) |
| 139 | peer_id_on_pub = pub_rx_msg_event["data"][aconsts.SESSION_CB_KEY_PEER_ID] |
| 140 | |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 141 | return (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub, |
| 142 | peer_id_on_pub) |
| 143 | |
| 144 | def run_ib_data_path_test(self, |
| 145 | ptype, |
| 146 | stype, |
| 147 | encr_type, |
| 148 | use_peer_id, |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 149 | passphrase_to_use=None, |
| 150 | pub_on_both=False, |
| 151 | pub_on_both_same=True): |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 152 | """Runs the in-band data-path tests. |
| 153 | |
| 154 | Args: |
| 155 | ptype: Publish discovery type |
| 156 | stype: Subscribe discovery type |
| 157 | encr_type: Encryption type, one of ENCR_TYPE_* |
| 158 | use_peer_id: On Responder (publisher): True to use peer ID, False to |
| 159 | accept any request |
| 160 | passphrase_to_use: The passphrase to use if encr_type=ENCR_TYPE_PASSPHRASE |
| 161 | If None then use self.PASSPHRASE |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 162 | pub_on_both: If True then set up a publisher on both devices. The second |
| 163 | publisher isn't used (existing to test use-case). |
| 164 | pub_on_both_same: If True then the second publish uses an identical |
| 165 | service name, otherwise a different service name. |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 166 | """ |
| 167 | (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub, |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 168 | peer_id_on_pub) = self.set_up_discovery(ptype, stype, use_peer_id, |
| 169 | pub_on_both=pub_on_both, |
| 170 | pub_on_both_same=pub_on_both_same) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 171 | |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 172 | passphrase = None |
| 173 | pmk = None |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 174 | if encr_type == self.ENCR_TYPE_PASSPHRASE: |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 175 | passphrase = ( |
| 176 | self.PASSPHRASE if passphrase_to_use == None else passphrase_to_use) |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 177 | elif encr_type == self.ENCR_TYPE_PMK: |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 178 | pmk = self.PMK |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 179 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 180 | # Publisher: request network |
| 181 | p_req_key = self.request_network( |
| 182 | p_dut, |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 183 | p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, peer_id_on_pub if |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 184 | use_peer_id else None, passphrase, pmk)) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 185 | |
| 186 | # Subscriber: request network |
| 187 | s_req_key = self.request_network( |
| 188 | s_dut, |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 189 | s_dut.droid.wifiAwareCreateNetworkSpecifier(s_disc_id, peer_id_on_sub, |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 190 | passphrase, pmk)) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 191 | |
| 192 | # Publisher & Subscriber: wait for network formation |
| 193 | p_net_event = autils.wait_for_event_with_keys( |
| 194 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 195 | autils.EVENT_NDP_TIMEOUT, |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 196 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 197 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 198 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 199 | s_net_event = autils.wait_for_event_with_keys( |
| 200 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 201 | autils.EVENT_NDP_TIMEOUT, |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 202 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 203 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 204 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
| 205 | |
| 206 | p_aware_if = p_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 207 | s_aware_if = s_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
| 208 | self.log.info("Interface names: p=%s, s=%s", p_aware_if, s_aware_if) |
| 209 | |
| 210 | p_ipv6 = p_dut.droid.connectivityGetLinkLocalIpv6Address(p_aware_if).split( |
| 211 | "%")[0] |
| 212 | s_ipv6 = s_dut.droid.connectivityGetLinkLocalIpv6Address(s_aware_if).split( |
| 213 | "%")[0] |
| 214 | self.log.info("Interface addresses (IPv6): p=%s, s=%s", p_ipv6, s_ipv6) |
| 215 | |
| 216 | # TODO: possibly send messages back and forth, prefer to use netcat/nc |
| 217 | |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 218 | # terminate sessions and wait for ON_LOST callbacks |
| 219 | p_dut.droid.wifiAwareDestroy(p_id) |
| 220 | s_dut.droid.wifiAwareDestroy(s_id) |
| 221 | |
| 222 | autils.wait_for_event_with_keys( |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 223 | p_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 224 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 225 | cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 226 | autils.wait_for_event_with_keys( |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 227 | s_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 228 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 229 | cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
| 230 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 231 | # clean-up |
| 232 | p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key) |
| 233 | s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key) |
| 234 | |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame^] | 235 | def run_oob_data_path_test(self, encr_type, use_peer_id, |
| 236 | setup_discovery_sessions=False): |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 237 | """Runs the out-of-band data-path tests. |
| 238 | |
| 239 | Args: |
| 240 | encr_type: Encryption type, one of ENCR_TYPE_* |
| 241 | use_peer_id: On Responder: True to use peer ID, False to accept any |
| 242 | request |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame^] | 243 | setup_discovery_sessions: If True also set up a (spurious) discovery |
| 244 | session (pub on both sides, sub on Responder side). Validates a corner |
| 245 | case. |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 246 | """ |
| 247 | init_dut = self.android_devices[0] |
| 248 | init_dut.pretty_name = "Initiator" |
| 249 | resp_dut = self.android_devices[1] |
| 250 | resp_dut.pretty_name = "Responder" |
| 251 | |
Etan Cohen | bfb149f | 2017-06-06 10:13:17 -0700 | [diff] [blame] | 252 | # Initiator+Responder: attach and wait for confirmation & identity |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 253 | init_id = init_dut.droid.wifiAwareAttach(True) |
| 254 | autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 255 | init_ident_event = autils.wait_for_event( |
| 256 | init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 257 | init_mac = init_ident_event["data"]["mac"] |
Etan Cohen | 76ff801 | 2017-06-16 13:13:44 -0700 | [diff] [blame] | 258 | time.sleep(self.device_startup_offset) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 259 | resp_id = resp_dut.droid.wifiAwareAttach(True) |
| 260 | autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 261 | resp_ident_event = autils.wait_for_event( |
| 262 | resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 263 | resp_mac = resp_ident_event["data"]["mac"] |
| 264 | |
| 265 | # wait for for devices to synchronize with each other - there are no other |
| 266 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 267 | # to execute the data-path request) |
| 268 | time.sleep(self.WAIT_FOR_CLUSTER) |
| 269 | |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame^] | 270 | if setup_discovery_sessions: |
| 271 | init_dut.droid.wifiAwarePublish(init_id, self.create_config( |
| 272 | aconsts.PUBLISH_TYPE_UNSOLICITED)) |
| 273 | autils.wait_for_event(init_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
| 274 | resp_dut.droid.wifiAwarePublish(resp_id, self.create_config( |
| 275 | aconsts.PUBLISH_TYPE_UNSOLICITED)) |
| 276 | autils.wait_for_event(resp_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
| 277 | resp_dut.droid.wifiAwareSubscribe(resp_id, self.create_config( |
| 278 | aconsts.SUBSCRIBE_TYPE_PASSIVE)) |
| 279 | autils.wait_for_event(resp_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED) |
| 280 | autils.wait_for_event(resp_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) |
| 281 | |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 282 | passphrase = None |
| 283 | pmk = None |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 284 | if encr_type == self.ENCR_TYPE_PASSPHRASE: |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 285 | passphrase = self.PASSPHRASE |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 286 | elif encr_type == self.ENCR_TYPE_PMK: |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 287 | pmk = self.PMK |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 288 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 289 | # Responder: request network |
| 290 | resp_req_key = self.request_network( |
| 291 | resp_dut, |
| 292 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 293 | resp_id, aconsts.DATA_PATH_RESPONDER, init_mac |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 294 | if use_peer_id else None, passphrase, pmk)) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 295 | |
| 296 | # Initiator: request network |
| 297 | init_req_key = self.request_network( |
| 298 | init_dut, |
| 299 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 300 | init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase, pmk)) |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 301 | |
| 302 | # Initiator & Responder: wait for network formation |
| 303 | init_net_event = autils.wait_for_event_with_keys( |
| 304 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 305 | autils.EVENT_NDP_TIMEOUT, |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 306 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 307 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 308 | (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 309 | resp_net_event = autils.wait_for_event_with_keys( |
| 310 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 311 | autils.EVENT_NDP_TIMEOUT, |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 312 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 313 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 314 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
| 315 | |
| 316 | init_aware_if = init_net_event["data"][ |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 317 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 318 | resp_aware_if = resp_net_event["data"][ |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 319 | cconsts.NETWORK_CB_KEY_INTERFACE_NAME] |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 320 | self.log.info("Interface names: I=%s, R=%s", init_aware_if, resp_aware_if) |
| 321 | |
| 322 | init_ipv6 = init_dut.droid.connectivityGetLinkLocalIpv6Address( |
| 323 | init_aware_if).split("%")[0] |
| 324 | resp_ipv6 = resp_dut.droid.connectivityGetLinkLocalIpv6Address( |
| 325 | resp_aware_if).split("%")[0] |
| 326 | self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6, |
| 327 | resp_ipv6) |
| 328 | |
| 329 | # TODO: possibly send messages back and forth, prefer to use netcat/nc |
| 330 | |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 331 | # terminate sessions and wait for ON_LOST callbacks |
| 332 | init_dut.droid.wifiAwareDestroy(init_id) |
| 333 | resp_dut.droid.wifiAwareDestroy(resp_id) |
| 334 | |
| 335 | autils.wait_for_event_with_keys( |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 336 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 337 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 338 | cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 339 | autils.wait_for_event_with_keys( |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 340 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, |
Etan Cohen | ce20229 | 2017-06-05 13:55:54 -0700 | [diff] [blame] | 341 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 342 | cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
| 343 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 344 | # clean-up |
| 345 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 346 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
| 347 | |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 348 | def run_mismatched_ib_data_path_test(self, pub_mismatch, sub_mismatch): |
| 349 | """Runs the negative in-band data-path tests: mismatched peer ID. |
| 350 | |
| 351 | Args: |
| 352 | pub_mismatch: Mismatch the publisher's ID |
| 353 | sub_mismatch: Mismatch the subscriber's ID |
| 354 | """ |
| 355 | (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, |
| 356 | peer_id_on_sub, peer_id_on_pub) = self.set_up_discovery( |
| 357 | aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE, True) |
| 358 | |
| 359 | if pub_mismatch: |
| 360 | peer_id_on_pub = peer_id_on_pub -1 |
| 361 | if sub_mismatch: |
| 362 | peer_id_on_sub = peer_id_on_sub - 1 |
| 363 | |
| 364 | # Publisher: request network |
| 365 | p_req_key = self.request_network( |
| 366 | p_dut, |
| 367 | p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, peer_id_on_pub, |
| 368 | None)) |
| 369 | |
| 370 | # Subscriber: request network |
| 371 | s_req_key = self.request_network( |
| 372 | s_dut, |
| 373 | s_dut.droid.wifiAwareCreateNetworkSpecifier(s_disc_id, peer_id_on_sub, |
| 374 | None)) |
| 375 | |
| 376 | # Publisher & Subscriber: fail on network formation |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 377 | time.sleep(autils.EVENT_NDP_TIMEOUT) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 378 | autils.fail_on_event_with_keys(p_dut, cconsts.EVENT_NETWORK_CALLBACK, 0, |
| 379 | (cconsts.NETWORK_CB_KEY_ID, p_req_key)) |
| 380 | autils.fail_on_event_with_keys(s_dut, cconsts.EVENT_NETWORK_CALLBACK, 0, |
| 381 | (cconsts.NETWORK_CB_KEY_ID, s_req_key)) |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 382 | |
| 383 | # clean-up |
| 384 | p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key) |
| 385 | s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key) |
| 386 | |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 387 | def run_mismatched_oob_data_path_test(self, |
| 388 | init_mismatch_mac=False, |
| 389 | resp_mismatch_mac=False, |
| 390 | init_encr_type=ENCR_TYPE_OPEN, |
| 391 | resp_encr_type=ENCR_TYPE_OPEN): |
| 392 | """Runs the negative out-of-band data-path tests: mismatched information |
| 393 | between Responder and Initiator. |
| 394 | |
| 395 | Args: |
| 396 | init_mismatch_mac: True to mismatch the Initiator MAC address |
| 397 | resp_mismatch_mac: True to mismatch the Responder MAC address |
| 398 | init_encr_type: Encryption type of Initiator - ENCR_TYPE_* |
| 399 | resp_encr_type: Encryption type of Responder - ENCR_TYPE_* |
| 400 | """ |
| 401 | init_dut = self.android_devices[0] |
| 402 | init_dut.pretty_name = "Initiator" |
| 403 | resp_dut = self.android_devices[1] |
| 404 | resp_dut.pretty_name = "Responder" |
| 405 | |
Etan Cohen | bfb149f | 2017-06-06 10:13:17 -0700 | [diff] [blame] | 406 | # Initiator+Responder: attach and wait for confirmation & identity |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 407 | init_id = init_dut.droid.wifiAwareAttach(True) |
| 408 | autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 409 | init_ident_event = autils.wait_for_event( |
| 410 | init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 411 | init_mac = init_ident_event["data"]["mac"] |
Etan Cohen | 76ff801 | 2017-06-16 13:13:44 -0700 | [diff] [blame] | 412 | time.sleep(self.device_startup_offset) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 413 | resp_id = resp_dut.droid.wifiAwareAttach(True) |
| 414 | autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 415 | resp_ident_event = autils.wait_for_event( |
| 416 | resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED) |
| 417 | resp_mac = resp_ident_event["data"]["mac"] |
| 418 | |
| 419 | if init_mismatch_mac: # assumes legit ones don't start with "00" |
| 420 | init_mac = "00" + init_mac[2:] |
| 421 | if resp_mismatch_mac: |
| 422 | resp_mac = "00" + resp_mac[2:] |
| 423 | |
| 424 | # wait for for devices to synchronize with each other - there are no other |
| 425 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 426 | # to execute the data-path request) |
| 427 | time.sleep(self.WAIT_FOR_CLUSTER) |
| 428 | |
| 429 | # set up separate keys: even if types are the same we want a mismatch |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 430 | init_passphrase = None |
| 431 | init_pmk = None |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 432 | if init_encr_type == self.ENCR_TYPE_PASSPHRASE: |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 433 | init_passphrase = self.PASSPHRASE |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 434 | elif init_encr_type == self.ENCR_TYPE_PMK: |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 435 | init_pmk = self.PMK |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 436 | |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 437 | resp_passphrase = None |
| 438 | resp_pmk = None |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 439 | if resp_encr_type == self.ENCR_TYPE_PASSPHRASE: |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 440 | resp_passphrase = self.PASSPHRASE2 |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 441 | elif resp_encr_type == self.ENCR_TYPE_PMK: |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 442 | resp_pmk = self.PMK2 |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 443 | |
| 444 | # Responder: request network |
| 445 | resp_req_key = self.request_network( |
| 446 | resp_dut, |
| 447 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 448 | resp_id, aconsts.DATA_PATH_RESPONDER, init_mac, resp_passphrase, |
| 449 | resp_pmk)) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 450 | |
| 451 | # Initiator: request network |
| 452 | init_req_key = self.request_network( |
| 453 | init_dut, |
| 454 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
Etan Cohen | 23b9229 | 2017-07-11 11:09:06 -0700 | [diff] [blame] | 455 | init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, init_passphrase, |
| 456 | init_pmk)) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 457 | |
| 458 | # Initiator & Responder: fail on network formation |
Etan Cohen | e47ec43 | 2017-06-21 10:42:16 -0700 | [diff] [blame] | 459 | time.sleep(autils.EVENT_NDP_TIMEOUT) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 460 | autils.fail_on_event_with_keys(init_dut, cconsts.EVENT_NETWORK_CALLBACK, 0, |
| 461 | (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 462 | autils.fail_on_event_with_keys(resp_dut, cconsts.EVENT_NETWORK_CALLBACK, 0, |
| 463 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 464 | |
| 465 | # clean-up |
| 466 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 467 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
| 468 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 469 | |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 470 | ####################################### |
| 471 | # Positive In-Band (IB) tests key: |
| 472 | # |
| 473 | # names is: test_ib_<pub_type>_<sub_type>_<encr_type>_<peer_spec> |
| 474 | # where: |
| 475 | # |
| 476 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 477 | # sub_type: Type of subscribe discovery session: passive or active. |
| 478 | # encr_type: Encription type: open, passphrase |
| 479 | # peer_spec: Peer specification method: any or specific |
| 480 | # |
| 481 | # Note: In-Band means using Wi-Fi Aware for discovery and referring to the |
| 482 | # peer using the Aware-provided peer handle (as opposed to a MAC address). |
| 483 | ####################################### |
| 484 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 485 | @test_tracker_info(uuid="fa30bedc-d1de-4440-bf25-ec00d10555af") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 486 | def test_ib_unsolicited_passive_open_specific(self): |
| 487 | """Data-path: in-band, unsolicited/passive, open encryption, specific peer |
| 488 | |
| 489 | Verifies end-to-end discovery + data-path creation. |
| 490 | """ |
| 491 | self.run_ib_data_path_test( |
| 492 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 493 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 494 | encr_type=self.ENCR_TYPE_OPEN, |
| 495 | use_peer_id=True) |
| 496 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 497 | @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 498 | def test_ib_unsolicited_passive_open_any(self): |
| 499 | """Data-path: in-band, unsolicited/passive, open encryption, any peer |
| 500 | |
| 501 | Verifies end-to-end discovery + data-path creation. |
| 502 | """ |
| 503 | self.run_ib_data_path_test( |
| 504 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 505 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 506 | encr_type=self.ENCR_TYPE_OPEN, |
| 507 | use_peer_id=False) |
| 508 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 509 | @test_tracker_info(uuid="93b2a23d-8579-448a-936c-7812929464cf") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 510 | def test_ib_unsolicited_passive_passphrase_specific(self): |
| 511 | """Data-path: in-band, unsolicited/passive, passphrase, specific peer |
| 512 | |
| 513 | Verifies end-to-end discovery + data-path creation. |
| 514 | """ |
| 515 | self.run_ib_data_path_test( |
| 516 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 517 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 518 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 519 | use_peer_id=True) |
| 520 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 521 | @test_tracker_info(uuid="1736126f-a0ff-4712-acc4-f89b4eef5716") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 522 | def test_ib_unsolicited_passive_passphrase_any(self): |
| 523 | """Data-path: in-band, unsolicited/passive, passphrase, any peer |
| 524 | |
| 525 | Verifies end-to-end discovery + data-path creation. |
| 526 | """ |
| 527 | self.run_ib_data_path_test( |
| 528 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 529 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 530 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 531 | use_peer_id=False) |
| 532 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 533 | @test_tracker_info(uuid="b9353d5b-3f77-46bf-bfd9-65d56a7c939a") |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 534 | def test_ib_unsolicited_passive_pmk_specific(self): |
| 535 | """Data-path: in-band, unsolicited/passive, PMK, specific peer |
| 536 | |
| 537 | Verifies end-to-end discovery + data-path creation. |
| 538 | """ |
| 539 | self.run_ib_data_path_test( |
| 540 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 541 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 542 | encr_type=self.ENCR_TYPE_PMK, |
| 543 | use_peer_id=True) |
| 544 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 545 | @test_tracker_info(uuid="06f3b2ab-4a10-4398-83a4-6a23851b1662") |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 546 | def test_ib_unsolicited_passive_pmk_any(self): |
| 547 | """Data-path: in-band, unsolicited/passive, PMK, any peer |
| 548 | |
| 549 | Verifies end-to-end discovery + data-path creation. |
| 550 | """ |
| 551 | self.run_ib_data_path_test( |
| 552 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 553 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 554 | encr_type=self.ENCR_TYPE_PMK, |
| 555 | use_peer_id=False) |
| 556 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 557 | @test_tracker_info(uuid="0ed7d8b3-a69e-46ba-aeb7-13e507ecf290") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 558 | def test_ib_solicited_active_open_specific(self): |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 559 | """Data-path: in-band, solicited/active, open encryption, specific peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 560 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 561 | Verifies end-to-end discovery + data-path creation. |
| 562 | """ |
| 563 | self.run_ib_data_path_test( |
| 564 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 565 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 566 | encr_type=self.ENCR_TYPE_OPEN, |
| 567 | use_peer_id=True) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 568 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 569 | @test_tracker_info(uuid="c7ba6d28-5ef6-45d9-95d5-583ad6d981f3") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 570 | def test_ib_solicited_active_open_any(self): |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 571 | """Data-path: in-band, solicited/active, open encryption, any peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 572 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 573 | Verifies end-to-end discovery + data-path creation. |
| 574 | """ |
| 575 | self.run_ib_data_path_test( |
| 576 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 577 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 578 | encr_type=self.ENCR_TYPE_OPEN, |
| 579 | use_peer_id=False) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 580 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 581 | @test_tracker_info(uuid="388cea99-0e2e-49ea-b00e-f3e56b6236e5") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 582 | def test_ib_solicited_active_passphrase_specific(self): |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 583 | """Data-path: in-band, solicited/active, passphrase, specific peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 584 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 585 | Verifies end-to-end discovery + data-path creation. |
| 586 | """ |
| 587 | self.run_ib_data_path_test( |
| 588 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 589 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 590 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 591 | use_peer_id=True) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 592 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 593 | @test_tracker_info(uuid="fcd3e28a-5eab-4169-8a0c-dc7204dcdc13") |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 594 | def test_ib_solicited_active_passphrase_any(self): |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 595 | """Data-path: in-band, solicited/active, passphrase, any peer |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 596 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 597 | Verifies end-to-end discovery + data-path creation. |
| 598 | """ |
| 599 | self.run_ib_data_path_test( |
| 600 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 601 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 602 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 603 | use_peer_id=False) |
Etan Cohen | fc5f373 | 2017-06-02 17:31:52 -0700 | [diff] [blame] | 604 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 605 | @test_tracker_info(uuid="9d4eaad7-ba53-4a06-8ce0-e308daea3309") |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 606 | def test_ib_solicited_active_pmk_specific(self): |
| 607 | """Data-path: in-band, solicited/active, PMK, specific peer |
| 608 | |
| 609 | Verifies end-to-end discovery + data-path creation. |
| 610 | """ |
| 611 | self.run_ib_data_path_test( |
| 612 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 613 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 614 | encr_type=self.ENCR_TYPE_PMK, |
| 615 | use_peer_id=True) |
| 616 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 617 | @test_tracker_info(uuid="129d850e-c312-4137-a67b-05ae95fe66cc") |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 618 | def test_ib_solicited_active_pmk_any(self): |
| 619 | """Data-path: in-band, solicited/active, PMK, any peer |
| 620 | |
| 621 | Verifies end-to-end discovery + data-path creation. |
| 622 | """ |
| 623 | self.run_ib_data_path_test( |
| 624 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 625 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 626 | encr_type=self.ENCR_TYPE_PMK, |
| 627 | use_peer_id=False) |
| 628 | |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 629 | ####################################### |
Etan Cohen | 204df17 | 2017-11-09 12:05:36 -0800 | [diff] [blame] | 630 | # Positive In-Band (IB) with a publish session running on the subscriber |
| 631 | # tests key: |
| 632 | # |
| 633 | # names is: test_ib_extra_pub_<same|diff>_<pub_type>_<sub_type> |
| 634 | # _<encr_type>_<peer_spec> |
| 635 | # where: |
| 636 | # |
| 637 | # same|diff: Whether the extra publish session (on the subscriber) is the same |
| 638 | # or different from the primary session. |
| 639 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 640 | # sub_type: Type of subscribe discovery session: passive or active. |
| 641 | # encr_type: Encription type: open, passphrase |
| 642 | # peer_spec: Peer specification method: any or specific |
| 643 | # |
| 644 | # Note: In-Band means using Wi-Fi Aware for discovery and referring to the |
| 645 | # peer using the Aware-provided peer handle (as opposed to a MAC address). |
| 646 | ####################################### |
| 647 | |
| 648 | def test_ib_extra_pub_same_unsolicited_passive_open_specific(self): |
| 649 | """Data-path: in-band, unsolicited/passive, open encryption, specific peer. |
| 650 | |
| 651 | Configuration contains a publisher (for the same service) running on *both* |
| 652 | devices. |
| 653 | |
| 654 | Verifies end-to-end discovery + data-path creation. |
| 655 | """ |
| 656 | self.run_ib_data_path_test( |
| 657 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 658 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 659 | encr_type=self.ENCR_TYPE_OPEN, |
| 660 | use_peer_id=True, |
| 661 | pub_on_both=True, |
| 662 | pub_on_both_same=True) |
| 663 | |
| 664 | def test_ib_extra_pub_same_unsolicited_passive_open_any(self): |
| 665 | """Data-path: in-band, unsolicited/passive, open encryption, any peer. |
| 666 | |
| 667 | Configuration contains a publisher (for the same service) running on *both* |
| 668 | devices. |
| 669 | |
| 670 | Verifies end-to-end discovery + data-path creation. |
| 671 | """ |
| 672 | self.run_ib_data_path_test( |
| 673 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 674 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 675 | encr_type=self.ENCR_TYPE_OPEN, |
| 676 | use_peer_id=False, |
| 677 | pub_on_both=True, |
| 678 | pub_on_both_same=True) |
| 679 | |
| 680 | def test_ib_extra_pub_diff_unsolicited_passive_open_specific(self): |
| 681 | """Data-path: in-band, unsolicited/passive, open encryption, specific peer. |
| 682 | |
| 683 | Configuration contains a publisher (for a different service) running on |
| 684 | *both* devices. |
| 685 | |
| 686 | Verifies end-to-end discovery + data-path creation. |
| 687 | """ |
| 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_OPEN, |
| 692 | use_peer_id=True, |
| 693 | pub_on_both=True, |
| 694 | pub_on_both_same=False) |
| 695 | |
| 696 | def test_ib_extra_pub_diff_unsolicited_passive_open_any(self): |
| 697 | """Data-path: in-band, unsolicited/passive, open encryption, any peer. |
| 698 | |
| 699 | Configuration contains a publisher (for a different service) running on |
| 700 | *both* devices. |
| 701 | |
| 702 | Verifies end-to-end discovery + data-path creation. |
| 703 | """ |
| 704 | self.run_ib_data_path_test( |
| 705 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 706 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 707 | encr_type=self.ENCR_TYPE_OPEN, |
| 708 | use_peer_id=False, |
| 709 | pub_on_both=True, |
| 710 | pub_on_both_same=False) |
| 711 | |
| 712 | ####################################### |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 713 | # Positive Out-of-Band (OOB) tests key: |
| 714 | # |
| 715 | # names is: test_oob_<encr_type>_<peer_spec> |
| 716 | # where: |
| 717 | # |
| 718 | # encr_type: Encription type: open, passphrase |
| 719 | # peer_spec: Peer specification method: any or specific |
| 720 | # |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame^] | 721 | # Optionally set up an extra discovery session to test coexistence. If so |
| 722 | # add "ib_coex" to test name. |
| 723 | # |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 724 | # Note: Out-of-Band means using a non-Wi-Fi Aware mechanism for discovery and |
| 725 | # exchange of MAC addresses and then Wi-Fi Aware for data-path. |
| 726 | ####################################### |
| 727 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 728 | @test_tracker_info(uuid="7db17d8c-1dce-4084-b695-215bbcfe7d41") |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 729 | def test_oob_open_specific(self): |
| 730 | """Data-path: out-of-band, open encryption, specific peer |
| 731 | |
| 732 | Verifies end-to-end discovery + data-path creation. |
| 733 | """ |
| 734 | self.run_oob_data_path_test( |
| 735 | encr_type=self.ENCR_TYPE_OPEN, |
| 736 | use_peer_id=True) |
| 737 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 738 | @test_tracker_info(uuid="ad416d89-cb95-4a07-8d29-ee213117450b") |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 739 | def test_oob_open_any(self): |
| 740 | """Data-path: out-of-band, open encryption, any peer |
| 741 | |
| 742 | Verifies end-to-end discovery + data-path creation. |
| 743 | """ |
| 744 | self.run_oob_data_path_test( |
| 745 | encr_type=self.ENCR_TYPE_OPEN, |
| 746 | use_peer_id=False) |
| 747 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 748 | @test_tracker_info(uuid="74937a3a-d524-43e2-8979-4449271cab52") |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 749 | def test_oob_passphrase_specific(self): |
| 750 | """Data-path: out-of-band, passphrase, specific peer |
| 751 | |
| 752 | Verifies end-to-end discovery + data-path creation. |
| 753 | """ |
| 754 | self.run_oob_data_path_test( |
| 755 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 756 | use_peer_id=True) |
| 757 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 758 | @test_tracker_info(uuid="afcbdc7e-d3a9-465b-b1da-ce2e42e3941e") |
Etan Cohen | ba8a53f | 2017-06-05 12:55:02 -0700 | [diff] [blame] | 759 | def test_oob_passphrase_any(self): |
| 760 | """Data-path: out-of-band, passphrase, any peer |
| 761 | |
| 762 | Verifies end-to-end discovery + data-path creation. |
| 763 | """ |
| 764 | self.run_oob_data_path_test( |
| 765 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 766 | use_peer_id=False) |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 767 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 768 | @test_tracker_info(uuid="0d095031-160a-4537-aab5-41b6ad5d55f8") |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 769 | def test_oob_pmk_specific(self): |
| 770 | """Data-path: out-of-band, PMK, specific peer |
| 771 | |
| 772 | Verifies end-to-end discovery + data-path creation. |
| 773 | """ |
| 774 | self.run_oob_data_path_test( |
| 775 | encr_type=self.ENCR_TYPE_PMK, |
| 776 | use_peer_id=True) |
| 777 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 778 | @test_tracker_info(uuid="e45477bd-66cc-4eb7-88dd-4518c8aa2a74") |
Etan Cohen | 058aaba | 2017-06-05 17:01:54 -0700 | [diff] [blame] | 779 | def test_oob_pmk_any(self): |
| 780 | """Data-path: out-of-band, PMK, any peer |
| 781 | |
| 782 | Verifies end-to-end discovery + data-path creation. |
| 783 | """ |
| 784 | self.run_oob_data_path_test( |
| 785 | encr_type=self.ENCR_TYPE_PMK, |
| 786 | use_peer_id=False) |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 787 | |
Etan Cohen | 3565352 | 2017-11-09 13:47:20 -0800 | [diff] [blame^] | 788 | def test_oob_ib_coex_open_specific(self): |
| 789 | """Data-path: out-of-band, open encryption, specific peer - in-band coex: |
| 790 | set up a concurrent discovery session to verify no impact. The session |
| 791 | consists of Publisher on both ends, and a Subscriber on the Responder. |
| 792 | |
| 793 | Verifies end-to-end discovery + data-path creation. |
| 794 | """ |
| 795 | self.run_oob_data_path_test( |
| 796 | encr_type=self.ENCR_TYPE_OPEN, |
| 797 | use_peer_id=True, |
| 798 | setup_discovery_sessions=True) |
| 799 | |
| 800 | def test_oob_ib_coex_open_any(self): |
| 801 | """Data-path: out-of-band, open encryption, any peer - in-band coex: |
| 802 | set up a concurrent discovery session to verify no impact. The session |
| 803 | consists of Publisher on both ends, and a Subscriber on the Responder. |
| 804 | |
| 805 | Verifies end-to-end discovery + data-path creation. |
| 806 | """ |
| 807 | self.run_oob_data_path_test( |
| 808 | encr_type=self.ENCR_TYPE_OPEN, |
| 809 | use_peer_id=False, |
| 810 | setup_discovery_sessions=True) |
| 811 | |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 812 | ############################################################## |
| 813 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 814 | @test_tracker_info(uuid="1c2c9805-dc1e-43b5-a1b8-315e8c9a4337") |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 815 | def test_passphrase_min(self): |
| 816 | """Data-path: minimum passphrase length |
| 817 | |
| 818 | Use in-band, unsolicited/passive, any peer combination |
| 819 | """ |
| 820 | self.run_ib_data_path_test(ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 821 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 822 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 823 | use_peer_id=False, |
| 824 | passphrase_to_use=self.PASSPHRASE_MIN) |
| 825 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 826 | @test_tracker_info(uuid="e696e2b9-87a9-4521-b337-61b9efaa2057") |
Etan Cohen | 6ace458 | 2017-06-05 17:21:55 -0700 | [diff] [blame] | 827 | def test_passphrase_max(self): |
| 828 | """Data-path: maximum passphrase length |
| 829 | |
| 830 | Use in-band, unsolicited/passive, any peer combination |
| 831 | """ |
| 832 | self.run_ib_data_path_test(ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 833 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 834 | encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 835 | use_peer_id=False, |
| 836 | passphrase_to_use=self.PASSPHRASE_MAX) |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 837 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 838 | @test_tracker_info(uuid="533cd44c-ff30-4283-ac28-f71fd7b4f02d") |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 839 | def test_negative_mismatch_publisher_peer_id(self): |
| 840 | """Data-path: failure when publisher peer ID is mismatched""" |
| 841 | self.run_mismatched_ib_data_path_test(pub_mismatch=True, sub_mismatch=False) |
| 842 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 843 | @test_tracker_info(uuid="682f275e-722a-4f8b-85e7-0dcea9d25532") |
Etan Cohen | bc80da1 | 2017-06-06 09:26:02 -0700 | [diff] [blame] | 844 | def test_negative_mismatch_subscriber_peer_id(self): |
| 845 | """Data-path: failure when subscriber peer ID is mismatched""" |
| 846 | self.run_mismatched_ib_data_path_test(pub_mismatch=False, sub_mismatch=True) |
| 847 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 848 | @test_tracker_info(uuid="7fa82796-7fc9-4d9e-bbbb-84b751788943") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 849 | def test_negative_mismatch_init_mac(self): |
| 850 | """Data-path: failure when Initiator MAC address mismatch""" |
| 851 | self.run_mismatched_oob_data_path_test( |
| 852 | init_mismatch_mac=True, |
| 853 | resp_mismatch_mac=False) |
| 854 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 855 | @test_tracker_info(uuid="edeae959-4644-44f9-8d41-bdeb5216954e") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 856 | def test_negative_mismatch_resp_mac(self): |
| 857 | """Data-path: failure when Responder MAC address mismatch""" |
| 858 | self.run_mismatched_oob_data_path_test( |
| 859 | init_mismatch_mac=False, |
| 860 | resp_mismatch_mac=True) |
| 861 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 862 | @test_tracker_info(uuid="91f46949-c47f-49f9-a90f-6fae699613a7") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 863 | def test_negative_mismatch_passphrase(self): |
| 864 | """Data-path: failure when passphrases mismatch""" |
| 865 | self.run_mismatched_oob_data_path_test( |
| 866 | init_encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 867 | resp_encr_type=self.ENCR_TYPE_PASSPHRASE) |
| 868 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 869 | @test_tracker_info(uuid="01c49c2e-dc92-4a27-bb47-c4fc67617c23") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 870 | def test_negative_mismatch_pmk(self): |
| 871 | """Data-path: failure when PMK mismatch""" |
| 872 | self.run_mismatched_oob_data_path_test( |
| 873 | init_encr_type=self.ENCR_TYPE_PMK, |
| 874 | resp_encr_type=self.ENCR_TYPE_PMK) |
| 875 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 876 | @test_tracker_info(uuid="4d651797-5fbb-408e-a4b6-a6e1944136da") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 877 | def test_negative_mismatch_open_passphrase(self): |
| 878 | """Data-path: failure when initiator is open, and responder passphrase""" |
| 879 | self.run_mismatched_oob_data_path_test( |
| 880 | init_encr_type=self.ENCR_TYPE_OPEN, |
| 881 | resp_encr_type=self.ENCR_TYPE_PASSPHRASE) |
| 882 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 883 | @test_tracker_info(uuid="1ae697f4-5987-4187-aeef-1e22d07d4a7c") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 884 | def test_negative_mismatch_open_pmk(self): |
| 885 | """Data-path: failure when initiator is open, and responder PMK""" |
| 886 | self.run_mismatched_oob_data_path_test( |
| 887 | init_encr_type=self.ENCR_TYPE_OPEN, |
| 888 | resp_encr_type=self.ENCR_TYPE_PMK) |
| 889 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 890 | @test_tracker_info(uuid="f027b1cc-0e7a-4075-b880-5e64b288afbd") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 891 | def test_negative_mismatch_pmk_passphrase(self): |
| 892 | """Data-path: failure when initiator is pmk, and responder passphrase""" |
| 893 | self.run_mismatched_oob_data_path_test( |
| 894 | init_encr_type=self.ENCR_TYPE_PMK, |
| 895 | resp_encr_type=self.ENCR_TYPE_PASSPHRASE) |
| 896 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 897 | @test_tracker_info(uuid="0819bbd4-72ae-49c4-bd46-5448db2b0a06") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 898 | def test_negative_mismatch_passphrase_open(self): |
| 899 | """Data-path: failure when initiator is passphrase, and responder open""" |
| 900 | self.run_mismatched_oob_data_path_test( |
| 901 | init_encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 902 | resp_encr_type=self.ENCR_TYPE_OPEN) |
| 903 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 904 | @test_tracker_info(uuid="7ef24f62-8e6b-4732-88a3-80a43584dda4") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 905 | def test_negative_mismatch_pmk_open(self): |
| 906 | """Data-path: failure when initiator is PMK, and responder open""" |
| 907 | self.run_mismatched_oob_data_path_test( |
| 908 | init_encr_type=self.ENCR_TYPE_PMK, |
| 909 | resp_encr_type=self.ENCR_TYPE_OPEN) |
| 910 | |
Etan Cohen | 185b3cf | 2017-08-22 14:10:10 -0700 | [diff] [blame] | 911 | @test_tracker_info(uuid="7b9c9efc-1c06-465e-8a5e-d6a22ac1da97") |
Etan Cohen | 85adc45 | 2017-06-06 08:32:08 -0700 | [diff] [blame] | 912 | def test_negative_mismatch_passphrase_pmk(self): |
| 913 | """Data-path: failure when initiator is passphrase, and responder pmk""" |
| 914 | self.run_mismatched_oob_data_path_test( |
| 915 | init_encr_type=self.ENCR_TYPE_PASSPHRASE, |
| 916 | resp_encr_type=self.ENCR_TYPE_OPEN) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 917 | |
| 918 | |
| 919 | ########################################################################## |
| 920 | |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 921 | def wait_for_request_responses(self, dut, req_keys, aware_ifs): |
| 922 | """Wait for network request confirmation for all request keys. |
| 923 | |
| 924 | Args: |
| 925 | dut: Device under test |
| 926 | req_keys: (in) A list of the network requests |
| 927 | aware_ifs: (out) A list into which to append the network interface |
| 928 | """ |
| 929 | num_events = 0 |
| 930 | while num_events != len(req_keys): |
| 931 | event = autils.wait_for_event(dut, cconsts.EVENT_NETWORK_CALLBACK) |
| 932 | if (event["data"][cconsts.NETWORK_CB_KEY_EVENT] == |
| 933 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED): |
| 934 | if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys: |
| 935 | num_events = num_events + 1 |
| 936 | aware_ifs.append(event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME]) |
| 937 | else: |
| 938 | self.log.info("Received an unexpected connectivity, the revoked " |
| 939 | "network request probably went through -- %s", event) |
| 940 | |
Etan Cohen | b199cd1 | 2017-09-22 10:20:44 -0700 | [diff] [blame] | 941 | @test_tracker_info(uuid="2e325e2b-d552-4890-b470-20b40284395d") |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 942 | def test_multiple_identical_networks(self): |
| 943 | """Validate that creating multiple networks between 2 devices, each network |
| 944 | with identical configuration is supported over a single NDP. |
| 945 | |
| 946 | Verify that the interface and IPv6 address is the same for all networks. |
| 947 | """ |
| 948 | init_dut = self.android_devices[0] |
| 949 | init_dut.pretty_name = "Initiator" |
| 950 | resp_dut = self.android_devices[1] |
| 951 | resp_dut.pretty_name = "Responder" |
| 952 | |
| 953 | N = 2 # first iteration (must be 2 to give us a chance to cancel the first) |
| 954 | M = 5 # second iteration |
| 955 | |
| 956 | init_ids = [] |
| 957 | resp_ids = [] |
| 958 | |
| 959 | # Initiator+Responder: attach and wait for confirmation & identity |
| 960 | # create 10 sessions to be used in the different (but identical) NDPs |
| 961 | for i in range(N + M): |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 962 | id, init_mac = autils.attach_with_identity(init_dut) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 963 | init_ids.append(id) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 964 | id, resp_mac = autils.attach_with_identity(resp_dut) |
Etan Cohen | 38c3d5a | 2017-07-28 10:02:48 -0700 | [diff] [blame] | 965 | resp_ids.append(id) |
| 966 | |
| 967 | # wait for for devices to synchronize with each other - there are no other |
| 968 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 969 | # to execute the data-path request) |
| 970 | time.sleep(autils.WAIT_FOR_CLUSTER) |
| 971 | |
| 972 | resp_req_keys = [] |
| 973 | init_req_keys = [] |
| 974 | resp_aware_ifs = [] |
| 975 | init_aware_ifs = [] |
| 976 | |
| 977 | # issue N quick requests for identical NDPs - without waiting for result |
| 978 | # tests whether pre-setup multiple NDP procedure |
| 979 | for i in range(N): |
| 980 | # Responder: request network |
| 981 | resp_req_keys.append(autils.request_network( |
| 982 | resp_dut, |
| 983 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 984 | resp_ids[i], aconsts.DATA_PATH_RESPONDER, init_mac, None))) |
| 985 | |
| 986 | # Initiator: request network |
| 987 | init_req_keys.append(autils.request_network( |
| 988 | init_dut, |
| 989 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 990 | init_ids[i], aconsts.DATA_PATH_INITIATOR, resp_mac, None))) |
| 991 | |
| 992 | # remove the first request (hopefully before completed) testing that NDP |
| 993 | # is still created |
| 994 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_keys[0]) |
| 995 | resp_req_keys.remove(resp_req_keys[0]) |
| 996 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_keys[0]) |
| 997 | init_req_keys.remove(init_req_keys[0]) |
| 998 | |
| 999 | # wait for network formation for all initial requests |
| 1000 | self.wait_for_request_responses(resp_dut, resp_req_keys, resp_aware_ifs) |
| 1001 | self.wait_for_request_responses(init_dut, init_req_keys, init_aware_ifs) |
| 1002 | |
| 1003 | # issue N more requests for the same NDPs - tests post-setup multiple NDP |
| 1004 | for i in range(M): |
| 1005 | # Responder: request network |
| 1006 | resp_req_keys.append(autils.request_network( |
| 1007 | resp_dut, |
| 1008 | resp_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1009 | resp_ids[N + i], aconsts.DATA_PATH_RESPONDER, init_mac, None))) |
| 1010 | |
| 1011 | # Initiator: request network |
| 1012 | init_req_keys.append(autils.request_network( |
| 1013 | init_dut, |
| 1014 | init_dut.droid.wifiAwareCreateNetworkSpecifierOob( |
| 1015 | init_ids[N + i], aconsts.DATA_PATH_INITIATOR, resp_mac, None))) |
| 1016 | |
| 1017 | # wait for network formation for all subsequent requests |
| 1018 | self.wait_for_request_responses(resp_dut, resp_req_keys[N - 1:], |
| 1019 | resp_aware_ifs) |
| 1020 | self.wait_for_request_responses(init_dut, init_req_keys[N - 1:], |
| 1021 | init_aware_ifs) |
| 1022 | |
| 1023 | # determine whether all interfaces are identical (single NDP) - can't really |
| 1024 | # test the IPv6 address since it is not part of the callback event - it is |
| 1025 | # simply obtained from the system (so we'll always get the same for the same |
| 1026 | # interface) |
| 1027 | init_aware_ifs = list(set(init_aware_ifs)) |
| 1028 | resp_aware_ifs = list(set(resp_aware_ifs)) |
| 1029 | |
| 1030 | self.log.info("Interface names: I=%s, R=%s", init_aware_ifs, resp_aware_ifs) |
| 1031 | self.log.info("Initiator requests: %s", init_req_keys) |
| 1032 | self.log.info("Responder requests: %s", resp_req_keys) |
| 1033 | |
| 1034 | asserts.assert_equal( |
| 1035 | len(init_aware_ifs), 1, "Multiple initiator interfaces") |
| 1036 | asserts.assert_equal( |
| 1037 | len(resp_aware_ifs), 1, "Multiple responder interfaces") |
| 1038 | |
| 1039 | self.log.info("Interface IPv6 (using ifconfig): I=%s, R=%s", |
| 1040 | autils.get_ipv6_addr(init_dut, init_aware_ifs[0]), |
| 1041 | autils.get_ipv6_addr(resp_dut, resp_aware_ifs[0])) |
| 1042 | |
| 1043 | for i in range(init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]): |
| 1044 | if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i) |
| 1045 | init_ipv6 = autils.get_ipv6_addr(init_dut, if_name) |
| 1046 | resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name) |
| 1047 | |
| 1048 | asserts.assert_equal( |
| 1049 | init_ipv6 is None, if_name not in init_aware_ifs, |
| 1050 | "Initiator interface %s in unexpected state" % if_name) |
| 1051 | asserts.assert_equal( |
| 1052 | resp_ipv6 is None, if_name not in resp_aware_ifs, |
| 1053 | "Responder interface %s in unexpected state" % if_name) |
| 1054 | |
| 1055 | # release requests |
| 1056 | for resp_req_key in resp_req_keys: |
| 1057 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 1058 | for init_req_key in init_req_keys: |
| 1059 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1060 | |
| 1061 | ######################################################################## |
| 1062 | |
| 1063 | def run_multiple_ndi(self, sec_configs): |
| 1064 | """Validate that the device can create and use multiple NDIs. |
| 1065 | |
| 1066 | The security configuration can be: |
| 1067 | - None: open |
| 1068 | - String: passphrase |
| 1069 | - otherwise: PMK (byte array) |
| 1070 | |
| 1071 | Args: |
| 1072 | sec_configs: list of security configurations |
| 1073 | """ |
| 1074 | init_dut = self.android_devices[0] |
| 1075 | init_dut.pretty_name = "Initiator" |
| 1076 | resp_dut = self.android_devices[1] |
| 1077 | resp_dut.pretty_name = "Responder" |
| 1078 | |
| 1079 | asserts.skip_if(init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] |
| 1080 | < len(sec_configs) or |
| 1081 | resp_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] |
| 1082 | < len(sec_configs), |
| 1083 | "Initiator or Responder do not support multiple NDIs") |
| 1084 | |
| 1085 | init_id, init_mac = autils.attach_with_identity(init_dut) |
| 1086 | resp_id, resp_mac = autils.attach_with_identity(resp_dut) |
| 1087 | |
| 1088 | # wait for for devices to synchronize with each other - there are no other |
| 1089 | # mechanisms to make sure this happens for OOB discovery (except retrying |
| 1090 | # to execute the data-path request) |
| 1091 | time.sleep(autils.WAIT_FOR_CLUSTER) |
| 1092 | |
| 1093 | resp_req_keys = [] |
| 1094 | init_req_keys = [] |
| 1095 | resp_aware_ifs = [] |
| 1096 | init_aware_ifs = [] |
| 1097 | |
| 1098 | for sec in sec_configs: |
| 1099 | # Responder: request network |
| 1100 | resp_req_key = autils.request_network(resp_dut, |
| 1101 | autils.get_network_specifier( |
| 1102 | resp_dut, resp_id, |
| 1103 | aconsts.DATA_PATH_RESPONDER, |
| 1104 | init_mac, sec)) |
| 1105 | resp_req_keys.append(resp_req_key) |
| 1106 | |
| 1107 | # Initiator: request network |
| 1108 | init_req_key = autils.request_network(init_dut, |
| 1109 | autils.get_network_specifier( |
| 1110 | init_dut, init_id, |
| 1111 | aconsts.DATA_PATH_INITIATOR, |
| 1112 | resp_mac, sec)) |
| 1113 | init_req_keys.append(init_req_key) |
| 1114 | |
| 1115 | # Wait for network |
| 1116 | init_net_event = autils.wait_for_event_with_keys( |
| 1117 | init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT, |
| 1118 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1119 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1120 | (cconsts.NETWORK_CB_KEY_ID, init_req_key)) |
| 1121 | resp_net_event = autils.wait_for_event_with_keys( |
| 1122 | resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT, |
| 1123 | (cconsts.NETWORK_CB_KEY_EVENT, |
| 1124 | cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED), |
| 1125 | (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) |
| 1126 | |
| 1127 | resp_aware_ifs.append( |
| 1128 | resp_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME]) |
| 1129 | init_aware_ifs.append( |
| 1130 | init_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME]) |
| 1131 | |
| 1132 | # check that we are using 2 NDIs |
| 1133 | init_aware_ifs = list(set(init_aware_ifs)) |
| 1134 | resp_aware_ifs = list(set(resp_aware_ifs)) |
| 1135 | |
| 1136 | self.log.info("Interface names: I=%s, R=%s", init_aware_ifs, resp_aware_ifs) |
| 1137 | self.log.info("Initiator requests: %s", init_req_keys) |
| 1138 | self.log.info("Responder requests: %s", resp_req_keys) |
| 1139 | |
| 1140 | asserts.assert_equal( |
| 1141 | len(init_aware_ifs), len(sec_configs), "Multiple initiator interfaces") |
| 1142 | asserts.assert_equal( |
| 1143 | len(resp_aware_ifs), len(sec_configs), "Multiple responder interfaces") |
| 1144 | |
| 1145 | for i in range(len(sec_configs)): |
| 1146 | if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i) |
| 1147 | init_ipv6 = autils.get_ipv6_addr(init_dut, if_name) |
| 1148 | resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name) |
| 1149 | |
| 1150 | asserts.assert_equal( |
| 1151 | init_ipv6 is None, if_name not in init_aware_ifs, |
| 1152 | "Initiator interface %s in unexpected state" % if_name) |
| 1153 | asserts.assert_equal( |
| 1154 | resp_ipv6 is None, if_name not in resp_aware_ifs, |
| 1155 | "Responder interface %s in unexpected state" % if_name) |
| 1156 | |
| 1157 | # release requests |
| 1158 | for resp_req_key in resp_req_keys: |
| 1159 | resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) |
| 1160 | for init_req_key in init_req_keys: |
| 1161 | init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) |
| 1162 | |
Etan Cohen | b199cd1 | 2017-09-22 10:20:44 -0700 | [diff] [blame] | 1163 | @test_tracker_info(uuid="2d728163-11cc-46ba-a973-c8e1e71397fc") |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1164 | def test_multiple_ndi_open_passphrase(self): |
| 1165 | """Verify that can between 2 DUTs can create 2 NDPs with different security |
| 1166 | configuration (one open, one using passphrase). The result should use two |
| 1167 | different NDIs""" |
| 1168 | self.run_multiple_ndi([None, self.PASSPHRASE]) |
| 1169 | |
Etan Cohen | b199cd1 | 2017-09-22 10:20:44 -0700 | [diff] [blame] | 1170 | @test_tracker_info(uuid="5f2c32aa-20b2-41f0-8b1e-d0b68df73ada") |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1171 | def test_multiple_ndi_open_pmk(self): |
| 1172 | """Verify that can between 2 DUTs can create 2 NDPs with different security |
| 1173 | configuration (one open, one using pmk). The result should use two |
| 1174 | different NDIs""" |
| 1175 | self.run_multiple_ndi([None, self.PMK]) |
| 1176 | |
Etan Cohen | b199cd1 | 2017-09-22 10:20:44 -0700 | [diff] [blame] | 1177 | @test_tracker_info(uuid="34467659-bcfb-40cd-ba25-7e50560fca63") |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1178 | def test_multiple_ndi_passphrase_pmk(self): |
| 1179 | """Verify that can between 2 DUTs can create 2 NDPs with different security |
| 1180 | configuration (one using passphrase, one using pmk). The result should use |
| 1181 | two different NDIs""" |
| 1182 | self.run_multiple_ndi([self.PASSPHRASE, self.PMK]) |
| 1183 | |
Etan Cohen | b199cd1 | 2017-09-22 10:20:44 -0700 | [diff] [blame] | 1184 | @test_tracker_info(uuid="d9194ce6-45b6-41b1-9cc8-ada79968966d") |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1185 | def test_multiple_ndi_passphrases(self): |
| 1186 | """Verify that can between 2 DUTs can create 2 NDPs with different security |
| 1187 | configuration (using different passphrases). The result should use two |
| 1188 | different NDIs""" |
| 1189 | self.run_multiple_ndi([self.PASSPHRASE, self.PASSPHRASE2]) |
| 1190 | |
Etan Cohen | b199cd1 | 2017-09-22 10:20:44 -0700 | [diff] [blame] | 1191 | @test_tracker_info(uuid="879df795-62d2-40d4-a862-bd46d8f7e67f") |
Etan Cohen | a1e8d50 | 2017-08-16 09:28:18 -0700 | [diff] [blame] | 1192 | def test_multiple_ndi_pmks(self): |
| 1193 | """Verify that can between 2 DUTs can create 2 NDPs with different security |
| 1194 | configuration (using different PMKS). The result should use two different |
| 1195 | NDIs""" |
| 1196 | self.run_multiple_ndi([self.PMK, self.PMK2]) |