Search in sources :

Example 41 with CertificateRequest

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

the class CloudConnectorCertResource method beforeEach.

@Override
public void beforeEach(ExtensionContext context) throws Exception {
    super.beforeEach(context);
    zoneConfiguration = connector().readZoneConfiguration(TestUtils.CLOUD_ZONE);
    certificateRequest = new CertificateRequest().subject(new CertificateRequest.PKIXName().commonName(TestUtils.randomCN()).organization(Collections.singletonList("Venafi, Inc.")).organizationalUnit(Arrays.asList("DevOps", "Automated Tests")).country(Collections.singletonList("US")).locality(Collections.singletonList("Salt Lake City")).province(Collections.singletonList("Utah"))).dnsNames(Collections.singletonList(InetAddress.getLocalHost().getHostName()));
}
Also used : CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest)

Example 42 with CertificateRequest

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

the class CloudConnectorIT method requestCertificate.

@Test
void requestCertificate() throws VCertException {
    CertificateRequest certificateRequest = new CertificateRequest().csr("-----BEGIN CERTIFICATE REQUEST-----\nMIIBrDCCARUCAQAwbDELMAkGA1UEBhMCVVMxDTALBgNVBAgMBFV0YWgxEjAQBgNV\nBAcMCVNhbHQgTGFrZTEPMA0GA1UECgwGVmVuYWZpMQ8wDQYDVQQLDAZEZXZPcHMx\nGDAWBgNVBAMMD3Rlc3QudmVuZGV2LmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw\ngYkCgYEAqIPiGtjnxep5gQHIiDXhHpHYhr/ndwFKQ2HNGftD3AMjMDyolSQY27w7\nPScTZXcuENew0zsH4iA7UsFhEGB6AIoelBWxiWc1SYRNslIgsSxsRlksJowFcL/E\n40qkmL0TerI2vq829jF3XY6X1E3e1OXo0kbmBLwEB/xnpfuvpt0CAwEAAaAAMA0G\nCSqGSIb3DQEBCwUAA4GBAGsKm5fJ8Zm/j9XMPXhPYmOdiDj+9QlcFq7uRRqwpxo7\nC507RR5Pj2zBRZRLJcc/bNTQFqnW92kIcvJ+YvrQl/GkEMKM2wds/RyMXRHtOJvZ\nYQt6JtkAeQOMECJ7RRHrZiG+m2by2YAB2krthK2gJGSr80xWzZWzrgdwdTe2sxUG\n-----BEGIN CERTIFICATE REQUEST-----".getBytes());
    // todo: improve test: add request matcher (and add data to request to ensure it gets passed
    // through all right)
    ZoneConfiguration zoneConfiguration = new ZoneConfiguration();
    zoneConfiguration.zoneId("Default");
    String requestId = classUnderTest.requestCertificate(certificateRequest, zoneConfiguration);
    assertThat(requestId).isEqualTo("04c051d0-f118-11e5-8b33-d96cf8021ce5");
}
Also used : ZoneConfiguration(com.venafi.vcert.sdk.connectors.ZoneConfiguration) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) Test(org.junit.jupiter.api.Test)

Example 43 with CertificateRequest

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

the class VCertClientTest method retrieveCertificateWithServerError.

@Test
@DisplayName("Retrieve certificate with server error")
void retrieveCertificateWithServerError() throws VCertException {
    final CertificateRequest certificateRequest = mock(CertificateRequest.class);
    doThrow(new FeignException.InternalServerError("Error", request, "".getBytes())).when(connector).retrieveCertificate(certificateRequest);
    assertThrows(VCertException.class, () -> classUnderTest.retrieveCertificate(certificateRequest));
}
Also used : FeignException(feign.FeignException) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 44 with CertificateRequest

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

the class VCertTknClientTest method requestCertificateWithServerError.

@Test
@DisplayName("Request certificate with server error")
void requestCertificateWithServerError() throws VCertException {
    final CertificateRequest certificateRequest = mock(CertificateRequest.class);
    final ZoneConfiguration zoneConfiguration = mock(ZoneConfiguration.class);
    zoneConfiguration.zoneId("test_zone");
    doThrow(new FeignException.InternalServerError("Error", request, "".getBytes())).when(connector).requestCertificate(certificateRequest, zoneConfiguration);
    assertThrows(VCertException.class, () -> classUnderTest.requestCertificate(certificateRequest, zoneConfiguration));
}
Also used : ZoneConfiguration(com.venafi.vcert.sdk.connectors.ZoneConfiguration) FeignException(feign.FeignException) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 45 with CertificateRequest

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

the class VCertTknClientTest method generateRequestWithServerError.

@Test
@DisplayName("Generate request with server error")
void generateRequestWithServerError() throws VCertException {
    final ZoneConfiguration zoneConfiguration = mock(ZoneConfiguration.class);
    final CertificateRequest certificateRequest = mock(CertificateRequest.class);
    doThrow(new FeignException.InternalServerError("Error", request, "".getBytes())).when(connector).generateRequest(zoneConfiguration, certificateRequest);
    assertThrows(VCertException.class, () -> classUnderTest.generateRequest(zoneConfiguration, certificateRequest));
}
Also used : ZoneConfiguration(com.venafi.vcert.sdk.connectors.ZoneConfiguration) FeignException(feign.FeignException) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CertificateRequest (com.venafi.vcert.sdk.certificate.CertificateRequest)53 Test (org.junit.jupiter.api.Test)44 ZoneConfiguration (com.venafi.vcert.sdk.connectors.ZoneConfiguration)43 DisplayName (org.junit.jupiter.api.DisplayName)24 PEMCollection (com.venafi.vcert.sdk.certificate.PEMCollection)20 RenewalRequest (com.venafi.vcert.sdk.certificate.RenewalRequest)9 Authentication (com.venafi.vcert.sdk.endpoint.Authentication)8 StringReader (java.io.StringReader)8 FeignException (feign.FeignException)7 X509Certificate (java.security.cert.X509Certificate)7 RevocationRequest (com.venafi.vcert.sdk.certificate.RevocationRequest)6 VCertException (com.venafi.vcert.sdk.VCertException)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 PEMParser (org.bouncycastle.openssl.PEMParser)5 CsrOriginOption (com.venafi.vcert.sdk.certificate.CsrOriginOption)4 DataFormat (com.venafi.vcert.sdk.certificate.DataFormat)4 Instant (java.time.Instant)4 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)4 PKCS10CertificationRequest (org.bouncycastle.pkcs.PKCS10CertificationRequest)4