use of com.venafi.vcert.sdk.policy.domain.PolicySpecification in project vcert-java by Venafi.
the class TppTokenConnectorTest method testExceptionValidatingPolicyLocalities.
@Test
@DisplayName("TPP - Testing Exception in Validation of Policy Localities with more than one value")
public void testExceptionValidatingPolicyLocalities() throws VCertException {
PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
// setting the localities to a list of more than 1 values
// to validate that the related VCertException is thrown
policySpecification.policy().subject().localities(new String[] { "Loc1", "Loc2" });
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_LOCALITIES), exception.getMessage());
}
use of com.venafi.vcert.sdk.policy.domain.PolicySpecification 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.policy.domain.PolicySpecification 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.policy.domain.PolicySpecification 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.policy.domain.PolicySpecification in project vcert-java by Venafi.
the class TppTokenConnectorAT method createAndGetPolicy.
@Test
@DisplayName("TPP - Testing the setPolicy() and getPolicy() methods")
public void createAndGetPolicy() throws VCertException {
String policyName = TppTestUtils.getRandomZone();
PolicySpecification policySpecification = TppTestUtils.getPolicySpecification();
connectorResource.connector().setPolicy(policyName, policySpecification);
PolicySpecification policySpecificationReturned = connectorResource.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());
// setting to null, because the returned should not contains the defaults
policySpecification.defaults(null);
assertEquals(policySpecification, policySpecificationReturned);
}
Aggregations