use of com.venafi.vcert.sdk.certificate.CustomField in project vcert-java by Venafi.
the class TppTokenConnectorCertAT method createCertificateValidateValidityHours.
@Test
@DisplayName("Create a cerfiticate that contais custom fields and validate if certifcate were created correctly")
void createCertificateValidateValidityHours() throws UnknownHostException, VCertException {
// Custom fields
List<CustomField> customFields = new ArrayList<CustomField>();
customFields.add(new CustomField("custom", "java-test"));
customFields.add(new CustomField("cfList", "item2"));
customFields.add(new CustomField("cfListMulti", "tier1"));
customFields.add(new CustomField("cfListMulti", "tier2"));
TppTokenConnector connector = connectorResource.connector();
ZoneConfiguration zoneConfiguration = connectorResource.zoneConfiguration();
CertificateRequest certificateRequest = connectorResource.certificateRequest().customFields(customFields);
certificateRequest = connector.generateRequest(zoneConfiguration, connectorResource.certificateRequest());
// Submit the certificate request
connector.requestCertificate(certificateRequest, zoneConfiguration);
// Retrieve PEM collection from Venafi
PEMCollection pemCollection = connector.retrieveCertificate(certificateRequest);
// At this moment certificate, must be created, it will fail if some custom fields aren't supported or specified on tpp
// so is enough to validate if certificate is created.
assertTrue(pemCollection.certificate() != null);
}
Aggregations