summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-06-07 11:27:34 -0700
committerRoshan Pius <rpius@google.com>2019-06-07 13:35:59 -0700
commit5574a79d435528ded31153e07c24acd25127c703 (patch)
treeac28e770c767b3d6bb847373ffe0389bd421b2a4 /tests
parent92f61910b2b2615d6a062366dc365a5f3597468d (diff)
WifiNetworkFactory: Reject requests for internet with specifier
Reject any NetworkRequest with WifiNetworkSpecifier attached and has INTERNET capability set. This will otherwise trigger an unwanted connection which will be torn down by connectivity service immediately (because WifiNetworkAgent will not have INTERNET capability & hence will never match the app's request). Bug: 134735892 Test: atest com.android.server.wifi Test: act.py -c wifi_manager_cross.config -tb dut-name -tc WifiNetworkRequestTest Test: CtsVerifier tests Change-Id: Ia9932379825cec7777baf92e058cd04d181ffc0b
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
index 118b96245..d4e6594c8 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
@@ -279,6 +279,24 @@ public class WifiNetworkFactoryTest {
}
/**
+ * Validates handling of acceptNetwork with a network specifier with internet capability.
+ */
+ @Test
+ public void testHandleAcceptNetworkRequestFromWithInternetCapability() throws Exception {
+ when(mActivityManager.getPackageImportance(TEST_PACKAGE_NAME_1))
+ .thenReturn(IMPORTANCE_FOREGROUND);
+
+ WifiNetworkSpecifier specifier = createWifiNetworkSpecifier(TEST_UID_1, false);
+ mNetworkRequest.networkCapabilities.setNetworkSpecifier(specifier);
+ mNetworkRequest.networkCapabilities.addCapability(
+ NetworkCapabilities.NET_CAPABILITY_INTERNET);
+
+ assertFalse(mWifiNetworkFactory.acceptRequest(mNetworkRequest, 0));
+ mLooper.dispatchAll();
+ verifyUnfullfillableDispatched(mConnectivityMessenger);
+ }
+
+ /**
* Validates handling of acceptNetwork with a network specifier from a non foreground
* app/service.
*/
@@ -499,6 +517,21 @@ public class WifiNetworkFactoryTest {
}
/**
+ * Validates handling of new network request with network specifier with internet capability.
+ */
+ @Test
+ public void testHandleNetworkRequestWithSpecifierAndInternetCapability() throws Exception {
+ WifiNetworkSpecifier specifier = createWifiNetworkSpecifier(TEST_UID_1, false);
+ mNetworkRequest.networkCapabilities.setNetworkSpecifier(specifier);
+ mNetworkRequest.networkCapabilities.addCapability(
+ NetworkCapabilities.NET_CAPABILITY_INTERNET);
+
+ mWifiNetworkFactory.needNetworkFor(mNetworkRequest, 0);
+ mLooper.dispatchAll();
+ verifyUnfullfillableDispatched(mConnectivityMessenger);
+ }
+
+ /**
* Verify handling of new network request with network specifier for a hidden network.
*/
@Test