diff options
author | Etan Cohen <etancohen@google.com> | 2017-07-14 12:13:53 -0700 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2017-07-14 16:03:58 -0700 |
commit | e24b61801dbf5c1470254e946e1b2f47f9392fda (patch) | |
tree | 65c6b6b52b86a0a27f775a72178495382505541f /tests | |
parent | 3dd02f1e60b930f59d33c462aa2daefb4baf65e5 (diff) |
[AWARE] Abort data-path setup if there are no data-interfaces
Data-interfaces are currently checked only when the data-path setup
process starts. Add checks when actually using data-interface name
and abort process if a data-interface is no longer available.
Bug: 63702690
Test: unit tests + integration tests passing
Change-Id: I922e157228762fc923fd26b350b625724b94ef06
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java index f3927357f..806300423 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java @@ -26,6 +26,7 @@ import static org.mockito.ArgumentMatchers.anyByte; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyShort; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; @@ -290,6 +291,60 @@ public class WifiAwareDataPathStateManagerTest { verifyNoMoreInteractions(mMockNative, mMockCm, mAwareMetricsMock); } + /** + * Validate that if the data-interfaces are deleted while a data-path is being created, the + * process will terminate. + */ + @Test + public void testDestroyNdiDuringNdpSetupResponder() throws Exception { + final int clientId = 123; + final byte pubSubId = 55; + final int requestorId = 1341234; + final byte[] peerDiscoveryMac = HexEncoding.decode("000102030405".toCharArray(), false); + final int ndpId = 3; + + InOrder inOrder = inOrder(mMockNative, mMockCm, mMockCallback, mMockSessionCallback); + InOrder inOrderM = inOrder(mAwareMetricsMock); + + ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); + + // (0) initialize + DataPathEndPointInfo res = initDataPathEndPoint(clientId, pubSubId, requestorId, + peerDiscoveryMac, inOrder, inOrderM, true); + + // (1) request network + NetworkRequest nr = getSessionNetworkRequest(clientId, res.mSessionId, res.mPeerHandle, + null, null, true); + + Message reqNetworkMsg = Message.obtain(); + reqNetworkMsg.what = NetworkFactory.CMD_REQUEST_NETWORK; + reqNetworkMsg.obj = nr; + reqNetworkMsg.arg1 = 0; + res.mMessenger.send(reqNetworkMsg); + mMockLooper.dispatchAll(); + + // (2) delete interface(s) + mDut.deleteAllDataPathInterfaces(); + mMockLooper.dispatchAll(); + inOrder.verify(mMockNative).deleteAwareNetworkInterface(transactionId.capture(), + anyString()); + mDut.onDeleteDataPathInterfaceResponse(transactionId.getValue(), true, 0); + mMockLooper.dispatchAll(); + + // (3) have responder receive request + mDut.onDataPathRequestNotification(pubSubId, peerDiscoveryMac, ndpId); + mMockLooper.dispatchAll(); + + // (4) verify that responder aborts (i.e. refuses request) + inOrder.verify(mMockNative).respondToDataPathRequest(transactionId.capture(), eq(false), + eq(ndpId), eq(""), eq(null), eq(null), eq(false), any()); + mDut.onRespondToDataPathSetupRequestResponse(transactionId.getValue(), true, 0); + mMockLooper.dispatchAll(); + + // failure if there's further activity + verifyNoMoreInteractions(mMockNative, mMockCm, mAwareMetricsMock); + } + /* * Initiator tests */ |