summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorarangelov <arangelov@google.com>2020-06-23 13:40:04 +0100
committerarangelov <arangelov@google.com>2020-06-23 13:54:30 +0100
commit8dfba0e35b584fe4a1a1fad1110168009d4dbef1 (patch)
treef112cb9aaddce2672edabe339674b61c0b131dd0 /tests
parentbb47b319352980ed1f65336cece756707ccc7e1b (diff)
Allow NETWORK_MANAGED_PROVISIONING to modify proxy settings.
Bug: 159606385 Test: manual Test: atest WifiConfigManagerTest Change-Id: I9bf6c900bf68aa18cb775929a6ac36d3c066cc33
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java36
1 files changed, 33 insertions, 3 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index dcd0fa8c5..0559c6385 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -4006,6 +4006,33 @@ public class WifiConfigManagerTest extends WifiBaseTest {
true, // assertSuccess
WifiConfiguration.INVALID_NETWORK_ID); // Update networkID
}
+
+ /**
+ * Verifies that adding a network with a PAC or STATIC proxy, while having the
+ * {@link android.Manifest.permission#NETWORK_MANAGED_PROVISIONING} permission is successful
+ */
+ @Test
+ public void testAddNetworkWithProxyWithNetworkManagedPermission() {
+ verifyAddOrUpdateNetworkWithProxySettingsAndPermissions(
+ false, // withNetworkSettings
+ false, // withNetworkSetupWizard
+ true, // withNetworkManagedProvisioning
+ false, // withProfileOwnerPolicy
+ false, // withDeviceOwnerPolicy
+ WifiConfigurationTestUtil.createDHCPIpConfigurationWithPacProxy(),
+ true, // assertSuccess
+ WifiConfiguration.INVALID_NETWORK_ID); // Update networkID
+ verifyAddOrUpdateNetworkWithProxySettingsAndPermissions(
+ false, // withNetworkSettings
+ false, // withNetworkSetupWizard
+ true, // withNetworkManagedProvisioning
+ false, // withProfileOwnerPolicy
+ false, // withDeviceOwnerPolicy
+ WifiConfigurationTestUtil.createDHCPIpConfigurationWithStaticProxy(),
+ true, // assertSuccess
+ WifiConfiguration.INVALID_NETWORK_ID); // Update networkID
+ }
+
/**
* Verifies that updating a network (that has no proxy) and adding a PAC or STATIC proxy fails
* without being able to override configs, or holding Device or Profile owner policies.
@@ -4055,7 +4082,7 @@ public class WifiConfigManagerTest extends WifiBaseTest {
verifyAddOrUpdateNetworkWithProxySettingsAndPermissions(
false, // withNetworkSettings
true, // withNetworkSetupWizard
- false, // withProfileOwnerPolicy
+ false, false, // withProfileOwnerPolicy
false, // withDeviceOwnerPolicy
WifiConfigurationTestUtil.createDHCPIpConfigurationWithPacProxy(),
true, // assertSuccess
@@ -4636,13 +4663,14 @@ public class WifiConfigManagerTest extends WifiBaseTest {
boolean assertSuccess,
int networkId) {
return verifyAddOrUpdateNetworkWithProxySettingsAndPermissions(withNetworkSettings,
- false, withProfileOwnerPolicy, withDeviceOwnerPolicy, ipConfiguration,
+ false, false, withProfileOwnerPolicy, withDeviceOwnerPolicy, ipConfiguration,
assertSuccess, networkId);
}
private NetworkUpdateResult verifyAddOrUpdateNetworkWithProxySettingsAndPermissions(
boolean withNetworkSettings,
boolean withNetworkSetupWizard,
+ boolean withNetworkManagedProvisioning,
boolean withProfileOwnerPolicy,
boolean withDeviceOwnerPolicy,
IpConfiguration ipConfiguration,
@@ -4663,7 +4691,9 @@ public class WifiConfigManagerTest extends WifiBaseTest {
.thenReturn(withNetworkSettings);
when(mWifiPermissionsUtil.checkNetworkSetupWizardPermission(anyInt()))
.thenReturn(withNetworkSetupWizard);
- int uid = withNetworkSettings || withNetworkSetupWizard
+ when(mWifiPermissionsUtil.checkNetworkManagedProvisioningPermission(anyInt()))
+ .thenReturn(withNetworkManagedProvisioning);
+ int uid = withNetworkSettings || withNetworkSetupWizard || withNetworkManagedProvisioning
? TEST_CREATOR_UID
: TEST_NO_PERM_UID;
NetworkUpdateResult result = addNetworkToWifiConfigManager(network, uid);