Search in sources :

Example 1 with PolicySpecification

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

the class CloudConnectorTest method testExceptionValidatingSANIpAllowed.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy SAN IpAllowed")
public void testExceptionValidatingSANIpAllowed() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the ipAllowed to true to validate that the related VCertException is thrown
    policySpecification.policy().subjectAltNames().ipAllowed(true);
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.SUBJECT_ALT_NAME_ATTRIBUTE_DOESNT_SUPPORTED_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_SUBJECT_ALT_NAMES_IP_ALLOWED), 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 2 with PolicySpecification

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

the class CloudConnectorTest method testExceptionValidatingDefaultCountryWithNot2Characters.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Defaults Country with not 2 char values")
public void testExceptionValidatingDefaultCountryWithNot2Characters() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the Country to a value which contains a string with more than 2 chars
    // to validate that the related VCertException is thrown
    policySpecification.policy(null);
    policySpecification.defaults().subject().country("MEX");
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.ATTRIBUTE_HAS_NOT_A_TWO_CHAR_STRING_VALUE_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_SUBJECT_COUNTRY), 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 3 with PolicySpecification

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

the class CloudConnectorTest method testExceptionValidatingDefaultState.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Defaults State not matching with the Policy States values")
public void testExceptionValidatingDefaultState() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the Default State to a value which doesn't match with the values in the Policy State values
    // to validate that the related VCertException is thrown
    policySpecification.defaults().subject().state("Yuc");
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_SUBJECT_STATE, PolicySpecificationConst.ATT_POLICY_SUBJECT_STATES), 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 4 with PolicySpecification

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

the class CloudConnectorTest method testExceptionValidatingDefaultKeyTypeDoesntMatchWithPolicyKeyType.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Default KeyType")
public void testExceptionValidatingDefaultKeyTypeDoesntMatchWithPolicyKeyType() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the keypair to a value which doesn't match with "RSA"
    // to validate that the related VCertException is thrown
    policySpecification.defaults().keyPair().keyType("ECDSA");
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_WITH_ACCEPTED_VALUES_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_KEYPAIR_KEY_TYPE), 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 5 with PolicySpecification

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

the class CloudConnectorTest method testExceptionValidatingDefaultOrgUnits.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Defaults OrgUnits not matching with the Policy OrgUnits values")
public void testExceptionValidatingDefaultOrgUnits() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the Default OrgUnits to a value which doesn't match with the values in the Policy
    // OrgUnits values to validate that the related VCertException is thrown
    policySpecification.defaults().subject().orgUnits(new String[] { "Dev" });
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_SUBJECT_ORG_UNITS, PolicySpecificationConst.ATT_POLICY_SUBJECT_ORG_UNITS), 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