Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e24cfe3a authored by Thiébaud Weksteen's avatar Thiébaud Weksteen
Browse files

Move X509TrustManagerExtensionsTest to JUnit4

Flag: android.security.certificate_transparency_configuration
Test: atest FrameworksCoreTests:android.net.http.X509TrustManagerExtensionsTest
Bug: 376139811
Change-Id: I32feb9a85a2260446976740fef8a4850420be4a2
parent 864ec575
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -16,6 +16,15 @@

package android.net.http;

import static org.junit.Assert.fail;

import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.android.org.conscrypt.TrustManagerImpl;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.security.KeyStore;
import java.security.cert.X509Certificate;

@@ -23,11 +32,8 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;

import junit.framework.TestCase;

import com.android.org.conscrypt.TrustManagerImpl;

public class X509TrustManagerExtensionsTest extends TestCase {
@RunWith(AndroidJUnit4.class)
public class X509TrustManagerExtensionsTest {

    private class NotATrustManagerImpl implements X509TrustManager {

@@ -40,6 +46,7 @@ public class X509TrustManagerExtensionsTest extends TestCase {
        }
    }

    @Test
    public void testBadCast() throws Exception {
        NotATrustManagerImpl ntmi = new NotATrustManagerImpl();
        try {
@@ -49,12 +56,14 @@ public class X509TrustManagerExtensionsTest extends TestCase {
        }
    }

    @Test
    public void testGoodCast() throws Exception {
        String defaultType = KeyStore.getDefaultType();
        TrustManagerImpl tmi = new TrustManagerImpl(KeyStore.getInstance(defaultType));
        X509TrustManagerExtensions tme = new X509TrustManagerExtensions(tmi);
    }

    @Test
    public void testNormalUseCase() throws Exception {
        String defaultAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(defaultAlgorithm);