Search in sources :

Example 11 with PolicySpecification

use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.

the class CloudConnectorTest method testExceptionValidatingMaxValidDays.

@Test
@DisplayName("Cloud - Testing Exception in Validation of MaxValidDays")
public void testExceptionValidatingMaxValidDays() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the maxValidDays to null to validate that the related VCertException is thrown
    policySpecification.policy().maxValidDays(-10);
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.MAX_VALID_DAYS_EXCEPTION_MESSAGE), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) Authentication(com.venafi.vcert.sdk.endpoint.Authentication) VCertException(com.venafi.vcert.sdk.VCertException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with PolicySpecification

use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.

the class CloudConnectorTest method testExceptionValidatingPolicyKeyTypeContainsInvalidValue.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy KeyType")
public void testExceptionValidatingPolicyKeyTypeContainsInvalidValue() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the keypair to a list of values which contains not only "RSA" to validate that the related VCertException is thrown
    policySpecification.policy().keyPair().keyTypes(new String[] { "RSA", "ECDSA" });
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.ATTRIBUTE_DOESNT_MATCH_WITH_ACCEPTED_VALUES_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_KEYPAIR_KEY_TYPES), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) Authentication(com.venafi.vcert.sdk.endpoint.Authentication) VCertException(com.venafi.vcert.sdk.VCertException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 13 with PolicySpecification

use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.

the class CloudConnectorPolicyAT method createAndGetPolicyForDigicert.

@Test
@DisplayName("Cloud - Testing the setPolicy() and getPolicy() methods for Digicert CA")
public void createAndGetPolicyForDigicert() throws VCertException {
    CloudConnector connector = connectorResource.connector();
    String policyName = CloudTestUtils.getRandomZone();
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    policySpecification.policy().certificateAuthority(TestUtils.CLOUD_DIGICERT_CA_NAME);
    connector.setPolicy(policyName, policySpecification);
    PolicySpecification policySpecificationReturned = connector.getPolicy(policyName);
    // The returned policySpecification will have the policy's name so it will copied to the source policySpecification
    // due it doesn't contain it
    policySpecification.name(policySpecificationReturned.name());
    assertEquals(policySpecification, policySpecificationReturned);
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 14 with PolicySpecification

use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.

the class CloudConnectorPolicyAT method createAndGetPolicy.

@Test
@DisplayName("Cloud - Testing the setPolicy() and getPolicy() methods")
public void createAndGetPolicy() throws VCertException {
    CloudConnector connector = connectorResource.connector();
    String policyName = CloudTestUtils.getRandomZone();
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    connector.setPolicy(policyName, policySpecification);
    PolicySpecification policySpecificationReturned = connector.getPolicy(policyName);
    // The returned policySpecification will have the policy's name so it will copied to the source policySpecification
    // due it doesn't contain it
    policySpecification.name(policySpecificationReturned.name());
    // The returned policySpecification will contains the default cloud CA, then it will needed
    // to set it to the policySpecification source
    policySpecification.policy().certificateAuthority(VCertConstants.CLOUD_DEFAULT_CA);
    assertEquals(policySpecification, policySpecificationReturned);
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 15 with PolicySpecification

use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.

the class CloudConnectorTest method testExceptionValidatingDefaultKeySizeDoesntMatchWithPolicyKeySizes.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Default KeySize with a value not matching with the Policy KeySizes")
public void testExceptionValidatingDefaultKeySizeDoesntMatchWithPolicyKeySizes() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the default keysize to a value which is not matching with
    // the Policy KeySizes to validate that the related VCertException is thrown
    policySpecification.defaults().keyPair().rsaKeySize(4096);
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_KEYPAIR_RSA_KEY_SIZE, PolicySpecificationConst.ATT_POLICY_KEYPAIR_RSA_KEY_SIZES), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) Authentication(com.venafi.vcert.sdk.endpoint.Authentication) VCertException(com.venafi.vcert.sdk.VCertException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

PolicySpecification (com.venafi.vcert.sdk.policy.domain.PolicySpecification)57 DisplayName (org.junit.jupiter.api.DisplayName)49 Test (org.junit.jupiter.api.Test)49 VCertException (com.venafi.vcert.sdk.VCertException)48 CertificateDNOrThumbprintWasNotProvidedException (com.venafi.vcert.sdk.connectors.ConnectorException.CertificateDNOrThumbprintWasNotProvidedException)24 CertificateNotFoundByThumbprintException (com.venafi.vcert.sdk.connectors.ConnectorException.CertificateNotFoundByThumbprintException)24 MoreThanOneCertificateWithSameThumbprintException (com.venafi.vcert.sdk.connectors.ConnectorException.MoreThanOneCertificateWithSameThumbprintException)24 Authentication (com.venafi.vcert.sdk.endpoint.Authentication)24 FeignException (feign.FeignException)24 IOException (java.io.IOException)24 FailedToRevokeTokenException (com.venafi.vcert.sdk.connectors.ConnectorException.FailedToRevokeTokenException)23 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Config (com.venafi.vcert.sdk.Config)2 VCertClient (com.venafi.vcert.sdk.VCertClient)2 CertificateIssuingTemplate (com.venafi.vcert.sdk.connectors.cloud.domain.CertificateIssuingTemplate)2 TPPPolicy (com.venafi.vcert.sdk.policy.api.domain.TPPPolicy)2 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 CertificateRequest (com.venafi.vcert.sdk.certificate.CertificateRequest)1 ChainOption (com.venafi.vcert.sdk.certificate.ChainOption)1 DataFormat (com.venafi.vcert.sdk.certificate.DataFormat)1