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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations