diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java index a66fcdb0ba..8e66cb8953 100644 --- a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java +++ b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java @@ -509,164 +509,6 @@ public class WifiManagerTest extends AndroidTestCase { assertTrue(i < 15); } - /** - * Verify Passpoint configuration management APIs (add, remove, get) for a Passpoint - * configuration with an user credential. - * - * @throws Exception - */ - public void testAddPasspointConfigWithUserCredential() throws Exception { - if (!WifiFeature.isWifiSupported(getContext())) { - // skip the test if WiFi is not supported - return; - } - testAddPasspointConfig(generatePasspointConfig(generateUserCredential())); - } - - /** - * Verify Passpoint configuration management APIs (add, remove, get) for a Passpoint - * configuration with a certificate credential. - * - * @throws Exception - */ - public void testAddPasspointConfigWithCertCredential() throws Exception { - if (!WifiFeature.isWifiSupported(getContext())) { - // skip the test if WiFi is not supported - return; - } - testAddPasspointConfig(generatePasspointConfig(generateCertCredential())); - } - - /** - * Verify Passpoint configuration management APIs (add, remove, get) for a Passpoint - * configuration with a SIm credential. - * - * @throws Exception - */ - public void testAddPasspointConfigWithSimCredential() throws Exception { - if (!WifiFeature.isWifiSupported(getContext())) { - // skip the test if WiFi is not supported - return; - } - testAddPasspointConfig(generatePasspointConfig(generateSimCredential())); - } - - /** - * Helper function for generating a {@link PasspointConfiguration} for testing. - * - * @return {@link PasspointConfiguration} - */ - private PasspointConfiguration generatePasspointConfig(Credential credential) { - PasspointConfiguration config = new PasspointConfiguration(); - config.setCredential(credential); - - // Setup HomeSp. - HomeSp homeSp = new HomeSp(); - homeSp.setFqdn("Test.com"); - homeSp.setFriendlyName("Test Provider"); - homeSp.setRoamingConsortiumOis(new long[] {0x11223344}); - config.setHomeSp(homeSp); - - return config; - } - - /** - * Helper function for generating an user credential for testing. - * - * @return {@link Credential} - */ - private Credential generateUserCredential() { - Credential credential = new Credential(); - credential.setRealm("test.net"); - Credential.UserCredential userCred = new Credential.UserCredential(); - userCred.setEapType(21 /* EAP_TTLS */); - userCred.setUsername("username"); - userCred.setPassword("password"); - userCred.setNonEapInnerMethod("PAP"); - credential.setUserCredential(userCred); - credential.setCaCertificate(FakeKeys.CA_PUBLIC_CERT); - return credential; - } - - /** - * Helper function for generating a certificate credential for testing. - * - * @return {@link Credential} - */ - private Credential generateCertCredential() throws Exception { - Credential credential = new Credential(); - credential.setRealm("test.net"); - Credential.CertificateCredential certCredential = new Credential.CertificateCredential(); - certCredential.setCertType("x509v3"); - certCredential.setCertSha256Fingerprint( - MessageDigest.getInstance("SHA-256").digest(FakeKeys.CLIENT_CERT.getEncoded())); - credential.setCertCredential(certCredential); - credential.setCaCertificate(FakeKeys.CA_PUBLIC_CERT); - credential.setClientCertificateChain(new X509Certificate[] {FakeKeys.CLIENT_CERT}); - credential.setClientPrivateKey(FakeKeys.RSA_KEY1); - return credential; - } - - /** - * Helper function for generating a SIM credential for testing. - * - * @return {@link Credential} - */ - private Credential generateSimCredential() throws Exception { - Credential credential = new Credential(); - credential.setRealm("test.net"); - Credential.SimCredential simCredential = new Credential.SimCredential(); - simCredential.setImsi("1234*"); - simCredential.setEapType(18 /* EAP_SIM */); - credential.setSimCredential(simCredential); - return credential; - } - - /** - * Helper function verifying Passpoint configuration management APIs (add, remove, get) for - * a given configuration. - * - * @param config The configuration to test with - */ - private void testAddPasspointConfig(PasspointConfiguration config) throws Exception { - try { - - // obtain number of passpoint networks already present in device (preloaded) - List preConfigList = mWifiManager.getPasspointConfigurations(); - int numOfNetworks = preConfigList.size(); - - // add new (test) configuration - mWifiManager.addOrUpdatePasspointConfiguration(config); - - // Certificates and keys will be set to null after it is installed to the KeyStore by - // WifiManager. Reset them in the expected config so that it can be used to compare - // against the retrieved config. - config.getCredential().setCaCertificate(null); - config.getCredential().setClientCertificateChain(null); - config.getCredential().setClientPrivateKey(null); - - // retrieve the configuration and verify it. The retrieved list may not be in order - - // check all configs to see if any match - List configList = mWifiManager.getPasspointConfigurations(); - assertEquals(numOfNetworks + 1, configList.size()); - - boolean anyMatch = false; - for (PasspointConfiguration passpointConfiguration : configList) { - if (passpointConfiguration.equals(config)) { - anyMatch = true; - break; - } - } - assertTrue(anyMatch); - - // remove the (test) configuration and verify number of installed configurations - mWifiManager.removePasspointConfiguration(config.getHomeSp().getFqdn()); - assertEquals(mWifiManager.getPasspointConfigurations().size(), numOfNetworks); - } catch (UnsupportedOperationException e) { - // Passpoint build config |config_wifi_hotspot2_enabled| is disabled, so noop. - } - } - public class TestLocalOnlyHotspotCallback extends WifiManager.LocalOnlyHotspotCallback { Object hotspotLock; WifiManager.LocalOnlyHotspotReservation reservation = null;