use of com.venafi.vcert.sdk.VCertException in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingPolicyLocalitiesWhenWildcards.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy Localities with wildcard value")
public void testExceptionValidatingPolicyLocalitiesWhenWildcards() throws VCertException {
classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
// setting the Localities to a list of values which contains ".*" to validate that the related VCertException is thrown
policySpecification.policy().subject().localities(new String[] { PolicySpecificationConst.ALLOW_ALL, "Merida" });
Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.ATTRIBUTE_HAS_MORE_THAN_ONE_VALUE_CONTAINING_ALLOW_ALL_STRING_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_SUBJECT_LOCALITIES), exception.getMessage());
}
use of com.venafi.vcert.sdk.VCertException in project vcert-java by Venafi.
the class TppTokenConnectorTest method testExceptionValidatingDefaultKeyTypeDoesntMatchWithPolicyKeyType.
@Test
@DisplayName("TPP - Testing Exception in Validation of Default KeyType with a value not matching with the Policy KeyType")
public void testExceptionValidatingDefaultKeyTypeDoesntMatchWithPolicyKeyType() throws VCertException {
PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
// setting the default KeyType to a value which is not matching with
// the Policy KeyType to validate that the related VCertException is thrown
policySpecification.defaults().keyPair().keyType("ECDSA");
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_KEY_TYPE, 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 testExceptionValidatingDefaultECContainsUnsupportedValue.
@Test
@DisplayName("TPP - Testing Exception in Validation of Default EC that has unsupported value")
public void testExceptionValidatingDefaultECContainsUnsupportedValue() throws VCertException {
PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
// setting the default EC to a value which is not supported
// to validate that the related VCertException is thrown
policySpecification.defaults().keyPair().ellipticCurve("P224");
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_ELLIPTIC_CURVE), exception.getMessage());
}
use of com.venafi.vcert.sdk.VCertException in project vcert-java by Venafi.
the class TppTokenConnectorTest method testExceptionValidatingPolicyCountries.
@Test
@DisplayName("TPP - Testing Exception in Validation of Policy Countries with more than one value")
public void testExceptionValidatingPolicyCountries() throws VCertException {
PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
// setting the countries to a list of more than 1 values
// to validate that the related VCertException is thrown
policySpecification.policy().subject().countries(new String[] { "Country1", "Country2" });
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_COUNTRIES), exception.getMessage());
}
use of com.venafi.vcert.sdk.VCertException in project vcert-java by Venafi.
the class TppTokenConnectorTest method testExceptionValidatingDefaultOrgUnits.
@Test
@DisplayName("TPP - Testing Exception in Validation of Defaults OrgUnits not matching with the Policy OrgUnits values")
public void testExceptionValidatingDefaultOrgUnits() throws VCertException {
PolicySpecification policySpecification = TppTestUtils.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(TppTestUtils.getRandomZone(), policySpecification));
Assertions.assertEquals(TppTestUtils.getVCertExceptionMessage(TPPPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_SUBJECT_ORG_UNITS, PolicySpecificationConst.ATT_POLICY_SUBJECT_ORG_UNITS), exception.getMessage());
}
Aggregations