Search in sources :

Example 36 with PolicySpecification

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

the class TppTokenConnectorTest method testExceptionValidatingDefaultCountryWithNot2Characters.

@Test
@DisplayName("TPP - Testing Exception in Validation of Defaults Country with not 2 char values")
public void testExceptionValidatingDefaultCountryWithNot2Characters() throws VCertException {
    PolicySpecification policySpecification = TppTestUtils.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(TppTestUtils.getRandomZone(), policySpecification));
    Assertions.assertEquals(TppTestUtils.getVCertExceptionMessage(TPPPolicySpecificationValidator.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) CertificateDNOrThumbprintWasNotProvidedException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateDNOrThumbprintWasNotProvidedException) MoreThanOneCertificateWithSameThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.MoreThanOneCertificateWithSameThumbprintException) CertificateNotFoundByThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateNotFoundByThumbprintException) FeignException(feign.FeignException) VCertException(com.venafi.vcert.sdk.VCertException) FailedToRevokeTokenException(com.venafi.vcert.sdk.connectors.ConnectorException.FailedToRevokeTokenException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 37 with PolicySpecification

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

the class TppTokenConnectorTest method testExceptionValidatingDefaultKeySizeContainsUnsupportedValue.

@Test
@DisplayName("TPP - Testing Exception in Validation of Default KeySize that has unsupported value")
public void testExceptionValidatingDefaultKeySizeContainsUnsupportedValue() throws VCertException {
    PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
    // setting the default KeySize to a value which is not supported
    // to validate that the related VCertException is thrown
    policySpecification.defaults().keyPair().rsaKeySize(256);
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(TppTestUtils.getRandomZone(), policySpecification));
    Assertions.assertEquals(TppTestUtils.getVCertExceptionMessage(TPPPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_WITH_ACCEPTED_VALUES_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_KEYPAIR_RSA_KEY_SIZE), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) CertificateDNOrThumbprintWasNotProvidedException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateDNOrThumbprintWasNotProvidedException) MoreThanOneCertificateWithSameThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.MoreThanOneCertificateWithSameThumbprintException) CertificateNotFoundByThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateNotFoundByThumbprintException) FeignException(feign.FeignException) VCertException(com.venafi.vcert.sdk.VCertException) FailedToRevokeTokenException(com.venafi.vcert.sdk.connectors.ConnectorException.FailedToRevokeTokenException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 38 with PolicySpecification

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

the class TppTokenConnectorTest method testExceptionValidatingDefaultECDoesntMatchWithPolicyEC.

@Test
@DisplayName("TPP - Testing Exception in Validation of Default EC with a value not matching with the Policy EC")
public void testExceptionValidatingDefaultECDoesntMatchWithPolicyEC() throws VCertException {
    PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
    // setting the default KeySize to a value which is not matching with
    // the Policy KeySize to validate that the related VCertException is thrown
    policySpecification.policy().keyPair().ellipticCurves(new String[] { "P256" });
    policySpecification.defaults().keyPair().ellipticCurve("P384");
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(TppTestUtils.getRandomZone(), policySpecification));
    Assertions.assertEquals(TppTestUtils.getVCertExceptionMessage(TPPPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_KEYPAIR_ELLIPTIC_CURVE, PolicySpecificationConst.ATT_POLICY_KEYPAIR_ELLIPTIC_CURVES), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) CertificateDNOrThumbprintWasNotProvidedException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateDNOrThumbprintWasNotProvidedException) MoreThanOneCertificateWithSameThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.MoreThanOneCertificateWithSameThumbprintException) CertificateNotFoundByThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateNotFoundByThumbprintException) FeignException(feign.FeignException) VCertException(com.venafi.vcert.sdk.VCertException) FailedToRevokeTokenException(com.venafi.vcert.sdk.connectors.ConnectorException.FailedToRevokeTokenException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 39 with PolicySpecification

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

the class TppTokenConnectorTest method testExceptionValidatingPolicyOrgs.

@Test
@DisplayName("TPP - Testing Exception in Validation of Policy Orgs with more than one value")
public void testExceptionValidatingPolicyOrgs() throws VCertException {
    PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
    // setting the orgs to a list of more than 1 values
    // to validate that the related VCertException is thrown
    policySpecification.policy().subject().orgs(new String[] { "Org1", "Org2" });
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(TppTestUtils.getRandomZone(), policySpecification));
    Assertions.assertEquals(TppTestUtils.getVCertExceptionMessage(TPPPolicySpecificationValidator.ATTRIBUTE_HAS_MORE_THAN_ONE_VALUE_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_SUBJECT_ORGS), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) CertificateDNOrThumbprintWasNotProvidedException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateDNOrThumbprintWasNotProvidedException) MoreThanOneCertificateWithSameThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.MoreThanOneCertificateWithSameThumbprintException) CertificateNotFoundByThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateNotFoundByThumbprintException) FeignException(feign.FeignException) VCertException(com.venafi.vcert.sdk.VCertException) FailedToRevokeTokenException(com.venafi.vcert.sdk.connectors.ConnectorException.FailedToRevokeTokenException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 40 with PolicySpecification

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

the class TppTokenConnectorTest method testExceptionValidatingPolicyECContainsUnsupportedValue.

@Test
@DisplayName("TPP - Testing Exception in Validation of Policy EC that has unsupported value")
public void testExceptionValidatingPolicyECContainsUnsupportedValue() throws VCertException {
    PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
    // setting the EC to a list of values which contains
    // more than on value to validate that the related VCertException is thrown
    policySpecification.policy().keyPair().ellipticCurves(new String[] { "P224" });
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(TppTestUtils.getRandomZone(), policySpecification));
    Assertions.assertEquals(TppTestUtils.getVCertExceptionMessage(TPPPolicySpecificationValidator.ATTRIBUTE_DOESNT_MATCH_WITH_ACCEPTED_VALUES_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_KEYPAIR_ELLIPTIC_CURVES), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) CertificateDNOrThumbprintWasNotProvidedException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateDNOrThumbprintWasNotProvidedException) MoreThanOneCertificateWithSameThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.MoreThanOneCertificateWithSameThumbprintException) CertificateNotFoundByThumbprintException(com.venafi.vcert.sdk.connectors.ConnectorException.CertificateNotFoundByThumbprintException) FeignException(feign.FeignException) VCertException(com.venafi.vcert.sdk.VCertException) FailedToRevokeTokenException(com.venafi.vcert.sdk.connectors.ConnectorException.FailedToRevokeTokenException) 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