use of com.venafi.vcert.sdk.VCertException in project vcert-java by Venafi.
the class TppTokenConnectorTest method testExceptionValidatingPolicyKeyTypeHasMoreThanOneValue.
@Test
@DisplayName("TPP - Testing Exception in Validation of Policy KeyType that has more than one value")
public void testExceptionValidatingPolicyKeyTypeHasMoreThanOneValue() throws VCertException {
PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
// setting the keypair to a list of values which contains not only one
// to validate that the related VCertException is thrown
policySpecification.policy().keyPair().keyTypes(new String[] { "RSA", "ECDSA" });
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_KEYPAIR_KEY_TYPES), exception.getMessage());
}
use of com.venafi.vcert.sdk.VCertException in project vcert-java by Venafi.
the class TppTokenConnectorTest method testExceptionValidatingDefaultKeyTypeContainsUnsupportedValue.
@Test
@DisplayName("TPP - Testing Exception in Validation of Default KeyType that has unsupported value")
public void testExceptionValidatingDefaultKeyTypeContainsUnsupportedValue() throws VCertException {
PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
// setting the default keypair to a value which is not supported
// to validate that the related VCertException is thrown
policySpecification.defaults().keyPair().keyType("KT");
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_KEY_TYPE), exception.getMessage());
}
use of com.venafi.vcert.sdk.VCertException in project vcert-java by Venafi.
the class TppTokenConnectorTest method testExceptionValidatingDefaultCountry.
@Test
@DisplayName("TPP - Testing Exception in Validation of Defaults Country not matching with the Policy Countries values")
public void testExceptionValidatingDefaultCountry() throws VCertException {
PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
// setting the Default country to a value which doesn't match with the values in the
// Policy Countries values to validate that the related VCertException is thrown
policySpecification.defaults().subject().country("CO");
Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(TppTestUtils.getRandomZone(), policySpecification));
Assertions.assertEquals(TppTestUtils.getVCertExceptionMessage(TPPPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_SUBJECT_COUNTRY, PolicySpecificationConst.ATT_POLICY_SUBJECT_COUNTRIES), exception.getMessage());
}
use of com.venafi.vcert.sdk.VCertException in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingPolicyCountriesWithNot2Characters.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy Countries with not 2 char values")
public void testExceptionValidatingPolicyCountriesWithNot2Characters() throws VCertException {
classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
// setting the Countries to a list of values which contains a string with more than
// 2 chars to validate that the related VCertException is thrown
policySpecification.policy().subject().countries(new String[] { "US", "Mexico" });
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_POLICY_SUBJECT_COUNTRIES), exception.getMessage());
}
use of com.venafi.vcert.sdk.VCertException in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingDefaultKeySize.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Default KeySize with a not supported value")
public void testExceptionValidatingDefaultKeySize() 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 supported to
// validate that the related VCertException is thrown
policySpecification.defaults().keyPair().rsaKeySize(3072);
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_RSA_KEY_SIZE), exception.getMessage());
}
Aggregations