diff options
author | Steven Liu <steveliu@google.com> | 2019-08-19 14:32:09 -0700 |
---|---|---|
committer | Steven Liu <steveliu@google.com> | 2019-10-29 14:42:50 -0700 |
commit | e4cb48546eff7305a98b11646fd991d213345630 (patch) | |
tree | 702b4abc03500c618838a3cbb3dc0a4b3c7de69d /tests | |
parent | 2bf5f0154051d5e31f8e553803dae38bc6fad421 (diff) |
Add carrier ID field for WifiConfiguration and PasspointConfiguration.
This is only for the load and save carrier ID field.
Bug: 130875004
Test: build, boot up, unit test.
Change-Id: Ie190fc331862a61df29a7ad4a01b818a016122bf
Diffstat (limited to 'tests')
3 files changed, 59 insertions, 3 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java index 6032680b6..d9b565494 100644 --- a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java @@ -103,6 +103,7 @@ public class NetworkListStoreDataTest extends WifiBaseTest { + "<long-array name=\"RoamingConsortiumOIs\" num=\"0\" />\n" + "<string name=\"RandomizedMacAddress\">%s</string>\n" + "<int name=\"MacRandomizationSetting\" value=\"1\" />\n" + + "<int name=\"CarrierId\" value=\"-1\" />\n" + "</WifiConfiguration>\n" + "<NetworkStatus>\n" + "<string name=\"SelectionStatus\">NETWORK_SELECTION_ENABLED</string>\n" @@ -159,6 +160,7 @@ public class NetworkListStoreDataTest extends WifiBaseTest { + "<long-array name=\"RoamingConsortiumOIs\" num=\"0\" />\n" + "<string name=\"RandomizedMacAddress\">%s</string>\n" + "<int name=\"MacRandomizationSetting\" value=\"1\" />\n" + + "<int name=\"CarrierId\" value=\"-1\" />\n" + "</WifiConfiguration>\n" + "<NetworkStatus>\n" + "<string name=\"SelectionStatus\">NETWORK_SELECTION_ENABLED</string>\n" diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java index 799ad70f0..5eba36461 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java @@ -123,6 +123,7 @@ public class WifiConfigStoreTest extends WifiBaseTest { + "<long-array name=\"RoamingConsortiumOIs\" num=\"0\" />\n" + "<string name=\"RandomizedMacAddress\">%s</string>\n" + "<int name=\"MacRandomizationSetting\" value=\"1\" />\n" + + "<int name=\"CarrierId\" value=\"-1\" />\n" + "</WifiConfiguration>\n" + "<NetworkStatus>\n" + "<string name=\"SelectionStatus\">NETWORK_SELECTION_ENABLED</string>\n" diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java index 0726514bb..5755c5858 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -91,6 +91,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { private static final String TEST_FQDN = "FQDN"; private static final int TEST_UID_1 = 5667; private static final int TEST_UID_2 = 4537; + private static final int VALID_CARRIER_ID = 1; private @Mock Context mContext; private @Mock Resources mResources; @@ -1137,7 +1138,6 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS, mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1, TEST_PACKAGE_1)); - verify(mWifiPermissionsUtil).checkNetworkCarrierProvisioningPermission(TEST_UID_1); assertFalse(mWifiNetworkSuggestionsManager.hasUserApprovedForApp(TEST_PACKAGE_1)); WifiConfiguration connectNetwork = @@ -1176,7 +1176,6 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS, mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1, TEST_PACKAGE_1)); - verify(mWifiPermissionsUtil).checkNetworkCarrierProvisioningPermission(TEST_UID_1); mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1); WifiConfiguration connectNetwork = @@ -1215,7 +1214,6 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS, mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1, TEST_PACKAGE_1)); - verify(mWifiPermissionsUtil).checkNetworkCarrierProvisioningPermission(TEST_UID_1); mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1); doThrow(new SecurityException()) @@ -2400,4 +2398,59 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { assertNotNull(mBroadcastReceiverCaptor.getValue()); mBroadcastReceiverCaptor.getValue().onReceive(mContext, intent); } + + @Test + public void testAddSuggestionWithValidCarrierIdWithCarrierProvisionPermission() { + WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); + config.carrierId = VALID_CARRIER_ID; + WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion( + config, null, true, false, TEST_UID_1, + TEST_PACKAGE_1); + List<WifiNetworkSuggestion> networkSuggestionList = new ArrayList<>(); + networkSuggestionList.add(networkSuggestion); + when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(TEST_UID_1)) + .thenReturn(true); + + int status = mWifiNetworkSuggestionsManager + .add(networkSuggestionList, TEST_UID_1, TEST_APP_NAME_1); + + assertEquals(status, WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS); + + } + + @Test + public void testAddSuggestionWithValidCarrierIdWithoutCarrierProvisionPermission() { + WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); + config.carrierId = VALID_CARRIER_ID; + WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion( + config, null, true, false, TEST_UID_1, + TEST_PACKAGE_1); + List<WifiNetworkSuggestion> networkSuggestionList = new ArrayList<>(); + networkSuggestionList.add(networkSuggestion); + when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(TEST_UID_1)) + .thenReturn(false); + + int status = mWifiNetworkSuggestionsManager + .add(networkSuggestionList, TEST_UID_1, TEST_APP_NAME_1); + + assertEquals(status, + WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_APP_DISALLOWED); + } + + @Test + public void testAddSuggestionWithDefaultCarrierIdWithoutCarrierProvisionPermission() { + WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); + WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion( + config, null, true, false, TEST_UID_1, + TEST_PACKAGE_1); + List<WifiNetworkSuggestion> networkSuggestionList = new ArrayList<>(); + networkSuggestionList.add(networkSuggestion); + when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(TEST_UID_1)) + .thenReturn(false); + + int status = mWifiNetworkSuggestionsManager + .add(networkSuggestionList, TEST_UID_1, TEST_APP_NAME_1); + + assertEquals(status, WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS); + } } |