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