blob: 145b1a6da31463351b19f135d6f9ebf54fe2c901 [file] [log] [blame]
Etan Cohenfc5f3732017-06-02 17:31:52 -07001#!/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
17import time
18
Etan Cohen38c3d5a2017-07-28 10:02:48 -070019from acts import asserts
Etan Cohenf02703c2017-08-24 11:11:44 -070020from acts.test_decorators import test_tracker_info
Xianyuan Jia63751fb2020-11-17 00:07:40 +000021from acts_contrib.test_utils.net import connectivity_const as cconsts
22from acts_contrib.test_utils.wifi import wifi_test_utils as wutils
23from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest
24from acts_contrib.test_utils.wifi.aware import aware_const as aconsts
25from acts_contrib.test_utils.wifi.aware import aware_test_utils as autils
26from acts_contrib.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest
Etan Cohenfc5f3732017-06-02 17:31:52 -070027
28
29class DataPathTest(AwareBaseTest):
Jaineel7e67a3f2019-08-28 15:58:49 -070030 """Set of tests for Wi-Fi Aware data-path."""
Etan Cohenfc5f3732017-06-02 17:31:52 -070031
Jaineel7e67a3f2019-08-28 15:58:49 -070032 # configuration parameters used by tests
33 ENCR_TYPE_OPEN = 0
34 ENCR_TYPE_PASSPHRASE = 1
35 ENCR_TYPE_PMK = 2
Etan Cohenfc5f3732017-06-02 17:31:52 -070036
Jaineel7e67a3f2019-08-28 15:58:49 -070037 PASSPHRASE = "This is some random passphrase - very very secure!!"
38 PASSPHRASE_MIN = "01234567"
39 PASSPHRASE_MAX = "012345678901234567890123456789012345678901234567890123456789012"
40 PMK = "ODU0YjE3YzdmNDJiNWI4NTQ2NDJjNDI3M2VkZTQyZGU="
41 PASSPHRASE2 = "This is some random passphrase - very very secure - but diff!!"
42 PMK2 = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="
Etan Cohenfc5f3732017-06-02 17:31:52 -070043
Jaineel7e67a3f2019-08-28 15:58:49 -070044 PING_MSG = "ping"
Etan Cohenfc5f3732017-06-02 17:31:52 -070045
Jaineel7e67a3f2019-08-28 15:58:49 -070046 # message re-transmit counter (increases reliability in open-environment)
47 # Note: reliability of message transmission is tested elsewhere
48 MSG_RETX_COUNT = 5 # hard-coded max value, internal API
Etan Cohenfc5f3732017-06-02 17:31:52 -070049
Jaineel7e67a3f2019-08-28 15:58:49 -070050 # number of second to 'reasonably' wait to make sure that devices synchronize
51 # with each other - useful for OOB test cases, where the OOB discovery would
52 # take some time
53 WAIT_FOR_CLUSTER = 5
Etan Cohenba8a53f2017-06-05 12:55:02 -070054
Jaineel7e67a3f2019-08-28 15:58:49 -070055 def create_config(self, dtype):
56 """Create a base configuration based on input parameters.
Etan Cohenfc5f3732017-06-02 17:31:52 -070057
58 Args:
59 dtype: Publish or Subscribe discovery type
60
61 Returns:
62 Discovery configuration object.
63 """
Jaineel7e67a3f2019-08-28 15:58:49 -070064 config = {}
65 config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = dtype
66 config[
67 aconsts.DISCOVERY_KEY_SERVICE_NAME] = "GoogleTestServiceDataPath"
68 return config
Etan Cohenfc5f3732017-06-02 17:31:52 -070069
Jaineel7e67a3f2019-08-28 15:58:49 -070070 def request_network(self, dut, ns):
71 """Request a Wi-Fi Aware network.
Etan Cohenfc5f3732017-06-02 17:31:52 -070072
73 Args:
74 dut: Device
75 ns: Network specifier
76 Returns: the request key
77 """
Jaineel7e67a3f2019-08-28 15:58:49 -070078 network_req = {"TransportType": 5, "NetworkSpecifier": ns}
79 return dut.droid.connectivityRequestWifiAwareNetwork(network_req)
Etan Cohenfc5f3732017-06-02 17:31:52 -070080
Jaineel7e67a3f2019-08-28 15:58:49 -070081 def set_up_discovery(self,
82 ptype,
83 stype,
84 get_peer_id,
85 pub_on_both=False,
86 pub_on_both_same=True):
87 """Set up discovery sessions and wait for service discovery.
Etan Cohenfc5f3732017-06-02 17:31:52 -070088
89 Args:
90 ptype: Publish discovery type
91 stype: Subscribe discovery type
Etan Cohenbc80da12017-06-06 09:26:02 -070092 get_peer_id: Send a message across to get the peer's id
Etan Cohen204df172017-11-09 12:05:36 -080093 pub_on_both: If True then set up a publisher on both devices. The second
94 publisher isn't used (existing to test use-case).
95 pub_on_both_same: If True then the second publish uses an identical
96 service name, otherwise a different service name.
Etan Cohenfc5f3732017-06-02 17:31:52 -070097 """
Jaineel7e67a3f2019-08-28 15:58:49 -070098 p_dut = self.android_devices[0]
99 p_dut.pretty_name = "Publisher"
100 s_dut = self.android_devices[1]
101 s_dut.pretty_name = "Subscriber"
Etan Cohenfc5f3732017-06-02 17:31:52 -0700102
Jaineel7e67a3f2019-08-28 15:58:49 -0700103 # Publisher+Subscriber: attach and wait for confirmation
104 p_id = p_dut.droid.wifiAwareAttach()
105 autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED)
106 time.sleep(self.device_startup_offset)
107 s_id = s_dut.droid.wifiAwareAttach()
108 autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700109
Jaineel7e67a3f2019-08-28 15:58:49 -0700110 # Publisher: start publish and wait for confirmation
111 p_disc_id = p_dut.droid.wifiAwarePublish(p_id,
112 self.create_config(ptype))
113 autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700114
Jaineel7e67a3f2019-08-28 15:58:49 -0700115 # Optionally set up a publish session on the Subscriber device
116 if pub_on_both:
117 p2_config = self.create_config(ptype)
118 if not pub_on_both_same:
119 p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = (
120 p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] + "-XYZXYZ")
121 s_dut.droid.wifiAwarePublish(s_id, p2_config)
122 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
Etan Cohen204df172017-11-09 12:05:36 -0800123
Jaineel7e67a3f2019-08-28 15:58:49 -0700124 # Subscriber: start subscribe and wait for confirmation
125 s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id,
126 self.create_config(stype))
127 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700128
Jaineel7e67a3f2019-08-28 15:58:49 -0700129 # Subscriber: wait for service discovery
130 discovery_event = autils.wait_for_event(
131 s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
132 peer_id_on_sub = discovery_event["data"][
133 aconsts.SESSION_CB_KEY_PEER_ID]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700134
Jaineel7e67a3f2019-08-28 15:58:49 -0700135 peer_id_on_pub = None
136 if get_peer_id: # only need message to receive peer ID
137 # Subscriber: send message to peer (Publisher - so it knows our address)
138 s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub,
139 self.get_next_msg_id(),
140 self.PING_MSG,
141 self.MSG_RETX_COUNT)
142 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700143
Jaineel7e67a3f2019-08-28 15:58:49 -0700144 # Publisher: wait for received message
145 pub_rx_msg_event = autils.wait_for_event(
146 p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED)
147 peer_id_on_pub = pub_rx_msg_event["data"][
148 aconsts.SESSION_CB_KEY_PEER_ID]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700149
Jaineel7e67a3f2019-08-28 15:58:49 -0700150 return (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
151 peer_id_on_pub)
Etan Cohenbc80da12017-06-06 09:26:02 -0700152
Jaineel7e67a3f2019-08-28 15:58:49 -0700153 def run_ib_data_path_test(self,
154 ptype,
155 stype,
156 encr_type,
157 use_peer_id,
158 passphrase_to_use=None,
159 pub_on_both=False,
160 pub_on_both_same=True,
161 expect_failure=False):
162 """Runs the in-band data-path tests.
Etan Cohenbc80da12017-06-06 09:26:02 -0700163
164 Args:
165 ptype: Publish discovery type
166 stype: Subscribe discovery type
167 encr_type: Encryption type, one of ENCR_TYPE_*
168 use_peer_id: On Responder (publisher): True to use peer ID, False to
169 accept any request
170 passphrase_to_use: The passphrase to use if encr_type=ENCR_TYPE_PASSPHRASE
171 If None then use self.PASSPHRASE
Etan Cohen204df172017-11-09 12:05:36 -0800172 pub_on_both: If True then set up a publisher on both devices. The second
173 publisher isn't used (existing to test use-case).
174 pub_on_both_same: If True then the second publish uses an identical
175 service name, otherwise a different service name.
Etan Cohen7922a312018-01-23 13:34:55 -0800176 expect_failure: If True then don't expect NDP formation, otherwise expect
177 NDP setup to succeed.
Etan Cohenbc80da12017-06-06 09:26:02 -0700178 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700179 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
180 peer_id_on_pub) = self.set_up_discovery(
181 ptype,
182 stype,
183 use_peer_id,
184 pub_on_both=pub_on_both,
185 pub_on_both_same=pub_on_both_same)
Etan Cohenbc80da12017-06-06 09:26:02 -0700186
Jaineel7e67a3f2019-08-28 15:58:49 -0700187 passphrase = None
188 pmk = None
189 if encr_type == self.ENCR_TYPE_PASSPHRASE:
190 passphrase = (self.PASSPHRASE
191 if passphrase_to_use == None else passphrase_to_use)
192 elif encr_type == self.ENCR_TYPE_PMK:
193 pmk = self.PMK
Etan Cohen058aaba2017-06-05 17:01:54 -0700194
Jaineel7e67a3f2019-08-28 15:58:49 -0700195 port = 1234
196 transport_protocol = 6 # TCP/IP
Etan Cohenfc5f3732017-06-02 17:31:52 -0700197
Jaineel7e67a3f2019-08-28 15:58:49 -0700198 # Publisher: request network
199 if encr_type == self.ENCR_TYPE_OPEN:
200 p_req_key = self.request_network(
201 p_dut,
202 p_dut.droid.wifiAwareCreateNetworkSpecifier(
203 p_disc_id, peer_id_on_pub
204 if use_peer_id else None, passphrase, pmk))
205 else:
206 p_req_key = self.request_network(
207 p_dut,
208 p_dut.droid.wifiAwareCreateNetworkSpecifier(
209 p_disc_id, peer_id_on_pub if use_peer_id else None,
210 passphrase, pmk, port, transport_protocol))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700211
Jaineel7e67a3f2019-08-28 15:58:49 -0700212 # Subscriber: request network
213 s_req_key = self.request_network(
214 s_dut,
215 s_dut.droid.wifiAwareCreateNetworkSpecifier(
216 s_disc_id, peer_id_on_sub, passphrase, pmk))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700217
Jaineel7e67a3f2019-08-28 15:58:49 -0700218 if expect_failure:
219 # Publisher & Subscriber: expect unavailable callbacks
220 autils.wait_for_event_with_keys(
221 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
222 autils.EVENT_NDP_TIMEOUT,
223 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
224 autils.wait_for_event_with_keys(
225 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
226 autils.EVENT_NDP_TIMEOUT,
227 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
228 else:
229 # Publisher & Subscriber: wait for network formation
230 p_net_event_nc = autils.wait_for_event_with_keys(
231 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
232 autils.EVENT_NDP_TIMEOUT,
233 (cconsts.NETWORK_CB_KEY_EVENT,
234 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
235 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
236 s_net_event_nc = autils.wait_for_event_with_keys(
237 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
238 autils.EVENT_NDP_TIMEOUT,
239 (cconsts.NETWORK_CB_KEY_EVENT,
240 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
241 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700242
Jaineel7e67a3f2019-08-28 15:58:49 -0700243 # validate no leak of information
244 asserts.assert_false(
245 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[
246 "data"], "Network specifier leak!")
247 asserts.assert_false(
248 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[
249 "data"], "Network specifier leak!")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700250
Jaineel7e67a3f2019-08-28 15:58:49 -0700251 # note that Pub <-> Sub since IPv6 are of peer's!
252 s_ipv6 = p_net_event_nc["data"][aconsts.NET_CAP_IPV6]
253 p_ipv6 = s_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700254
Jaineel7e67a3f2019-08-28 15:58:49 -0700255 self.verify_network_info(
256 p_net_event_nc["data"], s_net_event_nc["data"],
257 encr_type == self.ENCR_TYPE_OPEN, port, transport_protocol)
Etan Cohence202292017-06-05 13:55:54 -0700258
Jaineel7e67a3f2019-08-28 15:58:49 -0700259 p_net_event_lp = autils.wait_for_event_with_keys(
260 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
261 autils.EVENT_NDP_TIMEOUT,
262 (cconsts.NETWORK_CB_KEY_EVENT,
263 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
264 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
265 s_net_event_lp = autils.wait_for_event_with_keys(
266 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
267 autils.EVENT_NDP_TIMEOUT,
268 (cconsts.NETWORK_CB_KEY_EVENT,
269 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
270 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohence202292017-06-05 13:55:54 -0700271
Jaineel7e67a3f2019-08-28 15:58:49 -0700272 p_aware_if = p_net_event_lp["data"][
273 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
274 s_aware_if = s_net_event_lp["data"][
275 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700276
Jaineel7e67a3f2019-08-28 15:58:49 -0700277 self.log.info("Interface names: p=%s, s=%s", p_aware_if,
278 s_aware_if)
279 self.log.info("Interface addresses (IPv6): p=%s, s=%s", p_ipv6,
280 s_ipv6)
281
282 # open sockets to test connection
283 asserts.assert_true(
284 autils.verify_socket_connect(p_dut, s_dut, p_ipv6, s_ipv6, 0),
285 "Failed socket link with Pub as Server")
286 asserts.assert_true(
287 autils.verify_socket_connect(s_dut, p_dut, s_ipv6, p_ipv6, 0),
288 "Failed socket link with Sub as Server")
289
290 # terminate sessions and wait for ON_LOST callbacks
291 p_dut.droid.wifiAwareDestroy(p_id)
292 s_dut.droid.wifiAwareDestroy(s_id)
293
294 autils.wait_for_event_with_keys(
295 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
296 autils.EVENT_NDP_TIMEOUT,
297 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
298 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
299 autils.wait_for_event_with_keys(
300 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
301 autils.EVENT_NDP_TIMEOUT,
302 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
303 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
304
305 # clean-up
306 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
307 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
308
309 def run_oob_data_path_test(self,
310 encr_type,
311 use_peer_id,
312 setup_discovery_sessions=False,
313 expect_failure=False):
314 """Runs the out-of-band data-path tests.
Etan Cohenba8a53f2017-06-05 12:55:02 -0700315
316 Args:
317 encr_type: Encryption type, one of ENCR_TYPE_*
318 use_peer_id: On Responder: True to use peer ID, False to accept any
319 request
Etan Cohen35653522017-11-09 13:47:20 -0800320 setup_discovery_sessions: If True also set up a (spurious) discovery
321 session (pub on both sides, sub on Responder side). Validates a corner
322 case.
Etan Cohen7922a312018-01-23 13:34:55 -0800323 expect_failure: If True then don't expect NDP formation, otherwise expect
324 NDP setup to succeed.
Etan Cohenba8a53f2017-06-05 12:55:02 -0700325 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700326 init_dut = self.android_devices[0]
327 init_dut.pretty_name = "Initiator"
328 resp_dut = self.android_devices[1]
329 resp_dut.pretty_name = "Responder"
Etan Cohenba8a53f2017-06-05 12:55:02 -0700330
Jaineel7e67a3f2019-08-28 15:58:49 -0700331 # Initiator+Responder: attach and wait for confirmation & identity
332 init_id = init_dut.droid.wifiAwareAttach(True)
333 autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
334 init_ident_event = autils.wait_for_event(
335 init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
336 init_mac = init_ident_event["data"]["mac"]
337 time.sleep(self.device_startup_offset)
338 resp_id = resp_dut.droid.wifiAwareAttach(True)
339 autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
340 resp_ident_event = autils.wait_for_event(
341 resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
342 resp_mac = resp_ident_event["data"]["mac"]
Etan Cohenba8a53f2017-06-05 12:55:02 -0700343
Jaineel7e67a3f2019-08-28 15:58:49 -0700344 # wait for for devices to synchronize with each other - there are no other
345 # mechanisms to make sure this happens for OOB discovery (except retrying
346 # to execute the data-path request)
347 time.sleep(self.WAIT_FOR_CLUSTER)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700348
Jaineel7e67a3f2019-08-28 15:58:49 -0700349 if setup_discovery_sessions:
350 init_dut.droid.wifiAwarePublish(
351 init_id, self.create_config(aconsts.PUBLISH_TYPE_UNSOLICITED))
352 autils.wait_for_event(init_dut,
353 aconsts.SESSION_CB_ON_PUBLISH_STARTED)
354 resp_dut.droid.wifiAwarePublish(
355 resp_id, self.create_config(aconsts.PUBLISH_TYPE_UNSOLICITED))
356 autils.wait_for_event(resp_dut,
357 aconsts.SESSION_CB_ON_PUBLISH_STARTED)
358 resp_dut.droid.wifiAwareSubscribe(
359 resp_id, self.create_config(aconsts.SUBSCRIBE_TYPE_PASSIVE))
360 autils.wait_for_event(resp_dut,
361 aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED)
362 autils.wait_for_event(resp_dut,
363 aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
Etan Cohen35653522017-11-09 13:47:20 -0800364
Jaineel7e67a3f2019-08-28 15:58:49 -0700365 passphrase = None
366 pmk = None
367 if encr_type == self.ENCR_TYPE_PASSPHRASE:
368 passphrase = self.PASSPHRASE
369 elif encr_type == self.ENCR_TYPE_PMK:
370 pmk = self.PMK
Etan Cohen058aaba2017-06-05 17:01:54 -0700371
Jaineel7e67a3f2019-08-28 15:58:49 -0700372 # Responder: request network
373 resp_req_key = self.request_network(
374 resp_dut,
375 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
376 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac
377 if use_peer_id else None, passphrase, pmk))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700378
Jaineel7e67a3f2019-08-28 15:58:49 -0700379 # Initiator: request network
380 init_req_key = self.request_network(
381 init_dut,
382 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
383 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase,
384 pmk))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700385
Jaineel7e67a3f2019-08-28 15:58:49 -0700386 if expect_failure:
387 # Initiator & Responder: expect unavailable callbacks
388 autils.wait_for_event_with_keys(
389 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
390 autils.EVENT_NDP_TIMEOUT,
391 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
392 autils.wait_for_event_with_keys(
393 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
394 autils.EVENT_NDP_TIMEOUT,
395 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
396 else:
397 # Initiator & Responder: wait for network formation
398 init_net_event_nc = autils.wait_for_event_with_keys(
399 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
400 autils.EVENT_NDP_TIMEOUT,
401 (cconsts.NETWORK_CB_KEY_EVENT,
402 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
403 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
404 resp_net_event_nc = autils.wait_for_event_with_keys(
405 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
406 autils.EVENT_NDP_TIMEOUT,
407 (cconsts.NETWORK_CB_KEY_EVENT,
408 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
409 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700410
Jaineel7e67a3f2019-08-28 15:58:49 -0700411 # validate no leak of information
412 asserts.assert_false(
413 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in init_net_event_nc[
414 "data"], "Network specifier leak!")
415 asserts.assert_false(
416 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in resp_net_event_nc[
417 "data"], "Network specifier leak!")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700418
Jaineel7e67a3f2019-08-28 15:58:49 -0700419 # note that Init <-> Resp since IPv6 are of peer's!
420 init_ipv6 = resp_net_event_nc["data"][aconsts.NET_CAP_IPV6]
421 resp_ipv6 = init_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohenba8a53f2017-06-05 12:55:02 -0700422
Jaineel7e67a3f2019-08-28 15:58:49 -0700423 init_net_event_lp = autils.wait_for_event_with_keys(
424 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
425 autils.EVENT_NDP_TIMEOUT,
426 (cconsts.NETWORK_CB_KEY_EVENT,
427 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
428 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
429 resp_net_event_lp = autils.wait_for_event_with_keys(
430 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
431 autils.EVENT_NDP_TIMEOUT,
432 (cconsts.NETWORK_CB_KEY_EVENT,
433 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
434 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700435
Jaineel7e67a3f2019-08-28 15:58:49 -0700436 init_aware_if = init_net_event_lp["data"][
437 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
438 resp_aware_if = resp_net_event_lp["data"][
439 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohence202292017-06-05 13:55:54 -0700440
Jaineel7e67a3f2019-08-28 15:58:49 -0700441 self.log.info("Interface names: I=%s, R=%s", init_aware_if,
442 resp_aware_if)
443 self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
444 resp_ipv6)
Etan Cohence202292017-06-05 13:55:54 -0700445
Jaineel7e67a3f2019-08-28 15:58:49 -0700446 # open sockets to test connection
447 asserts.assert_true(
448 autils.verify_socket_connect(init_dut, resp_dut, init_ipv6,
449 resp_ipv6, 0),
450 "Failed socket link with Initiator as Server")
451 asserts.assert_true(
452 autils.verify_socket_connect(resp_dut, init_dut, resp_ipv6,
453 init_ipv6, 0),
454 "Failed socket link with Responder as Server")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700455
Jaineel7e67a3f2019-08-28 15:58:49 -0700456 # terminate sessions and wait for ON_LOST callbacks
457 init_dut.droid.wifiAwareDestroy(init_id)
458 resp_dut.droid.wifiAwareDestroy(resp_id)
459
460 autils.wait_for_event_with_keys(
461 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
462 autils.EVENT_NDP_TIMEOUT,
463 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
464 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
465 autils.wait_for_event_with_keys(
466 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
467 autils.EVENT_NDP_TIMEOUT,
468 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
469 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
470
471 # clean-up
472 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
473 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
474
475 def run_mismatched_ib_data_path_test(self, pub_mismatch, sub_mismatch):
476 """Runs the negative in-band data-path tests: mismatched peer ID.
Etan Cohenbc80da12017-06-06 09:26:02 -0700477
478 Args:
479 pub_mismatch: Mismatch the publisher's ID
480 sub_mismatch: Mismatch the subscriber's ID
481 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700482 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
483 peer_id_on_pub) = self.set_up_discovery(
484 aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE,
485 True)
Etan Cohenbc80da12017-06-06 09:26:02 -0700486
Jaineel7e67a3f2019-08-28 15:58:49 -0700487 if pub_mismatch:
488 peer_id_on_pub = peer_id_on_pub - 1
489 if sub_mismatch:
490 peer_id_on_sub = peer_id_on_sub - 1
Etan Cohenbc80da12017-06-06 09:26:02 -0700491
Jaineel7e67a3f2019-08-28 15:58:49 -0700492 # Publisher: request network
493 p_req_key = self.request_network(
494 p_dut,
495 p_dut.droid.wifiAwareCreateNetworkSpecifier(
496 p_disc_id, peer_id_on_pub, None))
Etan Cohenbc80da12017-06-06 09:26:02 -0700497
Jaineel7e67a3f2019-08-28 15:58:49 -0700498 # Subscriber: request network
499 s_req_key = self.request_network(
500 s_dut,
501 s_dut.droid.wifiAwareCreateNetworkSpecifier(
502 s_disc_id, peer_id_on_sub, None))
Etan Cohenbc80da12017-06-06 09:26:02 -0700503
Jaineel7e67a3f2019-08-28 15:58:49 -0700504 # Publisher & Subscriber:
505 # - expect unavailable callbacks on the party with the bad ID
506 # - also expect unavailable on the Initiator party (i.e. the
507 # Subscriber) if the Publisher has a bad ID
508 # - but a Publisher with a valid ID will keep waiting ...
509 autils.wait_for_event_with_keys(
510 s_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
511 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
512 if pub_mismatch:
513 autils.wait_for_event_with_keys(
514 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
515 autils.EVENT_NDP_TIMEOUT,
516 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
517 else:
518 time.sleep(autils.EVENT_NDP_TIMEOUT)
519 autils.fail_on_event_with_keys(
520 p_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
521 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
Etan Cohenbc80da12017-06-06 09:26:02 -0700522
Jaineel7e67a3f2019-08-28 15:58:49 -0700523 # clean-up
524 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
525 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
Etan Cohenbc80da12017-06-06 09:26:02 -0700526
Jaineel7e67a3f2019-08-28 15:58:49 -0700527 def run_mismatched_oob_data_path_test(self,
528 init_mismatch_mac=False,
529 resp_mismatch_mac=False,
530 init_encr_type=ENCR_TYPE_OPEN,
531 resp_encr_type=ENCR_TYPE_OPEN):
532 """Runs the negative out-of-band data-path tests: mismatched information
Etan Cohen85adc452017-06-06 08:32:08 -0700533 between Responder and Initiator.
534
535 Args:
536 init_mismatch_mac: True to mismatch the Initiator MAC address
537 resp_mismatch_mac: True to mismatch the Responder MAC address
538 init_encr_type: Encryption type of Initiator - ENCR_TYPE_*
539 resp_encr_type: Encryption type of Responder - ENCR_TYPE_*
540 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700541 init_dut = self.android_devices[0]
542 init_dut.pretty_name = "Initiator"
543 resp_dut = self.android_devices[1]
544 resp_dut.pretty_name = "Responder"
Etan Cohen85adc452017-06-06 08:32:08 -0700545
Jaineel7e67a3f2019-08-28 15:58:49 -0700546 # Initiator+Responder: attach and wait for confirmation & identity
547 init_id = init_dut.droid.wifiAwareAttach(True)
548 autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
549 init_ident_event = autils.wait_for_event(
550 init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
551 init_mac = init_ident_event["data"]["mac"]
552 time.sleep(self.device_startup_offset)
553 resp_id = resp_dut.droid.wifiAwareAttach(True)
554 autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
555 resp_ident_event = autils.wait_for_event(
556 resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
557 resp_mac = resp_ident_event["data"]["mac"]
Etan Cohen85adc452017-06-06 08:32:08 -0700558
Jaineel7e67a3f2019-08-28 15:58:49 -0700559 if init_mismatch_mac: # assumes legit ones don't start with "00"
560 init_mac = "00" + init_mac[2:]
561 if resp_mismatch_mac:
562 resp_mac = "00" + resp_mac[2:]
Etan Cohen85adc452017-06-06 08:32:08 -0700563
Jaineel7e67a3f2019-08-28 15:58:49 -0700564 # wait for for devices to synchronize with each other - there are no other
565 # mechanisms to make sure this happens for OOB discovery (except retrying
566 # to execute the data-path request)
567 time.sleep(self.WAIT_FOR_CLUSTER)
Etan Cohen85adc452017-06-06 08:32:08 -0700568
Jaineel7e67a3f2019-08-28 15:58:49 -0700569 # set up separate keys: even if types are the same we want a mismatch
570 init_passphrase = None
571 init_pmk = None
572 if init_encr_type == self.ENCR_TYPE_PASSPHRASE:
573 init_passphrase = self.PASSPHRASE
574 elif init_encr_type == self.ENCR_TYPE_PMK:
575 init_pmk = self.PMK
Etan Cohen85adc452017-06-06 08:32:08 -0700576
Jaineel7e67a3f2019-08-28 15:58:49 -0700577 resp_passphrase = None
578 resp_pmk = None
579 if resp_encr_type == self.ENCR_TYPE_PASSPHRASE:
580 resp_passphrase = self.PASSPHRASE2
581 elif resp_encr_type == self.ENCR_TYPE_PMK:
582 resp_pmk = self.PMK2
Etan Cohen85adc452017-06-06 08:32:08 -0700583
Jaineel7e67a3f2019-08-28 15:58:49 -0700584 # Responder: request network
585 resp_req_key = self.request_network(
586 resp_dut,
587 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
588 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac,
589 resp_passphrase, resp_pmk))
Etan Cohen85adc452017-06-06 08:32:08 -0700590
Jaineel7e67a3f2019-08-28 15:58:49 -0700591 # Initiator: request network
592 init_req_key = self.request_network(
593 init_dut,
594 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
595 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac,
596 init_passphrase, init_pmk))
Etan Cohen85adc452017-06-06 08:32:08 -0700597
Jaineel7e67a3f2019-08-28 15:58:49 -0700598 # Initiator & Responder:
599 # - expect unavailable on the Initiator party if the
Nate Jiang40f5d7b2020-05-19 17:04:18 -0700600 # Initiator and Responder with mac or encryption mismatch
601 # - For responder:
602 # - If mac mismatch, responder will keep waiting ...
603 # - If encryption mismatch, responder expect unavailable
Jaineel7e67a3f2019-08-28 15:58:49 -0700604 autils.wait_for_event_with_keys(
605 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
606 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
607 time.sleep(autils.EVENT_NDP_TIMEOUT)
Nate Jiang40f5d7b2020-05-19 17:04:18 -0700608 if init_mismatch_mac or resp_mismatch_mac:
609 autils.fail_on_event_with_keys(
610 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
611 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
612 else:
613 autils.wait_for_event_with_keys(
614 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
615 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
Etan Cohen85adc452017-06-06 08:32:08 -0700616
Jaineel7e67a3f2019-08-28 15:58:49 -0700617 # clean-up
618 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
619 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohen85adc452017-06-06 08:32:08 -0700620
Jaineel7e67a3f2019-08-28 15:58:49 -0700621 def verify_network_info(self, p_data, s_data, open, port,
622 transport_protocol):
623 """Verify that the port and transport protocol information is correct.
624 - should only exist on subscriber (received from publisher)
625 and match transmitted values
626 - should only exist on an encrypted NDP
Etan Cohenba8a53f2017-06-05 12:55:02 -0700627
Jaineel7e67a3f2019-08-28 15:58:49 -0700628 Args:
629 p_data, s_data: Pub and Sub (respectively) net cap event data.
630 open: True if NDP unencrypted, False if encrypted.
631 port: Expected port value.
632 transport_protocol: Expected transport protocol value.
633 """
634 asserts.assert_true(aconsts.NET_CAP_PORT not in p_data,
635 "port info not expected on Pub")
636 asserts.assert_true(aconsts.NET_CAP_TRANSPORT_PROTOCOL not in p_data,
637 "transport protocol info not expected on Pub")
638 if open:
639 asserts.assert_true(aconsts.NET_CAP_PORT not in s_data,
640 "port info not expected on Sub (open NDP)")
641 asserts.assert_true(
642 aconsts.NET_CAP_TRANSPORT_PROTOCOL not in s_data,
643 "transport protocol info not expected on Sub (open NDP)")
644 else:
645 asserts.assert_equal(s_data[aconsts.NET_CAP_PORT], port,
646 "Port info does not match on Sub (from Pub)")
647 asserts.assert_equal(
648 s_data[aconsts.NET_CAP_TRANSPORT_PROTOCOL], transport_protocol,
649 "Transport protocol info does not match on Sub (from Pub)")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700650
Jaineel7e67a3f2019-08-28 15:58:49 -0700651 #######################################
652 # Positive In-Band (IB) tests key:
653 #
654 # names is: test_ib_<pub_type>_<sub_type>_<encr_type>_<peer_spec>
655 # where:
656 #
657 # pub_type: Type of publish discovery session: unsolicited or solicited.
658 # sub_type: Type of subscribe discovery session: passive or active.
659 # encr_type: Encription type: open, passphrase
660 # peer_spec: Peer specification method: any or specific
661 #
662 # Note: In-Band means using Wi-Fi Aware for discovery and referring to the
663 # peer using the Aware-provided peer handle (as opposed to a MAC address).
664 #######################################
665
666 @test_tracker_info(uuid="fa30bedc-d1de-4440-bf25-ec00d10555af")
Girish Moturuaac2f212020-05-15 21:20:46 -0700667 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700668 def test_ib_unsolicited_passive_open_specific(self):
669 """Data-path: in-band, unsolicited/passive, open encryption, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700670
671 Verifies end-to-end discovery + data-path creation.
672 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700673 self.run_ib_data_path_test(
674 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
675 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
676 encr_type=self.ENCR_TYPE_OPEN,
677 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700678
Jaineel7e67a3f2019-08-28 15:58:49 -0700679 @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d")
Girish Moturuaac2f212020-05-15 21:20:46 -0700680 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700681 def test_ib_unsolicited_passive_open_any(self):
682 """Data-path: in-band, unsolicited/passive, open encryption, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700683
684 Verifies end-to-end discovery + data-path creation.
685 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700686 self.run_ib_data_path_test(
687 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
688 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
689 encr_type=self.ENCR_TYPE_OPEN,
690 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700691
Jaineel7e67a3f2019-08-28 15:58:49 -0700692 @test_tracker_info(uuid="93b2a23d-8579-448a-936c-7812929464cf")
Girish Moturuaac2f212020-05-15 21:20:46 -0700693 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700694 def test_ib_unsolicited_passive_passphrase_specific(self):
695 """Data-path: in-band, unsolicited/passive, passphrase, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700696
697 Verifies end-to-end discovery + data-path creation.
698 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700699 self.run_ib_data_path_test(
700 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
701 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
702 encr_type=self.ENCR_TYPE_PASSPHRASE,
703 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700704
Jaineel7e67a3f2019-08-28 15:58:49 -0700705 @test_tracker_info(uuid="1736126f-a0ff-4712-acc4-f89b4eef5716")
Girish Moturuaac2f212020-05-15 21:20:46 -0700706 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700707 def test_ib_unsolicited_passive_passphrase_any(self):
708 """Data-path: in-band, unsolicited/passive, passphrase, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700709
710 Verifies end-to-end discovery + data-path creation.
711 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700712 self.run_ib_data_path_test(
713 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
714 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
715 encr_type=self.ENCR_TYPE_PASSPHRASE,
716 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700717
Jaineel7e67a3f2019-08-28 15:58:49 -0700718 @test_tracker_info(uuid="b9353d5b-3f77-46bf-bfd9-65d56a7c939a")
Girish Moturuaac2f212020-05-15 21:20:46 -0700719 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700720 def test_ib_unsolicited_passive_pmk_specific(self):
721 """Data-path: in-band, unsolicited/passive, PMK, specific peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700722
723 Verifies end-to-end discovery + data-path creation.
724 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700725 self.run_ib_data_path_test(
726 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
727 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
728 encr_type=self.ENCR_TYPE_PMK,
729 use_peer_id=True)
Etan Cohen058aaba2017-06-05 17:01:54 -0700730
Jaineel7e67a3f2019-08-28 15:58:49 -0700731 @test_tracker_info(uuid="06f3b2ab-4a10-4398-83a4-6a23851b1662")
Girish Moturuaac2f212020-05-15 21:20:46 -0700732 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700733 def test_ib_unsolicited_passive_pmk_any(self):
734 """Data-path: in-band, unsolicited/passive, PMK, any peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700735
736 Verifies end-to-end discovery + data-path creation.
737 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700738 self.run_ib_data_path_test(
739 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
740 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
741 encr_type=self.ENCR_TYPE_PMK,
742 use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700743
Jaineel7e67a3f2019-08-28 15:58:49 -0700744 @test_tracker_info(uuid="0ed7d8b3-a69e-46ba-aeb7-13e507ecf290")
Girish Moturuaac2f212020-05-15 21:20:46 -0700745 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700746 def test_ib_solicited_active_open_specific(self):
747 """Data-path: in-band, solicited/active, open encryption, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700748
Etan Cohenba8a53f2017-06-05 12:55:02 -0700749 Verifies end-to-end discovery + data-path creation.
750 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700751 self.run_ib_data_path_test(
752 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
753 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
754 encr_type=self.ENCR_TYPE_OPEN,
755 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700756
Jaineel7e67a3f2019-08-28 15:58:49 -0700757 @test_tracker_info(uuid="c7ba6d28-5ef6-45d9-95d5-583ad6d981f3")
Girish Moturuaac2f212020-05-15 21:20:46 -0700758 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700759 def test_ib_solicited_active_open_any(self):
760 """Data-path: in-band, solicited/active, open encryption, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700761
Etan Cohenba8a53f2017-06-05 12:55:02 -0700762 Verifies end-to-end discovery + data-path creation.
763 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700764 self.run_ib_data_path_test(
765 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
766 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
767 encr_type=self.ENCR_TYPE_OPEN,
768 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700769
Jaineel7e67a3f2019-08-28 15:58:49 -0700770 @test_tracker_info(uuid="388cea99-0e2e-49ea-b00e-f3e56b6236e5")
Girish Moturuaac2f212020-05-15 21:20:46 -0700771 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700772 def test_ib_solicited_active_passphrase_specific(self):
773 """Data-path: in-band, solicited/active, passphrase, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700774
Etan Cohenba8a53f2017-06-05 12:55:02 -0700775 Verifies end-to-end discovery + data-path creation.
776 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700777 self.run_ib_data_path_test(
778 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
779 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
780 encr_type=self.ENCR_TYPE_PASSPHRASE,
781 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700782
Jaineel7e67a3f2019-08-28 15:58:49 -0700783 @test_tracker_info(uuid="fcd3e28a-5eab-4169-8a0c-dc7204dcdc13")
Girish Moturuaac2f212020-05-15 21:20:46 -0700784 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700785 def test_ib_solicited_active_passphrase_any(self):
786 """Data-path: in-band, solicited/active, passphrase, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700787
Etan Cohenba8a53f2017-06-05 12:55:02 -0700788 Verifies end-to-end discovery + data-path creation.
789 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700790 self.run_ib_data_path_test(
791 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
792 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
793 encr_type=self.ENCR_TYPE_PASSPHRASE,
794 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700795
Jaineel7e67a3f2019-08-28 15:58:49 -0700796 @test_tracker_info(uuid="9d4eaad7-ba53-4a06-8ce0-e308daea3309")
Girish Moturuaac2f212020-05-15 21:20:46 -0700797 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700798 def test_ib_solicited_active_pmk_specific(self):
799 """Data-path: in-band, solicited/active, PMK, specific peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700800
801 Verifies end-to-end discovery + data-path creation.
802 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700803 self.run_ib_data_path_test(
804 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
805 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
806 encr_type=self.ENCR_TYPE_PMK,
807 use_peer_id=True)
Etan Cohen058aaba2017-06-05 17:01:54 -0700808
Jaineel7e67a3f2019-08-28 15:58:49 -0700809 @test_tracker_info(uuid="129d850e-c312-4137-a67b-05ae95fe66cc")
Girish Moturuaac2f212020-05-15 21:20:46 -0700810 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700811 def test_ib_solicited_active_pmk_any(self):
812 """Data-path: in-band, solicited/active, PMK, any peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700813
814 Verifies end-to-end discovery + data-path creation.
815 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700816 self.run_ib_data_path_test(
817 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
818 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
819 encr_type=self.ENCR_TYPE_PMK,
820 use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700821
Jaineel7e67a3f2019-08-28 15:58:49 -0700822 #######################################
823 # Positive In-Band (IB) with a publish session running on the subscriber
824 # tests key:
825 #
826 # names is: test_ib_extra_pub_<same|diff>_<pub_type>_<sub_type>
827 # _<encr_type>_<peer_spec>
828 # where:
829 #
830 # same|diff: Whether the extra publish session (on the subscriber) is the same
831 # or different from the primary session.
832 # pub_type: Type of publish discovery session: unsolicited or solicited.
833 # sub_type: Type of subscribe discovery session: passive or active.
834 # encr_type: Encryption type: open, passphrase
835 # peer_spec: Peer specification method: any or specific
836 #
837 # Note: In-Band means using Wi-Fi Aware for discovery and referring to the
838 # peer using the Aware-provided peer handle (as opposed to a MAC address).
839 #######################################
Etan Cohen204df172017-11-09 12:05:36 -0800840
Jaineel7e67a3f2019-08-28 15:58:49 -0700841 @test_tracker_info(uuid="e855dd81-45c8-4bb2-a204-7687c48ff843")
Girish Moturuaac2f212020-05-15 21:20:46 -0700842 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700843 def test_ib_extra_pub_same_unsolicited_passive_open_specific(self):
844 """Data-path: in-band, unsolicited/passive, open encryption, specific peer.
Etan Cohen204df172017-11-09 12:05:36 -0800845
846 Configuration contains a publisher (for the same service) running on *both*
847 devices.
848
849 Verifies end-to-end discovery + data-path creation.
850 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700851 self.run_ib_data_path_test(
852 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
853 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
854 encr_type=self.ENCR_TYPE_OPEN,
855 use_peer_id=True,
856 pub_on_both=True,
857 pub_on_both_same=True)
Etan Cohen204df172017-11-09 12:05:36 -0800858
Girish Moturuc0f87bc2020-05-23 21:20:05 -0700859 @test_tracker_info(uuid="228ea657-82e6-44bc-8369-a2c719a5e252")
Girish Moturuaac2f212020-05-15 21:20:46 -0700860 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700861 def test_ib_extra_pub_same_unsolicited_passive_open_any(self):
862 """Data-path: in-band, unsolicited/passive, open encryption, any peer.
Etan Cohen204df172017-11-09 12:05:36 -0800863
864 Configuration contains a publisher (for the same service) running on *both*
865 devices.
866
867 Verifies end-to-end discovery + data-path creation.
868 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700869 self.run_ib_data_path_test(
870 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
871 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
872 encr_type=self.ENCR_TYPE_OPEN,
873 use_peer_id=False,
874 pub_on_both=True,
875 pub_on_both_same=True)
Etan Cohen204df172017-11-09 12:05:36 -0800876
Jaineel7e67a3f2019-08-28 15:58:49 -0700877 @test_tracker_info(uuid="7a32f439-d745-4716-a75e-b54109aaaf82")
Girish Moturuaac2f212020-05-15 21:20:46 -0700878 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700879 def test_ib_extra_pub_diff_unsolicited_passive_open_specific(self):
880 """Data-path: in-band, unsolicited/passive, open encryption, specific peer.
Etan Cohen204df172017-11-09 12:05:36 -0800881
882 Configuration contains a publisher (for a different service) running on
883 *both* devices.
884
885 Verifies end-to-end discovery + data-path creation.
886 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700887 self.run_ib_data_path_test(
888 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
889 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
890 encr_type=self.ENCR_TYPE_OPEN,
891 use_peer_id=True,
892 pub_on_both=True,
893 pub_on_both_same=False)
Etan Cohen204df172017-11-09 12:05:36 -0800894
Jaineel7e67a3f2019-08-28 15:58:49 -0700895 @test_tracker_info(uuid="a14ddc66-88fd-4b49-ab37-225533867c63")
Girish Moturuaac2f212020-05-15 21:20:46 -0700896 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700897 def test_ib_extra_pub_diff_unsolicited_passive_open_any(self):
898 """Data-path: in-band, unsolicited/passive, open encryption, any peer.
Etan Cohen204df172017-11-09 12:05:36 -0800899
900 Configuration contains a publisher (for a different service) running on
901 *both* devices.
902
903 Verifies end-to-end discovery + data-path creation.
904 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700905 self.run_ib_data_path_test(
906 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
907 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
908 encr_type=self.ENCR_TYPE_OPEN,
909 use_peer_id=False,
910 pub_on_both=True,
911 pub_on_both_same=False)
Etan Cohen204df172017-11-09 12:05:36 -0800912
Jaineel7e67a3f2019-08-28 15:58:49 -0700913 #######################################
914 # Positive Out-of-Band (OOB) tests key:
915 #
916 # names is: test_oob_<encr_type>_<peer_spec>
917 # where:
918 #
919 # encr_type: Encryption type: open, passphrase
920 # peer_spec: Peer specification method: any or specific
921 #
922 # Optionally set up an extra discovery session to test coexistence. If so
923 # add "ib_coex" to test name.
924 #
925 # Note: Out-of-Band means using a non-Wi-Fi Aware mechanism for discovery and
926 # exchange of MAC addresses and then Wi-Fi Aware for data-path.
927 #######################################
Etan Cohenba8a53f2017-06-05 12:55:02 -0700928
Jaineel7e67a3f2019-08-28 15:58:49 -0700929 @test_tracker_info(uuid="7db17d8c-1dce-4084-b695-215bbcfe7d41")
Girish Moturuaac2f212020-05-15 21:20:46 -0700930 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700931 def test_oob_open_specific(self):
932 """Data-path: out-of-band, open encryption, specific peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700933
934 Verifies end-to-end discovery + data-path creation.
935 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700936 self.run_oob_data_path_test(
937 encr_type=self.ENCR_TYPE_OPEN, use_peer_id=True)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700938
Jaineel7e67a3f2019-08-28 15:58:49 -0700939 @test_tracker_info(uuid="ad416d89-cb95-4a07-8d29-ee213117450b")
Girish Moturuaac2f212020-05-15 21:20:46 -0700940 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700941 def test_oob_open_any(self):
942 """Data-path: out-of-band, open encryption, any peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700943
944 Verifies end-to-end discovery + data-path creation.
945 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700946 self.run_oob_data_path_test(
947 encr_type=self.ENCR_TYPE_OPEN, use_peer_id=False)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700948
Jaineel7e67a3f2019-08-28 15:58:49 -0700949 @test_tracker_info(uuid="74937a3a-d524-43e2-8979-4449271cab52")
Girish Moturuaac2f212020-05-15 21:20:46 -0700950 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700951 def test_oob_passphrase_specific(self):
952 """Data-path: out-of-band, passphrase, specific peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700953
954 Verifies end-to-end discovery + data-path creation.
955 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700956 self.run_oob_data_path_test(
957 encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=True)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700958
Jaineel7e67a3f2019-08-28 15:58:49 -0700959 @test_tracker_info(uuid="afcbdc7e-d3a9-465b-b1da-ce2e42e3941e")
Girish Moturuaac2f212020-05-15 21:20:46 -0700960 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700961 def test_oob_passphrase_any(self):
962 """Data-path: out-of-band, passphrase, any peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700963
964 Verifies end-to-end discovery + data-path creation.
965 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700966 self.run_oob_data_path_test(
967 encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700968
Jaineel7e67a3f2019-08-28 15:58:49 -0700969 @test_tracker_info(uuid="0d095031-160a-4537-aab5-41b6ad5d55f8")
Girish Moturuaac2f212020-05-15 21:20:46 -0700970 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700971 def test_oob_pmk_specific(self):
972 """Data-path: out-of-band, PMK, specific peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700973
974 Verifies end-to-end discovery + data-path creation.
975 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700976 self.run_oob_data_path_test(
977 encr_type=self.ENCR_TYPE_PMK, use_peer_id=True)
Etan Cohen058aaba2017-06-05 17:01:54 -0700978
Jaineel7e67a3f2019-08-28 15:58:49 -0700979 @test_tracker_info(uuid="e45477bd-66cc-4eb7-88dd-4518c8aa2a74")
Girish Moturuaac2f212020-05-15 21:20:46 -0700980 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700981 def test_oob_pmk_any(self):
982 """Data-path: out-of-band, PMK, any peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700983
984 Verifies end-to-end discovery + data-path creation.
985 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700986 self.run_oob_data_path_test(
987 encr_type=self.ENCR_TYPE_PMK, use_peer_id=False)
Etan Cohen6ace4582017-06-05 17:21:55 -0700988
Jaineel7e67a3f2019-08-28 15:58:49 -0700989 @test_tracker_info(uuid="dd464f24-b404-4eea-955c-d10c9e8adefc")
Girish Moturuaac2f212020-05-15 21:20:46 -0700990 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -0700991 def test_oob_ib_coex_open_specific(self):
992 """Data-path: out-of-band, open encryption, specific peer - in-band coex:
Etan Cohen35653522017-11-09 13:47:20 -0800993 set up a concurrent discovery session to verify no impact. The session
994 consists of Publisher on both ends, and a Subscriber on the Responder.
995
996 Verifies end-to-end discovery + data-path creation.
997 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700998 self.run_oob_data_path_test(
999 encr_type=self.ENCR_TYPE_OPEN,
1000 use_peer_id=True,
1001 setup_discovery_sessions=True)
Etan Cohen35653522017-11-09 13:47:20 -08001002
Jaineel7e67a3f2019-08-28 15:58:49 -07001003 @test_tracker_info(uuid="088fcd3a-b015-4179-a9a5-91f782b03e3b")
Girish Moturuaac2f212020-05-15 21:20:46 -07001004 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001005 def test_oob_ib_coex_open_any(self):
1006 """Data-path: out-of-band, open encryption, any peer - in-band coex:
Etan Cohen35653522017-11-09 13:47:20 -08001007 set up a concurrent discovery session to verify no impact. The session
1008 consists of Publisher on both ends, and a Subscriber on the Responder.
1009
1010 Verifies end-to-end discovery + data-path creation.
1011 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001012 self.run_oob_data_path_test(
1013 encr_type=self.ENCR_TYPE_OPEN,
1014 use_peer_id=False,
1015 setup_discovery_sessions=True)
Etan Cohen35653522017-11-09 13:47:20 -08001016
Jaineel7e67a3f2019-08-28 15:58:49 -07001017 ##############################################################
Etan Cohen6ace4582017-06-05 17:21:55 -07001018
Jaineel7e67a3f2019-08-28 15:58:49 -07001019 @test_tracker_info(uuid="1c2c9805-dc1e-43b5-a1b8-315e8c9a4337")
Girish Moturuaac2f212020-05-15 21:20:46 -07001020 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001021 def test_passphrase_min(self):
1022 """Data-path: minimum passphrase length
Etan Cohen6ace4582017-06-05 17:21:55 -07001023
1024 Use in-band, unsolicited/passive, any peer combination
1025 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001026 self.run_ib_data_path_test(
1027 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1028 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1029 encr_type=self.ENCR_TYPE_PASSPHRASE,
1030 use_peer_id=False,
1031 passphrase_to_use=self.PASSPHRASE_MIN)
Etan Cohen6ace4582017-06-05 17:21:55 -07001032
Jaineel7e67a3f2019-08-28 15:58:49 -07001033 @test_tracker_info(uuid="e696e2b9-87a9-4521-b337-61b9efaa2057")
Girish Moturuaac2f212020-05-15 21:20:46 -07001034 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001035 def test_passphrase_max(self):
1036 """Data-path: maximum passphrase length
Etan Cohen6ace4582017-06-05 17:21:55 -07001037
1038 Use in-band, unsolicited/passive, any peer combination
1039 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001040 self.run_ib_data_path_test(
1041 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1042 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1043 encr_type=self.ENCR_TYPE_PASSPHRASE,
1044 use_peer_id=False,
1045 passphrase_to_use=self.PASSPHRASE_MAX)
Etan Cohen85adc452017-06-06 08:32:08 -07001046
Jaineel7e67a3f2019-08-28 15:58:49 -07001047 @test_tracker_info(uuid="533cd44c-ff30-4283-ac28-f71fd7b4f02d")
Girish Moturuaac2f212020-05-15 21:20:46 -07001048 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001049 def test_negative_mismatch_publisher_peer_id(self):
1050 """Data-path: failure when publisher peer ID is mismatched"""
1051 self.run_mismatched_ib_data_path_test(
1052 pub_mismatch=True, sub_mismatch=False)
Etan Cohenbc80da12017-06-06 09:26:02 -07001053
Jaineel7e67a3f2019-08-28 15:58:49 -07001054 @test_tracker_info(uuid="682f275e-722a-4f8b-85e7-0dcea9d25532")
Girish Moturuaac2f212020-05-15 21:20:46 -07001055 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001056 def test_negative_mismatch_subscriber_peer_id(self):
1057 """Data-path: failure when subscriber peer ID is mismatched"""
1058 self.run_mismatched_ib_data_path_test(
1059 pub_mismatch=False, sub_mismatch=True)
Etan Cohenbc80da12017-06-06 09:26:02 -07001060
Jaineel7e67a3f2019-08-28 15:58:49 -07001061 @test_tracker_info(uuid="7fa82796-7fc9-4d9e-bbbb-84b751788943")
Girish Moturuaac2f212020-05-15 21:20:46 -07001062 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001063 def test_negative_mismatch_init_mac(self):
1064 """Data-path: failure when Initiator MAC address mismatch"""
1065 self.run_mismatched_oob_data_path_test(
1066 init_mismatch_mac=True, resp_mismatch_mac=False)
Etan Cohen85adc452017-06-06 08:32:08 -07001067
Jaineel7e67a3f2019-08-28 15:58:49 -07001068 @test_tracker_info(uuid="edeae959-4644-44f9-8d41-bdeb5216954e")
Girish Moturuaac2f212020-05-15 21:20:46 -07001069 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001070 def test_negative_mismatch_resp_mac(self):
1071 """Data-path: failure when Responder MAC address mismatch"""
1072 self.run_mismatched_oob_data_path_test(
1073 init_mismatch_mac=False, resp_mismatch_mac=True)
Etan Cohen85adc452017-06-06 08:32:08 -07001074
Jaineel7e67a3f2019-08-28 15:58:49 -07001075 @test_tracker_info(uuid="91f46949-c47f-49f9-a90f-6fae699613a7")
Girish Moturuaac2f212020-05-15 21:20:46 -07001076 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001077 def test_negative_mismatch_passphrase(self):
1078 """Data-path: failure when passphrases mismatch"""
1079 self.run_mismatched_oob_data_path_test(
1080 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
1081 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
Etan Cohen85adc452017-06-06 08:32:08 -07001082
Jaineel7e67a3f2019-08-28 15:58:49 -07001083 @test_tracker_info(uuid="01c49c2e-dc92-4a27-bb47-c4fc67617c23")
Girish Moturuaac2f212020-05-15 21:20:46 -07001084 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001085 def test_negative_mismatch_pmk(self):
1086 """Data-path: failure when PMK mismatch"""
1087 self.run_mismatched_oob_data_path_test(
1088 init_encr_type=self.ENCR_TYPE_PMK,
1089 resp_encr_type=self.ENCR_TYPE_PMK)
Etan Cohen85adc452017-06-06 08:32:08 -07001090
Jaineel7e67a3f2019-08-28 15:58:49 -07001091 @test_tracker_info(uuid="4d651797-5fbb-408e-a4b6-a6e1944136da")
Girish Moturuaac2f212020-05-15 21:20:46 -07001092 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001093 def test_negative_mismatch_open_passphrase(self):
1094 """Data-path: failure when initiator is open, and responder passphrase"""
1095 self.run_mismatched_oob_data_path_test(
1096 init_encr_type=self.ENCR_TYPE_OPEN,
1097 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
Etan Cohen85adc452017-06-06 08:32:08 -07001098
Jaineel7e67a3f2019-08-28 15:58:49 -07001099 @test_tracker_info(uuid="1ae697f4-5987-4187-aeef-1e22d07d4a7c")
Girish Moturuaac2f212020-05-15 21:20:46 -07001100 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001101 def test_negative_mismatch_open_pmk(self):
1102 """Data-path: failure when initiator is open, and responder PMK"""
1103 self.run_mismatched_oob_data_path_test(
1104 init_encr_type=self.ENCR_TYPE_OPEN,
1105 resp_encr_type=self.ENCR_TYPE_PMK)
Etan Cohen85adc452017-06-06 08:32:08 -07001106
Jaineel7e67a3f2019-08-28 15:58:49 -07001107 @test_tracker_info(uuid="f027b1cc-0e7a-4075-b880-5e64b288afbd")
Girish Moturuaac2f212020-05-15 21:20:46 -07001108 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001109 def test_negative_mismatch_pmk_passphrase(self):
1110 """Data-path: failure when initiator is pmk, and responder passphrase"""
1111 self.run_mismatched_oob_data_path_test(
1112 init_encr_type=self.ENCR_TYPE_PMK,
1113 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
Etan Cohen85adc452017-06-06 08:32:08 -07001114
Jaineel7e67a3f2019-08-28 15:58:49 -07001115 @test_tracker_info(uuid="0819bbd4-72ae-49c4-bd46-5448db2b0a06")
Girish Moturuaac2f212020-05-15 21:20:46 -07001116 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001117 def test_negative_mismatch_passphrase_open(self):
1118 """Data-path: failure when initiator is passphrase, and responder open"""
1119 self.run_mismatched_oob_data_path_test(
1120 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
1121 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen85adc452017-06-06 08:32:08 -07001122
Jaineel7e67a3f2019-08-28 15:58:49 -07001123 @test_tracker_info(uuid="7ef24f62-8e6b-4732-88a3-80a43584dda4")
Girish Moturuaac2f212020-05-15 21:20:46 -07001124 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001125 def test_negative_mismatch_pmk_open(self):
1126 """Data-path: failure when initiator is PMK, and responder open"""
1127 self.run_mismatched_oob_data_path_test(
1128 init_encr_type=self.ENCR_TYPE_PMK,
1129 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen85adc452017-06-06 08:32:08 -07001130
Jaineel7e67a3f2019-08-28 15:58:49 -07001131 @test_tracker_info(uuid="7b9c9efc-1c06-465e-8a5e-d6a22ac1da97")
Girish Moturuaac2f212020-05-15 21:20:46 -07001132 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001133 def test_negative_mismatch_passphrase_pmk(self):
1134 """Data-path: failure when initiator is passphrase, and responder pmk"""
1135 self.run_mismatched_oob_data_path_test(
1136 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
1137 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001138
Jaineel7e67a3f2019-08-28 15:58:49 -07001139 ##########################################################################
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001140
Jaineel7e67a3f2019-08-28 15:58:49 -07001141 def wait_for_request_responses(self, dut, req_keys, aware_ifs, aware_ipv6):
1142 """Wait for network request confirmation for all request keys.
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001143
1144 Args:
1145 dut: Device under test
1146 req_keys: (in) A list of the network requests
1147 aware_ifs: (out) A list into which to append the network interface
Jaineel7e67a3f2019-08-28 15:58:49 -07001148 aware_ipv6: (out) A list into which to append the network ipv6 address
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001149 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001150 num_events = 0 # looking for 2 events per NDP: link-prop + net-cap
1151 while num_events != 2 * len(req_keys):
1152 event = autils.wait_for_event(
1153 dut,
1154 cconsts.EVENT_NETWORK_CALLBACK,
1155 timeout=autils.EVENT_NDP_TIMEOUT)
1156 if (event["data"][cconsts.NETWORK_CB_KEY_EVENT] ==
1157 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED):
1158 if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys:
1159 num_events = num_events + 1
1160 aware_ifs.append(
1161 event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME])
1162 else:
1163 self.log.info(
1164 "Received an unexpected connectivity, the revoked "
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001165 "network request probably went through -- %s", event)
Jaineel7e67a3f2019-08-28 15:58:49 -07001166 elif (event["data"][cconsts.NETWORK_CB_KEY_EVENT] ==
1167 cconsts.NETWORK_CB_CAPABILITIES_CHANGED):
1168 if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys:
1169 num_events = num_events + 1
1170 aware_ipv6.append(event["data"][aconsts.NET_CAP_IPV6])
1171 else:
1172 self.log.info(
1173 "Received an unexpected connectivity, the revoked "
1174 "network request probably went through -- %s", event)
1175 # validate no leak of information
1176 asserts.assert_false(
1177 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in event["data"],
1178 "Network specifier leak!")
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001179
Jaineel7e67a3f2019-08-28 15:58:49 -07001180 @test_tracker_info(uuid="2e325e2b-d552-4890-b470-20b40284395d")
Girish Moturuaac2f212020-05-15 21:20:46 -07001181 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001182 def test_multiple_identical_networks(self):
1183 """Validate that creating multiple networks between 2 devices, each network
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001184 with identical configuration is supported over a single NDP.
1185
1186 Verify that the interface and IPv6 address is the same for all networks.
1187 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001188 init_dut = self.android_devices[0]
1189 init_dut.pretty_name = "Initiator"
1190 resp_dut = self.android_devices[1]
1191 resp_dut.pretty_name = "Responder"
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001192
Jaineel7e67a3f2019-08-28 15:58:49 -07001193 N = 2 # first iteration (must be 2 to give us a chance to cancel the first)
1194 M = 5 # second iteration
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001195
Jaineel7e67a3f2019-08-28 15:58:49 -07001196 init_ids = []
1197 resp_ids = []
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001198
Jaineel7e67a3f2019-08-28 15:58:49 -07001199 # Initiator+Responder: attach and wait for confirmation & identity
1200 # create N+M sessions to be used in the different (but identical) NDPs
1201 for i in range(N + M):
1202 id, init_mac = autils.attach_with_identity(init_dut)
1203 init_ids.append(id)
1204 id, resp_mac = autils.attach_with_identity(resp_dut)
1205 resp_ids.append(id)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001206
Jaineel7e67a3f2019-08-28 15:58:49 -07001207 # wait for for devices to synchronize with each other - there are no other
1208 # mechanisms to make sure this happens for OOB discovery (except retrying
1209 # to execute the data-path request)
1210 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001211
Jaineel7e67a3f2019-08-28 15:58:49 -07001212 resp_req_keys = []
1213 init_req_keys = []
1214 resp_aware_ifs = []
1215 init_aware_ifs = []
1216 resp_aware_ipv6 = []
1217 init_aware_ipv6 = []
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001218
Jaineel7e67a3f2019-08-28 15:58:49 -07001219 # issue N quick requests for identical NDPs - without waiting for result
1220 # tests whether pre-setup multiple NDP procedure
1221 for i in range(N):
1222 # Responder: request network
1223 resp_req_keys.append(
1224 autils.request_network(
1225 resp_dut,
1226 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1227 resp_ids[i], aconsts.DATA_PATH_RESPONDER, init_mac,
1228 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001229
Jaineel7e67a3f2019-08-28 15:58:49 -07001230 # Initiator: request network
1231 init_req_keys.append(
1232 autils.request_network(
1233 init_dut,
1234 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1235 init_ids[i], aconsts.DATA_PATH_INITIATOR, resp_mac,
1236 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001237
Jaineel7e67a3f2019-08-28 15:58:49 -07001238 # remove the first request (hopefully before completed) testing that NDP
1239 # is still created
1240 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_keys[0])
1241 resp_req_keys.remove(resp_req_keys[0])
1242 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_keys[0])
1243 init_req_keys.remove(init_req_keys[0])
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001244
Jaineel7e67a3f2019-08-28 15:58:49 -07001245 # wait for network formation for all initial requests
1246 # note: for IPv6 Init <--> Resp since each reports the other's IPv6 address
1247 # in it's transport-specific network info
1248 self.wait_for_request_responses(resp_dut, resp_req_keys,
1249 resp_aware_ifs, init_aware_ipv6)
1250 self.wait_for_request_responses(init_dut, init_req_keys,
1251 init_aware_ifs, resp_aware_ipv6)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001252
Jaineel7e67a3f2019-08-28 15:58:49 -07001253 # issue M more requests for the same NDPs - tests post-setup multiple NDP
1254 for i in range(M):
1255 # Responder: request network
1256 resp_req_keys.append(
1257 autils.request_network(
1258 resp_dut,
1259 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1260 resp_ids[N + i], aconsts.DATA_PATH_RESPONDER, init_mac,
1261 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001262
Jaineel7e67a3f2019-08-28 15:58:49 -07001263 # Initiator: request network
1264 init_req_keys.append(
1265 autils.request_network(
1266 init_dut,
1267 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1268 init_ids[N + i], aconsts.DATA_PATH_INITIATOR, resp_mac,
1269 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001270
Jaineel7e67a3f2019-08-28 15:58:49 -07001271 # wait for network formation for all subsequent requests
1272 self.wait_for_request_responses(resp_dut, resp_req_keys[N - 1:],
1273 resp_aware_ifs, init_aware_ipv6)
1274 self.wait_for_request_responses(init_dut, init_req_keys[N - 1:],
1275 init_aware_ifs, resp_aware_ipv6)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001276
Jaineel7e67a3f2019-08-28 15:58:49 -07001277 # determine whether all interfaces and ipv6 addresses are identical
1278 # (single NDP)
1279 init_aware_ifs = list(set(init_aware_ifs))
1280 resp_aware_ifs = list(set(resp_aware_ifs))
1281 init_aware_ipv6 = list(set(init_aware_ipv6))
1282 resp_aware_ipv6 = list(set(resp_aware_ipv6))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001283
Jaineel7e67a3f2019-08-28 15:58:49 -07001284 self.log.info("Interface names: I=%s, R=%s", init_aware_ifs,
1285 resp_aware_ifs)
1286 self.log.info("Interface IPv6: I=%s, R=%s", init_aware_ipv6,
1287 resp_aware_ipv6)
1288 self.log.info("Initiator requests: %s", init_req_keys)
1289 self.log.info("Responder requests: %s", resp_req_keys)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001290
Jaineel7e67a3f2019-08-28 15:58:49 -07001291 asserts.assert_equal(
1292 len(init_aware_ifs), 1, "Multiple initiator interfaces")
1293 asserts.assert_equal(
1294 len(resp_aware_ifs), 1, "Multiple responder interfaces")
1295 asserts.assert_equal(
1296 len(init_aware_ipv6), 1, "Multiple initiator IPv6 addresses")
1297 asserts.assert_equal(
1298 len(resp_aware_ipv6), 1, "Multiple responder IPv6 addresses")
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001299
Jaineel7e67a3f2019-08-28 15:58:49 -07001300 for i in range(
1301 init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]):
1302 # note: using get_ipv6_addr (ifconfig method) since want to verify
1303 # that interfaces which do not have any NDPs on them do not have
1304 # an IPv6 link-local address.
1305 if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
1306 init_ipv6 = autils.get_ipv6_addr(init_dut, if_name)
1307 resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001308
Jaineel7e67a3f2019-08-28 15:58:49 -07001309 asserts.assert_equal(
1310 init_ipv6 is None, if_name not in init_aware_ifs,
1311 "Initiator interface %s in unexpected state" % if_name)
1312 asserts.assert_equal(
1313 resp_ipv6 is None, if_name not in resp_aware_ifs,
1314 "Responder interface %s in unexpected state" % if_name)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001315
Jaineel7e67a3f2019-08-28 15:58:49 -07001316 # release requests
1317 for resp_req_key in resp_req_keys:
1318 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
1319 for init_req_key in init_req_keys:
1320 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001321
Girish Moturuc0f87bc2020-05-23 21:20:05 -07001322 @test_tracker_info(uuid="34cf12e8-5df6-49bd-b384-e9935d89a5b7")
Girish Moturuaac2f212020-05-15 21:20:46 -07001323 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001324 def test_identical_network_from_both_sides(self):
1325 """Validate that requesting two identical NDPs (Open) each being initiated
Etan Cohenef38a7f2017-11-09 14:26:43 -08001326 from a different side, results in the same/single NDP.
1327
1328 Verify that the interface and IPv6 address is the same for all networks.
1329 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001330 dut1 = self.android_devices[0]
1331 dut2 = self.android_devices[1]
Etan Cohenef38a7f2017-11-09 14:26:43 -08001332
Jaineel7e67a3f2019-08-28 15:58:49 -07001333 id1, mac1 = autils.attach_with_identity(dut1)
1334 id2, mac2 = autils.attach_with_identity(dut2)
Etan Cohenef38a7f2017-11-09 14:26:43 -08001335
Jaineel7e67a3f2019-08-28 15:58:49 -07001336 # wait for for devices to synchronize with each other - there are no other
1337 # mechanisms to make sure this happens for OOB discovery (except retrying
1338 # to execute the data-path request)
1339 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohenef38a7f2017-11-09 14:26:43 -08001340
Jaineel7e67a3f2019-08-28 15:58:49 -07001341 # first NDP: DUT1 (Init) -> DUT2 (Resp)
1342 req_a_resp = autils.request_network(
1343 dut2,
1344 dut2.droid.wifiAwareCreateNetworkSpecifierOob(
1345 id2, aconsts.DATA_PATH_RESPONDER, mac1))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001346
Jaineel7e67a3f2019-08-28 15:58:49 -07001347 req_a_init = autils.request_network(
1348 dut1,
1349 dut1.droid.wifiAwareCreateNetworkSpecifierOob(
1350 id1, aconsts.DATA_PATH_INITIATOR, mac2))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001351
Jaineel7e67a3f2019-08-28 15:58:49 -07001352 req_a_resp_event_nc = autils.wait_for_event_with_keys(
1353 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1354 (cconsts.NETWORK_CB_KEY_EVENT,
1355 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1356 (cconsts.NETWORK_CB_KEY_ID, req_a_resp))
1357 req_a_init_event_nc = autils.wait_for_event_with_keys(
1358 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1359 (cconsts.NETWORK_CB_KEY_EVENT,
1360 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1361 (cconsts.NETWORK_CB_KEY_ID, req_a_init))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001362
Jaineel7e67a3f2019-08-28 15:58:49 -07001363 # validate no leak of information
1364 asserts.assert_false(
1365 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_a_resp_event_nc[
1366 "data"], "Network specifier leak!")
1367 asserts.assert_false(
1368 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_a_init_event_nc[
1369 "data"], "Network specifier leak!")
Etan Cohenef38a7f2017-11-09 14:26:43 -08001370
Jaineel7e67a3f2019-08-28 15:58:49 -07001371 # note that Init <-> Resp since IPv6 are of peer's!
1372 req_a_ipv6_init = req_a_resp_event_nc["data"][aconsts.NET_CAP_IPV6]
1373 req_a_ipv6_resp = req_a_init_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohenef38a7f2017-11-09 14:26:43 -08001374
Jaineel7e67a3f2019-08-28 15:58:49 -07001375 req_a_resp_event_lp = autils.wait_for_event_with_keys(
1376 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1377 (cconsts.NETWORK_CB_KEY_EVENT,
1378 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1379 (cconsts.NETWORK_CB_KEY_ID, req_a_resp))
1380 req_a_init_event_lp = autils.wait_for_event_with_keys(
1381 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1382 (cconsts.NETWORK_CB_KEY_EVENT,
1383 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1384 (cconsts.NETWORK_CB_KEY_ID, req_a_init))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001385
Jaineel7e67a3f2019-08-28 15:58:49 -07001386 req_a_if_resp = req_a_resp_event_lp["data"][
1387 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1388 req_a_if_init = req_a_init_event_lp["data"][
1389 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohenef38a7f2017-11-09 14:26:43 -08001390
Jaineel7e67a3f2019-08-28 15:58:49 -07001391 self.log.info("Interface names for A: I=%s, R=%s", req_a_if_init,
1392 req_a_if_resp)
1393 self.log.info("Interface addresses (IPv6) for A: I=%s, R=%s",
1394 req_a_ipv6_init, req_a_ipv6_resp)
Etan Cohenef38a7f2017-11-09 14:26:43 -08001395
Jaineel7e67a3f2019-08-28 15:58:49 -07001396 # second NDP: DUT2 (Init) -> DUT1 (Resp)
1397 req_b_resp = autils.request_network(
1398 dut1,
1399 dut1.droid.wifiAwareCreateNetworkSpecifierOob(
1400 id1, aconsts.DATA_PATH_RESPONDER, mac2))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001401
Jaineel7e67a3f2019-08-28 15:58:49 -07001402 req_b_init = autils.request_network(
1403 dut2,
1404 dut2.droid.wifiAwareCreateNetworkSpecifierOob(
1405 id2, aconsts.DATA_PATH_INITIATOR, mac1))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001406
Jaineel7e67a3f2019-08-28 15:58:49 -07001407 req_b_resp_event_nc = autils.wait_for_event_with_keys(
1408 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1409 (cconsts.NETWORK_CB_KEY_EVENT,
1410 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1411 (cconsts.NETWORK_CB_KEY_ID, req_b_resp))
1412 req_b_init_event_nc = autils.wait_for_event_with_keys(
1413 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1414 (cconsts.NETWORK_CB_KEY_EVENT,
1415 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1416 (cconsts.NETWORK_CB_KEY_ID, req_b_init))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001417
Jaineel7e67a3f2019-08-28 15:58:49 -07001418 # validate no leak of information
1419 asserts.assert_false(
1420 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_b_resp_event_nc[
1421 "data"], "Network specifier leak!")
1422 asserts.assert_false(
1423 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_b_init_event_nc[
1424 "data"], "Network specifier leak!")
Etan Cohenef38a7f2017-11-09 14:26:43 -08001425
Jaineel7e67a3f2019-08-28 15:58:49 -07001426 # note that Init <-> Resp since IPv6 are of peer's!
1427 req_b_ipv6_init = req_b_resp_event_nc["data"][aconsts.NET_CAP_IPV6]
1428 req_b_ipv6_resp = req_b_init_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohena1e8d502017-08-16 09:28:18 -07001429
Jaineel7e67a3f2019-08-28 15:58:49 -07001430 req_b_resp_event_lp = autils.wait_for_event_with_keys(
1431 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1432 (cconsts.NETWORK_CB_KEY_EVENT,
1433 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1434 (cconsts.NETWORK_CB_KEY_ID, req_b_resp))
1435 req_b_init_event_lp = autils.wait_for_event_with_keys(
1436 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1437 (cconsts.NETWORK_CB_KEY_EVENT,
1438 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1439 (cconsts.NETWORK_CB_KEY_ID, req_b_init))
1440
1441 req_b_if_resp = req_b_resp_event_lp["data"][
1442 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1443 req_b_if_init = req_b_init_event_lp["data"][
1444 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1445
1446 self.log.info("Interface names for B: I=%s, R=%s", req_b_if_init,
1447 req_b_if_resp)
1448 self.log.info("Interface addresses (IPv6) for B: I=%s, R=%s",
1449 req_b_ipv6_init, req_b_ipv6_resp)
1450
1451 # validate equality of NDPs (using interface names & ipv6)
1452 asserts.assert_equal(req_a_if_init, req_b_if_resp,
1453 "DUT1 NDPs are on different interfaces")
1454 asserts.assert_equal(req_a_if_resp, req_b_if_init,
1455 "DUT2 NDPs are on different interfaces")
1456 asserts.assert_equal(req_a_ipv6_init, req_b_ipv6_resp,
1457 "DUT1 NDPs are using different IPv6 addresses")
1458 asserts.assert_equal(req_a_ipv6_resp, req_b_ipv6_init,
1459 "DUT2 NDPs are using different IPv6 addresses")
1460
1461 # release requests
1462 dut1.droid.connectivityUnregisterNetworkCallback(req_a_init)
1463 dut1.droid.connectivityUnregisterNetworkCallback(req_b_resp)
1464 dut2.droid.connectivityUnregisterNetworkCallback(req_a_resp)
1465 dut2.droid.connectivityUnregisterNetworkCallback(req_b_init)
1466
1467 ########################################################################
1468
1469 def run_multiple_ndi(self, sec_configs, flip_init_resp=False):
1470 """Validate that the device can create and use multiple NDIs.
Etan Cohena1e8d502017-08-16 09:28:18 -07001471
1472 The security configuration can be:
1473 - None: open
1474 - String: passphrase
1475 - otherwise: PMK (byte array)
1476
1477 Args:
1478 sec_configs: list of security configurations
Etan Cohend6923f22017-11-09 15:37:16 -08001479 flip_init_resp: if True the roles of Initiator and Responder are flipped
1480 between the 2 devices, otherwise same devices are always
1481 configured in the same role.
Etan Cohena1e8d502017-08-16 09:28:18 -07001482 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001483 dut1 = self.android_devices[0]
1484 dut2 = self.android_devices[1]
Etan Cohena1e8d502017-08-16 09:28:18 -07001485
Jaineel7e67a3f2019-08-28 15:58:49 -07001486 asserts.skip_if(
1487 dut1.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] <
1488 len(sec_configs)
1489 or dut2.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] <
1490 len(sec_configs), "DUTs do not support enough NDIs")
Etan Cohena1e8d502017-08-16 09:28:18 -07001491
Jaineel7e67a3f2019-08-28 15:58:49 -07001492 id1, mac1 = autils.attach_with_identity(dut1)
1493 id2, mac2 = autils.attach_with_identity(dut2)
Etan Cohena1e8d502017-08-16 09:28:18 -07001494
Jaineel7e67a3f2019-08-28 15:58:49 -07001495 # wait for for devices to synchronize with each other - there are no other
1496 # mechanisms to make sure this happens for OOB discovery (except retrying
1497 # to execute the data-path request)
1498 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohena1e8d502017-08-16 09:28:18 -07001499
Jaineel7e67a3f2019-08-28 15:58:49 -07001500 dut2_req_keys = []
1501 dut1_req_keys = []
1502 dut2_aware_ifs = []
1503 dut1_aware_ifs = []
1504 dut2_aware_ipv6s = []
1505 dut1_aware_ipv6s = []
Etan Cohena1e8d502017-08-16 09:28:18 -07001506
Jaineel7e67a3f2019-08-28 15:58:49 -07001507 dut2_type = aconsts.DATA_PATH_RESPONDER
1508 dut1_type = aconsts.DATA_PATH_INITIATOR
1509 dut2_is_responder = True
1510 for sec in sec_configs:
1511 if dut2_is_responder:
1512 # DUT2 (Responder): request network
1513 dut2_req_key = autils.request_network(
1514 dut2,
1515 autils.get_network_specifier(dut2, id2, dut2_type, mac1,
1516 sec))
1517 dut2_req_keys.append(dut2_req_key)
Etan Cohena1e8d502017-08-16 09:28:18 -07001518
Jaineel7e67a3f2019-08-28 15:58:49 -07001519 # DUT1 (Initiator): request network
1520 dut1_req_key = autils.request_network(
1521 dut1,
1522 autils.get_network_specifier(dut1, id1, dut1_type, mac2,
1523 sec))
1524 dut1_req_keys.append(dut1_req_key)
1525 else:
1526 # DUT1 (Responder): request network
1527 dut1_req_key = autils.request_network(
1528 dut1,
1529 autils.get_network_specifier(dut1, id1, dut1_type, mac2,
1530 sec))
1531 dut1_req_keys.append(dut1_req_key)
Etan Cohend6923f22017-11-09 15:37:16 -08001532
Jaineel7e67a3f2019-08-28 15:58:49 -07001533 # DUT2 (Initiator): request network
1534 dut2_req_key = autils.request_network(
1535 dut2,
1536 autils.get_network_specifier(dut2, id2, dut2_type, mac1,
1537 sec))
1538 dut2_req_keys.append(dut2_req_key)
Etan Cohena1e8d502017-08-16 09:28:18 -07001539
Jaineel7e67a3f2019-08-28 15:58:49 -07001540 # Wait for network
1541 dut1_net_event_nc = autils.wait_for_event_with_keys(
1542 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1543 (cconsts.NETWORK_CB_KEY_EVENT,
1544 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1545 (cconsts.NETWORK_CB_KEY_ID, dut1_req_key))
1546 dut2_net_event_nc = autils.wait_for_event_with_keys(
1547 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1548 (cconsts.NETWORK_CB_KEY_EVENT,
1549 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1550 (cconsts.NETWORK_CB_KEY_ID, dut2_req_key))
Etan Cohena1e8d502017-08-16 09:28:18 -07001551
Jaineel7e67a3f2019-08-28 15:58:49 -07001552 # validate no leak of information
1553 asserts.assert_false(
1554 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in dut1_net_event_nc[
1555 "data"], "Network specifier leak!")
1556 asserts.assert_false(
1557 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in dut2_net_event_nc[
1558 "data"], "Network specifier leak!")
Etan Cohena1e8d502017-08-16 09:28:18 -07001559
Jaineel7e67a3f2019-08-28 15:58:49 -07001560 # Note: dut1 <--> dut2 IPv6's addresses since it is peer's info
1561 dut2_aware_ipv6 = dut1_net_event_nc["data"][aconsts.NET_CAP_IPV6]
1562 dut1_aware_ipv6 = dut2_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohend6923f22017-11-09 15:37:16 -08001563
Jaineel7e67a3f2019-08-28 15:58:49 -07001564 dut1_net_event_lp = autils.wait_for_event_with_keys(
1565 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1566 (cconsts.NETWORK_CB_KEY_EVENT,
1567 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1568 (cconsts.NETWORK_CB_KEY_ID, dut1_req_key))
1569 dut2_net_event_lp = autils.wait_for_event_with_keys(
1570 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1571 (cconsts.NETWORK_CB_KEY_EVENT,
1572 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1573 (cconsts.NETWORK_CB_KEY_ID, dut2_req_key))
Etan Cohena1e8d502017-08-16 09:28:18 -07001574
Jaineel7e67a3f2019-08-28 15:58:49 -07001575 dut2_aware_if = dut2_net_event_lp["data"][
1576 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1577 dut1_aware_if = dut1_net_event_lp["data"][
1578 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohena1e8d502017-08-16 09:28:18 -07001579
Jaineel7e67a3f2019-08-28 15:58:49 -07001580 dut2_aware_ifs.append(dut2_aware_if)
1581 dut1_aware_ifs.append(dut1_aware_if)
1582 dut2_aware_ipv6s.append(dut2_aware_ipv6)
1583 dut1_aware_ipv6s.append(dut1_aware_ipv6)
Etan Cohena1e8d502017-08-16 09:28:18 -07001584
Jaineel7e67a3f2019-08-28 15:58:49 -07001585 if flip_init_resp:
1586 if dut2_is_responder:
1587 dut2_type = aconsts.DATA_PATH_INITIATOR
1588 dut1_type = aconsts.DATA_PATH_RESPONDER
1589 else:
1590 dut2_type = aconsts.DATA_PATH_RESPONDER
1591 dut1_type = aconsts.DATA_PATH_INITIATOR
1592 dut2_is_responder = not dut2_is_responder
Etan Cohena1e8d502017-08-16 09:28:18 -07001593
Jaineel7e67a3f2019-08-28 15:58:49 -07001594 # check that we are using 2 NDIs & that they have unique IPv6 addresses
1595 dut1_aware_ifs = list(set(dut1_aware_ifs))
1596 dut2_aware_ifs = list(set(dut2_aware_ifs))
1597 dut1_aware_ipv6s = list(set(dut1_aware_ipv6s))
1598 dut2_aware_ipv6s = list(set(dut2_aware_ipv6s))
Etan Cohena1e8d502017-08-16 09:28:18 -07001599
Jaineel7e67a3f2019-08-28 15:58:49 -07001600 self.log.info("Interface names: DUT1=%s, DUT2=%s", dut1_aware_ifs,
1601 dut2_aware_ifs)
1602 self.log.info("IPv6 addresses: DUT1=%s, DUT2=%s", dut1_aware_ipv6s,
1603 dut2_aware_ipv6s)
1604 self.log.info("DUT1 requests: %s", dut1_req_keys)
1605 self.log.info("DUT2 requests: %s", dut2_req_keys)
Etan Cohena1e8d502017-08-16 09:28:18 -07001606
Jaineel7e67a3f2019-08-28 15:58:49 -07001607 asserts.assert_equal(
1608 len(dut1_aware_ifs), len(sec_configs), "Multiple DUT1 interfaces")
1609 asserts.assert_equal(
1610 len(dut2_aware_ifs), len(sec_configs), "Multiple DUT2 interfaces")
1611 asserts.assert_equal(
1612 len(dut1_aware_ipv6s), len(sec_configs),
1613 "Multiple DUT1 IPv6 addresses")
1614 asserts.assert_equal(
1615 len(dut2_aware_ipv6s), len(sec_configs),
1616 "Multiple DUT2 IPv6 addresses")
1617
1618 for i in range(len(sec_configs)):
1619 # note: using get_ipv6_addr (ifconfig method) since want to verify
1620 # that the system information is the same as the reported information
1621 if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
1622 dut1_ipv6 = autils.get_ipv6_addr(dut1, if_name)
1623 dut2_ipv6 = autils.get_ipv6_addr(dut2, if_name)
1624
1625 asserts.assert_equal(
1626 dut1_ipv6 is None, if_name not in dut1_aware_ifs,
1627 "DUT1 interface %s in unexpected state" % if_name)
1628 asserts.assert_equal(
1629 dut2_ipv6 is None, if_name not in dut2_aware_ifs,
1630 "DUT2 interface %s in unexpected state" % if_name)
1631
1632 # release requests
1633 for dut2_req_key in dut2_req_keys:
1634 dut2.droid.connectivityUnregisterNetworkCallback(dut2_req_key)
1635 for dut1_req_key in dut1_req_keys:
1636 dut1.droid.connectivityUnregisterNetworkCallback(dut1_req_key)
1637
1638 @test_tracker_info(uuid="2d728163-11cc-46ba-a973-c8e1e71397fc")
Girish Moturuaac2f212020-05-15 21:20:46 -07001639 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001640 def test_multiple_ndi_open_passphrase(self):
1641 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001642 configuration (one open, one using passphrase). The result should use two
1643 different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001644 self.run_multiple_ndi([None, self.PASSPHRASE])
Etan Cohena1e8d502017-08-16 09:28:18 -07001645
Jaineel7e67a3f2019-08-28 15:58:49 -07001646 @test_tracker_info(uuid="5f2c32aa-20b2-41f0-8b1e-d0b68df73ada")
Girish Moturuaac2f212020-05-15 21:20:46 -07001647 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001648 def test_multiple_ndi_open_pmk(self):
1649 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001650 configuration (one open, one using pmk). The result should use two
1651 different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001652 self.run_multiple_ndi([None, self.PMK])
Etan Cohena1e8d502017-08-16 09:28:18 -07001653
Jaineel7e67a3f2019-08-28 15:58:49 -07001654 @test_tracker_info(uuid="34467659-bcfb-40cd-ba25-7e50560fca63")
Girish Moturuaac2f212020-05-15 21:20:46 -07001655 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001656 def test_multiple_ndi_passphrase_pmk(self):
1657 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001658 configuration (one using passphrase, one using pmk). The result should use
1659 two different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001660 self.run_multiple_ndi([self.PASSPHRASE, self.PMK])
Etan Cohena1e8d502017-08-16 09:28:18 -07001661
Jaineel7e67a3f2019-08-28 15:58:49 -07001662 @test_tracker_info(uuid="d9194ce6-45b6-41b1-9cc8-ada79968966d")
Girish Moturuaac2f212020-05-15 21:20:46 -07001663 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001664 def test_multiple_ndi_passphrases(self):
1665 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001666 configuration (using different passphrases). The result should use two
1667 different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001668 self.run_multiple_ndi([self.PASSPHRASE, self.PASSPHRASE2])
Etan Cohena1e8d502017-08-16 09:28:18 -07001669
Jaineel7e67a3f2019-08-28 15:58:49 -07001670 @test_tracker_info(uuid="879df795-62d2-40d4-a862-bd46d8f7e67f")
Girish Moturuaac2f212020-05-15 21:20:46 -07001671 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001672 def test_multiple_ndi_pmks(self):
1673 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001674 configuration (using different PMKS). The result should use two different
1675 NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001676 self.run_multiple_ndi([self.PMK, self.PMK2])
Etan Cohend6923f22017-11-09 15:37:16 -08001677
Jaineel7e67a3f2019-08-28 15:58:49 -07001678 @test_tracker_info(uuid="397d380a-8e41-466e-9ccb-cf8f413d83ba")
Girish Moturuaac2f212020-05-15 21:20:46 -07001679 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001680 def test_multiple_ndi_open_passphrase_flip(self):
1681 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001682 configuration (one open, one using passphrase). The result should use two
1683 different NDIs.
1684
1685 Flip Initiator and Responder roles.
1686 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001687 self.run_multiple_ndi([None, self.PASSPHRASE], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001688
Jaineel7e67a3f2019-08-28 15:58:49 -07001689 @test_tracker_info(uuid="b3a4300b-1514-4cb8-a814-9c2baa449700")
Girish Moturuaac2f212020-05-15 21:20:46 -07001690 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001691 def test_multiple_ndi_open_pmk_flip(self):
1692 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001693 configuration (one open, one using pmk). The result should use two
1694 different NDIs
1695
1696 Flip Initiator and Responder roles.
1697 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001698 self.run_multiple_ndi([None, self.PMK], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001699
Jaineel7e67a3f2019-08-28 15:58:49 -07001700 @test_tracker_info(uuid="0bfea9e4-e57d-417f-8db4-245741e9bbd5")
Girish Moturuaac2f212020-05-15 21:20:46 -07001701 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001702 def test_multiple_ndi_passphrase_pmk_flip(self):
1703 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001704 configuration (one using passphrase, one using pmk). The result should use
1705 two different NDIs
1706
1707 Flip Initiator and Responder roles.
1708 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001709 self.run_multiple_ndi([self.PASSPHRASE, self.PMK], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001710
Jaineel7e67a3f2019-08-28 15:58:49 -07001711 @test_tracker_info(uuid="74023483-5417-431b-a362-991ad4a03ab8")
Girish Moturuaac2f212020-05-15 21:20:46 -07001712 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001713 def test_multiple_ndi_passphrases_flip(self):
1714 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001715 configuration (using different passphrases). The result should use two
1716 different NDIs
1717
1718 Flip Initiator and Responder roles.
1719 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001720 self.run_multiple_ndi(
1721 [self.PASSPHRASE, self.PASSPHRASE2], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001722
Jaineel7e67a3f2019-08-28 15:58:49 -07001723 @test_tracker_info(uuid="873b2d91-28a1-403f-ae9c-d756bb2f59ee")
Girish Moturuaac2f212020-05-15 21:20:46 -07001724 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001725 def test_multiple_ndi_pmks_flip(self):
1726 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001727 configuration (using different PMKS). The result should use two different
1728 NDIs
1729
1730 Flip Initiator and Responder roles.
1731 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001732 self.run_multiple_ndi([self.PMK, self.PMK2], flip_init_resp=True)
Etan Cohen7922a312018-01-23 13:34:55 -08001733
Jaineel7e67a3f2019-08-28 15:58:49 -07001734 #######################################
Etan Cohen7922a312018-01-23 13:34:55 -08001735
Jaineel7e67a3f2019-08-28 15:58:49 -07001736 @test_tracker_info(uuid="2f10a9df-7fbd-490d-a238-3523f47ab54c")
Girish Moturuaac2f212020-05-15 21:20:46 -07001737 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001738 def test_ib_responder_any_usage(self):
1739 """Verify that configuring an in-band (Aware discovery) Responder to receive
Etan Cohen7922a312018-01-23 13:34:55 -08001740 an NDP request from any peer is not permitted by current API level. Override
1741 API check to validate that possible (i.e. that failure at current API level
1742 is due to an API check and not some underlying failure).
1743 """
1744
Jaineel7e67a3f2019-08-28 15:58:49 -07001745 # configure all devices to override API check and allow a Responder from ANY
1746 for ad in self.android_devices:
1747 autils.configure_ndp_allow_any_override(ad, True)
1748 self.run_ib_data_path_test(
1749 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1750 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1751 encr_type=self.ENCR_TYPE_OPEN,
1752 use_peer_id=False)
Etan Cohen7922a312018-01-23 13:34:55 -08001753
Jaineel7e67a3f2019-08-28 15:58:49 -07001754 # configure all devices to respect API check - i.e. disallow a Responder
1755 # from ANY
1756 for ad in self.android_devices:
1757 autils.configure_ndp_allow_any_override(ad, False)
1758 self.run_ib_data_path_test(
1759 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1760 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1761 encr_type=self.ENCR_TYPE_OPEN,
1762 use_peer_id=False,
1763 expect_failure=True)
Etan Cohen7922a312018-01-23 13:34:55 -08001764
Jaineel7e67a3f2019-08-28 15:58:49 -07001765 @test_tracker_info(uuid="5889cd41-0a72-4b7b-ab82-5b9168b9b5b8")
Girish Moturuaac2f212020-05-15 21:20:46 -07001766 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001767 def test_oob_responder_any_usage(self):
1768 """Verify that configuring an out-of-band (Aware discovery) Responder to
Etan Cohen7922a312018-01-23 13:34:55 -08001769 receive an NDP request from any peer is not permitted by current API level.
1770 Override API check to validate that possible (i.e. that failure at current
1771 API level is due to an API check and not some underlying failure).
1772 """
1773
Jaineel7e67a3f2019-08-28 15:58:49 -07001774 # configure all devices to override API check and allow a Responder from ANY
1775 for ad in self.android_devices:
1776 autils.configure_ndp_allow_any_override(ad, True)
1777 self.run_oob_data_path_test(
1778 encr_type=self.ENCR_TYPE_OPEN, use_peer_id=False)
Etan Cohen7922a312018-01-23 13:34:55 -08001779
Jaineel7e67a3f2019-08-28 15:58:49 -07001780 # configure all devices to respect API check - i.e. disallow a Responder
1781 # from ANY
1782 for ad in self.android_devices:
1783 autils.configure_ndp_allow_any_override(ad, False)
1784 self.run_oob_data_path_test(
1785 encr_type=self.ENCR_TYPE_OPEN,
1786 use_peer_id=False,
1787 expect_failure=True)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001788
Jaineel7e67a3f2019-08-28 15:58:49 -07001789 #######################################
Etan Cohenc803dcc2018-02-02 15:14:04 -08001790
Jaineel7e67a3f2019-08-28 15:58:49 -07001791 def run_multiple_regulatory_domains(self, use_ib, init_domain,
1792 resp_domain):
1793 """Verify that a data-path setup with two conflicting regulatory domains
Etan Cohenc803dcc2018-02-02 15:14:04 -08001794 works (the result should be run in Channel 6 - but that is not tested).
1795
1796 Args:
1797 use_ib: True to use in-band discovery, False to use out-of-band discovery.
1798 init_domain: The regulatory domain of the Initiator/Subscriber.
1799 resp_domain: The regulator domain of the Responder/Publisher.
1800 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001801 init_dut = self.android_devices[0]
1802 resp_dut = self.android_devices[1]
Etan Cohenc803dcc2018-02-02 15:14:04 -08001803
Roshan Pius48df08c2019-09-13 08:07:30 -07001804 wutils.set_wifi_country_code(init_dut, init_domain)
1805 wutils.set_wifi_country_code(resp_dut, resp_domain)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001806
Jaineel7e67a3f2019-08-28 15:58:49 -07001807 if use_ib:
1808 (resp_req_key, init_req_key, resp_aware_if, init_aware_if,
1809 resp_ipv6, init_ipv6) = autils.create_ib_ndp(
1810 resp_dut, init_dut,
1811 autils.create_discovery_config(
1812 "GoogleTestXyz", aconsts.PUBLISH_TYPE_UNSOLICITED),
1813 autils.create_discovery_config(
1814 "GoogleTestXyz", aconsts.SUBSCRIBE_TYPE_PASSIVE),
1815 self.device_startup_offset)
1816 else:
1817 (init_req_key, resp_req_key, init_aware_if, resp_aware_if,
1818 init_ipv6, resp_ipv6) = autils.create_oob_ndp(init_dut, resp_dut)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001819
Jaineel7e67a3f2019-08-28 15:58:49 -07001820 self.log.info("Interface names: I=%s, R=%s", init_aware_if,
1821 resp_aware_if)
1822 self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
1823 resp_ipv6)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001824
Jaineel7e67a3f2019-08-28 15:58:49 -07001825 # clean-up
1826 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
1827 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001828
Jaineel7e67a3f2019-08-28 15:58:49 -07001829 @test_tracker_info(uuid="eff53739-35c5-47a6-81f0-d70b51d89c3b")
Girish Moturuaac2f212020-05-15 21:20:46 -07001830 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001831 def test_multiple_regulator_domains_ib_us_jp(self):
1832 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001833
1834 - Uses in-band discovery
1835 - Subscriber=US, Publisher=JP
1836 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001837 self.run_multiple_regulatory_domains(
1838 use_ib=True,
1839 init_domain=wutils.WifiEnums.CountryCode.US,
1840 resp_domain=wutils.WifiEnums.CountryCode.JAPAN)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001841
Jaineel7e67a3f2019-08-28 15:58:49 -07001842 @test_tracker_info(uuid="19af47cc-3204-40ef-b50f-14cf7b89cf4a")
Girish Moturuaac2f212020-05-15 21:20:46 -07001843 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001844 def test_multiple_regulator_domains_ib_jp_us(self):
1845 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001846
1847 - Uses in-band discovery
1848 - Subscriber=JP, Publisher=US
1849 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001850 self.run_multiple_regulatory_domains(
1851 use_ib=True,
1852 init_domain=wutils.WifiEnums.CountryCode.JAPAN,
1853 resp_domain=wutils.WifiEnums.CountryCode.US)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001854
Jaineel7e67a3f2019-08-28 15:58:49 -07001855 @test_tracker_info(uuid="65285ab3-977f-4dbd-b663-d5a02f4fc663")
Girish Moturuaac2f212020-05-15 21:20:46 -07001856 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001857 def test_multiple_regulator_domains_oob_us_jp(self):
1858 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001859
1860 - Uses out-f-band discovery
1861 - Initiator=US, Responder=JP
1862 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001863 self.run_multiple_regulatory_domains(
1864 use_ib=False,
1865 init_domain=wutils.WifiEnums.CountryCode.US,
1866 resp_domain=wutils.WifiEnums.CountryCode.JAPAN)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001867
Jaineel7e67a3f2019-08-28 15:58:49 -07001868 @test_tracker_info(uuid="8a417e24-aaf6-44b9-a089-a07c3ba8d954")
Girish Moturuaac2f212020-05-15 21:20:46 -07001869 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07001870 def test_multiple_regulator_domains_oob_jp_us(self):
1871 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001872
1873 - Uses out-of-band discovery
1874 - Initiator=JP, Responder=US
1875 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001876 self.run_multiple_regulatory_domains(
1877 use_ib=False,
1878 init_domain=wutils.WifiEnums.CountryCode.JAPAN,
1879 resp_domain=wutils.WifiEnums.CountryCode.US)
Etan Cohen0ead4552017-12-27 16:17:50 -08001880
Jaineel7e67a3f2019-08-28 15:58:49 -07001881 ########################################################################
Etan Cohen0ead4552017-12-27 16:17:50 -08001882
Jaineel7e67a3f2019-08-28 15:58:49 -07001883 def run_mix_ib_oob(self, same_request, ib_first, inits_on_same_dut):
1884 """Validate that multiple network requests issued using both in-band and
Etan Cohen0ead4552017-12-27 16:17:50 -08001885 out-of-band discovery behave as expected.
1886
1887 The same_request parameter controls whether identical single NDP is
1888 expected, if True, or whether multiple NDPs on different NDIs are expected,
1889 if False.
1890
1891 Args:
1892 same_request: Issue canonically identical requests (same NMI peer, same
1893 passphrase) if True, if False use different passphrases.
1894 ib_first: If True then the in-band network is requested first, otherwise
1895 (if False) then the out-of-band network is requested first.
1896 inits_on_same_dut: If True then the Initiators are run on the same device,
1897 otherwise (if False) then the Initiators are run on
1898 different devices. Note that Subscribe == Initiator.
1899 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001900 if not same_request:
1901 asserts.skip_if(
1902 self.android_devices[0]
1903 .aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < 2
1904 or self.android_devices[1]
1905 .aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < 2,
1906 "DUTs do not support enough NDIs")
Etan Cohen0ead4552017-12-27 16:17:50 -08001907
Jaineel7e67a3f2019-08-28 15:58:49 -07001908 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
1909 peer_id_on_pub_null) = self.set_up_discovery(
1910 aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE,
1911 False)
Etan Cohen0ead4552017-12-27 16:17:50 -08001912
Jaineel7e67a3f2019-08-28 15:58:49 -07001913 p_id2, p_mac = autils.attach_with_identity(p_dut)
1914 s_id2, s_mac = autils.attach_with_identity(s_dut)
Etan Cohen0ead4552017-12-27 16:17:50 -08001915
Jaineel7e67a3f2019-08-28 15:58:49 -07001916 if inits_on_same_dut:
1917 resp_dut = p_dut
1918 resp_id = p_id2
1919 resp_mac = p_mac
Etan Cohen0ead4552017-12-27 16:17:50 -08001920
Jaineel7e67a3f2019-08-28 15:58:49 -07001921 init_dut = s_dut
1922 init_id = s_id2
1923 init_mac = s_mac
1924 else:
1925 resp_dut = s_dut
1926 resp_id = s_id2
1927 resp_mac = s_mac
Etan Cohen0ead4552017-12-27 16:17:50 -08001928
Jaineel7e67a3f2019-08-28 15:58:49 -07001929 init_dut = p_dut
1930 init_id = p_id2
1931 init_mac = p_mac
Etan Cohen0ead4552017-12-27 16:17:50 -08001932
Jaineel7e67a3f2019-08-28 15:58:49 -07001933 passphrase = None if same_request else self.PASSPHRASE
Etan Cohen0ead4552017-12-27 16:17:50 -08001934
Jaineel7e67a3f2019-08-28 15:58:49 -07001935 if ib_first:
1936 # request in-band network (to completion)
1937 p_req_key = self.request_network(
1938 p_dut,
1939 p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, None))
1940 s_req_key = self.request_network(
1941 s_dut,
1942 s_dut.droid.wifiAwareCreateNetworkSpecifier(
1943 s_disc_id, peer_id_on_sub))
Etan Cohen0ead4552017-12-27 16:17:50 -08001944
Jaineel7e67a3f2019-08-28 15:58:49 -07001945 # Publisher & Subscriber: wait for network formation
1946 p_net_event_nc = autils.wait_for_event_with_keys(
1947 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1948 autils.EVENT_NDP_TIMEOUT,
1949 (cconsts.NETWORK_CB_KEY_EVENT,
1950 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1951 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1952 s_net_event_nc = autils.wait_for_event_with_keys(
1953 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1954 autils.EVENT_NDP_TIMEOUT,
1955 (cconsts.NETWORK_CB_KEY_EVENT,
1956 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1957 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
1958 p_net_event_lp = autils.wait_for_event_with_keys(
1959 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1960 autils.EVENT_NDP_TIMEOUT,
1961 (cconsts.NETWORK_CB_KEY_EVENT,
1962 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1963 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1964 s_net_event_lp = autils.wait_for_event_with_keys(
1965 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1966 autils.EVENT_NDP_TIMEOUT,
1967 (cconsts.NETWORK_CB_KEY_EVENT,
1968 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1969 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohen0ead4552017-12-27 16:17:50 -08001970
Jaineel7e67a3f2019-08-28 15:58:49 -07001971 # validate no leak of information
1972 asserts.assert_false(
1973 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[
1974 "data"], "Network specifier leak!")
1975 asserts.assert_false(
1976 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[
1977 "data"], "Network specifier leak!")
Etan Cohen0ead4552017-12-27 16:17:50 -08001978
Jaineel7e67a3f2019-08-28 15:58:49 -07001979 # request out-of-band network
1980 resp_req_key = autils.request_network(
1981 resp_dut,
1982 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1983 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac, passphrase))
1984 init_req_key = autils.request_network(
1985 init_dut,
1986 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1987 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase))
Etan Cohen0ead4552017-12-27 16:17:50 -08001988
Jaineel7e67a3f2019-08-28 15:58:49 -07001989 resp_net_event_nc = autils.wait_for_event_with_keys(
1990 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1991 (cconsts.NETWORK_CB_KEY_EVENT,
1992 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1993 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
1994 init_net_event_nc = autils.wait_for_event_with_keys(
1995 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1996 (cconsts.NETWORK_CB_KEY_EVENT,
1997 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1998 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
1999 resp_net_event_lp = autils.wait_for_event_with_keys(
2000 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
2001 (cconsts.NETWORK_CB_KEY_EVENT,
2002 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
2003 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
2004 init_net_event_lp = autils.wait_for_event_with_keys(
2005 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
2006 (cconsts.NETWORK_CB_KEY_EVENT,
2007 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
2008 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
Etan Cohen0ead4552017-12-27 16:17:50 -08002009
Jaineel7e67a3f2019-08-28 15:58:49 -07002010 # validate no leak of information
2011 asserts.assert_false(
2012 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in resp_net_event_nc[
2013 "data"], "Network specifier leak!")
2014 asserts.assert_false(
2015 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in init_net_event_nc[
2016 "data"], "Network specifier leak!")
Etan Cohen0ead4552017-12-27 16:17:50 -08002017
Jaineel7e67a3f2019-08-28 15:58:49 -07002018 if not ib_first:
2019 # request in-band network (to completion)
2020 p_req_key = self.request_network(
2021 p_dut,
2022 p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, None))
2023 s_req_key = self.request_network(
2024 s_dut,
2025 s_dut.droid.wifiAwareCreateNetworkSpecifier(
2026 s_disc_id, peer_id_on_sub))
Etan Cohen0ead4552017-12-27 16:17:50 -08002027
Jaineel7e67a3f2019-08-28 15:58:49 -07002028 # Publisher & Subscriber: wait for network formation
2029 p_net_event_nc = autils.wait_for_event_with_keys(
2030 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
2031 autils.EVENT_NDP_TIMEOUT,
2032 (cconsts.NETWORK_CB_KEY_EVENT,
2033 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
2034 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
2035 s_net_event_nc = autils.wait_for_event_with_keys(
2036 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
2037 autils.EVENT_NDP_TIMEOUT,
2038 (cconsts.NETWORK_CB_KEY_EVENT,
2039 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
2040 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
2041 p_net_event_lp = autils.wait_for_event_with_keys(
2042 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
2043 autils.EVENT_NDP_TIMEOUT,
2044 (cconsts.NETWORK_CB_KEY_EVENT,
2045 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
2046 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
2047 s_net_event_lp = autils.wait_for_event_with_keys(
2048 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
2049 autils.EVENT_NDP_TIMEOUT,
2050 (cconsts.NETWORK_CB_KEY_EVENT,
2051 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
2052 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohen0ead4552017-12-27 16:17:50 -08002053
Jaineel7e67a3f2019-08-28 15:58:49 -07002054 # validate no leak of information
2055 asserts.assert_false(
2056 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[
2057 "data"], "Network specifier leak!")
2058 asserts.assert_false(
2059 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[
2060 "data"], "Network specifier leak!")
Etan Cohen0ead4552017-12-27 16:17:50 -08002061
Jaineel7e67a3f2019-08-28 15:58:49 -07002062 # note that Init <-> Resp & Pub <--> Sub since IPv6 are of peer's!
2063 init_ipv6 = resp_net_event_nc["data"][aconsts.NET_CAP_IPV6]
2064 resp_ipv6 = init_net_event_nc["data"][aconsts.NET_CAP_IPV6]
2065 pub_ipv6 = s_net_event_nc["data"][aconsts.NET_CAP_IPV6]
2066 sub_ipv6 = p_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohen0ead4552017-12-27 16:17:50 -08002067
Jaineel7e67a3f2019-08-28 15:58:49 -07002068 # extract net info
2069 pub_interface = p_net_event_lp["data"][
2070 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
2071 sub_interface = s_net_event_lp["data"][
2072 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
2073 resp_interface = resp_net_event_lp["data"][
2074 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
2075 init_interface = init_net_event_lp["data"][
2076 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohen0ead4552017-12-27 16:17:50 -08002077
Jaineel7e67a3f2019-08-28 15:58:49 -07002078 self.log.info("Interface names: Pub=%s, Sub=%s, Resp=%s, Init=%s",
2079 pub_interface, sub_interface, resp_interface,
2080 init_interface)
2081 self.log.info(
2082 "Interface addresses (IPv6): Pub=%s, Sub=%s, Resp=%s, Init=%s",
2083 pub_ipv6, sub_ipv6, resp_ipv6, init_ipv6)
Etan Cohen0ead4552017-12-27 16:17:50 -08002084
Jaineel7e67a3f2019-08-28 15:58:49 -07002085 # validate NDP/NDI conditions (using interface names & ipv6)
2086 if same_request:
2087 asserts.assert_equal(
2088 pub_interface, resp_interface if inits_on_same_dut else
2089 init_interface, "NDP interfaces don't match on Pub/other")
2090 asserts.assert_equal(
2091 sub_interface, init_interface if inits_on_same_dut else
2092 resp_interface, "NDP interfaces don't match on Sub/other")
Etan Cohen0ead4552017-12-27 16:17:50 -08002093
Jaineel7e67a3f2019-08-28 15:58:49 -07002094 asserts.assert_equal(pub_ipv6, resp_ipv6
2095 if inits_on_same_dut else init_ipv6,
2096 "NDP IPv6 don't match on Pub/other")
2097 asserts.assert_equal(sub_ipv6, init_ipv6
2098 if inits_on_same_dut else resp_ipv6,
2099 "NDP IPv6 don't match on Sub/other")
2100 else:
2101 asserts.assert_false(
2102 pub_interface == (resp_interface
2103 if inits_on_same_dut else init_interface),
2104 "NDP interfaces match on Pub/other")
2105 asserts.assert_false(
2106 sub_interface == (init_interface
2107 if inits_on_same_dut else resp_interface),
2108 "NDP interfaces match on Sub/other")
Etan Cohen0ead4552017-12-27 16:17:50 -08002109
Jaineel7e67a3f2019-08-28 15:58:49 -07002110 asserts.assert_false(
2111 pub_ipv6 == (resp_ipv6 if inits_on_same_dut else init_ipv6),
2112 "NDP IPv6 match on Pub/other")
2113 asserts.assert_false(
2114 sub_ipv6 == (init_ipv6 if inits_on_same_dut else resp_ipv6),
2115 "NDP IPv6 match on Sub/other")
2116
2117 # release requests
2118 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
2119 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
2120 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
2121 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
2122
2123 @test_tracker_info(uuid="d8a0839d-4ba0-43f2-af93-3cf1382f9f16")
Girish Moturuaac2f212020-05-15 21:20:46 -07002124 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07002125 def test_identical_ndps_mix_ib_oob_ib_first_same_polarity(self):
2126 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002127 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2128
2129 The in-band request is issued first. Both Initiators (Sub == Initiator) are
2130 run on the same device.
2131 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002132 self.run_mix_ib_oob(
2133 same_request=True, ib_first=True, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002134
Jaineel7e67a3f2019-08-28 15:58:49 -07002135 @test_tracker_info(uuid="70bbb811-0bed-4a19-96b3-f2446e777c8a")
Girish Moturuaac2f212020-05-15 21:20:46 -07002136 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07002137 def test_identical_ndps_mix_ib_oob_oob_first_same_polarity(self):
2138 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002139 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2140
2141 The out-of-band request is issued first. Both Initiators (Sub == Initiator)
2142 are run on the same device.
2143 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002144 self.run_mix_ib_oob(
2145 same_request=True, ib_first=False, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002146
Jaineel7e67a3f2019-08-28 15:58:49 -07002147 @test_tracker_info(uuid="d9796da5-f96a-4a51-be0f-89d6f5bfe3ad")
Girish Moturuaac2f212020-05-15 21:20:46 -07002148 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07002149 def test_identical_ndps_mix_ib_oob_ib_first_diff_polarity(self):
2150 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002151 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2152
2153 The in-band request is issued first. Initiators (Sub == Initiator) are
2154 run on different devices.
2155 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002156 self.run_mix_ib_oob(
2157 same_request=True, ib_first=True, inits_on_same_dut=False)
Etan Cohen0ead4552017-12-27 16:17:50 -08002158
Girish Moturuc0f87bc2020-05-23 21:20:05 -07002159 @test_tracker_info(uuid="48b9005b-7851-4222-b41c-1fcbefbc704d")
Girish Moturuaac2f212020-05-15 21:20:46 -07002160 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07002161 def test_identical_ndps_mix_ib_oob_oob_first_diff_polarity(self):
2162 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002163 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2164
2165 The out-of-band request is issued first. Initiators (Sub == Initiator) are
2166 run on different devices.
2167 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002168 self.run_mix_ib_oob(
2169 same_request=True, ib_first=False, inits_on_same_dut=False)
Etan Cohen0ead4552017-12-27 16:17:50 -08002170
Jaineel7e67a3f2019-08-28 15:58:49 -07002171 @test_tracker_info(uuid="51f9581e-c5ee-48a7-84d2-adff4876c3d7")
Girish Moturuaac2f212020-05-15 21:20:46 -07002172 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07002173 def test_multiple_ndis_mix_ib_oob_ib_first_same_polarity(self):
2174 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002175 different security configurations. Use a mix of in-band and out-of-band APIs
2176 to request the different NDPs.
2177
2178 The in-band request is issued first. Initiators (Sub == Initiator) are
2179 run on the same device.
2180 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002181 self.run_mix_ib_oob(
2182 same_request=False, ib_first=True, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002183
Jaineel7e67a3f2019-08-28 15:58:49 -07002184 @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853")
Girish Moturuaac2f212020-05-15 21:20:46 -07002185 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07002186 def test_multiple_ndis_mix_ib_oob_oob_first_same_polarity(self):
2187 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002188 different security configurations. Use a mix of in-band and out-of-band APIs
2189 to request the different NDPs.
2190
2191 The out-of-band request is issued first. Initiators (Sub == Initiator) are
2192 run on the same device.
2193 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002194 self.run_mix_ib_oob(
2195 same_request=False, ib_first=False, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002196
Jaineel7e67a3f2019-08-28 15:58:49 -07002197 @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853")
Girish Moturuaac2f212020-05-15 21:20:46 -07002198 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07002199 def test_multiple_ndis_mix_ib_oob_ib_first_diff_polarity(self):
2200 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002201 different security configurations. Use a mix of in-band and out-of-band APIs
2202 to request the different NDPs.
2203
2204 The in-band request is issued first. Initiators (Sub == Initiator) are
2205 run on different devices.
2206 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002207 self.run_mix_ib_oob(
2208 same_request=False, ib_first=True, inits_on_same_dut=False)
Etan Cohen0ead4552017-12-27 16:17:50 -08002209
Jaineel7e67a3f2019-08-28 15:58:49 -07002210 @test_tracker_info(uuid="596caadf-028e-494b-bbce-8304ccec2cbb")
Girish Moturuaac2f212020-05-15 21:20:46 -07002211 @WifiBaseTest.wifi_test_wrap
Jaineel7e67a3f2019-08-28 15:58:49 -07002212 def test_multiple_ndis_mix_ib_oob_oob_first_diff_polarity(self):
2213 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002214 different security configurations. Use a mix of in-band and out-of-band APIs
2215 to request the different NDPs.
2216
2217 The out-of-band request is issued first. Initiators (Sub == Initiator) are
2218 run on different devices.
2219 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002220 self.run_mix_ib_oob(
2221 same_request=False, ib_first=False, inits_on_same_dut=False)
Etan Cohendbb49c92018-04-19 15:32:38 -07002222
Jaineel7e67a3f2019-08-28 15:58:49 -07002223 ########################################################################
Etan Cohendbb49c92018-04-19 15:32:38 -07002224
Girish Moturuc0f87bc2020-05-23 21:20:05 -07002225 @test_tracker_info(uuid="5ec10bf9-bfda-4093-8344-7ccc7764737e")
Jaineel7e67a3f2019-08-28 15:58:49 -07002226 def test_ndp_loop(self):
2227 """Validate that can create a loop (chain) of N NDPs between N devices,
Etan Cohendbb49c92018-04-19 15:32:38 -07002228 where N >= 3, e.g.
2229
2230 A - B
2231 B - C
2232 C - A
2233
2234 The NDPs are all OPEN (no encryption).
2235 """
Girish Moturuee454372019-10-14 11:23:02 -07002236 asserts.skip_if(
2237 len(self.android_devices) < 3,
Jaineel7e67a3f2019-08-28 15:58:49 -07002238 'A minimum of 3 devices is needed to run the test, have %d' % len(
2239 self.android_devices))
Etan Cohendbb49c92018-04-19 15:32:38 -07002240
Jaineel7e67a3f2019-08-28 15:58:49 -07002241 duts = self.android_devices
2242 loop_len = len(duts)
2243 ids = []
2244 macs = []
2245 reqs = []
2246 ifs = []
2247 ipv6s = []
Etan Cohendbb49c92018-04-19 15:32:38 -07002248
Jaineel7e67a3f2019-08-28 15:58:49 -07002249 for i in range(loop_len):
2250 duts[i].pretty_name = chr(ord("A") + i)
2251 reqs.append([])
2252 ifs.append([])
2253 ipv6s.append([])
Etan Cohendbb49c92018-04-19 15:32:38 -07002254
Jaineel7e67a3f2019-08-28 15:58:49 -07002255 # start-up 3 devices (attach w/ identity)
2256 for i in range(loop_len):
2257 ids.append(duts[i].droid.wifiAwareAttach(True))
2258 autils.wait_for_event(duts[i], aconsts.EVENT_CB_ON_ATTACHED)
2259 ident_event = autils.wait_for_event(
2260 duts[i], aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
2261 macs.append(ident_event['data']['mac'])
Etan Cohendbb49c92018-04-19 15:32:38 -07002262
Jaineel7e67a3f2019-08-28 15:58:49 -07002263 # wait for for devices to synchronize with each other - there are no other
2264 # mechanisms to make sure this happens for OOB discovery (except retrying
2265 # to execute the data-path request)
2266 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohendbb49c92018-04-19 15:32:38 -07002267
Jaineel7e67a3f2019-08-28 15:58:49 -07002268 # create the N NDPs: i to (i+1) % N
2269 for i in range(loop_len):
2270 peer_device = (i + 1) % loop_len
Etan Cohendbb49c92018-04-19 15:32:38 -07002271
Jaineel7e67a3f2019-08-28 15:58:49 -07002272 (init_req_key, resp_req_key, init_aware_if, resp_aware_if,
2273 init_ipv6, resp_ipv6) = autils.create_oob_ndp_on_sessions(
2274 duts[i], duts[peer_device], ids[i], macs[i], ids[peer_device],
2275 macs[peer_device])
Etan Cohendbb49c92018-04-19 15:32:38 -07002276
Jaineel7e67a3f2019-08-28 15:58:49 -07002277 reqs[i].append(init_req_key)
2278 reqs[peer_device].append(resp_req_key)
2279 ifs[i].append(init_aware_if)
2280 ifs[peer_device].append(resp_aware_if)
2281 ipv6s[i].append(init_ipv6)
2282 ipv6s[peer_device].append(resp_ipv6)
Etan Cohendbb49c92018-04-19 15:32:38 -07002283
Jaineel7e67a3f2019-08-28 15:58:49 -07002284 # clean-up
2285 for i in range(loop_len):
2286 for req in reqs[i]:
2287 duts[i].droid.connectivityUnregisterNetworkCallback(req)
Etan Cohendbb49c92018-04-19 15:32:38 -07002288
Jaineel7e67a3f2019-08-28 15:58:49 -07002289 # info
2290 self.log.info("MACs: %s", macs)
2291 self.log.info("Interface names: %s", ifs)
2292 self.log.info("IPv6 addresses: %s", ipv6s)
2293 asserts.explicit_pass(
2294 "NDP loop test", extras={
2295 "macs": macs,
2296 "ifs": ifs,
2297 "ipv6s": ipv6s
2298 })