blob: 9a8b54993b32ad180b7dfce87ba6e89c57609b97 [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
Etan Cohenfc5f3732017-06-02 17:31:52 -070021from acts.test_utils.net import connectivity_const as cconsts
22from acts.test_utils.wifi.aware import aware_const as aconsts
23from acts.test_utils.wifi.aware import aware_test_utils as autils
24from acts.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest
25
26
27class DataPathTest(AwareBaseTest):
Etan Cohenbfb149f2017-06-06 10:13:17 -070028 """Set of tests for Wi-Fi Aware data-path."""
Etan Cohenfc5f3732017-06-02 17:31:52 -070029
30 # configuration parameters used by tests
31 ENCR_TYPE_OPEN = 0
32 ENCR_TYPE_PASSPHRASE = 1
Etan Cohen058aaba2017-06-05 17:01:54 -070033 ENCR_TYPE_PMK = 2
Etan Cohenfc5f3732017-06-02 17:31:52 -070034
35 PASSPHRASE = "This is some random passphrase - very very secure!!"
Etan Cohen6ace4582017-06-05 17:21:55 -070036 PASSPHRASE_MIN = "01234567"
37 PASSPHRASE_MAX = "012345678901234567890123456789012345678901234567890123456789012"
Etan Cohen058aaba2017-06-05 17:01:54 -070038 PMK = "ODU0YjE3YzdmNDJiNWI4NTQ2NDJjNDI3M2VkZTQyZGU="
Etan Cohen85adc452017-06-06 08:32:08 -070039 PASSPHRASE2 = "This is some random passphrase - very very secure - but diff!!"
Etan Cohen23b92292017-07-11 11:09:06 -070040 PMK2 = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="
Etan Cohenfc5f3732017-06-02 17:31:52 -070041
42 PING_MSG = "ping"
43
44 # message re-transmit counter (increases reliability in open-environment)
45 # Note: reliability of message transmission is tested elsewhere
46 MSG_RETX_COUNT = 5 # hard-coded max value, internal API
47
Etan Cohenba8a53f2017-06-05 12:55:02 -070048 # number of second to 'reasonably' wait to make sure that devices synchronize
49 # with each other - useful for OOB test cases, where the OOB discovery would
50 # take some time
51 WAIT_FOR_CLUSTER = 5
52
Etan Cohenfc5f3732017-06-02 17:31:52 -070053 def __init__(self, controllers):
54 AwareBaseTest.__init__(self, controllers)
55
56 def create_config(self, dtype):
57 """Create a base configuration based on input parameters.
58
59 Args:
60 dtype: Publish or Subscribe discovery type
61
62 Returns:
63 Discovery configuration object.
64 """
65 config = {}
66 config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = dtype
67 config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = "GoogleTestServiceDataPath"
68 return config
69
70 def request_network(self, dut, ns):
71 """Request a Wi-Fi Aware network.
72
73 Args:
74 dut: Device
75 ns: Network specifier
76 Returns: the request key
77 """
78 network_req = {"TransportType": 5, "NetworkSpecifier": ns}
79 return dut.droid.connectivityRequestWifiAwareNetwork(network_req)
80
Etan Cohen204df172017-11-09 12:05:36 -080081 def set_up_discovery(self, ptype, stype, get_peer_id, pub_on_both=False,
82 pub_on_both_same=True):
Etan Cohenbc80da12017-06-06 09:26:02 -070083 """Set up discovery sessions and wait for service discovery.
Etan Cohenfc5f3732017-06-02 17:31:52 -070084
85 Args:
86 ptype: Publish discovery type
87 stype: Subscribe discovery type
Etan Cohenbc80da12017-06-06 09:26:02 -070088 get_peer_id: Send a message across to get the peer's id
Etan Cohen204df172017-11-09 12:05:36 -080089 pub_on_both: If True then set up a publisher on both devices. The second
90 publisher isn't used (existing to test use-case).
91 pub_on_both_same: If True then the second publish uses an identical
92 service name, otherwise a different service name.
Etan Cohenfc5f3732017-06-02 17:31:52 -070093 """
94 p_dut = self.android_devices[0]
95 p_dut.pretty_name = "Publisher"
96 s_dut = self.android_devices[1]
97 s_dut.pretty_name = "Subscriber"
98
99 # Publisher+Subscriber: attach and wait for confirmation
100 p_id = p_dut.droid.wifiAwareAttach()
101 autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED)
Etan Cohen76ff8012017-06-16 13:13:44 -0700102 time.sleep(self.device_startup_offset)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700103 s_id = s_dut.droid.wifiAwareAttach()
104 autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED)
105
106 # Publisher: start publish and wait for confirmation
107 p_disc_id = p_dut.droid.wifiAwarePublish(p_id, self.create_config(ptype))
108 autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
109
Etan Cohen204df172017-11-09 12:05:36 -0800110 # Optionally set up a publish session on the Subscriber device
111 if pub_on_both:
112 p2_config = self.create_config(ptype)
113 if not pub_on_both_same:
114 p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = (
115 p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] + "-XYZXYZ")
116 s_dut.droid.wifiAwarePublish(s_id, p2_config)
117 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
118
Etan Cohenfc5f3732017-06-02 17:31:52 -0700119 # Subscriber: start subscribe and wait for confirmation
120 s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id, self.create_config(stype))
121 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED)
122
123 # Subscriber: wait for service discovery
124 discovery_event = autils.wait_for_event(
125 s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
126 peer_id_on_sub = discovery_event["data"][aconsts.SESSION_CB_KEY_PEER_ID]
127
Etan Cohenbc80da12017-06-06 09:26:02 -0700128 peer_id_on_pub = None
129 if get_peer_id: # only need message to receive peer ID
Etan Cohenfc5f3732017-06-02 17:31:52 -0700130 # Subscriber: send message to peer (Publisher - so it knows our address)
131 s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub,
132 self.get_next_msg_id(), self.PING_MSG,
133 self.MSG_RETX_COUNT)
134 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT)
135
136 # Publisher: wait for received message
137 pub_rx_msg_event = autils.wait_for_event(
138 p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED)
139 peer_id_on_pub = pub_rx_msg_event["data"][aconsts.SESSION_CB_KEY_PEER_ID]
140
Etan Cohenbc80da12017-06-06 09:26:02 -0700141 return (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
142 peer_id_on_pub)
143
144 def run_ib_data_path_test(self,
145 ptype,
146 stype,
147 encr_type,
148 use_peer_id,
Etan Cohen204df172017-11-09 12:05:36 -0800149 passphrase_to_use=None,
150 pub_on_both=False,
151 pub_on_both_same=True):
Etan Cohenbc80da12017-06-06 09:26:02 -0700152 """Runs the in-band data-path tests.
153
154 Args:
155 ptype: Publish discovery type
156 stype: Subscribe discovery type
157 encr_type: Encryption type, one of ENCR_TYPE_*
158 use_peer_id: On Responder (publisher): True to use peer ID, False to
159 accept any request
160 passphrase_to_use: The passphrase to use if encr_type=ENCR_TYPE_PASSPHRASE
161 If None then use self.PASSPHRASE
Etan Cohen204df172017-11-09 12:05:36 -0800162 pub_on_both: If True then set up a publisher on both devices. The second
163 publisher isn't used (existing to test use-case).
164 pub_on_both_same: If True then the second publish uses an identical
165 service name, otherwise a different service name.
Etan Cohenbc80da12017-06-06 09:26:02 -0700166 """
167 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
Etan Cohen204df172017-11-09 12:05:36 -0800168 peer_id_on_pub) = self.set_up_discovery(ptype, stype, use_peer_id,
169 pub_on_both=pub_on_both,
170 pub_on_both_same=pub_on_both_same)
Etan Cohenbc80da12017-06-06 09:26:02 -0700171
Etan Cohen23b92292017-07-11 11:09:06 -0700172 passphrase = None
173 pmk = None
Etan Cohen058aaba2017-06-05 17:01:54 -0700174 if encr_type == self.ENCR_TYPE_PASSPHRASE:
Etan Cohen204df172017-11-09 12:05:36 -0800175 passphrase = (
176 self.PASSPHRASE if passphrase_to_use == None else passphrase_to_use)
Etan Cohen058aaba2017-06-05 17:01:54 -0700177 elif encr_type == self.ENCR_TYPE_PMK:
Etan Cohen23b92292017-07-11 11:09:06 -0700178 pmk = self.PMK
Etan Cohen058aaba2017-06-05 17:01:54 -0700179
Etan Cohenfc5f3732017-06-02 17:31:52 -0700180 # Publisher: request network
181 p_req_key = self.request_network(
182 p_dut,
Etan Cohen058aaba2017-06-05 17:01:54 -0700183 p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, peer_id_on_pub if
Etan Cohen23b92292017-07-11 11:09:06 -0700184 use_peer_id else None, passphrase, pmk))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700185
186 # Subscriber: request network
187 s_req_key = self.request_network(
188 s_dut,
Etan Cohen058aaba2017-06-05 17:01:54 -0700189 s_dut.droid.wifiAwareCreateNetworkSpecifier(s_disc_id, peer_id_on_sub,
Etan Cohen23b92292017-07-11 11:09:06 -0700190 passphrase, pmk))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700191
192 # Publisher & Subscriber: wait for network formation
193 p_net_event = autils.wait_for_event_with_keys(
194 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
Etan Cohene47ec432017-06-21 10:42:16 -0700195 autils.EVENT_NDP_TIMEOUT,
Etan Cohenfc5f3732017-06-02 17:31:52 -0700196 (cconsts.NETWORK_CB_KEY_EVENT,
197 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
198 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
199 s_net_event = autils.wait_for_event_with_keys(
200 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
Etan Cohene47ec432017-06-21 10:42:16 -0700201 autils.EVENT_NDP_TIMEOUT,
Etan Cohenfc5f3732017-06-02 17:31:52 -0700202 (cconsts.NETWORK_CB_KEY_EVENT,
203 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
204 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
205
206 p_aware_if = p_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
207 s_aware_if = s_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
208 self.log.info("Interface names: p=%s, s=%s", p_aware_if, s_aware_if)
209
210 p_ipv6 = p_dut.droid.connectivityGetLinkLocalIpv6Address(p_aware_if).split(
211 "%")[0]
212 s_ipv6 = s_dut.droid.connectivityGetLinkLocalIpv6Address(s_aware_if).split(
213 "%")[0]
214 self.log.info("Interface addresses (IPv6): p=%s, s=%s", p_ipv6, s_ipv6)
215
216 # TODO: possibly send messages back and forth, prefer to use netcat/nc
217
Etan Cohence202292017-06-05 13:55:54 -0700218 # terminate sessions and wait for ON_LOST callbacks
219 p_dut.droid.wifiAwareDestroy(p_id)
220 s_dut.droid.wifiAwareDestroy(s_id)
221
222 autils.wait_for_event_with_keys(
Etan Cohene47ec432017-06-21 10:42:16 -0700223 p_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
Etan Cohence202292017-06-05 13:55:54 -0700224 (cconsts.NETWORK_CB_KEY_EVENT,
225 cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, p_req_key))
226 autils.wait_for_event_with_keys(
Etan Cohene47ec432017-06-21 10:42:16 -0700227 s_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
Etan Cohence202292017-06-05 13:55:54 -0700228 (cconsts.NETWORK_CB_KEY_EVENT,
229 cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, s_req_key))
230
Etan Cohenfc5f3732017-06-02 17:31:52 -0700231 # clean-up
232 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
233 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
234
Etan Cohen35653522017-11-09 13:47:20 -0800235 def run_oob_data_path_test(self, encr_type, use_peer_id,
236 setup_discovery_sessions=False):
Etan Cohenba8a53f2017-06-05 12:55:02 -0700237 """Runs the out-of-band data-path tests.
238
239 Args:
240 encr_type: Encryption type, one of ENCR_TYPE_*
241 use_peer_id: On Responder: True to use peer ID, False to accept any
242 request
Etan Cohen35653522017-11-09 13:47:20 -0800243 setup_discovery_sessions: If True also set up a (spurious) discovery
244 session (pub on both sides, sub on Responder side). Validates a corner
245 case.
Etan Cohenba8a53f2017-06-05 12:55:02 -0700246 """
247 init_dut = self.android_devices[0]
248 init_dut.pretty_name = "Initiator"
249 resp_dut = self.android_devices[1]
250 resp_dut.pretty_name = "Responder"
251
Etan Cohenbfb149f2017-06-06 10:13:17 -0700252 # Initiator+Responder: attach and wait for confirmation & identity
Etan Cohenba8a53f2017-06-05 12:55:02 -0700253 init_id = init_dut.droid.wifiAwareAttach(True)
254 autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
255 init_ident_event = autils.wait_for_event(
256 init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
257 init_mac = init_ident_event["data"]["mac"]
Etan Cohen76ff8012017-06-16 13:13:44 -0700258 time.sleep(self.device_startup_offset)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700259 resp_id = resp_dut.droid.wifiAwareAttach(True)
260 autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
261 resp_ident_event = autils.wait_for_event(
262 resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
263 resp_mac = resp_ident_event["data"]["mac"]
264
265 # wait for for devices to synchronize with each other - there are no other
266 # mechanisms to make sure this happens for OOB discovery (except retrying
267 # to execute the data-path request)
268 time.sleep(self.WAIT_FOR_CLUSTER)
269
Etan Cohen35653522017-11-09 13:47:20 -0800270 if setup_discovery_sessions:
271 init_dut.droid.wifiAwarePublish(init_id, self.create_config(
272 aconsts.PUBLISH_TYPE_UNSOLICITED))
273 autils.wait_for_event(init_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
274 resp_dut.droid.wifiAwarePublish(resp_id, self.create_config(
275 aconsts.PUBLISH_TYPE_UNSOLICITED))
276 autils.wait_for_event(resp_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
277 resp_dut.droid.wifiAwareSubscribe(resp_id, self.create_config(
278 aconsts.SUBSCRIBE_TYPE_PASSIVE))
279 autils.wait_for_event(resp_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED)
280 autils.wait_for_event(resp_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
281
Etan Cohen23b92292017-07-11 11:09:06 -0700282 passphrase = None
283 pmk = None
Etan Cohen058aaba2017-06-05 17:01:54 -0700284 if encr_type == self.ENCR_TYPE_PASSPHRASE:
Etan Cohen23b92292017-07-11 11:09:06 -0700285 passphrase = self.PASSPHRASE
Etan Cohen058aaba2017-06-05 17:01:54 -0700286 elif encr_type == self.ENCR_TYPE_PMK:
Etan Cohen23b92292017-07-11 11:09:06 -0700287 pmk = self.PMK
Etan Cohen058aaba2017-06-05 17:01:54 -0700288
Etan Cohenba8a53f2017-06-05 12:55:02 -0700289 # Responder: request network
290 resp_req_key = self.request_network(
291 resp_dut,
292 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
293 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac
Etan Cohen23b92292017-07-11 11:09:06 -0700294 if use_peer_id else None, passphrase, pmk))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700295
296 # Initiator: request network
297 init_req_key = self.request_network(
298 init_dut,
299 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
Etan Cohen23b92292017-07-11 11:09:06 -0700300 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase, pmk))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700301
302 # Initiator & Responder: wait for network formation
303 init_net_event = autils.wait_for_event_with_keys(
304 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
Etan Cohene47ec432017-06-21 10:42:16 -0700305 autils.EVENT_NDP_TIMEOUT,
Etan Cohenba8a53f2017-06-05 12:55:02 -0700306 (cconsts.NETWORK_CB_KEY_EVENT,
307 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
308 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
309 resp_net_event = autils.wait_for_event_with_keys(
310 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
Etan Cohene47ec432017-06-21 10:42:16 -0700311 autils.EVENT_NDP_TIMEOUT,
Etan Cohenba8a53f2017-06-05 12:55:02 -0700312 (cconsts.NETWORK_CB_KEY_EVENT,
313 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
314 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
315
316 init_aware_if = init_net_event["data"][
Etan Cohen85adc452017-06-06 08:32:08 -0700317 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohenba8a53f2017-06-05 12:55:02 -0700318 resp_aware_if = resp_net_event["data"][
Etan Cohen85adc452017-06-06 08:32:08 -0700319 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohenba8a53f2017-06-05 12:55:02 -0700320 self.log.info("Interface names: I=%s, R=%s", init_aware_if, resp_aware_if)
321
322 init_ipv6 = init_dut.droid.connectivityGetLinkLocalIpv6Address(
323 init_aware_if).split("%")[0]
324 resp_ipv6 = resp_dut.droid.connectivityGetLinkLocalIpv6Address(
325 resp_aware_if).split("%")[0]
326 self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
327 resp_ipv6)
328
329 # TODO: possibly send messages back and forth, prefer to use netcat/nc
330
Etan Cohence202292017-06-05 13:55:54 -0700331 # terminate sessions and wait for ON_LOST callbacks
332 init_dut.droid.wifiAwareDestroy(init_id)
333 resp_dut.droid.wifiAwareDestroy(resp_id)
334
335 autils.wait_for_event_with_keys(
Etan Cohene47ec432017-06-21 10:42:16 -0700336 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
Etan Cohence202292017-06-05 13:55:54 -0700337 (cconsts.NETWORK_CB_KEY_EVENT,
338 cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, init_req_key))
339 autils.wait_for_event_with_keys(
Etan Cohene47ec432017-06-21 10:42:16 -0700340 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
Etan Cohence202292017-06-05 13:55:54 -0700341 (cconsts.NETWORK_CB_KEY_EVENT,
342 cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
343
Etan Cohenba8a53f2017-06-05 12:55:02 -0700344 # clean-up
345 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
346 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
347
Etan Cohenbc80da12017-06-06 09:26:02 -0700348 def run_mismatched_ib_data_path_test(self, pub_mismatch, sub_mismatch):
349 """Runs the negative in-band data-path tests: mismatched peer ID.
350
351 Args:
352 pub_mismatch: Mismatch the publisher's ID
353 sub_mismatch: Mismatch the subscriber's ID
354 """
355 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id,
356 peer_id_on_sub, peer_id_on_pub) = self.set_up_discovery(
357 aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE, True)
358
359 if pub_mismatch:
360 peer_id_on_pub = peer_id_on_pub -1
361 if sub_mismatch:
362 peer_id_on_sub = peer_id_on_sub - 1
363
364 # Publisher: request network
365 p_req_key = self.request_network(
366 p_dut,
367 p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, peer_id_on_pub,
368 None))
369
370 # Subscriber: request network
371 s_req_key = self.request_network(
372 s_dut,
373 s_dut.droid.wifiAwareCreateNetworkSpecifier(s_disc_id, peer_id_on_sub,
374 None))
375
376 # Publisher & Subscriber: fail on network formation
Etan Cohene47ec432017-06-21 10:42:16 -0700377 time.sleep(autils.EVENT_NDP_TIMEOUT)
Etan Cohen38c3d5a2017-07-28 10:02:48 -0700378 autils.fail_on_event_with_keys(p_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
379 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
380 autils.fail_on_event_with_keys(s_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
381 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohenbc80da12017-06-06 09:26:02 -0700382
383 # clean-up
384 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
385 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
386
Etan Cohen85adc452017-06-06 08:32:08 -0700387 def run_mismatched_oob_data_path_test(self,
388 init_mismatch_mac=False,
389 resp_mismatch_mac=False,
390 init_encr_type=ENCR_TYPE_OPEN,
391 resp_encr_type=ENCR_TYPE_OPEN):
392 """Runs the negative out-of-band data-path tests: mismatched information
393 between Responder and Initiator.
394
395 Args:
396 init_mismatch_mac: True to mismatch the Initiator MAC address
397 resp_mismatch_mac: True to mismatch the Responder MAC address
398 init_encr_type: Encryption type of Initiator - ENCR_TYPE_*
399 resp_encr_type: Encryption type of Responder - ENCR_TYPE_*
400 """
401 init_dut = self.android_devices[0]
402 init_dut.pretty_name = "Initiator"
403 resp_dut = self.android_devices[1]
404 resp_dut.pretty_name = "Responder"
405
Etan Cohenbfb149f2017-06-06 10:13:17 -0700406 # Initiator+Responder: attach and wait for confirmation & identity
Etan Cohen85adc452017-06-06 08:32:08 -0700407 init_id = init_dut.droid.wifiAwareAttach(True)
408 autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
409 init_ident_event = autils.wait_for_event(
410 init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
411 init_mac = init_ident_event["data"]["mac"]
Etan Cohen76ff8012017-06-16 13:13:44 -0700412 time.sleep(self.device_startup_offset)
Etan Cohen85adc452017-06-06 08:32:08 -0700413 resp_id = resp_dut.droid.wifiAwareAttach(True)
414 autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
415 resp_ident_event = autils.wait_for_event(
416 resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
417 resp_mac = resp_ident_event["data"]["mac"]
418
419 if init_mismatch_mac: # assumes legit ones don't start with "00"
420 init_mac = "00" + init_mac[2:]
421 if resp_mismatch_mac:
422 resp_mac = "00" + resp_mac[2:]
423
424 # wait for for devices to synchronize with each other - there are no other
425 # mechanisms to make sure this happens for OOB discovery (except retrying
426 # to execute the data-path request)
427 time.sleep(self.WAIT_FOR_CLUSTER)
428
429 # set up separate keys: even if types are the same we want a mismatch
Etan Cohen23b92292017-07-11 11:09:06 -0700430 init_passphrase = None
431 init_pmk = None
Etan Cohen85adc452017-06-06 08:32:08 -0700432 if init_encr_type == self.ENCR_TYPE_PASSPHRASE:
Etan Cohen23b92292017-07-11 11:09:06 -0700433 init_passphrase = self.PASSPHRASE
Etan Cohen85adc452017-06-06 08:32:08 -0700434 elif init_encr_type == self.ENCR_TYPE_PMK:
Etan Cohen23b92292017-07-11 11:09:06 -0700435 init_pmk = self.PMK
Etan Cohen85adc452017-06-06 08:32:08 -0700436
Etan Cohen23b92292017-07-11 11:09:06 -0700437 resp_passphrase = None
438 resp_pmk = None
Etan Cohen85adc452017-06-06 08:32:08 -0700439 if resp_encr_type == self.ENCR_TYPE_PASSPHRASE:
Etan Cohen23b92292017-07-11 11:09:06 -0700440 resp_passphrase = self.PASSPHRASE2
Etan Cohen85adc452017-06-06 08:32:08 -0700441 elif resp_encr_type == self.ENCR_TYPE_PMK:
Etan Cohen23b92292017-07-11 11:09:06 -0700442 resp_pmk = self.PMK2
Etan Cohen85adc452017-06-06 08:32:08 -0700443
444 # Responder: request network
445 resp_req_key = self.request_network(
446 resp_dut,
447 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
Etan Cohen23b92292017-07-11 11:09:06 -0700448 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac, resp_passphrase,
449 resp_pmk))
Etan Cohen85adc452017-06-06 08:32:08 -0700450
451 # Initiator: request network
452 init_req_key = self.request_network(
453 init_dut,
454 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
Etan Cohen23b92292017-07-11 11:09:06 -0700455 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, init_passphrase,
456 init_pmk))
Etan Cohen85adc452017-06-06 08:32:08 -0700457
458 # Initiator & Responder: fail on network formation
Etan Cohene47ec432017-06-21 10:42:16 -0700459 time.sleep(autils.EVENT_NDP_TIMEOUT)
Etan Cohen38c3d5a2017-07-28 10:02:48 -0700460 autils.fail_on_event_with_keys(init_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
461 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
462 autils.fail_on_event_with_keys(resp_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
463 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
Etan Cohen85adc452017-06-06 08:32:08 -0700464
465 # clean-up
466 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
467 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
468
Etan Cohenba8a53f2017-06-05 12:55:02 -0700469
Etan Cohenfc5f3732017-06-02 17:31:52 -0700470 #######################################
471 # Positive In-Band (IB) tests key:
472 #
473 # names is: test_ib_<pub_type>_<sub_type>_<encr_type>_<peer_spec>
474 # where:
475 #
476 # pub_type: Type of publish discovery session: unsolicited or solicited.
477 # sub_type: Type of subscribe discovery session: passive or active.
478 # encr_type: Encription type: open, passphrase
479 # peer_spec: Peer specification method: any or specific
480 #
481 # Note: In-Band means using Wi-Fi Aware for discovery and referring to the
482 # peer using the Aware-provided peer handle (as opposed to a MAC address).
483 #######################################
484
Etan Cohen185b3cf2017-08-22 14:10:10 -0700485 @test_tracker_info(uuid="fa30bedc-d1de-4440-bf25-ec00d10555af")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700486 def test_ib_unsolicited_passive_open_specific(self):
487 """Data-path: in-band, unsolicited/passive, open encryption, specific peer
488
489 Verifies end-to-end discovery + data-path creation.
490 """
491 self.run_ib_data_path_test(
492 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
493 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
494 encr_type=self.ENCR_TYPE_OPEN,
495 use_peer_id=True)
496
Etan Cohen185b3cf2017-08-22 14:10:10 -0700497 @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700498 def test_ib_unsolicited_passive_open_any(self):
499 """Data-path: in-band, unsolicited/passive, open encryption, any peer
500
501 Verifies end-to-end discovery + data-path creation.
502 """
503 self.run_ib_data_path_test(
504 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
505 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
506 encr_type=self.ENCR_TYPE_OPEN,
507 use_peer_id=False)
508
Etan Cohen185b3cf2017-08-22 14:10:10 -0700509 @test_tracker_info(uuid="93b2a23d-8579-448a-936c-7812929464cf")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700510 def test_ib_unsolicited_passive_passphrase_specific(self):
511 """Data-path: in-band, unsolicited/passive, passphrase, specific peer
512
513 Verifies end-to-end discovery + data-path creation.
514 """
515 self.run_ib_data_path_test(
516 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
517 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
518 encr_type=self.ENCR_TYPE_PASSPHRASE,
519 use_peer_id=True)
520
Etan Cohen185b3cf2017-08-22 14:10:10 -0700521 @test_tracker_info(uuid="1736126f-a0ff-4712-acc4-f89b4eef5716")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700522 def test_ib_unsolicited_passive_passphrase_any(self):
523 """Data-path: in-band, unsolicited/passive, passphrase, any peer
524
525 Verifies end-to-end discovery + data-path creation.
526 """
527 self.run_ib_data_path_test(
528 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
529 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
530 encr_type=self.ENCR_TYPE_PASSPHRASE,
531 use_peer_id=False)
532
Etan Cohen185b3cf2017-08-22 14:10:10 -0700533 @test_tracker_info(uuid="b9353d5b-3f77-46bf-bfd9-65d56a7c939a")
Etan Cohen058aaba2017-06-05 17:01:54 -0700534 def test_ib_unsolicited_passive_pmk_specific(self):
535 """Data-path: in-band, unsolicited/passive, PMK, specific peer
536
537 Verifies end-to-end discovery + data-path creation.
538 """
539 self.run_ib_data_path_test(
540 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
541 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
542 encr_type=self.ENCR_TYPE_PMK,
543 use_peer_id=True)
544
Etan Cohen185b3cf2017-08-22 14:10:10 -0700545 @test_tracker_info(uuid="06f3b2ab-4a10-4398-83a4-6a23851b1662")
Etan Cohen058aaba2017-06-05 17:01:54 -0700546 def test_ib_unsolicited_passive_pmk_any(self):
547 """Data-path: in-band, unsolicited/passive, PMK, any peer
548
549 Verifies end-to-end discovery + data-path creation.
550 """
551 self.run_ib_data_path_test(
552 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
553 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
554 encr_type=self.ENCR_TYPE_PMK,
555 use_peer_id=False)
556
Etan Cohen185b3cf2017-08-22 14:10:10 -0700557 @test_tracker_info(uuid="0ed7d8b3-a69e-46ba-aeb7-13e507ecf290")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700558 def test_ib_solicited_active_open_specific(self):
Etan Cohenba8a53f2017-06-05 12:55:02 -0700559 """Data-path: in-band, solicited/active, open encryption, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700560
Etan Cohenba8a53f2017-06-05 12:55:02 -0700561 Verifies end-to-end discovery + data-path creation.
562 """
563 self.run_ib_data_path_test(
564 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
565 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
566 encr_type=self.ENCR_TYPE_OPEN,
567 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700568
Etan Cohen185b3cf2017-08-22 14:10:10 -0700569 @test_tracker_info(uuid="c7ba6d28-5ef6-45d9-95d5-583ad6d981f3")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700570 def test_ib_solicited_active_open_any(self):
Etan Cohenba8a53f2017-06-05 12:55:02 -0700571 """Data-path: in-band, solicited/active, open encryption, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700572
Etan Cohenba8a53f2017-06-05 12:55:02 -0700573 Verifies end-to-end discovery + data-path creation.
574 """
575 self.run_ib_data_path_test(
576 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
577 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
578 encr_type=self.ENCR_TYPE_OPEN,
579 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700580
Etan Cohen185b3cf2017-08-22 14:10:10 -0700581 @test_tracker_info(uuid="388cea99-0e2e-49ea-b00e-f3e56b6236e5")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700582 def test_ib_solicited_active_passphrase_specific(self):
Etan Cohenba8a53f2017-06-05 12:55:02 -0700583 """Data-path: in-band, solicited/active, passphrase, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700584
Etan Cohenba8a53f2017-06-05 12:55:02 -0700585 Verifies end-to-end discovery + data-path creation.
586 """
587 self.run_ib_data_path_test(
588 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
589 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
590 encr_type=self.ENCR_TYPE_PASSPHRASE,
591 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700592
Etan Cohen185b3cf2017-08-22 14:10:10 -0700593 @test_tracker_info(uuid="fcd3e28a-5eab-4169-8a0c-dc7204dcdc13")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700594 def test_ib_solicited_active_passphrase_any(self):
Etan Cohenba8a53f2017-06-05 12:55:02 -0700595 """Data-path: in-band, solicited/active, passphrase, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700596
Etan Cohenba8a53f2017-06-05 12:55:02 -0700597 Verifies end-to-end discovery + data-path creation.
598 """
599 self.run_ib_data_path_test(
600 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
601 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
602 encr_type=self.ENCR_TYPE_PASSPHRASE,
603 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700604
Etan Cohen185b3cf2017-08-22 14:10:10 -0700605 @test_tracker_info(uuid="9d4eaad7-ba53-4a06-8ce0-e308daea3309")
Etan Cohen058aaba2017-06-05 17:01:54 -0700606 def test_ib_solicited_active_pmk_specific(self):
607 """Data-path: in-band, solicited/active, PMK, specific peer
608
609 Verifies end-to-end discovery + data-path creation.
610 """
611 self.run_ib_data_path_test(
612 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
613 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
614 encr_type=self.ENCR_TYPE_PMK,
615 use_peer_id=True)
616
Etan Cohen185b3cf2017-08-22 14:10:10 -0700617 @test_tracker_info(uuid="129d850e-c312-4137-a67b-05ae95fe66cc")
Etan Cohen058aaba2017-06-05 17:01:54 -0700618 def test_ib_solicited_active_pmk_any(self):
619 """Data-path: in-band, solicited/active, PMK, any peer
620
621 Verifies end-to-end discovery + data-path creation.
622 """
623 self.run_ib_data_path_test(
624 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
625 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
626 encr_type=self.ENCR_TYPE_PMK,
627 use_peer_id=False)
628
Etan Cohenba8a53f2017-06-05 12:55:02 -0700629 #######################################
Etan Cohen204df172017-11-09 12:05:36 -0800630 # Positive In-Band (IB) with a publish session running on the subscriber
631 # tests key:
632 #
633 # names is: test_ib_extra_pub_<same|diff>_<pub_type>_<sub_type>
634 # _<encr_type>_<peer_spec>
635 # where:
636 #
637 # same|diff: Whether the extra publish session (on the subscriber) is the same
638 # or different from the primary session.
639 # pub_type: Type of publish discovery session: unsolicited or solicited.
640 # sub_type: Type of subscribe discovery session: passive or active.
641 # encr_type: Encription type: open, passphrase
642 # peer_spec: Peer specification method: any or specific
643 #
644 # Note: In-Band means using Wi-Fi Aware for discovery and referring to the
645 # peer using the Aware-provided peer handle (as opposed to a MAC address).
646 #######################################
647
648 def test_ib_extra_pub_same_unsolicited_passive_open_specific(self):
649 """Data-path: in-band, unsolicited/passive, open encryption, specific peer.
650
651 Configuration contains a publisher (for the same service) running on *both*
652 devices.
653
654 Verifies end-to-end discovery + data-path creation.
655 """
656 self.run_ib_data_path_test(
657 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
658 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
659 encr_type=self.ENCR_TYPE_OPEN,
660 use_peer_id=True,
661 pub_on_both=True,
662 pub_on_both_same=True)
663
664 def test_ib_extra_pub_same_unsolicited_passive_open_any(self):
665 """Data-path: in-band, unsolicited/passive, open encryption, any peer.
666
667 Configuration contains a publisher (for the same service) running on *both*
668 devices.
669
670 Verifies end-to-end discovery + data-path creation.
671 """
672 self.run_ib_data_path_test(
673 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
674 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
675 encr_type=self.ENCR_TYPE_OPEN,
676 use_peer_id=False,
677 pub_on_both=True,
678 pub_on_both_same=True)
679
680 def test_ib_extra_pub_diff_unsolicited_passive_open_specific(self):
681 """Data-path: in-band, unsolicited/passive, open encryption, specific peer.
682
683 Configuration contains a publisher (for a different service) running on
684 *both* devices.
685
686 Verifies end-to-end discovery + data-path creation.
687 """
688 self.run_ib_data_path_test(
689 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
690 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
691 encr_type=self.ENCR_TYPE_OPEN,
692 use_peer_id=True,
693 pub_on_both=True,
694 pub_on_both_same=False)
695
696 def test_ib_extra_pub_diff_unsolicited_passive_open_any(self):
697 """Data-path: in-band, unsolicited/passive, open encryption, any peer.
698
699 Configuration contains a publisher (for a different service) running on
700 *both* devices.
701
702 Verifies end-to-end discovery + data-path creation.
703 """
704 self.run_ib_data_path_test(
705 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
706 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
707 encr_type=self.ENCR_TYPE_OPEN,
708 use_peer_id=False,
709 pub_on_both=True,
710 pub_on_both_same=False)
711
712 #######################################
Etan Cohenba8a53f2017-06-05 12:55:02 -0700713 # Positive Out-of-Band (OOB) tests key:
714 #
715 # names is: test_oob_<encr_type>_<peer_spec>
716 # where:
717 #
718 # encr_type: Encription type: open, passphrase
719 # peer_spec: Peer specification method: any or specific
720 #
Etan Cohen35653522017-11-09 13:47:20 -0800721 # Optionally set up an extra discovery session to test coexistence. If so
722 # add "ib_coex" to test name.
723 #
Etan Cohenba8a53f2017-06-05 12:55:02 -0700724 # Note: Out-of-Band means using a non-Wi-Fi Aware mechanism for discovery and
725 # exchange of MAC addresses and then Wi-Fi Aware for data-path.
726 #######################################
727
Etan Cohen185b3cf2017-08-22 14:10:10 -0700728 @test_tracker_info(uuid="7db17d8c-1dce-4084-b695-215bbcfe7d41")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700729 def test_oob_open_specific(self):
730 """Data-path: out-of-band, open encryption, specific peer
731
732 Verifies end-to-end discovery + data-path creation.
733 """
734 self.run_oob_data_path_test(
735 encr_type=self.ENCR_TYPE_OPEN,
736 use_peer_id=True)
737
Etan Cohen185b3cf2017-08-22 14:10:10 -0700738 @test_tracker_info(uuid="ad416d89-cb95-4a07-8d29-ee213117450b")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700739 def test_oob_open_any(self):
740 """Data-path: out-of-band, open encryption, any peer
741
742 Verifies end-to-end discovery + data-path creation.
743 """
744 self.run_oob_data_path_test(
745 encr_type=self.ENCR_TYPE_OPEN,
746 use_peer_id=False)
747
Etan Cohen185b3cf2017-08-22 14:10:10 -0700748 @test_tracker_info(uuid="74937a3a-d524-43e2-8979-4449271cab52")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700749 def test_oob_passphrase_specific(self):
750 """Data-path: out-of-band, passphrase, specific peer
751
752 Verifies end-to-end discovery + data-path creation.
753 """
754 self.run_oob_data_path_test(
755 encr_type=self.ENCR_TYPE_PASSPHRASE,
756 use_peer_id=True)
757
Etan Cohen185b3cf2017-08-22 14:10:10 -0700758 @test_tracker_info(uuid="afcbdc7e-d3a9-465b-b1da-ce2e42e3941e")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700759 def test_oob_passphrase_any(self):
760 """Data-path: out-of-band, passphrase, any peer
761
762 Verifies end-to-end discovery + data-path creation.
763 """
764 self.run_oob_data_path_test(
765 encr_type=self.ENCR_TYPE_PASSPHRASE,
766 use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700767
Etan Cohen185b3cf2017-08-22 14:10:10 -0700768 @test_tracker_info(uuid="0d095031-160a-4537-aab5-41b6ad5d55f8")
Etan Cohen058aaba2017-06-05 17:01:54 -0700769 def test_oob_pmk_specific(self):
770 """Data-path: out-of-band, PMK, specific peer
771
772 Verifies end-to-end discovery + data-path creation.
773 """
774 self.run_oob_data_path_test(
775 encr_type=self.ENCR_TYPE_PMK,
776 use_peer_id=True)
777
Etan Cohen185b3cf2017-08-22 14:10:10 -0700778 @test_tracker_info(uuid="e45477bd-66cc-4eb7-88dd-4518c8aa2a74")
Etan Cohen058aaba2017-06-05 17:01:54 -0700779 def test_oob_pmk_any(self):
780 """Data-path: out-of-band, PMK, any peer
781
782 Verifies end-to-end discovery + data-path creation.
783 """
784 self.run_oob_data_path_test(
785 encr_type=self.ENCR_TYPE_PMK,
786 use_peer_id=False)
Etan Cohen6ace4582017-06-05 17:21:55 -0700787
Etan Cohen35653522017-11-09 13:47:20 -0800788 def test_oob_ib_coex_open_specific(self):
789 """Data-path: out-of-band, open encryption, specific peer - in-band coex:
790 set up a concurrent discovery session to verify no impact. The session
791 consists of Publisher on both ends, and a Subscriber on the Responder.
792
793 Verifies end-to-end discovery + data-path creation.
794 """
795 self.run_oob_data_path_test(
796 encr_type=self.ENCR_TYPE_OPEN,
797 use_peer_id=True,
798 setup_discovery_sessions=True)
799
800 def test_oob_ib_coex_open_any(self):
801 """Data-path: out-of-band, open encryption, any peer - in-band coex:
802 set up a concurrent discovery session to verify no impact. The session
803 consists of Publisher on both ends, and a Subscriber on the Responder.
804
805 Verifies end-to-end discovery + data-path creation.
806 """
807 self.run_oob_data_path_test(
808 encr_type=self.ENCR_TYPE_OPEN,
809 use_peer_id=False,
810 setup_discovery_sessions=True)
811
Etan Cohen6ace4582017-06-05 17:21:55 -0700812 ##############################################################
813
Etan Cohen185b3cf2017-08-22 14:10:10 -0700814 @test_tracker_info(uuid="1c2c9805-dc1e-43b5-a1b8-315e8c9a4337")
Etan Cohen6ace4582017-06-05 17:21:55 -0700815 def test_passphrase_min(self):
816 """Data-path: minimum passphrase length
817
818 Use in-band, unsolicited/passive, any peer combination
819 """
820 self.run_ib_data_path_test(ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
821 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
822 encr_type=self.ENCR_TYPE_PASSPHRASE,
823 use_peer_id=False,
824 passphrase_to_use=self.PASSPHRASE_MIN)
825
Etan Cohen185b3cf2017-08-22 14:10:10 -0700826 @test_tracker_info(uuid="e696e2b9-87a9-4521-b337-61b9efaa2057")
Etan Cohen6ace4582017-06-05 17:21:55 -0700827 def test_passphrase_max(self):
828 """Data-path: maximum passphrase length
829
830 Use in-band, unsolicited/passive, any peer combination
831 """
832 self.run_ib_data_path_test(ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
833 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
834 encr_type=self.ENCR_TYPE_PASSPHRASE,
835 use_peer_id=False,
836 passphrase_to_use=self.PASSPHRASE_MAX)
Etan Cohen85adc452017-06-06 08:32:08 -0700837
Etan Cohen185b3cf2017-08-22 14:10:10 -0700838 @test_tracker_info(uuid="533cd44c-ff30-4283-ac28-f71fd7b4f02d")
Etan Cohenbc80da12017-06-06 09:26:02 -0700839 def test_negative_mismatch_publisher_peer_id(self):
840 """Data-path: failure when publisher peer ID is mismatched"""
841 self.run_mismatched_ib_data_path_test(pub_mismatch=True, sub_mismatch=False)
842
Etan Cohen185b3cf2017-08-22 14:10:10 -0700843 @test_tracker_info(uuid="682f275e-722a-4f8b-85e7-0dcea9d25532")
Etan Cohenbc80da12017-06-06 09:26:02 -0700844 def test_negative_mismatch_subscriber_peer_id(self):
845 """Data-path: failure when subscriber peer ID is mismatched"""
846 self.run_mismatched_ib_data_path_test(pub_mismatch=False, sub_mismatch=True)
847
Etan Cohen185b3cf2017-08-22 14:10:10 -0700848 @test_tracker_info(uuid="7fa82796-7fc9-4d9e-bbbb-84b751788943")
Etan Cohen85adc452017-06-06 08:32:08 -0700849 def test_negative_mismatch_init_mac(self):
850 """Data-path: failure when Initiator MAC address mismatch"""
851 self.run_mismatched_oob_data_path_test(
852 init_mismatch_mac=True,
853 resp_mismatch_mac=False)
854
Etan Cohen185b3cf2017-08-22 14:10:10 -0700855 @test_tracker_info(uuid="edeae959-4644-44f9-8d41-bdeb5216954e")
Etan Cohen85adc452017-06-06 08:32:08 -0700856 def test_negative_mismatch_resp_mac(self):
857 """Data-path: failure when Responder MAC address mismatch"""
858 self.run_mismatched_oob_data_path_test(
859 init_mismatch_mac=False,
860 resp_mismatch_mac=True)
861
Etan Cohen185b3cf2017-08-22 14:10:10 -0700862 @test_tracker_info(uuid="91f46949-c47f-49f9-a90f-6fae699613a7")
Etan Cohen85adc452017-06-06 08:32:08 -0700863 def test_negative_mismatch_passphrase(self):
864 """Data-path: failure when passphrases mismatch"""
865 self.run_mismatched_oob_data_path_test(
866 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
867 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
868
Etan Cohen185b3cf2017-08-22 14:10:10 -0700869 @test_tracker_info(uuid="01c49c2e-dc92-4a27-bb47-c4fc67617c23")
Etan Cohen85adc452017-06-06 08:32:08 -0700870 def test_negative_mismatch_pmk(self):
871 """Data-path: failure when PMK mismatch"""
872 self.run_mismatched_oob_data_path_test(
873 init_encr_type=self.ENCR_TYPE_PMK,
874 resp_encr_type=self.ENCR_TYPE_PMK)
875
Etan Cohen185b3cf2017-08-22 14:10:10 -0700876 @test_tracker_info(uuid="4d651797-5fbb-408e-a4b6-a6e1944136da")
Etan Cohen85adc452017-06-06 08:32:08 -0700877 def test_negative_mismatch_open_passphrase(self):
878 """Data-path: failure when initiator is open, and responder passphrase"""
879 self.run_mismatched_oob_data_path_test(
880 init_encr_type=self.ENCR_TYPE_OPEN,
881 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
882
Etan Cohen185b3cf2017-08-22 14:10:10 -0700883 @test_tracker_info(uuid="1ae697f4-5987-4187-aeef-1e22d07d4a7c")
Etan Cohen85adc452017-06-06 08:32:08 -0700884 def test_negative_mismatch_open_pmk(self):
885 """Data-path: failure when initiator is open, and responder PMK"""
886 self.run_mismatched_oob_data_path_test(
887 init_encr_type=self.ENCR_TYPE_OPEN,
888 resp_encr_type=self.ENCR_TYPE_PMK)
889
Etan Cohen185b3cf2017-08-22 14:10:10 -0700890 @test_tracker_info(uuid="f027b1cc-0e7a-4075-b880-5e64b288afbd")
Etan Cohen85adc452017-06-06 08:32:08 -0700891 def test_negative_mismatch_pmk_passphrase(self):
892 """Data-path: failure when initiator is pmk, and responder passphrase"""
893 self.run_mismatched_oob_data_path_test(
894 init_encr_type=self.ENCR_TYPE_PMK,
895 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
896
Etan Cohen185b3cf2017-08-22 14:10:10 -0700897 @test_tracker_info(uuid="0819bbd4-72ae-49c4-bd46-5448db2b0a06")
Etan Cohen85adc452017-06-06 08:32:08 -0700898 def test_negative_mismatch_passphrase_open(self):
899 """Data-path: failure when initiator is passphrase, and responder open"""
900 self.run_mismatched_oob_data_path_test(
901 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
902 resp_encr_type=self.ENCR_TYPE_OPEN)
903
Etan Cohen185b3cf2017-08-22 14:10:10 -0700904 @test_tracker_info(uuid="7ef24f62-8e6b-4732-88a3-80a43584dda4")
Etan Cohen85adc452017-06-06 08:32:08 -0700905 def test_negative_mismatch_pmk_open(self):
906 """Data-path: failure when initiator is PMK, and responder open"""
907 self.run_mismatched_oob_data_path_test(
908 init_encr_type=self.ENCR_TYPE_PMK,
909 resp_encr_type=self.ENCR_TYPE_OPEN)
910
Etan Cohen185b3cf2017-08-22 14:10:10 -0700911 @test_tracker_info(uuid="7b9c9efc-1c06-465e-8a5e-d6a22ac1da97")
Etan Cohen85adc452017-06-06 08:32:08 -0700912 def test_negative_mismatch_passphrase_pmk(self):
913 """Data-path: failure when initiator is passphrase, and responder pmk"""
914 self.run_mismatched_oob_data_path_test(
915 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
916 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen38c3d5a2017-07-28 10:02:48 -0700917
918
919 ##########################################################################
920
Etan Cohen38c3d5a2017-07-28 10:02:48 -0700921 def wait_for_request_responses(self, dut, req_keys, aware_ifs):
922 """Wait for network request confirmation for all request keys.
923
924 Args:
925 dut: Device under test
926 req_keys: (in) A list of the network requests
927 aware_ifs: (out) A list into which to append the network interface
928 """
929 num_events = 0
930 while num_events != len(req_keys):
931 event = autils.wait_for_event(dut, cconsts.EVENT_NETWORK_CALLBACK)
932 if (event["data"][cconsts.NETWORK_CB_KEY_EVENT] ==
933 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED):
934 if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys:
935 num_events = num_events + 1
936 aware_ifs.append(event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME])
937 else:
938 self.log.info("Received an unexpected connectivity, the revoked "
939 "network request probably went through -- %s", event)
940
Etan Cohenb199cd12017-09-22 10:20:44 -0700941 @test_tracker_info(uuid="2e325e2b-d552-4890-b470-20b40284395d")
Etan Cohen38c3d5a2017-07-28 10:02:48 -0700942 def test_multiple_identical_networks(self):
943 """Validate that creating multiple networks between 2 devices, each network
944 with identical configuration is supported over a single NDP.
945
946 Verify that the interface and IPv6 address is the same for all networks.
947 """
948 init_dut = self.android_devices[0]
949 init_dut.pretty_name = "Initiator"
950 resp_dut = self.android_devices[1]
951 resp_dut.pretty_name = "Responder"
952
953 N = 2 # first iteration (must be 2 to give us a chance to cancel the first)
954 M = 5 # second iteration
955
956 init_ids = []
957 resp_ids = []
958
959 # Initiator+Responder: attach and wait for confirmation & identity
Etan Cohenef38a7f2017-11-09 14:26:43 -0800960 # create N+M sessions to be used in the different (but identical) NDPs
Etan Cohen38c3d5a2017-07-28 10:02:48 -0700961 for i in range(N + M):
Etan Cohena1e8d502017-08-16 09:28:18 -0700962 id, init_mac = autils.attach_with_identity(init_dut)
Etan Cohen38c3d5a2017-07-28 10:02:48 -0700963 init_ids.append(id)
Etan Cohena1e8d502017-08-16 09:28:18 -0700964 id, resp_mac = autils.attach_with_identity(resp_dut)
Etan Cohen38c3d5a2017-07-28 10:02:48 -0700965 resp_ids.append(id)
966
967 # wait for for devices to synchronize with each other - there are no other
968 # mechanisms to make sure this happens for OOB discovery (except retrying
969 # to execute the data-path request)
970 time.sleep(autils.WAIT_FOR_CLUSTER)
971
972 resp_req_keys = []
973 init_req_keys = []
974 resp_aware_ifs = []
975 init_aware_ifs = []
976
977 # issue N quick requests for identical NDPs - without waiting for result
978 # tests whether pre-setup multiple NDP procedure
979 for i in range(N):
980 # Responder: request network
981 resp_req_keys.append(autils.request_network(
982 resp_dut,
983 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
984 resp_ids[i], aconsts.DATA_PATH_RESPONDER, init_mac, None)))
985
986 # Initiator: request network
987 init_req_keys.append(autils.request_network(
988 init_dut,
989 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
990 init_ids[i], aconsts.DATA_PATH_INITIATOR, resp_mac, None)))
991
992 # remove the first request (hopefully before completed) testing that NDP
993 # is still created
994 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_keys[0])
995 resp_req_keys.remove(resp_req_keys[0])
996 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_keys[0])
997 init_req_keys.remove(init_req_keys[0])
998
999 # wait for network formation for all initial requests
1000 self.wait_for_request_responses(resp_dut, resp_req_keys, resp_aware_ifs)
1001 self.wait_for_request_responses(init_dut, init_req_keys, init_aware_ifs)
1002
Etan Cohenef38a7f2017-11-09 14:26:43 -08001003 # issue M more requests for the same NDPs - tests post-setup multiple NDP
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001004 for i in range(M):
1005 # Responder: request network
1006 resp_req_keys.append(autils.request_network(
1007 resp_dut,
1008 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1009 resp_ids[N + i], aconsts.DATA_PATH_RESPONDER, init_mac, None)))
1010
1011 # Initiator: request network
1012 init_req_keys.append(autils.request_network(
1013 init_dut,
1014 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1015 init_ids[N + i], aconsts.DATA_PATH_INITIATOR, resp_mac, None)))
1016
1017 # wait for network formation for all subsequent requests
1018 self.wait_for_request_responses(resp_dut, resp_req_keys[N - 1:],
1019 resp_aware_ifs)
1020 self.wait_for_request_responses(init_dut, init_req_keys[N - 1:],
1021 init_aware_ifs)
1022
1023 # determine whether all interfaces are identical (single NDP) - can't really
1024 # test the IPv6 address since it is not part of the callback event - it is
1025 # simply obtained from the system (so we'll always get the same for the same
1026 # interface)
1027 init_aware_ifs = list(set(init_aware_ifs))
1028 resp_aware_ifs = list(set(resp_aware_ifs))
1029
1030 self.log.info("Interface names: I=%s, R=%s", init_aware_ifs, resp_aware_ifs)
1031 self.log.info("Initiator requests: %s", init_req_keys)
1032 self.log.info("Responder requests: %s", resp_req_keys)
1033
1034 asserts.assert_equal(
1035 len(init_aware_ifs), 1, "Multiple initiator interfaces")
1036 asserts.assert_equal(
1037 len(resp_aware_ifs), 1, "Multiple responder interfaces")
1038
1039 self.log.info("Interface IPv6 (using ifconfig): I=%s, R=%s",
1040 autils.get_ipv6_addr(init_dut, init_aware_ifs[0]),
1041 autils.get_ipv6_addr(resp_dut, resp_aware_ifs[0]))
1042
1043 for i in range(init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]):
1044 if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
1045 init_ipv6 = autils.get_ipv6_addr(init_dut, if_name)
1046 resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name)
1047
1048 asserts.assert_equal(
1049 init_ipv6 is None, if_name not in init_aware_ifs,
1050 "Initiator interface %s in unexpected state" % if_name)
1051 asserts.assert_equal(
1052 resp_ipv6 is None, if_name not in resp_aware_ifs,
1053 "Responder interface %s in unexpected state" % if_name)
1054
1055 # release requests
1056 for resp_req_key in resp_req_keys:
1057 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
1058 for init_req_key in init_req_keys:
1059 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohena1e8d502017-08-16 09:28:18 -07001060
Etan Cohenef38a7f2017-11-09 14:26:43 -08001061 def test_identical_network_from_both_sides(self):
1062 """Validate that requesting two identical NDPs (Open) each being initiated
1063 from a different side, results in the same/single NDP.
1064
1065 Verify that the interface and IPv6 address is the same for all networks.
1066 """
1067 dut1 = self.android_devices[0]
1068 dut2 = self.android_devices[1]
1069
1070 id1, mac1 = autils.attach_with_identity(dut1)
1071 id2, mac2 = autils.attach_with_identity(dut2)
1072
1073 # wait for for devices to synchronize with each other - there are no other
1074 # mechanisms to make sure this happens for OOB discovery (except retrying
1075 # to execute the data-path request)
1076 time.sleep(autils.WAIT_FOR_CLUSTER)
1077
1078 # first NDP: DUT1 (Init) -> DUT2 (Resp)
1079 req_a_resp = autils.request_network(dut2,
1080 dut2.droid.wifiAwareCreateNetworkSpecifierOob(
1081 id2, aconsts.DATA_PATH_RESPONDER,
1082 mac1))
1083
1084 req_a_init = autils.request_network(dut1,
1085 dut1.droid.wifiAwareCreateNetworkSpecifierOob(
1086 id1, aconsts.DATA_PATH_INITIATOR,
1087 mac2))
1088
1089 req_a_resp_event = autils.wait_for_event_with_keys(
1090 dut2, cconsts.EVENT_NETWORK_CALLBACK,
1091 autils.EVENT_NDP_TIMEOUT,
1092 (cconsts.NETWORK_CB_KEY_EVENT,
1093 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1094 (cconsts.NETWORK_CB_KEY_ID, req_a_resp))
1095 req_a_init_event = autils.wait_for_event_with_keys(
1096 dut1, cconsts.EVENT_NETWORK_CALLBACK,
1097 autils.EVENT_NDP_TIMEOUT,
1098 (cconsts.NETWORK_CB_KEY_EVENT,
1099 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1100 (cconsts.NETWORK_CB_KEY_ID, req_a_init))
1101
1102 req_a_if_resp = req_a_resp_event["data"][
1103 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1104 req_a_if_init = req_a_init_event["data"][
1105 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1106 self.log.info("Interface names for A: I=%s, R=%s", req_a_if_init,
1107 req_a_if_resp)
1108
1109 req_a_ipv6_resp = \
1110 dut2.droid.connectivityGetLinkLocalIpv6Address(req_a_if_resp).split("%")[0]
1111 req_a_ipv6_init = \
1112 dut1.droid.connectivityGetLinkLocalIpv6Address(req_a_if_init).split("%")[0]
1113 self.log.info("Interface addresses (IPv6) for A: I=%s, R=%s",
1114 req_a_ipv6_init, req_a_ipv6_resp)
1115
1116 # second NDP: DUT2 (Init) -> DUT1 (Resp)
1117 req_b_resp = autils.request_network(dut1,
1118 dut1.droid.wifiAwareCreateNetworkSpecifierOob(
1119 id1, aconsts.DATA_PATH_RESPONDER,
1120 mac2))
1121
1122 req_b_init = autils.request_network(dut2,
1123 dut2.droid.wifiAwareCreateNetworkSpecifierOob(
1124 id2, aconsts.DATA_PATH_INITIATOR,
1125 mac1))
1126
1127 req_b_resp_event = autils.wait_for_event_with_keys(
1128 dut1, cconsts.EVENT_NETWORK_CALLBACK,
1129 autils.EVENT_NDP_TIMEOUT,
1130 (cconsts.NETWORK_CB_KEY_EVENT,
1131 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1132 (cconsts.NETWORK_CB_KEY_ID, req_b_resp))
1133 req_b_init_event = autils.wait_for_event_with_keys(
1134 dut2, cconsts.EVENT_NETWORK_CALLBACK,
1135 autils.EVENT_NDP_TIMEOUT,
1136 (cconsts.NETWORK_CB_KEY_EVENT,
1137 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1138 (cconsts.NETWORK_CB_KEY_ID, req_b_init))
1139
1140 req_b_if_resp = req_b_resp_event["data"][
1141 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1142 req_b_if_init = req_b_init_event["data"][
1143 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1144 self.log.info("Interface names for B: I=%s, R=%s", req_b_if_init,
1145 req_b_if_resp)
1146
1147 req_b_ipv6_resp = \
1148 dut1.droid.connectivityGetLinkLocalIpv6Address(req_b_if_resp).split("%")[0]
1149 req_b_ipv6_init = \
1150 dut2.droid.connectivityGetLinkLocalIpv6Address(req_b_if_init).split("%")[0]
1151 self.log.info("Interface addresses (IPv6) for B: I=%s, R=%s",
1152 req_b_ipv6_init, req_b_ipv6_resp)
1153
1154 # validate equality of NDPs (using interface names & ipv6)
1155 asserts.assert_equal(req_a_if_init, req_b_if_resp,
1156 "DUT1 NDPs are on different interfaces")
1157 asserts.assert_equal(req_a_if_resp, req_b_if_init,
1158 "DUT2 NDPs are on different interfaces")
1159 asserts.assert_equal(req_a_ipv6_init, req_b_ipv6_resp,
1160 "DUT1 NDPs are using different IPv6 addresses")
1161 asserts.assert_equal(req_a_ipv6_resp, req_b_ipv6_init,
1162 "DUT2 NDPs are using different IPv6 addresses")
1163
1164 # release requests
1165 dut1.droid.connectivityUnregisterNetworkCallback(req_a_init)
1166 dut1.droid.connectivityUnregisterNetworkCallback(req_b_resp)
1167 dut2.droid.connectivityUnregisterNetworkCallback(req_a_resp)
1168 dut2.droid.connectivityUnregisterNetworkCallback(req_b_init)
1169
Etan Cohena1e8d502017-08-16 09:28:18 -07001170 ########################################################################
1171
1172 def run_multiple_ndi(self, sec_configs):
1173 """Validate that the device can create and use multiple NDIs.
1174
1175 The security configuration can be:
1176 - None: open
1177 - String: passphrase
1178 - otherwise: PMK (byte array)
1179
1180 Args:
1181 sec_configs: list of security configurations
1182 """
1183 init_dut = self.android_devices[0]
1184 init_dut.pretty_name = "Initiator"
1185 resp_dut = self.android_devices[1]
1186 resp_dut.pretty_name = "Responder"
1187
1188 asserts.skip_if(init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]
1189 < len(sec_configs) or
1190 resp_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]
1191 < len(sec_configs),
1192 "Initiator or Responder do not support multiple NDIs")
1193
1194 init_id, init_mac = autils.attach_with_identity(init_dut)
1195 resp_id, resp_mac = autils.attach_with_identity(resp_dut)
1196
1197 # wait for for devices to synchronize with each other - there are no other
1198 # mechanisms to make sure this happens for OOB discovery (except retrying
1199 # to execute the data-path request)
1200 time.sleep(autils.WAIT_FOR_CLUSTER)
1201
1202 resp_req_keys = []
1203 init_req_keys = []
1204 resp_aware_ifs = []
1205 init_aware_ifs = []
1206
1207 for sec in sec_configs:
1208 # Responder: request network
1209 resp_req_key = autils.request_network(resp_dut,
1210 autils.get_network_specifier(
1211 resp_dut, resp_id,
1212 aconsts.DATA_PATH_RESPONDER,
1213 init_mac, sec))
1214 resp_req_keys.append(resp_req_key)
1215
1216 # Initiator: request network
1217 init_req_key = autils.request_network(init_dut,
1218 autils.get_network_specifier(
1219 init_dut, init_id,
1220 aconsts.DATA_PATH_INITIATOR,
1221 resp_mac, sec))
1222 init_req_keys.append(init_req_key)
1223
1224 # Wait for network
1225 init_net_event = autils.wait_for_event_with_keys(
1226 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT,
1227 (cconsts.NETWORK_CB_KEY_EVENT,
1228 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1229 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
1230 resp_net_event = autils.wait_for_event_with_keys(
1231 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT,
1232 (cconsts.NETWORK_CB_KEY_EVENT,
1233 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1234 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
1235
1236 resp_aware_ifs.append(
1237 resp_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME])
1238 init_aware_ifs.append(
1239 init_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME])
1240
1241 # check that we are using 2 NDIs
1242 init_aware_ifs = list(set(init_aware_ifs))
1243 resp_aware_ifs = list(set(resp_aware_ifs))
1244
1245 self.log.info("Interface names: I=%s, R=%s", init_aware_ifs, resp_aware_ifs)
1246 self.log.info("Initiator requests: %s", init_req_keys)
1247 self.log.info("Responder requests: %s", resp_req_keys)
1248
1249 asserts.assert_equal(
1250 len(init_aware_ifs), len(sec_configs), "Multiple initiator interfaces")
1251 asserts.assert_equal(
1252 len(resp_aware_ifs), len(sec_configs), "Multiple responder interfaces")
1253
1254 for i in range(len(sec_configs)):
1255 if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
1256 init_ipv6 = autils.get_ipv6_addr(init_dut, if_name)
1257 resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name)
1258
1259 asserts.assert_equal(
1260 init_ipv6 is None, if_name not in init_aware_ifs,
1261 "Initiator interface %s in unexpected state" % if_name)
1262 asserts.assert_equal(
1263 resp_ipv6 is None, if_name not in resp_aware_ifs,
1264 "Responder interface %s in unexpected state" % if_name)
1265
1266 # release requests
1267 for resp_req_key in resp_req_keys:
1268 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
1269 for init_req_key in init_req_keys:
1270 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
1271
Etan Cohenb199cd12017-09-22 10:20:44 -07001272 @test_tracker_info(uuid="2d728163-11cc-46ba-a973-c8e1e71397fc")
Etan Cohena1e8d502017-08-16 09:28:18 -07001273 def test_multiple_ndi_open_passphrase(self):
1274 """Verify that can between 2 DUTs can create 2 NDPs with different security
1275 configuration (one open, one using passphrase). The result should use two
1276 different NDIs"""
1277 self.run_multiple_ndi([None, self.PASSPHRASE])
1278
Etan Cohenb199cd12017-09-22 10:20:44 -07001279 @test_tracker_info(uuid="5f2c32aa-20b2-41f0-8b1e-d0b68df73ada")
Etan Cohena1e8d502017-08-16 09:28:18 -07001280 def test_multiple_ndi_open_pmk(self):
1281 """Verify that can between 2 DUTs can create 2 NDPs with different security
1282 configuration (one open, one using pmk). The result should use two
1283 different NDIs"""
1284 self.run_multiple_ndi([None, self.PMK])
1285
Etan Cohenb199cd12017-09-22 10:20:44 -07001286 @test_tracker_info(uuid="34467659-bcfb-40cd-ba25-7e50560fca63")
Etan Cohena1e8d502017-08-16 09:28:18 -07001287 def test_multiple_ndi_passphrase_pmk(self):
1288 """Verify that can between 2 DUTs can create 2 NDPs with different security
1289 configuration (one using passphrase, one using pmk). The result should use
1290 two different NDIs"""
1291 self.run_multiple_ndi([self.PASSPHRASE, self.PMK])
1292
Etan Cohenb199cd12017-09-22 10:20:44 -07001293 @test_tracker_info(uuid="d9194ce6-45b6-41b1-9cc8-ada79968966d")
Etan Cohena1e8d502017-08-16 09:28:18 -07001294 def test_multiple_ndi_passphrases(self):
1295 """Verify that can between 2 DUTs can create 2 NDPs with different security
1296 configuration (using different passphrases). The result should use two
1297 different NDIs"""
1298 self.run_multiple_ndi([self.PASSPHRASE, self.PASSPHRASE2])
1299
Etan Cohenb199cd12017-09-22 10:20:44 -07001300 @test_tracker_info(uuid="879df795-62d2-40d4-a862-bd46d8f7e67f")
Etan Cohena1e8d502017-08-16 09:28:18 -07001301 def test_multiple_ndi_pmks(self):
1302 """Verify that can between 2 DUTs can create 2 NDPs with different security
1303 configuration (using different PMKS). The result should use two different
1304 NDIs"""
1305 self.run_multiple_ndi([self.PMK, self.PMK2])