@Override protected HttpURLConnection openConnection(URL url) throws Exception { return openConnection(url, "client-key.jks"); }
@AfterClass public static void afterClass() throws Exception { testServer.tearDown(); }
/** * Test request to server using a client certificate that is not trusted by the server. * * @throws Exception */ @Test public void testInvalidClientCertForStatusEndpoint() throws Exception { HttpsURLConnection urlConn = openConnection(getURL(Constants.EndPoints.STATUS), "invalid-client.jks"); try { // Request is Authorized assertEquals(200, urlConn.getResponseCode()); } finally { urlConn.disconnect(); } }
sConfiguration = sConf; testServer = new ExternalMTLSAuthenticationServerTest(); testServer.setup();
/** * Test request to server using a client certificate that is not trusted by the server. * * @throws Exception */ @Override @Test public void testInvalidAuthentication() throws Exception { HttpsURLConnection urlConn = openConnection(getURL(GrantAccessToken.Paths.GET_TOKEN), "invalid-client.jks"); try { // Request is Unauthorized assertEquals(403, urlConn.getResponseCode()); } finally { urlConn.disconnect(); } }
/** * Test request to server without providing a client certificate * * @throws Exception */ @Test public void testMissingClientCertAuthentication() throws Exception { HttpsURLConnection urlConn = new HttpsEnabler() .setTrustAll(true) .enable((HttpsURLConnection) openConnection(getURL(GrantAccessToken.Paths.GET_TOKEN))); try { // Status request is authorized without any extra headers assertEquals(403, urlConn.getResponseCode()); } finally { urlConn.disconnect(); } }