use of com.venafi.vcert.sdk.certificate.RenewalRequest in project vcert-java by Venafi.
the class CloudConnectorTest method renewCertificateMultipleRequestIds.
@Test
@DisplayName("Renew a certificate with same fingerprint for multiple requests ids should fail")
void renewCertificateMultipleRequestIds() throws VCertException {
final String apiKey = "12345678-1234-1234-1234-123456789012";
final Authentication auth = new Authentication(null, null, apiKey);
final String thumbprint = "52030990E3DC44199DA11C2D73E41EF8EAD8A4E1";
final RenewalRequest renewalRequest = new RenewalRequest();
final Cloud.CertificateSearchResponse searchResponse = mock(Cloud.CertificateSearchResponse.class);
renewalRequest.thumbprint(thumbprint);
when(cloud.searchCertificates(eq(apiKey), searchRequestArgumentCaptor.capture())).thenReturn(searchResponse);
final Cloud.Certificate certificate1 = new Cloud.Certificate();
certificate1.certificateRequestId("request_1");
final Cloud.Certificate certificate2 = new Cloud.Certificate();
certificate2.certificateRequestId("request_2");
when(searchResponse.certificates()).thenReturn(Arrays.asList(certificate1, certificate2));
classUnderTest.authenticate(auth);
Throwable exception = assertThrows(VCertException.class, () -> classUnderTest.renewCertificate(renewalRequest));
assertThat(exception.getMessage()).contains("More than one CertificateRequestId was found");
assertThat(exception.getMessage()).contains(thumbprint);
}
use of com.venafi.vcert.sdk.certificate.RenewalRequest in project vcert-java by Venafi.
the class CloudConnectorTest method renewCertificateNotFound.
@Test
@DisplayName("Renew a certificate that do not exists in Cloud should fail")
void renewCertificateNotFound() throws VCertException {
final String apiKey = "12345678-1234-1234-1234-123456789012";
final Authentication auth = new Authentication(null, null, apiKey);
final String thumbprint = "52030990E3DC44199DA11C2D73E41EF8EAD8A4E1";
final RenewalRequest renewalRequest = new RenewalRequest();
final Cloud.CertificateSearchResponse searchResponse = mock(Cloud.CertificateSearchResponse.class);
renewalRequest.thumbprint(thumbprint);
when(cloud.searchCertificates(eq(apiKey), searchRequestArgumentCaptor.capture())).thenReturn(searchResponse);
classUnderTest.authenticate(auth);
Throwable exception = assertThrows(VCertException.class, () -> classUnderTest.renewCertificate(renewalRequest));
assertThat(exception.getMessage()).contains(thumbprint);
}
use of com.venafi.vcert.sdk.certificate.RenewalRequest in project vcert-java by Venafi.
the class VCertTknClientTest method renewCertificate.
@Test
@DisplayName("Renew certificate")
void renewCertificate() throws VCertException {
final RenewalRequest renewalRequest = mock(RenewalRequest.class);
classUnderTest.renewCertificate(renewalRequest);
verify(connector).renewCertificate(renewalRequest);
}
Aggregations