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);
}
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");
}
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");
}
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();
}
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");
}
Aggregations