### Question:
DefaultCAServer implements CertificateServer { @Override public Future<X509CertificateHolder> requestCertificate( PKCS10CertificationRequest csr, CertificateApprover.ApprovalType approverType) { LocalDate beginDate = LocalDate.now().atStartOfDay().toLocalDate(); LocalDateTime temp = LocalDateTime.of(beginDate, LocalTime.MIDNIGHT); LocalDate endDate = temp.plus(config.getDefaultCertDuration()).toLocalDate(); CompletableFuture<X509CertificateHolder> xcertHolder = approver.inspectCSR(csr); if(xcertHolder.isCompletedExceptionally()) { return xcertHolder; } try { switch (approverType) { case MANUAL: xcertHolder.completeExceptionally(new SCMSecurityException("Manual " + "approval is not yet implemented.")); break; case KERBEROS_TRUSTED: case TESTING_AUTOMATIC: X509CertificateHolder xcert; try { xcert = signAndStoreCertificate(beginDate, endDate, csr); } catch (SCMSecurityException e) { LOG.error("Certificate storage failed, retrying one more time.", e); xcert = signAndStoreCertificate(beginDate, endDate, csr); } xcertHolder.complete(xcert); break; default: return null; } } catch (CertificateException | IOException | OperatorCreationException e) { LOG.error("Unable to issue a certificate.", e); xcertHolder.completeExceptionally(new SCMSecurityException(e)); } return xcertHolder; } DefaultCAServer(String subject, String clusterID, String scmID,
                         CertificateStore certificateStore); @Override void init(SecurityConfig securityConfig, CAType type); @Override X509CertificateHolder getCACertificate(); @Override X509Certificate getCertificate(String certSerialId); @Override Future<X509CertificateHolder> requestCertificate(
      PKCS10CertificationRequest csr,
      CertificateApprover.ApprovalType approverType); @Override Future<X509CertificateHolder> requestCertificate(String csr,
      CertificateApprover.ApprovalType type); @Override Future<Boolean> revokeCertificate(X509Certificate certificate,
      CertificateApprover.ApprovalType approverType);  }### Answer:
@Test public void testRequestCertificate() throws IOException, ExecutionException, InterruptedException, NoSuchProviderException, NoSuchAlgorithmException { String scmId = RandomStringUtils.randomAlphabetic(4); String clusterId = RandomStringUtils.randomAlphabetic(4); KeyPair keyPair = new HDDSKeyGenerator(conf).generateKey(); PKCS10CertificationRequest csr = new CertificateSignRequest.Builder() .addDnsName("hadoop.apache.org") .addIpAddress("8.8.8.8") .addServiceName("OzoneMarketingCluster002") .setCA(false) .setClusterID(clusterId) .setScmID(scmId) .setSubject("Ozone Cluster") .setConfiguration(conf) .setKey(keyPair) .build(); String csrString = CertificateSignRequest.getEncodedString(csr); CertificateServer testCA = new DefaultCAServer("testCA", clusterId, scmId, caStore); testCA.init(new SecurityConfig(conf), CertificateServer.CAType.SELF_SIGNED_CA); Future<X509CertificateHolder> holder = testCA.requestCertificate(csrString, CertificateApprover.ApprovalType.TESTING_AUTOMATIC); assertTrue(holder.isDone()); assertNotNull(holder.get()); }