Search in sources :

Example 11 with Authentication

use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.

the class CloudConnectorTest method testExceptionValidatingDefaultLocality.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Defaults Locality not matching with the Policy Localities values")
public void testExceptionValidatingDefaultLocality() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.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(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_SUBJECT_LOCALITY, PolicySpecificationConst.ATT_POLICY_SUBJECT_LOCALITIES), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) Authentication(com.venafi.vcert.sdk.endpoint.Authentication) VCertException(com.venafi.vcert.sdk.VCertException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with Authentication

use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.

the class CloudConnectorTest method testExceptionValidatingPolicyKeySizes.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy KeySizes")
public void testExceptionValidatingPolicyKeySizes() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the keysizes to a list of values which contains a no valid value to validate that the related VCertException is thrown
    policySpecification.policy().keyPair().rsaKeySizes(new Integer[] { 1024, 3072 });
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.ATTRIBUTE_DOESNT_MATCH_WITH_ACCEPTED_VALUES_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_KEYPAIR_RSA_KEY_SIZES), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) Authentication(com.venafi.vcert.sdk.endpoint.Authentication) VCertException(com.venafi.vcert.sdk.VCertException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 13 with Authentication

use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.

the class CloudConnectorTest method testExceptionValidatingMaxValidDays.

@Test
@DisplayName("Cloud - Testing Exception in Validation of MaxValidDays")
public void testExceptionValidatingMaxValidDays() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the maxValidDays to null to validate that the related VCertException is thrown
    policySpecification.policy().maxValidDays(-10);
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.MAX_VALID_DAYS_EXCEPTION_MESSAGE), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) Authentication(com.venafi.vcert.sdk.endpoint.Authentication) VCertException(com.venafi.vcert.sdk.VCertException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 14 with Authentication

use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.

the class CloudConnectorTest method testExceptionValidatingPolicyKeyTypeContainsInvalidValue.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy KeyType")
public void testExceptionValidatingPolicyKeyTypeContainsInvalidValue() throws VCertException {
    classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
    PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
    // setting the keypair to a list of values which contains not only "RSA" to validate that the related VCertException is thrown
    policySpecification.policy().keyPair().keyTypes(new String[] { "RSA", "ECDSA" });
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.ATTRIBUTE_DOESNT_MATCH_WITH_ACCEPTED_VALUES_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_KEYPAIR_KEY_TYPES), exception.getMessage());
}
Also used : PolicySpecification(com.venafi.vcert.sdk.policy.domain.PolicySpecification) Authentication(com.venafi.vcert.sdk.endpoint.Authentication) VCertException(com.venafi.vcert.sdk.VCertException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 15 with Authentication

use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.

the class CloudConnectorResource method beforeEach.

@Override
public void beforeEach(ExtensionContext context) throws Exception {
    Security.addProvider(new BouncyCastleProvider());
    Cloud cloud = Cloud.connect();
    connector = new CloudConnector(cloud);
    Authentication authentication = Authentication.builder().apiKey(TestUtils.API_KEY).build();
    connector.authenticate(authentication);
}
Also used : Authentication(com.venafi.vcert.sdk.endpoint.Authentication) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider)

Aggregations

Authentication (com.venafi.vcert.sdk.endpoint.Authentication)57 Test (org.junit.jupiter.api.Test)36 DisplayName (org.junit.jupiter.api.DisplayName)31 PolicySpecification (com.venafi.vcert.sdk.policy.domain.PolicySpecification)24 VCertException (com.venafi.vcert.sdk.VCertException)22 IOException (java.io.IOException)22 Config (com.venafi.vcert.sdk.Config)9 CertificateRequest (com.venafi.vcert.sdk.certificate.CertificateRequest)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 VCertTknClient (com.venafi.vcert.sdk.VCertTknClient)5 PEMCollection (com.venafi.vcert.sdk.certificate.PEMCollection)5 RenewalRequest (com.venafi.vcert.sdk.certificate.RenewalRequest)5 ZoneConfiguration (com.venafi.vcert.sdk.connectors.ZoneConfiguration)5 VCertClient (com.venafi.vcert.sdk.VCertClient)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Tag (org.junit.jupiter.api.Tag)3 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)2 CertificateStatus (com.venafi.vcert.sdk.certificate.CertificateStatus)2