Search in sources :

Example 11 with ZoneConfiguration

use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.

the class VCertTknClientTest method requestCertificate.

@Test
@DisplayName("Request certificate")
void requestCertificate() throws VCertException {
    final CertificateRequest certificateRequest = mock(CertificateRequest.class);
    final ZoneConfiguration zoneConfiguration = mock(ZoneConfiguration.class);
    zoneConfiguration.zoneId("test_zone");
    classUnderTest.requestCertificate(certificateRequest, zoneConfiguration);
    verify(connector).requestCertificate(certificateRequest, zoneConfiguration);
}
Also used : ZoneConfiguration(com.venafi.vcert.sdk.connectors.ZoneConfiguration) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with ZoneConfiguration

use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.

the class VCertTknClientTest method generateRequest.

@Test
@DisplayName("Generate request")
void generateRequest() throws VCertException {
    final ZoneConfiguration zoneConfiguration = mock(ZoneConfiguration.class);
    final CertificateRequest certificateRequest = mock(CertificateRequest.class);
    classUnderTest.generateRequest(zoneConfiguration, certificateRequest);
    verify(connector).generateRequest(zoneConfiguration, certificateRequest);
}
Also used : ZoneConfiguration(com.venafi.vcert.sdk.connectors.ZoneConfiguration) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 13 with ZoneConfiguration

use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.

the class VCertClientTest 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 14 with ZoneConfiguration

use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.

the class ZoneConfigurationTest method getBaseZoneConfiguration.

private ZoneConfiguration getBaseZoneConfiguration() {
    final ZoneConfiguration defaultZoneConf = new ZoneConfiguration();
    final Policy policy = new Policy();
    final AllowedKeyConfiguration allowedKeyConfiguration = new AllowedKeyConfiguration();
    defaultZoneConf.organization("Venafi");
    defaultZoneConf.organizationalUnit(Arrays.asList("Engineering", "Automated Test"));
    defaultZoneConf.country("US");
    defaultZoneConf.province("Utah");
    defaultZoneConf.locality("SLC");
    allowedKeyConfiguration.keyType(KeyType.RSA);
    allowedKeyConfiguration.keySizes(singletonList(4096));
    policy.allowedKeyConfigurations(Arrays.asList(allowedKeyConfiguration));
    policy.subjectCNRegexes(singletonList(".*vfidev.com"));
    policy.subjectORegexes(singletonList("Venafi, Inc."));
    policy.subjectOURegexes(singletonList("Engineering"));
    policy.subjectSTRegexes(singletonList("Nevada"));
    policy.subjectLRegexes(singletonList("Las Vegas"));
    policy.subjectCRegexes(singletonList("US"));
    policy.dnsSanRegExs(singletonList(".*"));
    defaultZoneConf.policy(policy);
    return defaultZoneConf;
}
Also used : Policy(com.venafi.vcert.sdk.connectors.Policy) ZoneConfiguration(com.venafi.vcert.sdk.connectors.ZoneConfiguration) AllowedKeyConfiguration(com.venafi.vcert.sdk.endpoint.AllowedKeyConfiguration)

Example 15 with ZoneConfiguration

use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.

the class ZoneConfigurationTest method invalidKeyPolices.

@Test
@DisplayName("Key Policies should fail if do not match")
void invalidKeyPolices() throws VCertException {
    final ZoneConfiguration zoneConfiguration = getBaseZoneConfiguration();
    final CertificateRequest certificateRequest = getDefaultCertificateRequest();
    certificateRequest.keyType(KeyType.ECDSA);
    final Throwable exception = assertThrows(VCertException.class, () -> zoneConfiguration.validateCertificateRequest(certificateRequest));
    assertThat(exception.getMessage()).contains("Key Type and Size do not match");
}
Also used : ZoneConfiguration(com.venafi.vcert.sdk.connectors.ZoneConfiguration) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

ZoneConfiguration (com.venafi.vcert.sdk.connectors.ZoneConfiguration)50 CertificateRequest (com.venafi.vcert.sdk.certificate.CertificateRequest)42 Test (org.junit.jupiter.api.Test)42 DisplayName (org.junit.jupiter.api.DisplayName)20 PEMCollection (com.venafi.vcert.sdk.certificate.PEMCollection)17 RenewalRequest (com.venafi.vcert.sdk.certificate.RenewalRequest)7 StringReader (java.io.StringReader)7 X509Certificate (java.security.cert.X509Certificate)7 RevocationRequest (com.venafi.vcert.sdk.certificate.RevocationRequest)5 Authentication (com.venafi.vcert.sdk.endpoint.Authentication)5 PEMParser (org.bouncycastle.openssl.PEMParser)4 PKCS10CertificationRequest (org.bouncycastle.pkcs.PKCS10CertificationRequest)4 Config (com.venafi.vcert.sdk.Config)3 TestUtils (com.venafi.vcert.sdk.TestUtils)3 VCertException (com.venafi.vcert.sdk.VCertException)3 CsrOriginOption (com.venafi.vcert.sdk.certificate.CsrOriginOption)3 DataFormat (com.venafi.vcert.sdk.certificate.DataFormat)3 ServerPolicy (com.venafi.vcert.sdk.connectors.ServerPolicy)3 FeignException (feign.FeignException)3 IOException (java.io.IOException)3