Search in sources :

Example 16 with Authentication

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

the class CloudConnectorTest method testExceptionValidatingDefaultKeySizeDoesntMatchWithPolicyKeySizes.

@Test
@DisplayName("Cloud - Testing Exception in Validation of Default KeySize with a value not matching with the Policy KeySizes")
public void testExceptionValidatingDefaultKeySizeDoesntMatchWithPolicyKeySizes() 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 matching with
    // the Policy KeySizes to validate that the related VCertException is thrown
    policySpecification.defaults().keyPair().rsaKeySize(4096);
    Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
    assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_KEYPAIR_RSA_KEY_SIZE, 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 17 with Authentication

use of com.venafi.vcert.sdk.endpoint.Authentication 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());
}
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 18 with Authentication

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

the class VCertClientTest method authenticate.

@Test
@DisplayName("Authenticated with venafi endpoint with server error")
void authenticate() throws VCertException {
    final Authentication auth = mock(Authentication.class);
    classUnderTest.authenticate(auth);
    verify(connector).authenticate(auth);
}
Also used : Authentication(com.venafi.vcert.sdk.endpoint.Authentication) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 19 with Authentication

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

the class VCertClientTest method authenticateWithException.

@Test
@DisplayName("Authenticated with venafi endpoint")
void authenticateWithException() throws VCertException {
    final Authentication auth = mock(Authentication.class);
    doThrow(new FeignException.InternalServerError("Error", request, "".getBytes())).when(connector).authenticate(auth);
    assertThrows(VCertException.class, () -> classUnderTest.authenticate(auth));
}
Also used : Authentication(com.venafi.vcert.sdk.endpoint.Authentication) FeignException(feign.FeignException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 20 with Authentication

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

the class TppTokenConnectorIT method setup.

@BeforeEach
void setup() throws VCertException {
    serverMock.start();
    classUnderTest = new TppTokenConnector(Tpp.connect("http://localhost:" + serverMock.port() + "/"));
    // String.format()
    Authentication auth = Authentication.builder().user("user").password("pass").build();
    classUnderTest.credentials(auth);
    info = classUnderTest.getAccessToken();
}
Also used : Authentication(com.venafi.vcert.sdk.endpoint.Authentication) BeforeEach(org.junit.jupiter.api.BeforeEach)

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