Search in sources :

Example 11 with RenewalRequest

use of com.venafi.vcert.sdk.certificate.RenewalRequest in project vcert-java by Venafi.

the class VCertClientTest method renewCertificate.

@Test
@DisplayName("Renew certificate")
void renewCertificate() throws VCertException {
    final RenewalRequest renewalRequest = mock(RenewalRequest.class);
    classUnderTest.renewCertificate(renewalRequest);
    verify(connector).renewCertificate(renewalRequest);
}
Also used : RenewalRequest(com.venafi.vcert.sdk.certificate.RenewalRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with RenewalRequest

use of com.venafi.vcert.sdk.certificate.RenewalRequest in project vcert-java by Venafi.

the class TppTokenConnectorTest method renewCertificateWithDN.

@Test
@DisplayName("Renew Certificate with DN")
void renewCertificateWithDN() throws VCertException {
    final RenewalRequest renewalRequest = mock(RenewalRequest.class);
    final Tpp.CertificateRenewalResponse certificateRenewalResponse = mock(Tpp.CertificateRenewalResponse.class);
    when(renewalRequest.certificateDN()).thenReturn("certificateDN");
    when(tpp.renewCertificateToken(certificateRenewalRequestArgumentCaptor.capture(), any())).thenReturn(certificateRenewalResponse);
    when(certificateRenewalResponse.success()).thenReturn(true);
    String result = classUnderTest.renewCertificate(renewalRequest);
    assertThat(result).isEqualTo("certificateDN");
}
Also used : RenewalRequest(com.venafi.vcert.sdk.certificate.RenewalRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 13 with RenewalRequest

use of com.venafi.vcert.sdk.certificate.RenewalRequest in project vcert-java by Venafi.

the class TppTokenConnectorTest method renewCertificateWithFingerPrint.

@Test
@DisplayName("Renew Certificate with fingerprint")
void renewCertificateWithFingerPrint() throws VCertException {
    final RenewalRequest renewalRequest = mock(RenewalRequest.class);
    final Tpp.CertificateSearchResponse certificateSearchResponse = mock(Tpp.CertificateSearchResponse.class);
    final Tpp.Certificate certificate = mock(Tpp.Certificate.class);
    final Tpp.CertificateRenewalResponse certificateRenewalResponse = mock(Tpp.CertificateRenewalResponse.class);
    when(renewalRequest.thumbprint()).thenReturn("1111:1111:1111:1111");
    when(tpp.searchCertificatesToken(any(), eq(HEADER_AUTHORIZATION))).thenReturn(certificateSearchResponse);
    when(certificateSearchResponse.certificates()).thenReturn(Arrays.asList(certificate));
    when(certificate.certificateRequestId()).thenReturn("test_certificate_requestid");
    when(tpp.renewCertificateToken(certificateRenewalRequestArgumentCaptor.capture(), any())).thenReturn(certificateRenewalResponse);
    when(certificateRenewalResponse.success()).thenReturn(true);
    String result = classUnderTest.renewCertificate(renewalRequest);
    assertThat(result).isEqualTo("test_certificate_requestid");
}
Also used : RenewalRequest(com.venafi.vcert.sdk.certificate.RenewalRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 14 with RenewalRequest

use of com.venafi.vcert.sdk.certificate.RenewalRequest in project vcert-java by Venafi.

the class TppConnectorCertAT method renewCertificate.

@Test
void renewCertificate() throws VCertException, UnknownHostException, SocketException, CertificateException, NoSuchAlgorithmException {
    TppConnector connector = connectorResource.connector();
    ZoneConfiguration zoneConfiguration = connectorResource.zoneConfiguration();
    CertificateRequest certificateRequest = connector.generateRequest(zoneConfiguration, connectorResource.certificateRequest());
    certificateRequest = connector.generateRequest(zoneConfiguration, certificateRequest);
    String certificateId = connector.requestCertificate(certificateRequest, zoneConfiguration);
    assertThat(certificateId).isNotNull();
    PEMCollection pemCollection = connector.retrieveCertificate(certificateRequest);
    X509Certificate cert = (X509Certificate) pemCollection.certificate();
    String thumbprint = DigestUtils.sha1Hex(cert.getEncoded()).toUpperCase();
    CertificateRequest certificateRequestToRenew = new CertificateRequest().subject(certificateRequest.subject()).dnsNames(certificateRequest.dnsNames()).ipAddresses(certificateRequest.ipAddresses()).keyType(certificateRequest.keyType()).keyLength(certificateRequest.keyLength());
    connector.generateRequest(zoneConfiguration, certificateRequestToRenew);
    String renewRequestId = connector.renewCertificate(new RenewalRequest().request(certificateRequestToRenew).thumbprint(thumbprint));
    assertThat(renewRequestId).isNotNull();
}
Also used : PEMCollection(com.venafi.vcert.sdk.certificate.PEMCollection) RenewalRequest(com.venafi.vcert.sdk.certificate.RenewalRequest) ZoneConfiguration(com.venafi.vcert.sdk.connectors.ZoneConfiguration) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.jupiter.api.Test)

Example 15 with RenewalRequest

use of com.venafi.vcert.sdk.certificate.RenewalRequest in project vcert-java by Venafi.

the class TppConnectorTest method renewCertificateWithFingerPrint.

@Test
@DisplayName("Renew Certificate with fingerprint")
void renewCertificateWithFingerPrint() throws VCertException {
    final RenewalRequest renewalRequest = mock(RenewalRequest.class);
    final Tpp.CertificateSearchResponse certificateSearchResponse = mock(Tpp.CertificateSearchResponse.class);
    final Tpp.Certificate certificate = mock(Tpp.Certificate.class);
    final Tpp.CertificateRenewalResponse certificateRenewalResponse = mock(Tpp.CertificateRenewalResponse.class);
    when(renewalRequest.thumbprint()).thenReturn("1111:1111:1111:1111");
    when(tpp.searchCertificates(any(), eq(API_KEY))).thenReturn(certificateSearchResponse);
    when(certificateSearchResponse.certificates()).thenReturn(Arrays.asList(certificate));
    when(certificate.certificateRequestId()).thenReturn("test_certificate_requestid");
    when(tpp.renewCertificate(certificateRenewalRequestArgumentCaptor.capture(), any())).thenReturn(certificateRenewalResponse);
    when(certificateRenewalResponse.success()).thenReturn(true);
    String result = classUnderTest.renewCertificate(renewalRequest);
    assertThat(result).isEqualTo("test_certificate_requestid");
}
Also used : RenewalRequest(com.venafi.vcert.sdk.certificate.RenewalRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

RenewalRequest (com.venafi.vcert.sdk.certificate.RenewalRequest)23 Test (org.junit.jupiter.api.Test)21 DisplayName (org.junit.jupiter.api.DisplayName)18 CertificateRequest (com.venafi.vcert.sdk.certificate.CertificateRequest)6 Authentication (com.venafi.vcert.sdk.endpoint.Authentication)6 PEMCollection (com.venafi.vcert.sdk.certificate.PEMCollection)5 ZoneConfiguration (com.venafi.vcert.sdk.connectors.ZoneConfiguration)5 X509Certificate (java.security.cert.X509Certificate)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 CertificateNotFoundByThumbprintException (com.venafi.vcert.sdk.connectors.ConnectorException.CertificateNotFoundByThumbprintException)3 CertificateStatus (com.venafi.vcert.sdk.certificate.CertificateStatus)2 CertificateDNOrThumbprintWasNotProvidedException (com.venafi.vcert.sdk.connectors.ConnectorException.CertificateDNOrThumbprintWasNotProvidedException)2 MoreThanOneCertificateWithSameThumbprintException (com.venafi.vcert.sdk.connectors.ConnectorException.MoreThanOneCertificateWithSameThumbprintException)2 FeignException (feign.FeignException)2 CharStreams (com.google.common.io.CharStreams)1 SerializedName (com.google.gson.annotations.SerializedName)1 VCertException (com.venafi.vcert.sdk.VCertException)1 CsrOriginOption (com.venafi.vcert.sdk.certificate.CsrOriginOption)1 ImportRequest (com.venafi.vcert.sdk.certificate.ImportRequest)1 ImportResponse (com.venafi.vcert.sdk.certificate.ImportResponse)1