@Test
public void testGenerateX509Certificate() throws Exception {

    HttpClient httpClient = Mockito.mock(HttpClient.class);
    HttpCertSignerFactory certFactory = new HttpCertSignerFactory();
    HttpCertSigner certSigner = (HttpCertSigner) certFactory.create();
    certSigner.setHttpClient(httpClient);
    Request request = Mockito.mock(Request.class);
    Mockito.when(httpClient.POST("https://localhost:443/certsign/v2/x509")).thenReturn(request);
    ContentResponse response = Mockito.mock(ContentResponse.class);
    Mockito.when(request.send()).thenReturn(response);
    Mockito.when(response.getStatus()).thenReturn(201);
    Mockito.when(response.getContentAsString()).thenReturn("{\"pem\": \"pem-value\"}");
    String pem = certSigner.generateX509Certificate("csr", null, 0);
    assertEquals(pem, "pem-value");
    pem = certSigner.generateX509Certificate("csr", InstanceProvider.ZTS_CERT_USAGE_CLIENT, 0);
    assertEquals(pem, "pem-value");
    pem = certSigner.generateX509Certificate("csr", InstanceProvider.ZTS_CERT_USAGE_CLIENT, 30);
    assertEquals(pem, "pem-value");
    certSigner.requestTimeout = 120;
    pem = certSigner.generateX509Certificate("csr", InstanceProvider.ZTS_CERT_USAGE_CLIENT, 30);
    assertEquals(pem, "pem-value");
    certSigner.close();
}