use of com.venafi.vcert.sdk.certificate.CertificateRequest in project vcert-java by Venafi.
the class VCertClientTest 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.certificate.CertificateRequest in project vcert-java by Venafi.
the class VCertClientTest 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.certificate.CertificateRequest in project vcert-java by Venafi.
the class TppTokenConnectorCertAT method requestCertificate.
@Test
void requestCertificate() throws VCertException, SocketException, UnknownHostException {
TppTokenConnector connector = connectorResource.connector();
ZoneConfiguration zoneConfiguration = connectorResource.zoneConfiguration();
CertificateRequest certificateRequest = connector.generateRequest(zoneConfiguration, connectorResource.certificateRequest());
CertificateRequest csrRequestOnly = new CertificateRequest().csr(certificateRequest.csr());
assertThat(connector.requestCertificate(csrRequestOnly, zoneConfiguration)).isNotNull();
}
use of com.venafi.vcert.sdk.certificate.CertificateRequest in project vcert-java by Venafi.
the class TppTokenConnectorTest method requestCertificate.
@Test
@DisplayName("Request a certificate from TPP")
void requestCertificate() throws VCertException {
Security.addProvider(new BouncyCastleProvider());
TppTokenConnector.ReadZoneConfigurationRequest expectedRZCRequest = new TppTokenConnector.ReadZoneConfigurationRequest("\\VED\\Policy\\myZone");
when(tpp.readZoneConfigurationToken(eq(expectedRZCRequest), eq(HEADER_AUTHORIZATION))).thenReturn(new TppTokenConnector.ReadZoneConfigurationResponse().policy(new ServerPolicy().subject(new ServerPolicy.Subject().organizationalUnit(new LockableValues<String>(false, Collections.singletonList("OU"))).state(new LockableValue<>(false, "state")).city(new LockableValue<>(false, "city")).country(new LockableValue<>(false, "country")).organization(new LockableValue<>(false, "organization"))).keyPair(new ServerPolicy.KeyPair(new LockableValue<>(false, "keyAlgo"), new LockableValue<>(false, 1024), null))));
when(tpp.requestCertificateToken(any(TppTokenConnector.CertificateRequestsPayload.class), eq(HEADER_AUTHORIZATION))).thenReturn(new Tpp.CertificateRequestResponse().certificateDN("reqId"));
String zoneTag = "myZone";
ZoneConfiguration zoneConfig = classUnderTest.readZoneConfiguration(classUnderTest.getPolicyDN(zoneTag));
String cn = String.format("t%d-%s.venafi.xample.com", Instant.now().getEpochSecond(), RandomStringUtils.randomAlphabetic(4).toLowerCase());
CertificateRequest request = new CertificateRequest().subject(new CertificateRequest.PKIXName().commonName(cn).organization(Collections.singletonList("Venafi, Inc.")).organizationalUnit(Collections.singletonList("Automated Tests")).locality(Collections.singletonList("Las Vegas")).province(Collections.singletonList("Nevada")).country(Collections.singletonList("US"))).friendlyName(cn).keyLength(512);
classUnderTest.generateRequest(zoneConfig, request);
logger.info("getPolicyDN(ZoneTag) = %s", classUnderTest.getPolicyDN(zoneTag));
ZoneConfiguration zoneConfiguration = new ZoneConfiguration();
zoneConfiguration.zoneId(classUnderTest.getPolicyDN(zoneTag));
String requestId = classUnderTest.requestCertificate(request, zoneConfiguration);
assertEquals("reqId", requestId);
}
use of com.venafi.vcert.sdk.certificate.CertificateRequest in project vcert-java by Venafi.
the class TppConnectorCertAT method requestCertificate.
@Test
void requestCertificate() throws VCertException, SocketException, UnknownHostException {
TppConnector connector = connectorResource.connector();
ZoneConfiguration zoneConfiguration = connectorResource.zoneConfiguration();
CertificateRequest certificateRequest = connectorResource.certificateRequest();
certificateRequest = connector.generateRequest(zoneConfiguration, certificateRequest);
CertificateRequest csrRequestOnly = new CertificateRequest().csr(certificateRequest.csr());
assertThat(connector.requestCertificate(csrRequestOnly, zoneConfiguration)).isNotNull();
}
Aggregations