use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.
the class NetworkSecurityConfigTests method testEmptyPerNetworkSecurityConfig.
public void testEmptyPerNetworkSecurityConfig() throws Exception {
ArraySet<Pair<Domain, NetworkSecurityConfig>> domainMap = new ArraySet<Pair<Domain, NetworkSecurityConfig>>();
domainMap.add(new Pair<Domain, NetworkSecurityConfig>(new Domain("android.com", true), getEmptyConfig()));
NetworkSecurityConfig defaultConfig = getSystemStoreConfig();
SSLContext context = TestUtils.getSSLContext(new TestConfigSource(domainMap, defaultConfig));
TestUtils.assertConnectionFails(context, "android.com", 443);
TestUtils.assertConnectionSucceeds(context, "google.com", 443);
}
use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.
the class NetworkSecurityConfigTests method testMostSpecificNetworkSecurityConfig.
public void testMostSpecificNetworkSecurityConfig() throws Exception {
ArraySet<Pair<Domain, NetworkSecurityConfig>> domainMap = new ArraySet<Pair<Domain, NetworkSecurityConfig>>();
domainMap.add(new Pair<Domain, NetworkSecurityConfig>(new Domain("android.com", true), getEmptyConfig()));
domainMap.add(new Pair<Domain, NetworkSecurityConfig>(new Domain("developer.android.com", false), getSystemStoreConfig()));
SSLContext context = TestUtils.getSSLContext(new TestConfigSource(domainMap, getEmptyConfig()));
TestUtils.assertConnectionFails(context, "android.com", 443);
TestUtils.assertConnectionSucceeds(context, "developer.android.com", 443);
}
use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.
the class NetworkSecurityConfigTests method testOverridePins.
public void testOverridePins() throws Exception {
// Use a bad pin + granting the system CA store the ability to override pins.
ArraySet<Pin> pins = new ArraySet<Pin>();
pins.add(new Pin("SHA-256", new byte[0]));
NetworkSecurityConfig domain = new NetworkSecurityConfig.Builder().setPinSet(new PinSet(pins, Long.MAX_VALUE)).addCertificatesEntryRef(new CertificatesEntryRef(SystemCertificateSource.getInstance(), true)).build();
ArraySet<Pair<Domain, NetworkSecurityConfig>> domainMap = new ArraySet<Pair<Domain, NetworkSecurityConfig>>();
domainMap.add(new Pair<Domain, NetworkSecurityConfig>(new Domain("android.com", true), domain));
SSLContext context = TestUtils.getSSLContext(new TestConfigSource(domainMap, getEmptyConfig()));
TestUtils.assertConnectionSucceeds(context, "android.com", 443);
}
use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.
the class NetworkSecurityConfigTests method testSubdomainIncluded.
public void testSubdomainIncluded() throws Exception {
// First try connecting to a subdomain of a domain entry that includes subdomains.
ArraySet<Pair<Domain, NetworkSecurityConfig>> domainMap = new ArraySet<Pair<Domain, NetworkSecurityConfig>>();
domainMap.add(new Pair<Domain, NetworkSecurityConfig>(new Domain("android.com", true), getSystemStoreConfig()));
SSLContext context = TestUtils.getSSLContext(new TestConfigSource(domainMap, getEmptyConfig()));
TestUtils.assertConnectionSucceeds(context, "developer.android.com", 443);
// Now try without including subdomains.
domainMap = new ArraySet<Pair<Domain, NetworkSecurityConfig>>();
domainMap.add(new Pair<Domain, NetworkSecurityConfig>(new Domain("android.com", false), getSystemStoreConfig()));
context = TestUtils.getSSLContext(new TestConfigSource(domainMap, getEmptyConfig()));
TestUtils.assertConnectionFails(context, "developer.android.com", 443);
}
use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.
the class NetworkSecurityConfigTests method testBadPin.
public void testBadPin() throws Exception {
ArraySet<Pin> pins = new ArraySet<Pin>();
pins.add(new Pin("SHA-256", new byte[0]));
NetworkSecurityConfig domain = new NetworkSecurityConfig.Builder().setPinSet(new PinSet(pins, Long.MAX_VALUE)).addCertificatesEntryRef(new CertificatesEntryRef(SystemCertificateSource.getInstance(), false)).build();
ArraySet<Pair<Domain, NetworkSecurityConfig>> domainMap = new ArraySet<Pair<Domain, NetworkSecurityConfig>>();
domainMap.add(new Pair<Domain, NetworkSecurityConfig>(new Domain("android.com", true), domain));
SSLContext context = TestUtils.getSSLContext(new TestConfigSource(domainMap, getSystemStoreConfig()));
TestUtils.assertConnectionFails(context, "android.com", 443);
TestUtils.assertConnectionSucceeds(context, "google.com", 443);
}
Aggregations