Search in sources :

Example 46 with Authentication

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

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

the class TppConnectorATForSSH method authenticate.

@BeforeEach
void authenticate(TestInfo testInfo) throws VCertException {
    if (testInfo.getTags() != null && !testInfo.getTags().contains("AuthenticationUnneeded")) {
        Security.addProvider(new BouncyCastleProvider());
        Authentication authentication = new Authentication().user(TestUtils.TPP_USER).password(TestUtils.TPP_PASSWORD).scope("ssh:manage");
        classUnderTest.authenticate(authentication);
    }
}
Also used : Authentication(com.venafi.vcert.sdk.endpoint.Authentication) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 48 with Authentication

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

the class VCertTknClientTest 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).getAccessToken(auth);
    assertThrows(VCertException.class, () -> classUnderTest.getAccessToken(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 49 with Authentication

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

the class VCertTknClientTest method authenticate.

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

Example 50 with Authentication

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

the class TppTokenConnectorATForSSH method authenticate.

@BeforeEach
void authenticate(TestInfo testInfo) throws VCertException {
    if (testInfo.getTags() != null && !testInfo.getTags().contains("AuthenticationUnneeded")) {
        Security.addProvider(new BouncyCastleProvider());
        // Executes only once to ensure the same token is used across the tests
        if (TppTokenConnectorATForSSH.info == null) {
            Authentication authentication = Authentication.builder().user(TestUtils.TPP_USER).password(TestUtils.TPP_PASSWORD).scope("ssh:manage").build();
            TokenInfo info = classUnderTest.getAccessToken(authentication);
            assertThat(info).isNotNull();
            assertThat(info.authorized()).isTrue();
            assertThat(info.errorMessage()).isNull();
            assertThat(info.accessToken()).isNotNull();
            assertThat(info.refreshToken()).isNotNull();
            TppTokenConnectorATForSSH.info = info;
        }
    }
}
Also used : Authentication(com.venafi.vcert.sdk.endpoint.Authentication) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) 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