package net.kencochrane.raven.getsentry.connection;

import mockit.Deencapsulation;
import mockit.Injectable;
import mockit.Tested;
import org.testng.annotations.Test;

import javax.net.ssl.SSLHandshakeException;
import java.net.URL;
import java.net.URLConnection;

import static org.testng.Assert.fail;

public class GetSentryHttpsConnectionTest {
    @Tested
    private GetSentryHttpsConnection connection;
    @Injectable("projectId")
    private String projectId;
    @Injectable("privateKey")
    private String publicKey;
    @Injectable("secretKey")
    private String secretKey;

    @Test
    public void ensureHttpsConnectionToGetSentryIsSecure() throws Exception {
        connection.getConnection().connect();
    }

    @Test(expectedExceptions = SSLHandshakeException.class)
    public void ensureHttpsConnectionToGoogleComIsNotSecure() throws Exception {
        final URL url = new URL("https://www.google.com");
        Deencapsulation.setField(connection, "sentryUrl", url);

        connection.getConnection().connect();
    }

    @Test(expectedExceptions = SSLHandshakeException.class)
    public void ensureHttpsConnectionToGetSentryRequiresCustomSslFactory() throws Exception {
        final URLConnection httpsConnection = GetSentryHttpsConnection.getSentryUrl(projectId).openConnection();

        httpsConnection.connect();

        fail("Ensure that the StartCom certificate hasn't been added manually to the KeyStore or skip this test.");
    }
}

@@ -1033,32 +1033,239 @@
 nnect();%0A    %7D%0A%0A
+    /*%0A     * Test disabled as it will fail when the CA is available in the default KeyStore.%0A     * It is useful to be able to run it to ensure that it's indeed necessary to keep the entire module.%0A     */%0A
     @Test(expect
@@ -1298,32 +1298,49 @@
 eException.class
+, enabled = false
 )%0A    public voi

Disable the test on ensureHttpsConnectionToGetSentryRequiresCustomSslFactory