use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingPolicyStatesWhenWildcards.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy States with wildcard value")
public void testExceptionValidatingPolicyStatesWhenWildcards() throws VCertException {
classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
// setting the States to a list of values which contains ".*" to validate that the related VCertException is thrown
policySpecification.policy().subject().states(new String[] { PolicySpecificationConst.ALLOW_ALL, "Yucatan" });
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_STATES), exception.getMessage());
}
use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.
the class CloudConnectorPolicyAT method createAndGetPolicyForEntrust.
@Test
@DisplayName("Cloud - Testing the setPolicy() and getPolicy() methods for Entrust CA")
public void createAndGetPolicyForEntrust() throws VCertException {
CloudConnector connector = connectorResource.connector();
String policyName = CloudTestUtils.getRandomZone();
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
policySpecification.policy().certificateAuthority(TestUtils.CLOUD_ENTRUST_CA_NAME);
connector.setPolicy(policyName, policySpecification);
PolicySpecification policySpecificationReturned = connector.getPolicy(policyName);
// The returned policySpecification will have the policy's name so it will copied to the source policySpecification
// due it doesn't contain it
policySpecification.name(policySpecificationReturned.name());
assertEquals(policySpecification, policySpecificationReturned);
}
use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingPolicyCountriesWhenWildcards.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy Countries with wildcard value")
public void testExceptionValidatingPolicyCountriesWhenWildcards() 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 ".*" to validate that the related VCertException is thrown
policySpecification.policy().subject().countries(new String[] { PolicySpecificationConst.ALLOW_ALL, "Mexico" });
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_COUNTRIES), exception.getMessage());
}
use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingPolicyOrgsWhenWildcards.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy Orgs with wildcard value")
public void testExceptionValidatingPolicyOrgsWhenWildcards() throws VCertException {
classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
// setting the orgs to a list of values which contains ".*" to validate that the related VCertException is thrown
policySpecification.policy().subject().orgs(new String[] { PolicySpecificationConst.ALLOW_ALL, "org1" });
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_ORGS), exception.getMessage());
}
use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.
the class TppTokenConnectorTest method testExceptionValidatingDefaultLocality.
@Test
@DisplayName("TPP - Testing Exception in Validation of Defaults Locality not matching with the Policy Localities values")
public void testExceptionValidatingDefaultLocality() throws VCertException {
PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
// setting the Default Locality to a value which doesn't match with the values in the
// Policy Localities values to validate that the related VCertException is thrown
policySpecification.defaults().subject().locality("Mer");
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_LOCALITY, PolicySpecificationConst.ATT_POLICY_SUBJECT_LOCALITIES), exception.getMessage());
}
Aggregations