diff options
-rw-r--r-- | core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java b/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java index b2e1895..60c40db 100644 --- a/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java +++ b/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java @@ -19,6 +19,8 @@ package android.net.http; import java.security.KeyStore; import java.security.cert.X509Certificate; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; import junit.framework.TestCase; @@ -42,10 +44,9 @@ public class X509TrustManagerExtensionsTest extends TestCase { NotATrustManagerImpl ntmi = new NotATrustManagerImpl(); try { X509TrustManagerExtensions tme = new X509TrustManagerExtensions(ntmi); - } catch (IllegalArgumentException ignored) { - return; + fail(); + } catch (IllegalArgumentException expected) { } - fail(); } public void testGoodCast() throws Exception { @@ -53,4 +54,19 @@ public class X509TrustManagerExtensionsTest extends TestCase { TrustManagerImpl tmi = new TrustManagerImpl(KeyStore.getInstance(defaultType)); X509TrustManagerExtensions tme = new X509TrustManagerExtensions(tmi); } + + public void testNormalUseCase() throws Exception { + String defaultAlgorithm = TrustManagerFactory.getDefaultAlgorithm(); + TrustManagerFactory tmf = TrustManagerFactory.getInstance(defaultAlgorithm); + String defaultKeystoreType = KeyStore.getDefaultType(); + tmf.init(KeyStore.getInstance(defaultKeystoreType)); + TrustManager[] tms = tmf.getTrustManagers(); + for (TrustManager tm : tms) { + if (tm instanceof X509TrustManager) { + new X509TrustManagerExtensions((X509TrustManager)tm); + return; + } + } + fail(); + } } |